diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fdafdb99db..c4b9276233 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2020-04-22 Tom de Vries + + PR symtab/25764 + * dwarf2/read.c (scan_partial_symbols): Allow external variable decls + in psymtabs. + 2020-04-22 Tom de Vries PR symtab/25801 diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 450c53b519..c2a9103510 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -7951,7 +7951,8 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc, case DW_TAG_variable: case DW_TAG_typedef: case DW_TAG_union_type: - if (!pdi->is_declaration) + if (!pdi->is_declaration + || (pdi->tag == DW_TAG_variable && pdi->is_external)) { add_partial_symbol (pdi, cu); } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 1331fe5248..a81c37fe78 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2020-04-22 Tom de Vries + + PR symtab/25764 + * gdb.base/psym-external-decl-2.c: New test. + * gdb.base/psym-external-decl.c: New test. + * gdb.base/psym-external-decl.exp: New file. + * gdb.threads/tls.exp: Add PR25807 kfail. + 2020-04-22 Tom de Vries PR symtab/25801 diff --git a/gdb/testsuite/gdb.base/psym-external-decl-2.c b/gdb/testsuite/gdb.base/psym-external-decl-2.c new file mode 100644 index 0000000000..76e0587301 --- /dev/null +++ b/gdb/testsuite/gdb.base/psym-external-decl-2.c @@ -0,0 +1,18 @@ +/* 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 . */ + +int aaa = 33; diff --git a/gdb/testsuite/gdb.base/psym-external-decl.c b/gdb/testsuite/gdb.base/psym-external-decl.c new file mode 100644 index 0000000000..7a4b107774 --- /dev/null +++ b/gdb/testsuite/gdb.base/psym-external-decl.c @@ -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 . */ + +extern int aaa; + +int +main (void) +{ + return 0; +} + diff --git a/gdb/testsuite/gdb.base/psym-external-decl.exp b/gdb/testsuite/gdb.base/psym-external-decl.exp new file mode 100644 index 0000000000..bbcc274575 --- /dev/null +++ b/gdb/testsuite/gdb.base/psym-external-decl.exp @@ -0,0 +1,30 @@ +# 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 . */ + +standard_testfile .c psym-external-decl-2.c + +set srcfiles [list $srcfile $srcfile2] + +if { [build_executable_from_specs \ + "failed to prepare" \ + $testfile [list] \ + $srcfile [list debug] \ + $srcfile2 [list]] == -1 } { + return -1 +} + +clean_restart $testfile + +gdb_test "print aaa" " = 33" diff --git a/gdb/testsuite/gdb.threads/tls.exp b/gdb/testsuite/gdb.threads/tls.exp index fca5fa6db2..8147a6c132 100644 --- a/gdb/testsuite/gdb.threads/tls.exp +++ b/gdb/testsuite/gdb.threads/tls.exp @@ -153,8 +153,14 @@ proc check_thread_stack {number spin_threads spin_threads_level} { clean_restart ${binfile} -gdb_test "print a_thread_local" \ - "Cannot read .a_thread_local. without registers" +gdb_test_multiple "print a_thread_local" "" { + -re -wrap "Cannot find thread-local variables on this target" { + kfail "gdb/25807" $gdb_test_name + } + -re -wrap "Cannot read .a_thread_local. without registers" { + pass $gdb_test_name + } +} if ![runto_main] then { fail "can't run to main"