[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++: a gdb problem when debugging multiple files source program.
- To: linux-il(at-nospam)linux.org.il
- Subject: Re: C++: a gdb problem when debugging multiple files source program.
- From: Shaul Karl <shaulka(at-nospam)bezeqint.net>
- Date: Sat, 22 Dec 2001 23:01:43 +0200
- Delivered-To: linux.org.il-linux-il@linux.org.il
- In-Reply-To: Message from Oleg Goldshmidt <ogoldshmidt@computer.org> of "22 Dec 2001 14:34:51 EST." <m3wuzfqc9w.fsf@localhost.localdomain>
- References: <E16HMwn-0002w1-00@rakefet> <m3wuzfqc9w.fsf@localhost.localdomain>
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
> Shaul Karl <shaulka@bezeqint.net> writes:
>
> > For some reason the behavior of gdb when I split a C++ program into
> > multiple files is not the same as when there is only one source file.
>
> > gdb version is 5.1.
>
> Can you provide more details on your platform, such as glibc version,
> architecture, kernel? Not sure it is relevant, but still, let's have
> all the info...
>
> > [02:50:20 tmp]$ g++-3.0 -v
>
> I have not been as adventurous as to use g++-3.0 yet. Does it happen
> with g++-2.95? Can you check with RH g++-2.96? [If you can't, I will
> be able to.] Before anyone plunges into it, maybe we can determine
> the scope of the problem...
>
> > CXXFLAGS = -Wall -ggdb
> > LDFLAGS = -ggdb
>
> Try just -g rather than -ggdb. Again, this is for sanity check.
>
> --
> Oleg Goldshmidt | ogoldshmidt@NOSPAM.computer.org
> If it aint't broken it hasn't got enough features yet.
With 2.95 I had to add
#include <string>
both to demo.h and to mainSingle.cc. Don't know why 3.0 could do
without it.
Anyway, 2.95 seems to behave better:
(gdb) b demo::demo
Breakpoint 1 at 0x804a259: file demo.cc, line 5.
(gdb) r
Starting program: /tmp/multipleFiles-2.95
Breakpoint 1, demo::demo (this=0x804d814) at demo.cc:5
5 ifstream input("mainMultiple.cc");
(gdb) n
6 istream_iterator<string> iter(input);
(gdb) n
7 while (input) cout << *iter++ << " ";
(gdb) p input
$1 = {<fstreambase> = {<ios> = {<_ios_fields> = {_strbuf = 0xbffffba4,
long printing omitted
(gdb) c
Continuing.
Breakpoint 2, demo::demo (this=0x804d814) at demo.cc:8
8 cout << "\n";
(gdb) c
Continuing.
#include "demo.h" int main() {}
Program exited normally.
(gdb)
This works, although it does not accept a breakpoint at demo::demo().
demo::demo is accepted.
Replacing -ggdb with -g make things a bit worse because with only -g
gdb does not recognize input:
(gdb) p input
$1 = <incomplete type>
(gdb)
Other then this it seems to work.
My overall impression so far is that the the ability to run substantial
code before main get started is quite problematic. However I am
currently programming only the initialization of my C++ program, which
is why I only encounter difficulties with the initialization of a C++
program.
I did not knew that g++-3.0 is adventurous. As far as I know 3.0
complies much better to the C++ standard, for example by accepting
namespaces properly. If possible I would like to use it over 2.95.
I have no access to RH 2.96 version.
[22:33:40 tmp]$ uname -a
Linux rakefet 2.2.20 #1 Fri Dec 7 06:46:11 IST 2001 i586 unknown
[22:34:14 tmp]$
glibc 2.95 info (copied from glibcbug script):
===============
Release: libc-2.2.4
Host type: i386-pc-linux-gnu
System: Linux rakefet 2.2.20 #1 Fri Dec 7 06:46:11 IST 2001 i586 unknown
Architecture: i586
Addons: linuxthreads
Build CC: gcc
Compiler version: 2.95.4 20011006 (Debian prerelease)
Kernel headers: UTS_RELEASE
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: yes
Build omitfp: no
Build bounded: no
Build static-nss: no
Stdio: libio
--
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.
=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il