Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Weird reverse problems
@ 2009-01-21 18:52 Marc Khouzam
  2009-01-22  6:06 ` teawater
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Khouzam @ 2009-01-21 18:52 UTC (permalink / raw)
  To: gdb

Hi,

so I'm trying Reverse Debugging by having applied teawater's patches
on top of HEAD which contains Michael S reverse infrastructure.

I ran into some bizarre behavior when reverse stepping.
I found that with (I'm guessing) library functions, a reverse next
will skip a line.  If you look at the simple session I ran below
(a bit long, but very simple) you can see that on the reverse, 
every two printf gets skipped.
Also, on a reverse step, multiple sleep() can be skipped.

Weird no?

I tried to look at the code, but performing steps gets pretty
low level, so I gave up.

Thanks

Marc

GNU gdb (GDB) 6.8.50.20090113-cvs
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show
copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(gdb) l
1       #include <stdio.h>
2       #include <unistd.h>
3
4       int foo(int i) {
5           return i;
6       }
7       int main()
8       {
9           sleep(0);//1
10          sleep(0);//2
(gdb) 
11          sleep(0);//3
12          sleep(0);//4
13          printf("A\n");
14          printf("B\n");
15          printf("C\n");
16          printf("D\n");
17          int a = 0;
18          a++;
19          printf("E\n");
20          printf("F\n");
(gdb) 
21          printf("G\n");
22          printf("H\n");
23          return a;
24      }
(gdb) b main
Breakpoint 1 at 0x80484bd: file a.cc, line 9.
(gdb) r
Starting program: /local/home/lmckhou/testing/a.out 

Breakpoint 1, main () at a.cc:9
9           sleep(0);//1
(gdb) record
(gdb) b 24
Breakpoint 2 at 0x804855b: file a.cc, line 24.
(gdb) c
Continuing.
A
B
C
D
E
F
G
H

Breakpoint 2, main () at a.cc:24
24      }
(gdb) rn
23          return a;
(gdb) rn
21          printf("G\n");    <--- Missed a printf here!
(gdb) rn
19          printf("E\n");    <--- Missed a printf here!
(gdb) rn
18          a++;
(gdb) rn
17          int a = 0;
(gdb) rn
15          printf("C\n");    <--- Missed a printf here!
(gdb) rn
13          printf("A\n");    <--- Missed a printf here!
(gdb) rn
11          sleep(0);//3    <--- Missed a sleep here!
(gdb) rn

No more reverse-execution history.
main () at a.cc:9
9           sleep(0);//1
(gdb) n
10          sleep(0);//2
(gdb) n
11          sleep(0);//3
(gdb) n
12          sleep(0);//4
(gdb) n
13          printf("A\n");
(gdb) rs
12          sleep(0);//4
(gdb) rs
11          sleep(0);//3
(gdb) rs
10          sleep(0);//2
(gdb) n
11          sleep(0);//3
(gdb) n
12          sleep(0);//4
(gdb) n
13          printf("A\n");
(gdb) n
14          printf("B\n");
(gdb) n
15          printf("C\n");
(gdb) rs
14          printf("B\n");
(gdb) 

No more reverse-execution history.
main () at a.cc:9
9           sleep(0);//1       <--- Woah, missed a bunch of stuff on the
reverse step!




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Weird reverse problems
  2009-01-21 18:52 Weird reverse problems Marc Khouzam
@ 2009-01-22  6:06 ` teawater
  2009-01-22  9:02   ` teawater
  0 siblings, 1 reply; 3+ messages in thread
From: teawater @ 2009-01-22  6:06 UTC (permalink / raw)
  To: Marc Khouzam, Michael Snyder; +Cc: gdb

Hi Marc,

I had reproduced it.

13	     printf("A\n");
(gdb) rn
infrun: clear_proceed_status_thread (process 21364)
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: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0xb7f01af8
infrun: stepped into subroutine
infrun: inserting step-resume breakpoint at 0xb7f01980
infrun: resume (step=0, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0xb7f01980
infrun: BPSTAT_WHAT_STEP_RESUME
infrun: resume (step=1, signal=0), trap_expected=1
infrun: prepare_to_wait
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x80482f8
infrun: stepped into subroutine
infrun: inserting step-resume breakpoint at 0x80482f8
infrun: resume (step=0, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x80482f8
infrun: BPSTAT_WHAT_STEP_RESUME
infrun: resume (step=1, signal=0), trap_expected=1
infrun: prepare_to_wait
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x80483dc
infrun: keep going
infrun: resume (step=1, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x80483d5
infrun: stepping inside range [0x80483d5-0x80483e1]
infrun: stop_stepping
11	   sleep(0);//3
(gdb)



I think this is a bug of reverse code in infrun.c.  That is because it
deal with plt not very well.

Michael, could you please take a look at this bug?
And I will try to deal with it too. :)

Thanks,
Hui

On Thu, Jan 22, 2009 at 02:52, Marc Khouzam <marc.khouzam@ericsson.com> wrote:
> Hi,
>
> so I'm trying Reverse Debugging by having applied teawater's patches
> on top of HEAD which contains Michael S reverse infrastructure.
>
> I ran into some bizarre behavior when reverse stepping.
> I found that with (I'm guessing) library functions, a reverse next
> will skip a line.  If you look at the simple session I ran below
> (a bit long, but very simple) you can see that on the reverse,
> every two printf gets skipped.
> Also, on a reverse step, multiple sleep() can be skipped.
>
> Weird no?
>
> I tried to look at the code, but performing steps gets pretty
> low level, so I gave up.
>
> Thanks
>
> Marc
>
> GNU gdb (GDB) 6.8.50.20090113-cvs
> Copyright (C) 2009 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show
> copying"
> and "show warranty" for details.
> This GDB was configured as "i686-pc-linux-gnu".
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>...
> (gdb) l
> 1       #include <stdio.h>
> 2       #include <unistd.h>
> 3
> 4       int foo(int i) {
> 5           return i;
> 6       }
> 7       int main()
> 8       {
> 9           sleep(0);//1
> 10          sleep(0);//2
> (gdb)
> 11          sleep(0);//3
> 12          sleep(0);//4
> 13          printf("A\n");
> 14          printf("B\n");
> 15          printf("C\n");
> 16          printf("D\n");
> 17          int a = 0;
> 18          a++;
> 19          printf("E\n");
> 20          printf("F\n");
> (gdb)
> 21          printf("G\n");
> 22          printf("H\n");
> 23          return a;
> 24      }
> (gdb) b main
> Breakpoint 1 at 0x80484bd: file a.cc, line 9.
> (gdb) r
> Starting program: /local/home/lmckhou/testing/a.out
>
> Breakpoint 1, main () at a.cc:9
> 9           sleep(0);//1
> (gdb) record
> (gdb) b 24
> Breakpoint 2 at 0x804855b: file a.cc, line 24.
> (gdb) c
> Continuing.
> A
> B
> C
> D
> E
> F
> G
> H
>
> Breakpoint 2, main () at a.cc:24
> 24      }
> (gdb) rn
> 23          return a;
> (gdb) rn
> 21          printf("G\n");    <--- Missed a printf here!
> (gdb) rn
> 19          printf("E\n");    <--- Missed a printf here!
> (gdb) rn
> 18          a++;
> (gdb) rn
> 17          int a = 0;
> (gdb) rn
> 15          printf("C\n");    <--- Missed a printf here!
> (gdb) rn
> 13          printf("A\n");    <--- Missed a printf here!
> (gdb) rn
> 11          sleep(0);//3    <--- Missed a sleep here!
> (gdb) rn
>
> No more reverse-execution history.
> main () at a.cc:9
> 9           sleep(0);//1
> (gdb) n
> 10          sleep(0);//2
> (gdb) n
> 11          sleep(0);//3
> (gdb) n
> 12          sleep(0);//4
> (gdb) n
> 13          printf("A\n");
> (gdb) rs
> 12          sleep(0);//4
> (gdb) rs
> 11          sleep(0);//3
> (gdb) rs
> 10          sleep(0);//2
> (gdb) n
> 11          sleep(0);//3
> (gdb) n
> 12          sleep(0);//4
> (gdb) n
> 13          printf("A\n");
> (gdb) n
> 14          printf("B\n");
> (gdb) n
> 15          printf("C\n");
> (gdb) rs
> 14          printf("B\n");
> (gdb)
>
> No more reverse-execution history.
> main () at a.cc:9
> 9           sleep(0);//1       <--- Woah, missed a bunch of stuff on the
> reverse step!
>
>
>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Weird reverse problems
  2009-01-22  6:06 ` teawater
