* [PATCH] Fix toplevel types with -fdebug-types-section
@ 2020-01-18 18:59 Mark Williams
2020-01-19 2:04 ` Simon Marchi
0 siblings, 1 reply; 6+ messages in thread
From: Mark Williams @ 2020-01-18 18:59 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 322 bytes --]
Per https://sourceware.org/bugzilla/show_bug.cgi?id=24480 toplevel
types were broken by
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=93b8bea4143cafae79076076c64aaa4c46a9b73c
because it only set list_in_scope in start_sym_tab. With type-units,
It also needs to be set when re-opening a symtab.
Mark
[-- Attachment #2: 0001-gdb-Fix-toplevel-types-with-fdebug-types-section.patch --]
[-- Type: application/octet-stream, Size: 1285 bytes --]
From 87fd17d7cc15fc0e49c4afe30edb2faf8f2b83a9 Mon Sep 17 00:00:00 2001
From: mwilliams <mwilliams@fb.com>
Date: Wed, 15 Jan 2020 20:19:39 -0800
Subject: [PATCH] gdb: Fix toplevel types with -fdebug-types-section
When debugging a program compiled with -fdebug-types-section,
only the first top-level type in each file is visible to gdb.
gdb/Changelog
2020-01-18 Mark Williams <mark@myosotissp.com>
PR gdb/24480
* dwarf2read.c add missing assingments to list_in_scope when
start_symtab was already called.
---
gdb/dwarf2read.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index d1b65b7bc3..c8f0d27f91 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11762,6 +11762,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
COMPUNIT_DIRNAME (cust),
compunit_language (cust),
0, cust));
+ list_in_scope = get_builder ()->get_file_symbols ();
}
return;
}
@@ -11813,6 +11814,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
COMPUNIT_DIRNAME (cust),
compunit_language (cust),
0, cust));
+ list_in_scope = get_builder ()->get_file_symbols ();
auto &file_names = line_header->file_names ();
for (i = 0; i < file_names.size (); ++i)
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix toplevel types with -fdebug-types-section
2020-01-18 18:59 [PATCH] Fix toplevel types with -fdebug-types-section Mark Williams
@ 2020-01-19 2:04 ` Simon Marchi
2020-01-19 2:10 ` Simon Marchi
0 siblings, 1 reply; 6+ messages in thread
From: Simon Marchi @ 2020-01-19 2:04 UTC (permalink / raw)
To: Mark Williams, gdb-patches
On 2020-01-18 1:53 p.m., Mark Williams wrote:
> Per https://sourceware.org/bugzilla/show_bug.cgi?id=24480 toplevel
> types were broken by
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=93b8bea4143cafae79076076c64aaa4c46a9b73c
> because it only set list_in_scope in start_sym_tab. With type-units,
> It also needs to be set when re-opening a symtab.
>
> Mark
>
Hi Mark,
Thanks for sending a patch.
Can you please put a bit more information in the commit message? In particular:
- An illustration of the problem, and how to reproduce it
- Why/how this patch fixes the problem
There are good elements about that in the bug report discussions, it's just a matter
of synthesizing them in the commit message.
Thanks,
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix toplevel types with -fdebug-types-section
2020-01-19 2:04 ` Simon Marchi
@ 2020-01-19 2:10 ` Simon Marchi
2020-01-19 16:31 ` Mark Williams
0 siblings, 1 reply; 6+ messages in thread
From: Simon Marchi @ 2020-01-19 2:10 UTC (permalink / raw)
To: Mark Williams, gdb-patches
On 2020-01-18 8:59 p.m., Simon Marchi wrote:
> On 2020-01-18 1:53 p.m., Mark Williams wrote:
>> Per https://sourceware.org/bugzilla/show_bug.cgi?id=24480 toplevel
>> types were broken by
>> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=93b8bea4143cafae79076076c64aaa4c46a9b73c
>> because it only set list_in_scope in start_sym_tab. With type-units,
>> It also needs to be set when re-opening a symtab.
>>
>> Mark
>>
>
> Hi Mark,
>
> Thanks for sending a patch.
>
> Can you please put a bit more information in the commit message? In particular:
>
> - An illustration of the problem, and how to reproduce it
> - Why/how this patch fixes the problem
>
> There are good elements about that in the bug report discussions, it's just a matter
> of synthesizing them in the commit message.
>
> Thanks,
>
> Simon
>
Oh, and also we try our best to add a test (in gdb/testsuite) when we fix a bug, so
that this particular bug doesn't come back later. I think this is something that
would be pretty easy to test. That test would probably belong in testsuite/gdb.dwarf2,
since this is quite dwarf-specific.
There are hints on how to write tests here:
https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Building_the_Example_Program
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix toplevel types with -fdebug-types-section
2020-01-19 2:10 ` Simon Marchi
@ 2020-01-19 16:31 ` Mark Williams
2020-01-19 16:40 ` Simon Marchi
2020-01-21 19:56 ` Tom Tromey
0 siblings, 2 replies; 6+ messages in thread
From: Mark Williams @ 2020-01-19 16:31 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 68 bytes --]
New patch, with more detail in the commit message, and a test case.
[-- Attachment #2: 0001-gdb-Fix-toplevel-types-with-fdebug-types-section.patch --]
[-- Type: application/octet-stream, Size: 4848 bytes --]
From fac8ac9559f2b97325f0fab3315afc5088d6c38d Mon Sep 17 00:00:00 2001
From: mwilliams <mwilliams@fb.com>
Date: Sun, 19 Jan 2020 08:09:59 -0800
Subject: [PATCH] gdb: Fix toplevel types with -fdebug-types-section
When debugging a program compiled with -fdebug-types-section,
only the first top-level type in each file is visible to gdb.
The problem was caused by moving the assignment to list_in_scope
from process_full_comp_unit and process_full_type_unit to
start_symtab. This was fine for process_full_comp_unit, because
symtabs and comp units are one-to-one. But there can be many type
units per symtab (one for each type), and we only call start_symtab
for the first one. This adds the necessary assignments on the paths
where start_symtab is not called.
gdb/Changelog
2020-01-19 Mark Williams <mark@myosotissp.com>
PR gdb/24480
* dwarf2read.c add missing assingments to list_in_scope when
start_symtab was already called.
gdb/testsuite/Changelog
2020-01-19 Mark Williams <mark@myosotissp.com>
PR gdb/24480
* dw4-toplevel-types.exp Test for top level types
* dw4-toplevel-types.cc Test for top level types
---
gdb/dwarf2read.c | 2 ++
.../gdb.dwarf2/dw4-toplevel-types.cc | 21 +++++++++++
.../gdb.dwarf2/dw4-toplevel-types.exp | 35 +++++++++++++++++++
3 files changed, 58 insertions(+)
create mode 100644 gdb/testsuite/gdb.dwarf2/dw4-toplevel-types.cc
create mode 100644 gdb/testsuite/gdb.dwarf2/dw4-toplevel-types.exp
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index d1b65b7bc3..c8f0d27f91 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11762,6 +11762,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
COMPUNIT_DIRNAME (cust),
compunit_language (cust),
0, cust));
+ list_in_scope = get_builder ()->get_file_symbols ();
}
return;
}
@@ -11813,6 +11814,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
COMPUNIT_DIRNAME (cust),
compunit_language (cust),
0, cust));
+ list_in_scope = get_builder ()->get_file_symbols ();
auto &file_names = line_header->file_names ();
for (i = 0; i < file_names.size (); ++i)
diff --git a/gdb/testsuite/gdb.dwarf2/dw4-toplevel-types.cc b/gdb/testsuite/gdb.dwarf2/dw4-toplevel-types.cc
new file mode 100644
index 0000000000..ebb9ea7f16
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw4-toplevel-types.cc
@@ -0,0 +1,21 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2016 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/>. */
+
+struct X {} x;
+struct Y {} y;
+struct Z {} z;
+int main() {}
diff --git a/gdb/testsuite/gdb.dwarf2/dw4-toplevel-types.exp b/gdb/testsuite/gdb.dwarf2/dw4-toplevel-types.exp
new file mode 100644
index 0000000000..70dc24cba5
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw4-toplevel-types.exp
@@ -0,0 +1,35 @@
+# Copyright 2010-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/>.
+
+# Test dwarf4 signatured types (DW_TAG_type_unit).
+
+standard_testfile .cc
+
+# This test is intended for targets which support DWARF-4.
+# Since we pass an explicit -gdwarf-4 -fdebug-types-section to the compiler,
+# we let that be the test of whether the target supports it.
+
+if { [prepare_for_testing "failed to prepare" "${testfile}" \
+ $srcfile {debug c++ additional_flags=-gdwarf-4 additional_flags=-fdebug-types-section}] } {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+gdb_test "ptype X" "type = struct X {.*"
+gdb_test "ptype Y" "type = struct Y {.*"
+gdb_test "ptype Z" "type = struct Z {.*"
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix toplevel types with -fdebug-types-section
2020-01-19 16:31 ` Mark Williams
@ 2020-01-19 16:40 ` Simon Marchi
2020-01-21 19:56 ` Tom Tromey
1 sibling, 0 replies; 6+ messages in thread
From: Simon Marchi @ 2020-01-19 16:40 UTC (permalink / raw)
To: Mark Williams; +Cc: gdb-patches, Tom Tromey
On 2020-01-19 11:18 a.m., Mark Williams wrote:
> New patch, with more detail in the commit message, and a test case.
>
Awesome, thanks. The patch looks good to me, but I'd like to leave a chance
for Tom (who did the original change) to approve as well.
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix toplevel types with -fdebug-types-section
2020-01-19 16:31 ` Mark Williams
2020-01-19 16:40 ` Simon Marchi
@ 2020-01-21 19:56 ` Tom Tromey
1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2020-01-21 19:56 UTC (permalink / raw)
To: Mark Williams; +Cc: Simon Marchi, gdb-patches
>>>>> "Mark" == Mark Williams <mark@myosotissp.com> writes:
Mark> gdb/Changelog
Mark> 2020-01-19 Mark Williams <mark@myosotissp.com>
Mark> PR gdb/24480
Mark> * dwarf2read.c add missing assingments to list_in_scope when
Mark> start_symtab was already called.
Mark> gdb/testsuite/Changelog
Mark> 2020-01-19 Mark Williams <mark@myosotissp.com>
Mark> PR gdb/24480
Mark> * dw4-toplevel-types.exp Test for top level types
Mark> * dw4-toplevel-types.cc Test for top level types
Thanks, this looks good to me.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-01-21 19:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-18 18:59 [PATCH] Fix toplevel types with -fdebug-types-section Mark Williams
2020-01-19 2:04 ` Simon Marchi
2020-01-19 2:10 ` Simon Marchi
2020-01-19 16:31 ` Mark Williams
2020-01-19 16:40 ` Simon Marchi
2020-01-21 19:56 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox