Let me have C ++ code. I compile it with the command:

g++ -g code.cpp -o code.o 

Now I need to get the source code back, having only code.o

I'm definitely not sure that this is very simple, but I know that gdbtui (and, most likely, gdb) somehow gets this code and uses it for output to the user.

Task: Get the source code from a file compiled with the -g flag

  • 2
    gdb stores all information about compiled characters (functions, global variables, etc.). For the code, it accesses the source file. This can be noticed if you change the file and start the debugger - it swears that the source is newer than the binary. - handicraftsman
  • @Ancient, there were such thoughts, but never checked. Thank. - Oskar Sharipov

0