This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bug in 5.2.1 (and latest cvs)


I have discussed this before, gone away and tried to fathom the problem
myself, but the learning curve was too steep for the time I have
available, so I present the bug here, and in the bug database.

gcc (g++) 3.x might be significant if you want to try it...

With newly built gdb 5.2.1 and gcc 3.1.1 (On several intel gnu/linux
test platforms - it's not just me!)...

struct Base
{
	int a; //Take out this line and it works
	virtual void fn()=0;
};

struct Intermediate : virtual Base //remove virtual and it works
{
};

struct Derived : Intermediate
{
	virtual void fn();
};

void Derived::fn()
{
	int a=1;
	int b=2;
	int c = a+b;
} //....here! (see below)

int main(int argc,char* argv[])
{
	Derived d;
	Base* p = &d;
	p->fn(); //'s' here ends up....
	return 0;
}

[thunk]$ g++ -g2 -o thunk thunk.cpp
[thunk]$ gdb thunk
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) break main
Breakpoint 1 at 0x8048650: file thunk.cpp, line 26.
(gdb) run
Starting program: /home/daedalus/src/thunk/thunk 

Breakpoint 1, main (argc=1, argv=0xbffffa34) at thunk.cpp:26
26		Derived d;
(gdb) n
27		Base* p = &d;
(gdb) n
28		p->fn(); //'s' here ends up....
(gdb) s
virtual thunk to Derived::fn() () at thunk.cpp:22
22	} //....here! (see below)
(gdb) s
main (argc=1, argv=0xbffffa34) at thunk.cpp:29
29		return 0;
(gdb) n
30	}
(gdb) c
Continuing.

With more complex programmes and multiple files, the step can end up
anywhere. It doesn't always land on the exiting brace.

Anyway I hope that someone who understands gdb better might be able to
sort this out (and if you do, please let me know!)

Andrew Walrond


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]