* [PATCH][gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie @ 2019-08-08 12:49 Tom de Vries 2019-08-08 17:16 ` Tom Tromey 0 siblings, 1 reply; 4+ messages in thread From: Tom de Vries @ 2019-08-08 12:49 UTC (permalink / raw) To: gdb-patches; +Cc: Kevin Buettner Hi, With target board unix/-fPIE/-pie, we get: ... FAIL: gdb.dwarf2/varval.exp: print varval2 ... This is due comparing a get_frame_pc result (which includes the for PIE non-zero relocation offset) with pc_high and pc_low obtained using get_scope_pc_bounds (which do not include the relocation offset). Fix this by adjusting pc_high and pc_low with the relocation offset. Tested on x86_64-linux with target board unix/-fPIE/-pie. OK for trunk? Thanks, - Tom [gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie gdb/ChangeLog: 2019-08-08 Tom de Vries <tdevries@suse.de> PR gdb/24591 * dwarf2read.c (dwarf2_fetch_die_loc_sect_off): Adjust pc_high and pc_low with relocation offset. --- gdb/dwarf2read.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 1c26f8355f..fde08047ca 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -23206,6 +23206,9 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, != dwarf2_per_objfile->abstract_to_concrete.end ())) { CORE_ADDR pc = (*get_frame_pc) (baton); + CORE_ADDR baseaddr + = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + struct gdbarch *gdbarch = get_objfile_arch (objfile); for (const auto &cand_off : dwarf2_per_objfile->abstract_to_concrete[die->sect_off]) @@ -23220,6 +23223,8 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, CORE_ADDR pc_low, pc_high; get_scope_pc_bounds (cand->parent, &pc_low, &pc_high, cu); + pc_low = gdbarch_adjust_dwarf2_addr (gdbarch, pc_low + baseaddr); + pc_high = gdbarch_adjust_dwarf2_addr (gdbarch, pc_high + baseaddr); if (pc_low == ((CORE_ADDR) -1) || !(pc_low <= pc && pc < pc_high)) continue; ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie 2019-08-08 12:49 [PATCH][gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie Tom de Vries @ 2019-08-08 17:16 ` Tom Tromey 2019-08-08 18:04 ` Kevin Buettner 0 siblings, 1 reply; 4+ messages in thread From: Tom Tromey @ 2019-08-08 17:16 UTC (permalink / raw) To: Tom de Vries; +Cc: gdb-patches, Kevin Buettner >>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes: Thanks for the patch. Tom> + CORE_ADDR baseaddr Tom> + = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); Tom> + struct gdbarch *gdbarch = get_objfile_arch (objfile); Tom> for (const auto &cand_off Tom> : dwarf2_per_objfile->abstract_to_concrete[die->sect_off]) Tom> @@ -23220,6 +23223,8 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, Tom> CORE_ADDR pc_low, pc_high; Tom> get_scope_pc_bounds (cand->parent, &pc_low, &pc_high, cu); Tom> + pc_low = gdbarch_adjust_dwarf2_addr (gdbarch, pc_low + baseaddr); Tom> + pc_high = gdbarch_adjust_dwarf2_addr (gdbarch, pc_high + baseaddr); Tom> if (pc_low == ((CORE_ADDR) -1) I think this test has to precede the offsetting. Tom ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie 2019-08-08 17:16 ` Tom Tromey @ 2019-08-08 18:04 ` Kevin Buettner 2019-08-09 4:50 ` Tom de Vries 0 siblings, 1 reply; 4+ messages in thread From: Kevin Buettner @ 2019-08-08 18:04 UTC (permalink / raw) To: gdb-patches; +Cc: Tom Tromey, Tom de Vries On Thu, 08 Aug 2019 11:16:44 -0600 Tom Tromey <tom@tromey.com> wrote: > >>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes: > > Thanks for the patch. > > Tom> + CORE_ADDR baseaddr > Tom> + = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); > Tom> + struct gdbarch *gdbarch = get_objfile_arch (objfile); > > Tom> for (const auto &cand_off > Tom> : dwarf2_per_objfile->abstract_to_concrete[die->sect_off]) > Tom> @@ -23220,6 +23223,8 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, > > Tom> CORE_ADDR pc_low, pc_high; > Tom> get_scope_pc_bounds (cand->parent, &pc_low, &pc_high, cu); > Tom> + pc_low = gdbarch_adjust_dwarf2_addr (gdbarch, pc_low + baseaddr); > Tom> + pc_high = gdbarch_adjust_dwarf2_addr (gdbarch, pc_high + baseaddr); > Tom> if (pc_low == ((CORE_ADDR) -1) > > I think this test has to precede the offsetting. Yes, I agree. It appears to me that the test / continue in its entirety... if (pc_low == ((CORE_ADDR) -1) || !(pc_low <= pc && pc < pc_high)) continue; ...will need to be split with the -1 part being performed before the pc_low/pc_high adjustment and the other part being performed after. Kevin ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie 2019-08-08 18:04 ` Kevin Buettner @ 2019-08-09 4:50 ` Tom de Vries 0 siblings, 0 replies; 4+ messages in thread From: Tom de Vries @ 2019-08-09 4:50 UTC (permalink / raw) To: Kevin Buettner, gdb-patches, Tom Tromey [-- Attachment #1: Type: text/plain, Size: 1379 bytes --] On 08-08-19 20:04, Kevin Buettner wrote: > On Thu, 08 Aug 2019 11:16:44 -0600 > Tom Tromey <tom@tromey.com> wrote: > >>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes: >> >> Thanks for the patch. >> >> Tom> + CORE_ADDR baseaddr >> Tom> + = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); >> Tom> + struct gdbarch *gdbarch = get_objfile_arch (objfile); >> >> Tom> for (const auto &cand_off >> Tom> : dwarf2_per_objfile->abstract_to_concrete[die->sect_off]) >> Tom> @@ -23220,6 +23223,8 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, >> >> Tom> CORE_ADDR pc_low, pc_high; >> Tom> get_scope_pc_bounds (cand->parent, &pc_low, &pc_high, cu); >> Tom> + pc_low = gdbarch_adjust_dwarf2_addr (gdbarch, pc_low + baseaddr); >> Tom> + pc_high = gdbarch_adjust_dwarf2_addr (gdbarch, pc_high + baseaddr); >> Tom> if (pc_low == ((CORE_ADDR) -1) >> >> I think this test has to precede the offsetting. Ouch, thanks for catching that. > > Yes, I agree. > > It appears to me that the test / continue in its entirety... > > if (pc_low == ((CORE_ADDR) -1) > || !(pc_low <= pc && pc < pc_high)) > continue; > > ...will need to be split with the -1 part being performed before the > pc_low/pc_high adjustment and the other part being performed after. Done. Committed as attached. Thanks, - Tom [-- Attachment #2: 0001-gdb-Fix-gdb.dwarf2-varval.exp-with-fPIE-pie.patch --] [-- Type: text/x-patch, Size: 1839 bytes --] [gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie With target board unix/-fPIE/-pie, we get: ... FAIL: gdb.dwarf2/varval.exp: print varval2 ... This is due comparing a get_frame_pc result (which includes the for PIE non-zero relocation offset) with pc_high and pc_low obtained using get_scope_pc_bounds (which do not include the relocation offset). Fix this by adjusting pc_high and pc_low with the relocation offset. Tested on x86_64-linux with target board unix/-fPIE/-pie. gdb/ChangeLog: 2019-08-08 Tom de Vries <tdevries@suse.de> PR gdb/24591 * dwarf2read.c (dwarf2_fetch_die_loc_sect_off): Adjust pc_high and pc_low with relocation offset. --- gdb/dwarf2read.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 1c26f8355f..de9755f6ce 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -23206,6 +23206,9 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, != dwarf2_per_objfile->abstract_to_concrete.end ())) { CORE_ADDR pc = (*get_frame_pc) (baton); + CORE_ADDR baseaddr + = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + struct gdbarch *gdbarch = get_objfile_arch (objfile); for (const auto &cand_off : dwarf2_per_objfile->abstract_to_concrete[die->sect_off]) @@ -23220,8 +23223,11 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, CORE_ADDR pc_low, pc_high; get_scope_pc_bounds (cand->parent, &pc_low, &pc_high, cu); - if (pc_low == ((CORE_ADDR) -1) - || !(pc_low <= pc && pc < pc_high)) + if (pc_low == ((CORE_ADDR) -1)) + continue; + pc_low = gdbarch_adjust_dwarf2_addr (gdbarch, pc_low + baseaddr); + pc_high = gdbarch_adjust_dwarf2_addr (gdbarch, pc_high + baseaddr); + if (!(pc_low <= pc && pc < pc_high)) continue; die = cand; ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-08-09 4:50 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-08-08 12:49 [PATCH][gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie Tom de Vries 2019-08-08 17:16 ` Tom Tromey 2019-08-08 18:04 ` Kevin Buettner 2019-08-09 4:50 ` Tom de Vries
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox