From: Daedalus <daedalus@projecticarus.com>
To: gdb@sources.redhat.com
Subject: Re: Is Single step into C++ virtual thunk still broken?
Date: Tue, 09 Jul 2002 08:56:00 -0000 [thread overview]
Message-ID: <1026229835.2426.30.camel@pan> (raw)
Well, after a bit of investigation, I have come up with this simple C++
code which gdb gets a bit wrong.
Having class Base as a *virtual* base class of class Derived seems to
cause the problem. Take out virtual and everything works fine.
Anyway, to see what I mean, stick a breakpoint in the code where
indicated, then single step into the virtual function. gdb ends up on
the last line of the virtual function, rather than the first. If you
move the function to another file, it can just end up somewhere random.
Take out the virtual as indicated and everything works fine
Let me know what you think.
Andrew
PS Are you a gdb maintainer? Whatever, thanks for the help.
#include <cstdio>
using namespace std;
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
class Base
{
int a;
public:
virtual bool VirtualFn()=0;
};
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// Remove virtual from the following line and everything works fine
class Intermediate1 : public virtual Base
{
int b;
public:
virtual bool VirtualFn();
};
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
class Derived : public Intermediate1
{
int d;
public:
virtual bool VirtualFn();
};
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
bool Intermediate1::VirtualFn()
{
printf("This Intermediate1::Virtual Function");
return true;
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
bool Derived::VirtualFn()
{
int a=1;
int b=2;
int c=a+b;
printf("This Base::Virtual Function");
return true;
//Single step ends up here if 'virtual' is left in above
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
int main(int argc,char* argv[])
{
Derived d;
Base* p = &d;
//Put your breakpoint on the next line and single step...
p->VirtualFn();
return 0;
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
next reply other threads:[~2002-07-09 15:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-09 8:56 Daedalus [this message]
2002-07-09 9:27 ` Daniel Jacobowitz
2002-07-09 11:44 ` Daedalus
2002-07-09 11:51 ` Daniel Jacobowitz
2002-07-09 13:10 ` Daedalus
[not found] ` <20020709202005.GA23405@nevyn.them.org>
2002-07-09 16:13 ` Daedalus
-- strict thread matches above, loose matches on Subject: below --
2002-07-09 14:14 Daedalus
2002-07-08 6:47 Daedalus
2002-07-08 6:52 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1026229835.2426.30.camel@pan \
--to=daedalus@projecticarus.com \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox