From patchwork Fri Aug 9 04:50:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 34011 Received: (qmail 61248 invoked by alias); 9 Aug 2019 04:50:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 61199 invoked by uid 89); 9 Aug 2019 04:50:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Aug 2019 04:50:51 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 033B2AE6F; Fri, 9 Aug 2019 04:50:48 +0000 (UTC) Subject: Re: [PATCH][gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie To: Kevin Buettner , gdb-patches@sourceware.org, Tom Tromey References: <20190808124907.GA19791@delia> <87h86r60hv.fsf@tromey.com> <20190808110418.378470a7@f29-4.lan> From: Tom de Vries Openpgp: preference=signencrypt Message-ID: <68956239-d105-8df0-dcb4-081d308b1122@suse.de> Date: Fri, 9 Aug 2019 06:50:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190808110418.378470a7@f29-4.lan> X-IsSubscribed: yes On 08-08-19 20:04, Kevin Buettner wrote: > On Thu, 08 Aug 2019 11:16:44 -0600 > Tom Tromey wrote: > >>>>>>> "Tom" == Tom de Vries 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 [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 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;