]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Adjust gdb.cp/cpexprs.exp for Cygwin
authorPedro Alves <pedro@palves.net>
Mon, 9 Jun 2025 14:41:28 +0000 (15:41 +0100)
committerPedro Alves <pedro@palves.net>
Mon, 9 Jun 2025 16:54:43 +0000 (17:54 +0100)
commit9495dfa89bffe114f5c31b3766acb5e4ea97f9fb
treec77551e6df9929eb9a5a9a8788aa7b0b570f17ed
parentbd85f0b3b126937d23dc93b1888b8eadad975fdd
Adjust gdb.cp/cpexprs.exp for Cygwin

Running gdb.cp/cpexprs.exp on x86-64 GNU/Linux, I see:

 break base::~base
 Breakpoint 117 at 0x555555555d90: file .../src/gdb/testsuite/gdb.cp/cpexprs.cc, line 135.
 (gdb) continue
 Continuing.

 Breakpoint 117, base::~base (this=0x7fffffffd0f8, __in_chrg=<optimized out>) at .../src/gdb/testsuite/gdb.cp/cpexprs.cc:135
 135   ~base (void) { } // base::~base
 (gdb) PASS: gdb.cp/cpexprs.exp: continue to base::~base

Here, the breakpoint only got one location because both the in-charge
and the not-in-charge dtors are identical and got the same address:

 $ nm -A ./testsuite/outputs/gdb.cp/cpexprs/cpexprs| c++filt |grep "~base"
 ./testsuite/outputs/gdb.cp/cpexprs/cpexprs:0000000000001d84 W base::~base()
 ./testsuite/outputs/gdb.cp/cpexprs/cpexprs:0000000000001d84 W base::~base()

While on Cygwin, we get two locations for the same breakpoint, which
the testcase isn't expecting:

 break base::~base
 Breakpoint 117 at 0x100402678: base::~base. (2 locations)
 (gdb) continue
 Continuing.

 Thread 1 "cpexprs" hit Breakpoint 117.1, base::~base (this=0x7ffffcaf8, __in_chrg=<optimized out>) at .../src/gdb/testsuite/gdb.cp/cpexprs.cc:135
 135   ~base (void) { } // base::~base
 (gdb) FAIL: gdb.cp/cpexprs.exp: continue to base::~base

We got two locations because the in-charge and the not-in-charge dtors
have different addresses:

 $ nm -A outputs/gdb.cp/cpexprs/cpexprs.exe | c++filt | grep "~base"
 outputs/gdb.cp/cpexprs/cpexprs.exe:0000000100402680 T base::~base()
 outputs/gdb.cp/cpexprs/cpexprs.exe:0000000100402690 T base::~base()

On Cygwin, we also see the typical failure due to not expecting the
inferior to be multi-threaded:

  (gdb) continue
  Continuing.
  [New Thread 628.0xe08]

  Thread 1 "cpexprs" hit Breakpoint 200, test_function (argc=1, argv=0x7ffffcc20) at .../src/gdb/testsuite/gdb.cp/cpexprs.cc:336
  336   derived d;
  (gdb) FAIL: gdb.cp/cpexprs.exp: continue to test_function for policyd3::~policyd

Both issues are fixed by this patch, and now the testcase passes
cleanly on Cygwin, for me.

Reviewed-By: Keith Seitz <keiths@redhat.com>
Change-Id: If7eb95d595f083f36dfebf9045c0fc40ef5c5df1
gdb/testsuite/gdb.cp/cpexprs.exp.tcl