[Bug gdb/23101] New: gdb get insane when there are several c++ classes linked with the same name but different scope

apovalyaev at gmail dot com sourceware-bugzilla@sourceware.org
Fri Apr 20 22:06:00 GMT 2018


https://sourceware.org/bugzilla/show_bug.cgi?id=23101

            Bug ID: 23101
           Summary: gdb get insane when there are several c++ classes
                    linked with the same name but different scope
           Product: gdb
           Version: 7.11.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: apovalyaev at gmail dot com
  Target Milestone: ---

Three .cpp files are linked. Each of them has a TryDuplicate class declared.
So, all these three classes have the same name, but don't conflict each other.
Each of these class has a single virtual function, but the virtual function
names differ (let it be VirtualFunc, VirtualFunc2 and VirtualFunc3). Each of
.cpp files have a code calling an appropriate function inside. And this code is
executed for all these three files once a program run.

GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 (x64)


First.cpp:

class TryDuplicate
{
public:
      virtual void VirtualFunc() {}
};
...
    // code which calls virtual function
    TryDuplicate * c = new TryDuplicate();
    c->VirtualFunc();


Second.cpp:

class TryDuplicate
{
public:
      virtual void VirtualFunc2() {}
};
...
    // code which calls virtual function
    TryDuplicate * c = new TryDuplicate();
    c->VirtualFunc2();

Third.cpp:

class TryDuplicate
{
public:
      virtual void VirtualFunc3() {}
};
...
    // code which calls virtual function
    TryDuplicate * c = new TryDuplicate();
    c->VirtualFunc3();


Once all these .cpp files are compiled and linked, issues with breakpoint
appears:
BUG1) When all these functions have breakpoint set up on it, only one can be
reached.
      step1) (gdb) b TryDuplicate::VirtualFunc
      step2) (gdb) b TryDuplicate::VirtualFunc2
      step3) (gdb) b TryDuplicate::VirtualFunc3
      step4) <run program>
      step5) breakpoint on TryDuplicate::VirtualFunc is reached
      step6) breakpoints on TryDuplicate::VirtualFunc2 and
             TryDuplicate::VirtualFunc3 are not reached

      NOTE: on another linkage it might be the case that only breakpoint on
            TryDuplicate::VirtualFunc2 is reached and
            TryDuplicate::VirtualFunc, TryDuplicate::VirtualFunc3 are not.
            The essense is that only one of three breakpoints is reached.

BUG2) If you set up a breakpoint on line where TryDuplicate::VirtualFunc2 is
      called, the breakpoint can be reached but after "Step in" gdb command
      you will be inside TryDuplicate::VirtualFunc (not VirtualFunc2)

      NOTE: the same logic as writte in NOTE for BUG1

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Gdb-prs mailing list