From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20064 invoked by alias); 21 Aug 2014 08:26:30 -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 19993 invoked by uid 89); 21 Aug 2014 08:26:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Aug 2014 08:26:28 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1XKNhQ-0004JR-SV from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 21 Aug 2014 01:26:24 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 21 Aug 2014 01:26:24 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.2.247.3; Thu, 21 Aug 2014 01:26:23 -0700 From: Yao Qi To: Subject: [PATCH 1/3] Check function is GC'ed Date: Thu, 21 Aug 2014 08:26:00 -0000 Message-ID: <1408609338-17561-1-git-send-email-yao@codesourcery.com> In-Reply-To: <53D8A264.1050103@codesourcery.com> References: <53D8A264.1050103@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00468.txt.bz2 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 */ -- 1.9.3