From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7236 invoked by alias); 26 Aug 2006 11:56:31 -0000 Received: (qmail 7216 invoked by uid 22791); 26 Aug 2006 11:56:28 -0000 X-Spam-Check-By: sourceware.org Received: from ip-160-218-131-25.eurotel.cz (HELO host0.dyn.jankratochvil.net) (160.218.131.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 26 Aug 2006 11:56:24 +0000 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.13.7/8.13.7) with ESMTP id k7QBuJRv020518 for ; Sat, 26 Aug 2006 13:56:19 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.13.7/8.13.7/Submit) id k7QBuIe5020516 for gdb-patches@sources.redhat.com; Sat, 26 Aug 2006 13:56:18 +0200 Date: Mon, 28 Aug 2006 20:48:00 -0000 From: Jan Kratochvil To: gdb-patches@sources.redhat.com Subject: [patch] Testcase for missing ELF debug info [Re: [patch] Fix gdb crash on some missing ELF debug info] Message-ID: <20060826115617.GA20505@host0.dyn.jankratochvil.net> References: <20060623103735.GA28356@host0.dyn.jankratochvil.net> <20060623123913.GB16879@nevyn.them.org> <20060623130732.GA28950@host0.dyn.jankratochvil.net> <20060712211533.GU24622@nevyn.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="OXfL5xGRrasGEqWY" Content-Disposition: inline In-Reply-To: <20060712211533.GU24622@nevyn.them.org> User-Agent: Mutt/1.4.2.1i X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-08/txt/msg00196.txt.bz2 --OXfL5xGRrasGEqWY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1613 Hi, attached testcase for the patch committed below. Regards, Jan On Wed, 12 Jul 2006 23:15:33 +0200, Daniel Jacobowitz wrote: > On Fri, Jun 23, 2006 at 03:07:32PM +0200, Jan Kratochvil wrote: > > 2006-06-23 Jan Kratochvil > > > > * dwarf2read.c (dwarf2_symbol_mark_computed): Fixed later crash > > on location list reference if the ".debug_loc" section is missing. > > I've committed this very similar patch (clearer comment). Thanks! > > -- > Daniel Jacobowitz > CodeSourcery > > 2006-07-12 Daniel Jacobowitz > > * dwarf2read.c (dwarf2_symbol_mark_computed): Handle corrupted > or missing location list information. Suggested by Jan > Kratochvil . > > Index: dwarf2read.c > =================================================================== > RCS file: /cvs/src/src/gdb/dwarf2read.c,v > retrieving revision 1.199 > diff -u -p -r1.199 dwarf2read.c > --- dwarf2read.c 14 Jun 2006 15:06:35 -0000 1.199 > +++ dwarf2read.c 12 Jul 2006 21:13:13 -0000 > @@ -9324,7 +9324,11 @@ static void > dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, > struct dwarf2_cu *cu) > { > - if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8) > + if ((attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8) > + /* ".debug_loc" may not exist at all, or the offset may be outside > + the section. If so, fall through to the complaint in the > + other branch. */ > + && DW_UNSND (attr) < dwarf2_per_objfile->loc_size) > { > struct dwarf2_loclist_baton *baton; > --OXfL5xGRrasGEqWY Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="gdb-6.5-bz196439-debug_loc-testsuite.patch" Content-length: 4762 2006-08-26 Jan Kratochvil * gdb.dwarf2/dw2-stripped.exp: New file, Handle corrupted or missing location list information. * gdb.dwarf2/dw2-stripped.c: New file, Handle corrupted or missing location list information. Testcase for: 2006-07-12 Daniel Jacobowitz * dwarf2read.c (dwarf2_symbol_mark_computed): Handle corrupted or missing location list information. Suggested by Jan Kratochvil . dwarf2read.c CVS rel. 1.200. Index: testsuite/gdb.dwarf2/dw2-stripped.c =================================================================== RCS file: testsuite/gdb.dwarf2/dw2-stripped.c diff -N testsuite/gdb.dwarf2/dw2-stripped.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.dwarf2/dw2-stripped.c 26 Aug 2006 11:47:26 -0000 @@ -0,0 +1,42 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2004 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + + +/* The function `func1' traced into must have debug info on offset > 0; + (DW_UNSND (attr)). This is the reason of `func0' existence. */ + +void +func0(int a, int b) +{ +} + +/* `func1' being traced into must have some arguments to dump. */ + +void +func1(int a, int b) +{ + func0 (a,b); +} + +int +main(void) +{ + func1 (1, 2); + return 0; +} Index: testsuite/gdb.dwarf2/dw2-stripped.exp =================================================================== RCS file: testsuite/gdb.dwarf2/dw2-stripped.exp diff -N testsuite/gdb.dwarf2/dw2-stripped.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.dwarf2/dw2-stripped.exp 26 Aug 2006 11:47:27 -0000 @@ -0,0 +1,79 @@ +# Copyright 2006 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Minimal DWARF-2 unit test + +# This test can only be run on targets which support DWARF-2. +# For now pick a sampling of likely targets. +if {![istarget *-*-linux*] + && ![istarget *-*-gnu*] + && ![istarget *-*-elf*] + && ![istarget *-*-openbsd*] + && ![istarget arm-*-eabi*] + && ![istarget powerpc-*-eabi*]} { + return 0 +} + +set testfile "dw2-stripped" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile}.x + +remote_exec build "rm -f ${binfile}" + +# get the value of gcc_compiled +if [get_compiler_info ${binfile}] { + return -1 +} + +# This test can only be run on gcc as we use additional_flags=FIXME +if {$gcc_compiled == 0} { + return 0 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } { + return -1 +} + +remote_exec build "objcopy -R .debug_loc ${binfile}" +set strip_output [remote_exec build "objdump -h ${binfile}"] + +set test "stripping test file preservation" +if [ regexp ".debug_info " $strip_output] { + pass "$test (.debug_info preserved)" +} else { + fail "$test (.debug_info got also stripped)" +} + +set test "stripping test file functionality" +if [ regexp ".debug_loc " $strip_output] { + fail "$test (.debug_loc still present)" +} else { + pass "$test (.debug_loc stripped)" +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# For C programs, "start" should stop in main(). + +gdb_test "start" \ + ".*main \\(\\) at .*" \ + "start" +gdb_test "step" \ + "func.* \\(.*\\) at .*" \ + "step" --OXfL5xGRrasGEqWY--