From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9195 invoked by alias); 21 Mar 2009 08:54:20 -0000 Received: (qmail 9187 invoked by uid 22791); 21 Mar 2009 08:54:20 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_12,J_CHICKENPOX_93,SARE_MSGID_LONG40,SPF_PASS,WEIRD_PORT X-Spam-Check-By: sourceware.org Received: from ti-out-0910.google.com (HELO ti-out-0910.google.com) (209.85.142.184) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 21 Mar 2009 08:54:15 +0000 Received: by ti-out-0910.google.com with SMTP id a1so849057tib.12 for ; Sat, 21 Mar 2009 01:54:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.110.20.15 with SMTP id 15mr7272637tit.54.1237625652667; Sat, 21 Mar 2009 01:54:12 -0700 (PDT) In-Reply-To: <6D19CA8D71C89C43A057926FE0D4ADAA07152198@ecamlmw720.eamcs.ericsson.se> References: <6D19CA8D71C89C43A057926FE0D4ADAA07152198@ecamlmw720.eamcs.ericsson.se> Date: Sat, 21 Mar 2009 08:54:00 -0000 Message-ID: Subject: Re: ProcessRecord problem with recursion From: Hui Zhu To: Marc Khouzam Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00134.txt.bz2 Hi Marc, I had post a patch for it in http://sourceware.org/ml/gdb-patches/2009-03/msg00428.html Thanks, Hui On Fri, Mar 20, 2009 at 09:13, Marc Khouzam wro= te: > Hi, > > I'm having problems with ProcessRecord and recursion. > It looks like the reverse-next operation behaves like > reverse-step when dealing with a recursive method. > > I have GDB HEAD from the 18th of March, with the patches included in > http://sourceware.org/ml/gdb-patches/2009-03/msg00375.html > http://sourceware.org/ml/gdb-patches/2009-03/msg00005.html > http://sourceware.org/ml/gdb-patches/2009-01/msg00444.html > > Here is a program and session that shows the problem: > > GNU gdb (GDB) 6.8.50.20090318-cvs > [...] > (gdb) l > 1 =A0 =A0 =A0 int factorial(int x) { > 2 =A0 =A0 =A0 =A0 =A0if (x =3D=3D 1) return 1; > 3 =A0 =A0 =A0 =A0 =A0int result =3D x * factorial(x-1); > 4 =A0 =A0 =A0 =A0 =A0return result; > 5 =A0 =A0 =A0 } > 6 > 7 =A0 =A0 =A0 int main() { > 8 =A0 =A0 =A0 =A0 =A0 factorial(5); > 9 =A0 =A0 =A0 =A0 =A0 return 0; > 10 =A0 =A0 =A0} > (gdb) start > Temporary breakpoint 1 at 0x804847b: file a.cc, line 8. > Starting program: /local/home/lmckhou/testing/a.out > > Temporary breakpoint 1, main () at a.cc:8 > 8 =A0 =A0 =A0 =A0 =A0 factorial(5); > (gdb) rec > (gdb) s > factorial (x=3D5) at a.cc:2 > 2 =A0 =A0 =A0 =A0 =A0if (x =3D=3D 1) return 1; > (gdb) n > 3 =A0 =A0 =A0 =A0 =A0int result =3D x * factorial(x-1); > (gdb) n > 4 =A0 =A0 =A0 =A0 =A0return result; > (gdb) rn > factorial (x=3D4) at a.cc:5 > 5 =A0 =A0 =A0 } > > Notice how the reverse-next(rn) command jumped to the end > of the next factorial method on the stack (x=3D4 instead of x=3D5). > > Thanks > > Marc > >