From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14502 invoked by alias); 8 Oct 2014 15:32:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 14484 invoked by uid 89); 8 Oct 2014 15:32:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-vc0-f171.google.com Received: from mail-vc0-f171.google.com (HELO mail-vc0-f171.google.com) (209.85.220.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 08 Oct 2014 15:32:02 +0000 Received: by mail-vc0-f171.google.com with SMTP id hy10so6937622vcb.16 for ; Wed, 08 Oct 2014 08:31:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=teGWnQkXBEKyacdIXv/CuDQdVEv5yaeFpC7IwacPY68=; b=EDcmnin8AdrJHV7nk8DOyjLO8qshf6IFzkUwx06WtTam5MvPkeehi9YdaglkyMZmLc OsQkNH/kK64EjnF4a/z5bsoM+qNEl0Ox34TpQi3wQtNB2ePx1zZnfML+CVqrS1Pxkc2P HKpxNwgYVZhTnF/WALUyxdHlHs0nU9yZ6MH+4BGJIg969JGk/FzbL24Ya+d196syOChJ w6zrlid6xxOgKccab7FNyulhQ7QElaqZXSs9/AJdFq/WLLn9RXRIlj7Mxz3rcw0EoXHi Ien1lUg1rXE+hZzYIS9407y7CIhoa9/CYC5B1rYbjHiZaSz0C6EGvryWLN1fq3/aZVeD Mu6w== X-Gm-Message-State: ALoCoQklaNOBPaM14ICK/cBLXwRbI0EWKMguzL4X6oTHIAvUxlW9SfJxLkMXAbHwk+MWvHOh/b7+ MIME-Version: 1.0 X-Received: by 10.220.169.75 with SMTP id x11mr10893113vcy.36.1412782319745; Wed, 08 Oct 2014 08:31:59 -0700 (PDT) Received: by 10.52.181.65 with HTTP; Wed, 8 Oct 2014 08:31:59 -0700 (PDT) In-Reply-To: <1411951921-16168-3-git-send-email-yao@codesourcery.com> References: <1411951921-16168-1-git-send-email-yao@codesourcery.com> <1411951921-16168-3-git-send-email-yao@codesourcery.com> Date: Wed, 08 Oct 2014 15:32:00 -0000 Message-ID: Subject: Re: [PATCH 2/2] Fix implptr-optimized-out.exp fail in thumb mode From: Doug Evans To: Yao Qi Cc: gdb-patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00155.txt.bz2 On Sun, Sep 28, 2014 at 8:52 PM, Yao Qi wrote: > Hi, > I see the fail in gdb.dwarf2/implptr-optimized-out.exp in thumb mode > > (gdb) p p->f^M > No symbol "p" in current context.^M > (gdb) FAIL: gdb.dwarf2/implptr-optimized-out.exp: p p->f > > In thumb mode, the lsb of references to 'main' in the assembly > (produced by dwarf assember) is set, so the generated debug > information is incorrect. > > in this patch, we add a label main_label inside function main. Linker > doesn't set its lsb in thumb mode, and we can get function main's > address by 'main_label - $main_label_offset'. > > gdb/testsuite: > > 2014-09-29 Yao Qi > > * gdb.dwarf2/implptr-optimized-out.exp: Compile main.c to object. > Calculate the offset of main_label to main. Compile the generated > asm file and link the executable. > (Dwarf::assemble): Get address of main by > main_label - $main_label_offset. > --- > gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp | 39 ++++++++++++++++++++-- > 1 file changed, 36 insertions(+), 3 deletions(-) > > diff --git a/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp > index 649f52d..534bed0 100644 > --- a/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp > +++ b/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp > @@ -22,9 +22,35 @@ if {![dwarf2_support]} { > standard_testfile main.c .S > set executable ${testfile} > > +if {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \ > + object {}] != ""} { > + return -1 > +} > +# Start GDB and load object file, compute the offset from main to > +# main_label which are needed in the Dwarf Assembler below. > +clean_restart ${binfile}1.o > + > +set main_label_offset "" > +set test "p main_label - main" > +gdb_test_multiple $test $test { > + -re ".* = ($decimal)\r\n$gdb_prompt $" { > + set main_label_offset $expect_out(1,string) > + } > +} > + > +if { $main_label_offset == "" } { > + # Bail out here, because we can't do the following tests if > + # $main_label_offset is unknown. > + return -1 > +} > + > +gdb_exit > + > # Create the DWARF. > set asm_file [standard_output_file $srcfile2] > Dwarf::assemble $asm_file { > + global main_label_offset > + > cu { version 3 } { > compile_unit { > {producer "GNU C 4.4.3"} > @@ -52,8 +78,8 @@ Dwarf::assemble $asm_file { > > subprogram { > {name main} > - {low_pc main addr} > - {high_pc main+0x100 addr} > + {low_pc "main_label - $main_label_offset" addr} > + {high_pc "main_label - $main_label_offset + 0x100" addr} > {type :$int_label} > {external 1 flag} > } { > @@ -80,10 +106,17 @@ Dwarf::assemble $asm_file { > } > } > > -if [prepare_for_testing ${testfile}.exp $executable "${asm_file} ${srcfile}" {}] { > +if {[gdb_compile $asm_file ${binfile}0.o object {}] != ""} { > return -1 > } > > +if {[gdb_compile [list ${binfile}0.o ${binfile}1.o] \ > + "${binfile}" executable {}] != ""} { > + return -1 > +} > + > +clean_restart ${testfile} > + > # DW_OP_GNU_implicit_pointer implementation requires a valid frame. > if ![runto_main] { > return -1 Hi. One question that comes to mind is: If this solution is going to proliferate it would be good to convince ourselves there's no better solution. I'm ok with this as a one-off here and there, but I'd like to understand how many more of these will there be. Plus I can imagine of course the number growing over time. Can we, for example, enhance the dwarf assembler and provide a hook for the thumb target to use to fix this there? But *if* we do decide there's no better solution, there's a lot of boilerplate here. Can we tuck it away in a utility?