Tutorial :How to tell if a binary is release or debug in both win and *nix


Is there a simple command line utility to inspect binaries like executable and dynamic libraries to tell if they are release or debug versions? Is there anything like that on *nix or windows?


  • for C++ on Linux, you can do:

        objdump --source yourbin |grep printf  

    Replace printf with whatever function call you do. If it is debug, it will display all the actual source code call you do. If it is release, it will just display the founded symbol from the symbol table.

  • for C++ on Windows, you can use depends.exe and see if it depends on MSVCRT (release) or MSVCRTD (debug)


On linux you can use the "file" command even for dynamic libraries. If it says "stripped" than all debugging symbols are stripped out. If it is saying "not stripped" it is the opposite


For unix: with ELF executables you may be able to use objdump or nm to look at the symbol tables for the executable (note that this will work a lot better if it's not stripped). The presence or absence of certain symbols will tend to indicate a debug or release build. (As to which, that probably depends on what libraries you're using, etc. You'd have to do a bit of digging to find common ones; feel free to suggest things to look for in comments, and I'll update the answer.)

For Windows: the dependencywalker suggestions are good. For command-line equivalents, you can find dumpbin in most Visual Studio installations and it's somewhat equivalent to objdump on *nix. You may also be able to find an nm or objdump in e.g. msys or cygwin that'll work on some windows exe files.


For Windows, the Dependency Walker has optional cmd-line output listing every dll the exe loads (and their dependencies). Run that through grep and see if the msvcrt-dll popups with a d or not.

This only works if it's dynamically linked. Otherwise it might be trickier.

You could perhaps grep for certain functions that are different in debug/release, if those strings are visible in the executable.

If your apps doesn't use the runtime at all, it'd be pretty tricky.


There's not much to go on. If you open an assembly in Reflector, you can look for the Assembly Attribute:

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.Default)]  

But apparently that's added to release mode as well.

If it's your own assembly than the solution is to use some preprocessor directives.

#ifdef DEBUG  [MyAttribute("foo")]  

Next Post »