This is the mail archive of the gdb-prs@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]

gdb/618: Stepping through c++ virtual thunk


>Number:         618
>Category:       gdb
>Synopsis:       Stepping through c++ virtual thunk
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jul 27 08:28:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     gdb@walrond.org
>Release:        unknown-1.0
>Organization:
>Environment:
GNU/Linux, intel, gcc3.1.1, gdb 5.2.1
>Description:
Stepping into a C++ virtual thunk ends up in wrong place.
Try this... (and note comments)

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

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

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.

Program exited normally.
(gdb) 
>How-To-Repeat:
See above
>Fix:
Unknown
>Release-Note:
>Audit-Trail:
>Unformatted:


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