From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26390 invoked by alias); 2 Jun 2009 16:51:30 -0000 Received: (qmail 26380 invoked by uid 22791); 2 Jun 2009 16:51:29 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 02 Jun 2009 16:51:22 +0000 Received: from wpaz9.hot.corp.google.com (wpaz9.hot.corp.google.com [172.24.198.73]) by smtp-out.google.com with ESMTP id n52GpKJp016510 for ; Tue, 2 Jun 2009 09:51:20 -0700 Received: from gxk21 (gxk21.prod.google.com [10.202.11.21]) by wpaz9.hot.corp.google.com with ESMTP id n52GpIiM011401 for ; Tue, 2 Jun 2009 09:51:19 -0700 Received: by gxk21 with SMTP id 21so20160355gxk.7 for ; Tue, 02 Jun 2009 09:51:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.90.71.16 with SMTP id t16mr6454480aga.66.1243961478496; Tue, 02 Jun 2009 09:51:18 -0700 (PDT) In-Reply-To: <20090602162133.GA20678@adacore.com> References: <20090602162133.GA20678@adacore.com> Date: Tue, 02 Jun 2009 16:51:00 -0000 Message-ID: Subject: Re: [RFA] skip_prologue_sal and sal expansion From: Doug Evans To: Jerome Guitton Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes 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 X-SW-Source: 2009-06/txt/msg00021.txt.bz2 On Tue, Jun 2, 2009 at 9:21 AM, Jerome Guitton wrote: > > A couple of cleanups in breakpoint.c. Let me give some background > first; consider the following program: > > int counter =3D 42; > > inline void > callee () > { > =A0counter =3D 0; /* set breakpoint in an inlined function. =A0*/ > } > > void > caller () > { > =A0callee (); > } > > int > main () > { > =A0caller (); > =A0callee (); > =A0return counter; > } > > > > When callee is inlined, we have three occurence for the line > "counter =3D 0;": inlined in caller, inlined in main, and not inlined. > When a breakpoint is set on this line, GDB sets a breakpoint on 3 > locations. > > (gdb) l p.c:6 > 1 =A0 =A0 =A0 int counter =3D 42; > 2 > 3 =A0 =A0 =A0 inline void > 4 =A0 =A0 =A0 callee () > 5 =A0 =A0 =A0 { > 6 =A0 =A0 =A0 =A0 counter =3D 0; > 7 =A0 =A0 =A0 } > 8 > 9 =A0 =A0 =A0 void > 10 =A0 =A0 =A0caller () > (gdb) b 6 > Breakpoint 1 at 0x1800074: file p.c, line 6. (3 locations) > > > I have recently hit a bug in an assembler which was optimizing out the > prologue line info; it was making GDB think that the line > "counter =3D 0;" was a part of callee's prologue. And this pointed me to > something strange in GDB. > > After having used this bogus assembler to generate my program, if I try > to set a breakpoint at line "counter =3D 0;", I end up with only one > occurence instead of three: > > (gdb) b 6 > Breakpoint 1 at 0x1800074: file p.c, line 6. > > The problem was in skip_prologue_sal defined in breakpoint.c. When it > actually skips a prologue, it does not assure that the other sal's > fields (explicit_pc and explicit_line) are left unchanged. In my case, > it was accidently changing explicit_line from 1 to 0. This change > disabled the line sal expansion, and in consequence we ended up with > the breakpoint set in only one location. I think that it's a bug in > skip_prologue_sal, this function should not change mess with these > fields. > > Now, if I change skip_prologue_sal to copy explicit_line and > explicit_pc, the line expansion is done; but we should make sure that > prologue is skipped similarly, otherwise we get an assertion failure > when the address returned by resolve_sal_pc cannot be found after > line sal expansion: > > (gdb) break p.c:6 > ../../src/gdb/breakpoint.c:5113: internal-error: expand_line_sal_maybe: > Assertion `found' failed. > > > Patch attached, tested on x86-linux. OK to apply? > > > 2009-06-02 =A0Jerome Guitton =A0 > > =A0 =A0 =A0 =A0* breakpoint.c (expand_line_sal_maybe): When explicit_line, > =A0 =A0 =A0 =A0skip prologue on each sals. > =A0 =A0 =A0 =A0(skip_prologue_sal): Return explicit_line and explicit_pc > =A0 =A0 =A0 =A0unmodified. > Sounds reasonable to me (fwiw). Still need to wait for an official maintainer's comments.