[gdb/testsuite] Add test-case gold-gdb-index.exp

There's a PR binutils/15646 - "gold-generated .gdb_index has duplicated
symbols that gdb-generated index doesn't", and gdb contains a workaround,
added in commit 8943b87476 "Work around gold/15646".

Add a test-case testing this workaround.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-26  Tom de Vries  <tdevries@suse.de>

	* gdb.base/gold-gdb-index-2.c: New test.
	* gdb.base/gold-gdb-index.c: New test.
	* gdb.base/gold-gdb-index.exp: New file.
	* gdb.base/gold-gdb-index.h: New test.
This commit is contained in:
Tom de Vries 2020-05-26 11:35:32 +02:00
parent c6412eeea9
commit 40d22035a7
5 changed files with 132 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2020-05-26 Tom de Vries <tdevries@suse.de>
* gdb.base/gold-gdb-index-2.c: New test.
* gdb.base/gold-gdb-index.c: New test.
* gdb.base/gold-gdb-index.exp: New file.
* gdb.base/gold-gdb-index.h: New test.
2020-05-25 Tom de Vries <tdevries@suse.de>
* boards/gold-gdb-index.exp: New file.

View File

@ -0,0 +1,23 @@
/* This testcase is part of GDB, the GNU debugger.
Copyright 2020 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "gold-gdb-index.h"
namespace N1
{
void bar () { C1::baz (); }
}

View File

@ -0,0 +1,29 @@
/* This testcase is part of GDB, the GNU debugger.
Copyright 2020 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "gold-gdb-index.h"
namespace N1
{
void foo () { C1::baz (); }
}
int
main ()
{
return 0;
}

View File

@ -0,0 +1,48 @@
# Copyright 2020 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
# This tests the gdb workaround for PR binutils/15646.
standard_testfile .c gold-gdb-index-2.c
if {[prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \
{debug c++ additional_flags=-fuse-ld=gold \
additional_flags=-Wl,--gdb-index \
additional_flags=-ggnu-pubnames}]} {
return -1
}
if { [readnow] } {
return -1
}
gdb_test_no_output "set auto-solib-add off"
if ![runto_main] then {
fail "can't run to main"
return 0
}
gdb_test_no_output "set breakpoint pending off"
gdb_test "break N1::misspelled" "Function \"N1::misspelled\" not defined\."
gdb_test_multiple "maint info symtabs" "" {
-re -wrap "\{ symtab \[^\r\n\]*gold-gdb-index-2.c.*" {
fail $gdb_test_name
}
-re -wrap "" {
pass $gdb_test_name
}
}

View File

@ -0,0 +1,25 @@
/* This testcase is part of GDB, the GNU debugger.
Copyright 2020 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
namespace N1
{
class C1
{
public:
static void baz () {}
};
}