[LC++]gdb debugging and multiple files source program.

Shaul Karl shaulka at bezeqint.net
Fri Dec 21 11:53:11 UTC 2001


For some reason the behavior of gdb when I split a program into 
multiple files is not the same as when there is only one source file. 
In particular, in the multiple file case gdb does not recognize local 
variables and does not honor breakpoints that are set by line numbers.
What am I missing?

The details are:

(gdb) b demo::demo()
Breakpoint 1 at 0x804d69c: file demo.cc, line 4.
(gdb) r
Starting program: /tmp/multipleFiles 

Breakpoint 1, 0x0804d69c in demo (this=0x804cb64) at demo.cc:4
4       {
(gdb) l
1       #include "demo.h"
2
3       demo::demo() 
4       {
5           ifstream input("mainMultiple.cc");
6           istream_iterator<string> iter(input);
7           while (input) cout << *iter++ << "  ";
8           cout << "\n";
9       };
10
(gdb) n
5           ifstream input("mainMultiple.cc");
(gdb) n
6           istream_iterator<string> iter(input);
(gdb) p input
No symbol "input" in current context.
(gdb) b 7
Breakpoint 2 at 0x804d53c: file demo.cc, line 7.
(gdb) c
Continuing.
#include  "demo.h"  int  main()  {}  

Program exited normally.
(gdb) q
[02:49:37 tmp]$ 

[02:50:20 tmp]$ g++-3.0 -v
Reading specs from /usr/lib/gcc-lib/i386-linux/3.0.2/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,p
roto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man 
--enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib 
--enable-long-long --enable-nls --without-included-gettext 
--disable-checking --enable-threads=posix --enable-java-gc=boehm 
--with-cpp-install-dir=bin --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.0.2 (Debian)
[02:50:27 tmp]$ 

There was a -ggdb flag on compilation and linking.
-- 

    Shaul Karl
    email: shaulka(at-no-spam)bezeqint.net 
           Please replace (at-no-spam) with an at - @ - character.
           (at-no-spam) is meant for unsolicitate mail senders only.





More information about the tuxCPProgramming mailing list