@ 2009-01-22  9:02   ` teawater
  0 siblings, 0 replies; 3+ messages in thread
From: teawater @ 2009-01-22  9:02 UTC (permalink / raw)
  To: Marc Khouzam, Michael Snyder; +Cc: gdb

Hi,

I make a patch for it in
http://sourceware.org/ml/gdb-patches/2009-01/msg00444.html

Thanks,
Hui

On Thu, Jan 22, 2009 at 14:05, teawater <teawater@gmail.com> wrote:
> Hi Marc,
>
> I had reproduced it.
>
> 13           printf("A\n");
> (gdb) rn
> infrun: clear_proceed_status_thread (process 21364)
> 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: infwait_normal_state
> infrun: TARGET_WAITKIND_STOPPED
> infrun: stop_pc = 0xb7f01af8
> infrun: stepped into subroutine
> infrun: inserting step-resume breakpoint at 0xb7f01980
> infrun: resume (step=0, signal=0), trap_expected=0
> infrun: prepare_to_wait
> infrun: infwait_normal_state
> infrun: TARGET_WAITKIND_STOPPED
> infrun: stop_pc = 0xb7f01980
> infrun: BPSTAT_WHAT_STEP_RESUME
> infrun: resume (step=1, signal=0), trap_expected=1
> infrun: prepare_to_wait
> infrun: infwait_normal_state
> infrun: TARGET_WAITKIND_STOPPED
> infrun: stop_pc = 0x80482f8
> infrun: stepped into subroutine
> infrun: inserting step-resume breakpoint at 0x80482f8
> infrun: resume (step=0, signal=0), trap_expected=0
> infrun: prepare_to_wait
> infrun: infwait_normal_state
> infrun: TARGET_WAITKIND_STOPPED
> infrun: stop_pc = 0x80482f8
> infrun: BPSTAT_WHAT_STEP_RESUME
> infrun: resume (step=1, signal=0), trap_expected=1
> infrun: prepare_to_wait
> infrun: infwait_normal_state
> infrun: TARGET_WAITKIND_STOPPED
> infrun: stop_pc = 0x80483dc
> infrun: keep going
> infrun: resume (step=1, signal=0), trap_expected=0
> infrun: prepare_to_wait
> infrun: infwait_normal_state
> infrun: TARGET_WAITKIND_STOPPED
> infrun: stop_pc = 0x80483d5
> infrun: stepping inside range [0x80483d5-0x80483e1]
> infrun: stop_stepping
> 11         sleep(0);//3
> (gdb)
>
>
>
> I think this is a bug of reverse code in infrun.c.  That is because it
> deal with plt not very well.
>
> Michael, could you please take a look at this bug?
> And I will try to deal with it too. :)
>
> Thanks,
> Hui
>
> On Thu, Jan 22, 2009 at 02:52, Marc Khouzam <marc.khouzam@ericsson.com> wrote:
>> Hi,
>>
>> so I'm trying Reverse Debugging by having applied teawater's patches
>> on top of HEAD which contains Michael S reverse infrastructure.
>>
>> I ran into some bizarre behavior when reverse stepping.
>> I found that with (I'm guessing) library functions, a reverse next
>> will skip a line.  If you look at the simple session I ran below
>> (a bit long, but very simple) you can see that on the reverse,
>> every two printf gets skipped.
>> Also, on a reverse step, multiple sleep() can be skipped.
>>
>> Weird no?
>>
>> I tried to look at the code, but performing steps gets pretty
>> low level, so I gave up.
>>
>> Thanks
>>
>> Marc
>>
>> GNU gdb (GDB) 6.8.50.20090113-cvs
>> Copyright (C) 2009 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later
>> <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show
>> copying"
>> and "show warranty" for details.
>> This GDB was configured as "i686-pc-linux-gnu".
>> For bug reporting instructions, please see:
>> <http://www.gnu.org/software/gdb/bugs/>...
>> (gdb) l
>> 1       #include <stdio.h>
>> 2       #include <unistd.h>
>> 3
>> 4       int foo(int i) {
>> 5           return i;
>> 6       }
>> 7       int main()
>> 8       {
>> 9           sleep(0);//1
>> 10          sleep(0);//2
>> (gdb)
>> 11          sleep(0);//3
>> 12          sleep(0);//4
>> 13          printf("A\n");
>> 14          printf("B\n");
>> 15          printf("C\n");
>> 16          printf("D\n");
>> 17          int a = 0;
>> 18          a++;
>> 19          printf("E\n");
>> 20          printf("F\n");
>> (gdb)
>> 21          printf("G\n");
>> 22          printf("H\n");
>> 23          return a;
>> 24      }
>> (gdb) b main
>> Breakpoint 1 at 0x80484bd: file a.cc, line 9.
>> (gdb) r
>> Starting program: /local/home/lmckhou/testing/a.out
>>
>> Breakpoint 1, main () at a.cc:9
>> 9           sleep(0);//1
>> (gdb) record
>> (gdb) b 24
>> Breakpoint 2 at 0x804855b: file a.cc, line 24.
>> (gdb) c
>> Continuing.
>> A
>> B
>> C
>> D
>> E
>> F
>> G
>> H
>>
>> Breakpoint 2, main () at a.cc:24
>> 24      }
>> (gdb) rn
>> 23          return a;
>> (gdb) rn
>> 21          printf("G\n");    <--- Missed a printf here!
>> (gdb) rn
>> 19          printf("E\n");    <--- Missed a printf here!
>> (gdb) rn
>> 18          a++;
>> (gdb) rn
>> 17          int a = 0;
>> (gdb) rn
>> 15          printf("C\n");    <--- Missed a printf here!
>> (gdb) rn
>> 13          printf("A\n");    <--- Missed a printf here!
>> (gdb) rn
>> 11          sleep(0);//3    <--- Missed a sleep here!
>> (gdb) rn
>>
>> No more reverse-execution history.
>> main () at a.cc:9
>> 9           sleep(0);//1
>> (gdb) n
>> 10          sleep(0);//2
>> (gdb) n
>> 11          sleep(0);//3
>> (gdb) n
>> 12          sleep(0);//4
>> (gdb) n
>> 13          printf("A\n");
>> (gdb) rs
>> 12          sleep(0);//4
>> (gdb) rs
>> 11          sleep(0);//3
>> (gdb) rs
>> 10          sleep(0);//2
>> (gdb) n
>> 11          sleep(0);//3
>> (gdb) n
>> 12          sleep(0);//4
>> (gdb) n
>> 13          printf("A\n");
>> (gdb) n
>> 14          printf("B\n");
>> (gdb) n
>> 15          printf("C\n");
>> (gdb) rs
>> 14          printf("B\n");
>> (gdb)
>>
>> No more reverse-execution history.
>> main () at a.cc:9
>> 9           sleep(0);//1       <--- Woah, missed a bunch of stuff on the
>> reverse step!
>>
>>
>>
>>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-22  9:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-21 18:52 Weird reverse problems Marc Khouzam
2009-01-22  6:06 ` teawater
2009-01-22  9:02   ` teawater

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox