Make options for debugging



  • Is there any way to pass options to either g++ or make to produce a cross reference listing of variables used and the address location of elements within the program like classes, line numbers and functions within the application similar to the "map" option of COBOL?

    This may be a stupid question but I have not seen anything referenced.

    It would be very convenient when debugging and valgrind or gdb gives an address rather than a symbol to reference the location of the error or to locate where a variable has been used (or not used).


  • Moderators

    I am not aware of a tool to generate a mapping of memory locations to source code (be it variable names or line numbers).

    Is the debug information included with your application not enough for you (provided you did a debug build)? GDB, valgrind and other tools will use that information to produce the information you want on demand (e.g. when reporting errors).



  • Sorry for the late reply...
    Yes, you can do that with the linker - pass "-Wl,-Map=myfile.map":http://sourceware.org/binutils/docs/ld/Options.html#index-g_t_002dMap_003d_0040var_007bmapfile_007d-183 to GCC.



  • so where does the -Wl,-Map-myfile.map go in QtCreator? Under the Make chain?



  • You will want to set it in QMAKE_LFLAGS (or if you want it only on debug builds, then in QMAKE_LFLAGS_DEBUG). You could put it in the qmake arguments as "QMAKE_LFLAGS+=-Wl,-Map=mapfile" (please note the equals sign, instead of a dash!), but then it will only apply when you build from Creator. A better way would be to put it directly into the .pro file.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.