From patchwork Thu Jun 25 15:47:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 7349 Received: (qmail 38886 invoked by alias); 25 Jun 2015 15:47:26 -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 38859 invoked by uid 89); 25 Jun 2015 15:47:23 -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, KAM_LAZY_DOMAIN_SECURITY, KAM_STOCKGEN, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 25 Jun 2015 15:47:22 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id B387675; Thu, 25 Jun 2015 15:47:20 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5PFlGBT019352 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 25 Jun 2015 11:47:19 -0400 Date: Thu, 25 Jun 2015 17:47:14 +0200 From: Jan Kratochvil To: Doug Evans Cc: gdb-patches , Sergio Durigan Junior Subject: [patchv2] Do not skip prologue for asm (.S) files Message-ID: <20150625154714.GA25382@host1.jankratochvil.net> References: <20150620154449.GA24593@host1.jankratochvil.net> <20150622211556.GA26323@host1.jankratochvil.net> <20150623203501.GA23565@host1.jankratochvil.net> <20150624201958.GA10697@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150624201958.GA10697@host1.jankratochvil.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi Doug, Sergio has found a regression on ppc64 so I had to patch another function. Now on ppc64: +Running /root/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp ... -PASS: gdb.base/break.exp: run until function breakpoint, optimized file +PASS: gdb.base/break.exp: run until function breakpoint, optimized file (code motion) -PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 3: attach +XFAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 3: attach (EPERM) Jan gdb/ChangeLog 2015-06-25 Jan Kratochvil * dwarf2read.c (process_full_comp_unit): Set LOCATIONS_VALID also for language_asm. * linespec.c (minsym_found): Reset sal.PC for COMPUNIT_LOCATIONS_VALID. * symtab.c (find_function_start_sal): Likewise. gdb/testsuite/ChangeLog 2015-06-20 Jan Kratochvil * gdb.arch/amd64-prologue-skip.S: New file. * gdb.arch/amd64-prologue-skip.exp: New file. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 496b74f..8bfd034 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -8094,7 +8094,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu, Still one can confuse GDB by using non-standard GCC compilation options - this waits on GCC PR other/32998 (-frecord-gcc-switches). */ - if (cu->has_loclist && gcc_4_minor >= 5) + if ((cu->has_loclist && gcc_4_minor >= 5) || cu->language == language_asm) cust->locations_valid = 1; if (gcc_4_minor >= 5) diff --git a/gdb/linespec.c b/gdb/linespec.c index d2089b5..e5b4c56 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3454,7 +3454,22 @@ minsym_found (struct linespec_state *self, struct objfile *objfile, sal = find_pc_sect_line (pc, NULL, 0); if (self->funfirstline) - skip_prologue_sal (&sal); + { + if (sal.symtab != NULL + && COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab))) + { + /* If gdbarch_convert_from_func_ptr_addr does not apply then + sal.SECTION, sal.LINE&co. will stay correct from above. + If gdbarch_convert_from_func_ptr_addr applies then + sal.SECTION is cleared from above and sal.LINE&co. will + stay correct from the last find_pc_sect_line above. */ + sal.pc = MSYMBOL_VALUE_ADDRESS (objfile, msymbol); + sal.pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc, + ¤t_target); + } + else + skip_prologue_sal (&sal); + } if (maybe_add_address (self->addr_set, objfile->pspace, sal.pc)) add_sal_to_sals (self, result, &sal, MSYMBOL_NATURAL_NAME (msymbol), 0); diff --git a/gdb/symtab.c b/gdb/symtab.c index 6693930..43840ab 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3617,6 +3617,13 @@ find_function_start_sal (struct symbol *sym, int funfirstline) section = SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym); sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), section, 0); + if (funfirstline && sal.symtab != NULL + && COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab))) + { + sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); + return sal; + } + /* We always should have a line for the function start address. If we don't, something is odd. Create a plain SAL refering just the PC and hope that skip_prologue_sal (if requested) diff --git a/gdb/testsuite/gdb.arch/amd64-prologue-skip.S b/gdb/testsuite/gdb.arch/amd64-prologue-skip.S new file mode 100644 index 0000000..66b806a --- /dev/null +++ b/gdb/testsuite/gdb.arch/amd64-prologue-skip.S @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2015 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .text +/*0*/ hlt +pushrbp: .globl pushrbp +#define PUSHRBP push %rbp; mov %rsp, %rbp; nop +/*1*/ PUSHRBP +/*6*/ hlt + +/*7*/ hlt +#define MINSYM nop; .globl minsym; minsym: nop +/*8*/ MINSYM +/*a*/ hlt diff --git a/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp b/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp new file mode 100644 index 0000000..015cd69 --- /dev/null +++ b/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp @@ -0,0 +1,35 @@ +# Copyright 2010-2015 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +standard_testfile .S +set binfile ${binfile}.o + +if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { + verbose "Skipping ${testfile}." + return +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}] != "" } { + untested ${testfile} + return +} + +clean_restart ${binfile} + +gdb_test "break *pushrbp" " at 0x1: file .*" +gdb_test "break pushrbp" " at 0x1: file .*" + +gdb_test "break *minsym" " at 0x9: file .*" +gdb_test "break minsym" " at 0x9: file .*"