From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10508 invoked by alias); 16 Feb 2004 15:47:02 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 10501 invoked from network); 16 Feb 2004 15:47:02 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 16 Feb 2004 15:47:02 -0000 Received: by localhost.redhat.com (Postfix, from userid 469) id 67B391A448A; Mon, 16 Feb 2004 10:42:47 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16432.58615.340874.880645@localhost.redhat.com> Date: Mon, 16 Feb 2004 15:47:00 -0000 To: fnf@redhat.com Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] Handle sh-elf-gcc scheduling code into a prologue when no debug info present In-Reply-To: <200402121505.37560.fnf@ninemoons.com> References: <200402121505.37560.fnf@ninemoons.com> X-SW-Source: 2004-02/txt/msg00404.txt.bz2 Fred Fish writes: > For the following test case: > > sub1 () > { > printf ("In sub1\n"); > } > > sub2 () > { > printf ("In sub2\n"); > } > > main () > { > sub1 (); > sub2 (); > } > Is this in our testsuite? (it looks familiar) If not could it be added? > sh-elf-gcc with -O2 will schedule the code to call sub1 into the > prologue of main. If the code is compiled WITHOUT debug info, the > prologue scanner in gdb will not stop when it sees the jsr and will > eventually return a pc somewhere after the jsr. For example: > > (gdb) br main > Breakpoint 1 at 0x1162 > (gdb) x/8i main > 0x1158
: mov.l r14,@-r15 > 0x115a : mov.l 0x116c ,r0 ! 0x1120 > 0x115c : sts.l pr,@-r15 > 0x115e : jsr @r0 > 0x1160 : mov r15,r14 > * 0x1162 : mov.l 0x1170 ,r1 ! 0x113c > 0x1164 : mov r14,r15 > 0x1166 : lds.l @r15+,pr > > Note that the breakpoint on main() gets set well after the jsr. When > you set breakpoints at sub1 and sub2 and run the program, you get: > > (gdb) run > Starting program: /links1/build/sourceware/gdb/T-sh-elf/gdb/g > Breakpoint 2, 0x00001128 in sub1 () > (gdb) c > Continuing. > In sub1 > Breakpoint 1, 0x00001162 in main () > (gdb) c > Continuing. > Breakpoint 3, 0x00001144 in sub2 () > (gdb) c > Continuing. > In sub2 > Program exited with code 012. > > which is very confusing because it appears that sub1 is called before main! > > With the attached patch, the prologue scanner returns the pc of the > jsr instruction, allowing the breakpoint at main to be hit before the > breakpoint at sub1: > OK.