From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4520 invoked by alias); 9 Jul 2002 15:56:08 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 4401 invoked from network); 9 Jul 2002 15:56:07 -0000 Received: from unknown (HELO gaea.projecticarus.com) (195.10.228.71) by sources.redhat.com with SMTP; 9 Jul 2002 15:56:07 -0000 Received: from [192.168.128.13] (host62-7-125-109.in-addr.btopenworld.com [62.7.125.109]) by gaea.projecticarus.com (8.11.6/8.11.6) with ESMTP id g69Fu5V09134 for ; Tue, 9 Jul 2002 16:56:05 +0100 Subject: Re: Is Single step into C++ virtual thunk still broken? From: Daedalus To: gdb@sources.redhat.com Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Tue, 09 Jul 2002 08:56:00 -0000 Message-Id: <1026229835.2426.30.camel@pan> Mime-Version: 1.0 X-SW-Source: 2002-07/txt/msg00093.txt.bz2 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 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; } /////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////