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?
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 Windows, there is a Dependency Checker utility (depends.exe) available somewhere (visual studio additional tool? Can't remember where I got it) that 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")]
#endif
edit: Sorry, I assumed .NET. There goes my hammer.
Most often debug versions of both executables and libraries are linked against debug version of runtime. On Windows there's a name scheme for debug/release versions that some follow, MS among them. The name of debug version of a library should end with d. You can use tool like Dependency Walker (http://www.dependencywalker.com) to see on what libraries your executable or library depends. If you find debug versions of runtime libraries there there is a big chance your executable or library was built in debug mode.
This however works only if
- you can tell by looking at a name of runtime which version it is (it follows some naming scheme like the one I described above)
- your executable/library is linked against dynamic runtime not static one. In the second case the runtime gets pulled into executable/library and it's no longer a dependency
- you are on Windows :)
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.