Gdb 7.7 not included with OS-X Mavericks with gcc4.7.3 (Macports)

Here is a simple program:

#include <iostream> #include <vector> namespace Example { template <int dim> class Problem { public: void run() { std::cout<<"here.."<<std::endl; } }; } int main(int argc, char *argv[]) { Example::Problem<2> problem; problem.run(); return 0; } 

compiled with Macport gcc 4.7.3:

 g++-mp-4.7 -g -O0 prog.cc -o prog 

If I try to debug in gdb 7.7 ( self- compiled, not Macport one!):

 $gdb file prog b main r s 

I can not enter the function :

 34 problem.run(); (gdb) s here.. 36 return 0; (gdb) 

Am I doing something wrong? Or does it look like a gdb error when used on os-x mavericks?

UPDATE

I do not see any warnings / errors when using gdb:

 $ gdb ./prog GNU gdb (GDB) 7.7 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-apple-darwin13.1.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./prog...Reading symbols from /Users/bla-bla-bla/prog.dSYM/Contents/Resources/DWARF/prog...done. done. (gdb) 

also '-gdwarf-2 -gstrict-dwarf' does not change behavior ....

UDAPTE2

I see the same thing as the behavior associated with the call code, as here . Although I was not able to check if compiling with -m32 in my case, since I have everything for 64-bit and, therefore, problems with undefined symbols .

Another issue when debugging here and here, at https://stackoverflow.com/a/165269/169 .

0
source share
1 answer

You need to add the -gdwarf-2 option along with -g to debug using gdb for the newer version of gcc.

g ++ - mp-4.7 -g -gdwarf-2 -O0 prog.cc -o prog

0
source

Source: https://habr.com/ru/post/945862/


All Articles