A Debugging Symbol Table maps instructions in the compiled binary program to their corresponding variable, function, or line in the source code. This mapping could be something like: Program instruction ⇒ item name, item type, original file, line number defined.
Basic Usage. All program to be debugged in gdb must be compiled by gcc with the option "-g" turning on.
How GDB Debugs? GDB allows you to do things like run the program up to a certain point then stop and print out the values of certain variables at that point, or step through the program one line at a time and print out the values of each variable after executing each line. GDB uses a simple command line interface.
As noted in the release notes for GCC 4.8 (i.e. current trunk):
DWARF4 is now the default when generating DWARF debug information. When -g is used on a platform that uses DWARF debugging information, GCC will now default to -gdwarf-4 -fno-debug-types-section. GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 debug information consumers support DWARF4 by default. Before GCC 4.8 the default version used was DWARF2. To make GCC 4.8 generate an older DWARF version use -g together with -gdwarf-2 or -gdwarf-3. The default for Darwin and VxWorks is still -gdwarf-2 -gstrict-dwarf.
So you need to use GDB 7.5 or compile with -g -gdwarf-2
No, even with --quiet it works for me. Maybe there's something wrong with your setup.
~/tmp $ g++ -Wall tmp.cpp -o tmp -O0 -ggdb3
~/tmp $ gdb --quiet --args ./tmp string
Reading symbols from /xxxxxxxx/tmp...done.
(gdb) b 12
Breakpoint 1 at 0x400c95: file tmp.cpp, line 12.
(gdb) run
Starting program: /xxxxxxxx/tmp string
Breakpoint 1, main (argc=2, argv=0x7fffffffdc58) at tmp.cpp:12
12 std::reverse(str.begin(), str.end());
(gdb) print str
$1 = "string"
(gdb) info locals
str = "string"
(gdb)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With