Re: declaring and defining virtual function in header file
> c++ -O2 lib.cpp -c This line is causing the problem. Try c++ -g -O2 lib.cpp -c and you should get better results. GDB cannot display the proper line number for modules compiled without -g. GDB also does not step into functions compiled without -g and executes a `next' (step over) instead, which explains why you end up back in `main' after a step into `problem'. > Hi! > > I think i found a very strange problem/bug: > > (using > -gdb version 4.16, 418 and to 5.0 configured for 'i586-pc-linux-gnu' and > solaris > - gcc version 2.95.2 19991024 (release) > ) > > i wonder if it is an bug of gdb or gcc. (Or maybe it isn't a bug???) > > Here's an example: (The very important part is in Class.h) > use the following commands on the files enclosed at the end of this mail: > > c++ -O2 lib.cpp -c > c++ -g -c cctest.cpp > c++ -o ttt cctest.o lib.o > > Execute binary 'ttt'. The output looks like this: > | 0x80485e0 > | 0x8048660 > | this is function no_problem > | this is function problem > > > > now start gdb ('gdb ttt') > use the 'info line *' command on both of the addresses. The output looks > like > this: > > | (gdb) info line * 0x80485e0 > | Line 6 of "cctest.cpp" starts at address 0x80485e0 > |and ends at 0x80485e6 . > > > > Everything's fine with this information > > | (gdb) info line * 0x8048660 > | Line 23 of "cctest.cpp" starts at address 0x8048652 > |and ends at 0x80486c0 <__tf4Test>. > > > > Oops: There is wrong line,file and symbol name information for the second > address. > try to step into the function 'problem'. > > without the keyword 'virtual' or/and without the function body of > Test::cctest() everything's fine! What's wrong? > > Best regards > Henning Moll -- Peter Schauer [EMAIL PROTECTED] ___ Bug-gdb mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-gdb
Re: declaring and defining virtual function in header file
Peter.Schauer wrote: > > c++ -O2 lib.cpp -c > > This line is causing the problem. > Try > c++ -g -O2 lib.cpp -c > and you should get better results. > > GDB cannot display the proper line number for modules compiled without -g. > GDB also does not step into functions compiled without -g and executes > a `next' (step over) instead, which explains why you end up back in `main' > after a step into `problem'. hmm, i think you didn't realize the real problem: Maybe i have to clearify: I don't expect that gdb shows me information for a file compiled without -g. But i expect that it does not show WRONG informaton for such files. if i compile the given example (without changes) gdb says for the command 'info line * 0x8048660' (it's the address of function 'problem') gdb> Line 23 of "cctest.cpp" starts at address 0x8048652 gdb>and ends at 0x80486c0 <__tf4Test>.( gdb shows wrong line and wrong file information. Now i just remove the keyword 'virtual' from file Class.h, compile again and redo the gdb-command: gdb> No line number information available for address 0x80485f0 gdb> Ok, that output is correct! (it is also correkt with keyword 'virtual' but without the functionbody!) (Anyway, note that there is no reference to the class defined in file Class.h) Best regards Henning Moll ___ Bug-gdb mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-gdb