This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
An error about AMD64 frame_unwind_caller_pc
- From: Hui Zhu <teawater at gmail dot com>
- To: gdb at sourceware dot org, Michael Snyder <msnyder at vmware dot com>, Daniel Jacobowitz <drow at false dot org>
- Date: Wed, 8 Jul 2009 16:19:55 +0800
- Subject: An error about AMD64 frame_unwind_caller_pc
Hi guys,
I got some error when I try the AMD64 reverse debug.
cat 1.c
#include<stdio.h>
int a = 0;
void
cool2 ()
{
printf ("a = %d\n", a);
}
int
cool ()
{
a += 3;
cool2();
return (a);
}
int
main()
{
int b = 0;
int c = 1;
printf ("a = %d b = %d c = %d\n", a, b, c);
b = cool ();
printf ("a = %d b = %d c = %d\n", a, b, c);
/*Line 27.*/c += 1;
/*Line 28.*/printf ("a = %d b = %d c = %d\n", a, b, c);
/*Line 29.*/a -= 2;
/*Line 30.*/printf ("a = %d b = %d c = %d\n", a, b, c);
/*Line 32.*/return (0);
}
gdb ./a.out
(gdb) record
(gdb) n
21 int c = 1;
(gdb)
23 printf ("a = %d b = %d c = %d\n", a, b, c);
(gdb)
a = 0 b = 0 c = 1
24 b = cool ();
(gdb)
a = 3
25 printf ("a = %d b = %d c = %d\n", a, b, c);
(gdb) rc
Continuing.
No more reverse-execution history.
main () at 1.c:20
20 int b = 0;
(gdb) n
21 int c = 1;
(gdb)
23 printf ("a = %d b = %d c = %d\n", a, b, c);
(gdb)
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x400398
infrun: stepped into subroutine
infrun: inserting step-resume breakpoint at 0x400513 #the breakpoint
address is not right.
infrun: resume (step=0, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun: 22024 [process 22024],
infrun: status->kind = stopped, signal = SIGTRAP
No more reverse-execution history.
main () at 1.c:25
25 printf ("a = %d b = %d c = %d\n", a, b, c); #It should stop at
line 24 "b = cool ();" but it stop at 25.
(gdb)
(gdb) rc
Continuing.
No more reverse-execution history.
main () at 1.c:20
20 int b = 0;
(gdb) n
21 int c = 1;
(gdb)
23 printf ("a = %d b = %d c = %d\n", a, b, c);
(gdb)
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x400398
infrun: stepped into subroutine
infrun: inserting step-resume breakpoint at 0x400531 #the breakpoint
address is not right two.
infrun: resume (step=0, signal=0), trap_expected=0
infrun: prepare_to_wait
No more reverse-execution history.
main () at 1.c:27
27 /*Line 27.*/c += 1; #It should stop at
line 24 "b = cool ();" but it stop at 27. Everything change.
This breakpoint address is inserted by
insert_step_resume_breakpoint_at_caller. The address is get from
frame_unwind_caller_pc.
I think this is a bug of AMD64 frame_unwind_caller_pc. Maybe it
didn't flash or something else.
Daniel, I found that you update frame_unwind_caller_pc this year in
changelog. Maybe you can take a look on it.
http://sourceware.org/ml/gdb/2009-07/msg00038.html the last issue is
about AMD64 frame_unwind_caller_pc too.
Now, I just found it affect reverse, but I am not sure it affect
another thing or not.
Thanks,
Hui