From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12115 invoked by alias); 20 Mar 2009 03:10:12 -0000 Received: (qmail 12097 invoked by uid 22791); 20 Mar 2009 03:10:10 -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.190) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 Mar 2009 03:10:04 +0000 Received: by ti-out-0910.google.com with SMTP id a1so465848tib.12 for ; Thu, 19 Mar 2009 20:10:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.110.31.5 with SMTP id e5mr5122606tie.35.1237518600861; Thu, 19 Mar 2009 20:10:00 -0700 (PDT) In-Reply-To: <6D19CA8D71C89C43A057926FE0D4ADAA07152198@ecamlmw720.eamcs.ericsson.se> References: <6D19CA8D71C89C43A057926FE0D4ADAA07152198@ecamlmw720.eamcs.ericsson.se> Date: Fri, 20 Mar 2009 03:10:00 -0000 Message-ID: Subject: Re: ProcessRecord problem with recursion From: Hui Zhu To: Marc Khouzam Cc: gdb@sourceware.org, Michael Snyder 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/msg00129.txt.bz2 Thanks Marc, That is a very cool test code. 4 return result; 0x0804844e <_Z9factoriali+42>: mov -0x4(%ebp),%eax 0x08048451 <_Z9factoriali+45>: mov %eax,-0x14(%ebp) 0x08048454 <_Z9factoriali+48>: mov -0x14(%ebp),%eax (gdb) rn infrun: clear_proceed_status_thread (process 9955) infrun: proceed (addr=3D0xffffffff, signal=3D144, step=3D1) infrun: resume (step=3D1, signal=3D0), trap_expected=3D0 infrun: wait_for_inferior (treat_exec_as_sigtrap=3D0) infrun: target_wait (-1, status) =3D infrun: 9955 [process 9955], infrun: status->kind =3D stopped, signal =3D SIGTRAP infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc =3D 0x804844b infrun: keep going infrun: resume (step=3D1, signal=3D0), trap_expected=3D0 infrun: prepare_to_wait infrun: target_wait (-1, status) =3D infrun: 9955 [process 9955], infrun: status->kind =3D stopped, signal =3D SIGTRAP infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc =3D 0x8048447 infrun: stepping inside range [0x8048439-0x804844e] infrun: resume (step=3D1, signal=3D0), trap_expected=3D0 infrun: prepare_to_wait infrun: target_wait (-1, status) =3D infrun: 9955 [process 9955], infrun: status->kind =3D stopped, signal =3D SIGTRAP infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc =3D 0x8048458 infrun: keep going infrun: resume (step=3D1, signal=3D0), trap_expected=3D0 infrun: prepare_to_wait infrun: target_wait (-1, status) =3D infrun: 9955 [process 9955], infrun: status->kind =3D stopped, signal =3D SIGTRAP infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc =3D 0x8048457 infrun: stepping inside range [0x8048457-0x804845a] infrun: stop_stepping factorial (x=3D4) at b.cc:5 5 } 0x08048457 <_Z9factoriali+51>: leave 0x08048458 <_Z9factoriali+52>: ret 0x08048459: nop I had reproduced it. I think this issue is about reverse execute. I will try to deal with it. 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 > >