From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26997 invoked by alias); 22 Aug 2014 17:40:17 -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 26987 invoked by uid 89); 22 Aug 2014 17:40:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 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-f202.google.com Received: from mail-vc0-f202.google.com (HELO mail-vc0-f202.google.com) (209.85.220.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 22 Aug 2014 17:40:15 +0000 Received: by mail-vc0-f202.google.com with SMTP id hq11so1294755vcb.1 for ; Fri, 22 Aug 2014 10:40:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:cc:subject:in-reply-to :references; bh=9x7Ym51xRkTlf1FhAICoJ9JymL2StLDnjdEBthl/tX0=; b=RpXD7QKIxvjjdMsJGk0goao40xuwkLtesVs24iNKl3ufOVrvIeKH6kIqoR+IpKcAIJ 36s0JLIEKJIE5QW+AxyCWp0Ujd83Z9kGePpkmTcHghn5MNfJ2/YRkAhCyIGgz3bkp4bs K6CeQJUcyKrgw4fbAhJXMMwSMd2A3fjIkbLlC7fQKapRzTc8KPnr4NqY3ppAkmlRp4t7 79l2q6GyqJbbbMy8NiVYnbGUFvPkq0b2jVkeWyhD7P8Y3Wn0e5EjWido5WR+TtssIlzp VeMDBcQI1RY8xT306jAYR0RwvZBeY3ZU6S6GL/foW6FlS92rMsOTKV71vp2J+ExMseDx XGQQ== X-Gm-Message-State: ALoCoQlq33akwYSvdbtL81o1OX6QrzTtEv1CuiXQS2ArpDYfZhsFMCBVRgWJPsqEnkLMUGmwx1dG X-Received: by 10.236.150.170 with SMTP id z30mr4849272yhj.58.1408729213524; Fri, 22 Aug 2014 10:40:13 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id f44si343618yhf.1.2014.08.22.10.40.13 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Aug 2014 10:40:13 -0700 (PDT) Received: from ruffy2.mtv.corp.google.com (ruffy2.mtv.corp.google.com [172.17.128.107]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id DF21431C1F3; Fri, 22 Aug 2014 10:40:12 -0700 (PDT) From: Doug Evans MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <21495.32892.341399.802579@ruffy2.mtv.corp.google.com> Date: Fri, 22 Aug 2014 17:40:00 -0000 To: Yao Qi Cc: Subject: Re: [PATCH 1/3] Check function is GC'ed In-Reply-To: <1408609338-17561-1-git-send-email-yao@codesourcery.com> References: <53D8A264.1050103@codesourcery.com> <1408609338-17561-1-git-send-email-yao@codesourcery.com> X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00503.txt.bz2 Yao Qi writes: > I see the following fail on arm-none-eabi target, > > (gdb) b 24^M > Breakpoint 1 at 0x4: file > ../../../../git/gdb/testsuite/gdb.base/break-on-linker-gcd-function.cc, > line 24.^M > (gdb) FAIL: gdb.base/break-on-linker-gcd-function.exp: b 24 > > Currently, we are using flag has_section_at_zero to determine whether > address zero in debug info means the corresponding code has been > GC'ed, like this: > > case DW_LNE_set_address: > address = read_address (abfd, line_ptr, cu, &bytes_read); > > if (address == 0 && !dwarf2_per_objfile->has_section_at_zero) > { > /* This line table is for a function which has been > GCd by the linker. Ignore it. PR gdb/12528 */ > > However, this is incorrect on some bare metal targets, as .text > section is located at 0x0, so dwarf2_per_objfile->has_section_at_zero > is true. If a function is GC'ed by linker, the address is zero. GDB > thinks address zero is a function's address rather than this function > is GC'ed. > > In this patch, we choose 'textlow' field of partial symtabl to check > whether 'textlow' is zero. If it isn't, address zero really means the > function is GC'ed. This patch fixes the fail above. Note that this > patch only fixes the problem on the path that partial symtab is used. > On other paths partial symtab isn't used (start gdb with --readnow for > example), I don't find a good way to fix it. > > It is regression tested on x86_64-linux, arm-none-eabi, > arm-none-linux-gnueabi. OK to apply? > > gdb: > > 2014-08-20 Yao Qi > > * dwarf2read.c (dwarf_decode_lines_1): Skip the line table if > PST->textlow is greater than zero. > --- > gdb/dwarf2read.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c > index b4d53c8..cf2ce76 100644 > --- a/gdb/dwarf2read.c > +++ b/gdb/dwarf2read.c > @@ -17229,6 +17229,8 @@ dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir, > /* Decode the table. */ > while (!end_sequence) > { > + struct partial_symtab *pst = NULL; > + > op_code = read_1_byte (abfd, line_ptr); > line_ptr += 1; > if (line_ptr > line_end) > @@ -17291,7 +17293,12 @@ dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir, > case DW_LNE_set_address: > address = read_address (abfd, line_ptr, cu, &bytes_read); > > - if (address == 0 && !dwarf2_per_objfile->has_section_at_zero) > + if (!decode_for_pst_p && !dwarf2_per_objfile->using_index) > + pst = cu->per_cu->v.psymtab; > + > + if (address == 0 > + && (!dwarf2_per_objfile->has_section_at_zero > + || (pst != NULL && pst->textlow > address))) > { > /* This line table is for a function which has been > GCd by the linker. Ignore it. PR gdb/12528 */ Hi. I'd like to solve this for both partial syms and .gdb_index. We want to, essentially, discard the entry if address is outside the range of the cu (the range needn't be contiguous, but for the task at hand I don't think it matters). I haven't dug into this too deeply, but if we have lowpc (which for example is that read_file_scope has before it calls handle_DW_AT_stmt_list (which calls dwarf_decode_lines), can we use that in the test? Can we arrange for all callers of dwarf_decode_lines_1 pass lowpc down to it? [Or both lowpc,highpc for a more complete test, but for the task at hand we've only been checking, effectively, lowpc all along so I don't mind leaving it at that for now.]