Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

How do you know if binary is debug or released?

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.

What is debug mode and Release mode?

In Debug Mode your .exe has debug information inside of it (source code, variable names and other similar stuff like that). In Release Mode your .exe lack of debug information makes it smaller and probably performs better due to its smaller footprint.

Is Release mode faster than debug?

Debug Mode: In debug mode the application will be slow. Release Mode: In release mode the application will be faster.


  • 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.