* ProcessRecord problem with recursion
@ 2009-03-20 1:18 Marc Khouzam
2009-03-20 3:10 ` Hui Zhu
2009-03-21 8:54 ` Hui Zhu
0 siblings, 2 replies; 4+ messages in thread
From: Marc Khouzam @ 2009-03-20 1:18 UTC (permalink / raw)
To: gdb
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 int factorial(int x) {
2 if (x == 1) return 1;
3 int result = x * factorial(x-1);
4 return result;
5 }
6
7 int main() {
8 factorial(5);
9 return 0;
10 }
(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 factorial(5);
(gdb) rec
(gdb) s
factorial (x=5) at a.cc:2
2 if (x == 1) return 1;
(gdb) n
3 int result = x * factorial(x-1);
(gdb) n
4 return result;
(gdb) rn
factorial (x=4) at a.cc:5
5 }
Notice how the reverse-next(rn) command jumped to the end
of the next factorial method on the stack (x=4 instead of x=5).
Thanks
Marc
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ProcessRecord problem with recursion
2009-03-20 1:18 ProcessRecord problem with recursion Marc Khouzam
@ 2009-03-20 3:10 ` Hui Zhu
2009-03-21 8:54 ` Hui Zhu
1 sibling, 0 replies; 4+ messages in thread
From: Hui Zhu @ 2009-03-20 3:10 UTC (permalink / raw)
To: Marc Khouzam; +Cc: gdb, Michael Snyder
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=0xffffffff, signal=144, step=1)
infrun: resume (step=1, signal=0), trap_expected=0
infrun: wait_for_inferior (treat_exec_as_sigtrap=0)
infrun: target_wait (-1, status) =
infrun: 9955 [process 9955],
infrun: status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x804844b
infrun: keep going
infrun: resume (step=1, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun: 9955 [process 9955],
infrun: status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x8048447
infrun: stepping inside range [0x8048439-0x804844e]
infrun: resume (step=1, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun: 9955 [process 9955],
infrun: status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x8048458
infrun: keep going
infrun: resume (step=1, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun: 9955 [process 9955],
infrun: status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x8048457
infrun: stepping inside range [0x8048457-0x804845a]
infrun: stop_stepping
factorial (x=4) 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 <marc.khouzam@ericsson.com> wrote:
> 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 int factorial(int x) {
> 2 if (x == 1) return 1;
> 3 int result = x * factorial(x-1);
> 4 return result;
> 5 }
> 6
> 7 int main() {
> 8 factorial(5);
> 9 return 0;
> 10 }
> (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 factorial(5);
> (gdb) rec
> (gdb) s
> factorial (x=5) at a.cc:2
> 2 if (x == 1) return 1;
> (gdb) n
> 3 int result = x * factorial(x-1);
> (gdb) n
> 4 return result;
> (gdb) rn
> factorial (x=4) at a.cc:5
> 5 }
>
> Notice how the reverse-next(rn) command jumped to the end
> of the next factorial method on the stack (x=4 instead of x=5).
>
> Thanks
>
> Marc
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ProcessRecord problem with recursion
2009-03-20 1:18 ProcessRecord problem with recursion Marc Khouzam
2009-03-20 3:10 ` Hui Zhu
@ 2009-03-21 8:54 ` Hui Zhu
1 sibling, 0 replies; 4+ messages in thread
From: Hui Zhu @ 2009-03-21 8:54 UTC (permalink / raw)
To: Marc Khouzam; +Cc: gdb
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 <marc.khouzam@ericsson.com> wrote:
> 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 int factorial(int x) {
> 2 if (x == 1) return 1;
> 3 int result = x * factorial(x-1);
> 4 return result;
> 5 }
> 6
> 7 int main() {
> 8 factorial(5);
> 9 return 0;
> 10 }
> (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 factorial(5);
> (gdb) rec
> (gdb) s
> factorial (x=5) at a.cc:2
> 2 if (x == 1) return 1;
> (gdb) n
> 3 int result = x * factorial(x-1);
> (gdb) n
> 4 return result;
> (gdb) rn
> factorial (x=4) at a.cc:5
> 5 }
>
> Notice how the reverse-next(rn) command jumped to the end
> of the next factorial method on the stack (x=4 instead of x=5).
>
> Thanks
>
> Marc
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* ProcessRecord problem with recursion
@ 2014-03-07 2:37 jian shen
0 siblings, 0 replies; 4+ messages in thread
From: jian shen @ 2014-03-07 2:37 UTC (permalink / raw)
To: gdb
I find an issue with record in recursion function. And I notice
there's a patch long ago.
https://sourceware.org/ml/gdb/2009-03/msg00134.html
But I still could reproduce the issue with the latest gdb7.7.
Now the code is different and the patch could not be applied.
Is it a missed bug? Is there any patch for the latest code?
Thanks,
Jian
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-07 2:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-20 1:18 ProcessRecord problem with recursion Marc Khouzam
2009-03-20 3:10 ` Hui Zhu
2009-03-21 8:54 ` Hui Zhu
2014-03-07 2:37 jian shen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox