From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6139 invoked by alias); 3 Sep 2014 17:51:25 -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 6129 invoked by uid 89); 3 Sep 2014 17:51:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f169.google.com Received: from mail-vc0-f169.google.com (HELO mail-vc0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 03 Sep 2014 17:51:20 +0000 Received: by mail-vc0-f169.google.com with SMTP id hq11so9433026vcb.28 for ; Wed, 03 Sep 2014 10:51:18 -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=WCtlflJwiHNH7/ybKGzeuBtgEVVyi5QJ4MjEMplAmUI=; b=FZo4r8G2TAi6peQXIiBt7AMv0yJZRHYsqXbehXaK0GO/5yKRi+iSBGNAGa36bJG5pR 01IROZBW9kbwulHI+ug1D1iCFn5RLy0j3XQkS/nBy2uqSCgQJTN0lM6ahuMvvka+IjPE PWI+3PkOvA27NKmgfbSaPvxg4oat/360Mojg+hqL/CDBbPPqwDiroxY3pQAaks4qjpKi mqh3UVVc/NNnTtXW5+8Bm+st68pwR529AkpyRYcoC4BuUgARhU2XEQ/QuJOa1hzYWm0u kOwXwTJ5baAa2KL99bN32j6P8wV+BanAQp/OGDay7AUe52GgRQklla7JnDoRsLgNfGVm mB/Q== X-Gm-Message-State: ALoCoQmxlCJLOVCvhATAck+7epmVZeV549mDhMk8d370/BIIa/7JymJneqaIdmWmYLt9+Nhb+hZF MIME-Version: 1.0 X-Received: by 10.220.86.72 with SMTP id r8mr2816724vcl.36.1409766678115; Wed, 03 Sep 2014 10:51:18 -0700 (PDT) Received: by 10.52.136.203 with HTTP; Wed, 3 Sep 2014 10:51:17 -0700 (PDT) In-Reply-To: <1409706936-11220-1-git-send-email-yao@codesourcery.com> References: <1409706936-11220-1-git-send-email-yao@codesourcery.com> Date: Wed, 03 Sep 2014 17:51:00 -0000 Message-ID: Subject: Re: [PATCH] Fix gdb.dwarf2/dwz.exp for 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-09/txt/msg00094.txt.bz2 On Tue, Sep 2, 2014 at 6:15 PM, Yao Qi wrote: > Hi, > We see the fail in gdb.dwarf2/dwz.exp in thumb mode, > > p the_int^M > $2 = 99^M > (gdb) FAIL: gdb.dwarf2/dwz.exp: p the_int > > 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. > > This patch copies the approach from > > [PATCH 4/4] Fix gdb.trace/entry-values.exp for thumb mode > https://sourceware.org/ml/gdb-patches/2014-07/msg00041.html > > introduce new label 'main_start' which is the correct > function address (without lsb set). This patch fixes these > fails we've seen. > > Regression tested on arm-none-eabi and x86_64-linux. > > gdb/testsuite: > > 2014-09-03 Yao Qi > > * gdb.dwarf2/dwz.exp: Use main_start instead of main. > * gdb.dwarf2/main.c: Define label 'main_start' at the beginning > function 'main'. > --- > gdb/testsuite/gdb.dwarf2/dwz.exp | 4 ++-- > gdb/testsuite/gdb.dwarf2/main.c | 4 ++++ > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/gdb/testsuite/gdb.dwarf2/dwz.exp b/gdb/testsuite/gdb.dwarf2/dwz.exp > index 9175f9e..ef19631 100644 > --- a/gdb/testsuite/gdb.dwarf2/dwz.exp > +++ b/gdb/testsuite/gdb.dwarf2/dwz.exp > @@ -79,8 +79,8 @@ Dwarf::assemble $asm_file { > partial_label: partial_unit {} { > subprogram { > {name main} > - {low_pc main addr} > - {high_pc "main + $main_length" addr} > + {low_pc main_start addr} > + {high_pc "main_start + $main_length" addr} > } > } > } > diff --git a/gdb/testsuite/gdb.dwarf2/main.c b/gdb/testsuite/gdb.dwarf2/main.c > index 3ddd194..5a4cbc3 100644 > --- a/gdb/testsuite/gdb.dwarf2/main.c > +++ b/gdb/testsuite/gdb.dwarf2/main.c > @@ -17,6 +17,10 @@ > > /* Dummy main function. */ > > +asm (".section \".text\""); > +asm (".balign 8"); > +asm ("main_start: .globl main_start"); > + > int > main() > { This approach is fragile w.r.t. clang. IIUC, Clang makes no guarantees about the ordering of global asms and other objects, or even other objects w.r.t. each other (even at -O0). The email you refer to above refers to another email, https://sourceware.org/ml/gdb-patches/2014-03/msg00202.html and that email does a similar thing to fix dw2-ifort-parameter.exp (not for thumb, but for similar reasons). dw2-ifort-parameter.exp currently fails with clang on amd64-linux because func gets moved after main, but the asms that wrap func stay put. Loosely speaking, asm ("func_start:"); void func () {} asm ("func_end:"); int main () { return 0; } gets emitted as: asm ("func_start:"); asm ("func_end:"); int main () { return 0; } void func () {} I don't have a solution yet, I'm just giving a "heads up".