From: Hui Zhu <teawater@gmail.com>
To: gdb@sourceware.org
Cc: Michael Snyder <msnyder@vmware.com>
Subject: About the gdb prec save/restore reverse exec behavior error (gcore error)
Date: Sat, 31 Oct 2009 17:41:00 -0000 [thread overview]
Message-ID: <daef60380910311006q688effcfge410d6405d4ab315@mail.gmail.com> (raw)
Hi guys,
I found that prec save/restore reverse exec behavior error. For example:
gdb ./a.out ./gdb_record.8810
Reading symbols from /home/teawater/gdb/a.out...done.
[New Thread 8810]
Core was generated by `/home/teawater/gdb/a.out'.
Program terminated with signal 5, Trace/breakpoint trap.
#0 main () at 1.c:20
20 int b = 0;
(gdb) record
Restored records from core file /home/teawater/gdb/./gdb_record.8810.
#0 main () at 1.c:20
20 int b = 0;
(gdb) n
21 int c = 1;
(gdb)
24 printf ("a = %d b = %d c = %d\n", a, b, c);
(gdb)
25 b = cool ();
(gdb) rn
No more reverse-execution history.
main () at 1.c:20
20 int b = 0;
The reason is:
(gdb) rn
infrun: stop_pc = 0x7ffff7abbec1
infrun: stepped into subroutine
infrun: inserting step-resume breakpoint at 0x0 #address error
infrun: status->kind = no-history
infrun: infwait_normal_state
No more reverse-execution history.
infrun: stop_stepping
main () at 1.c:20
20 int b = 0;
The address is not right because:
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x00007ffff7ddea90 0x00007ffff7df7334 Yes (*) /lib64/ld-linux-x86-64.so.2
(*): Shared library is missing debugging information.
Without the solib that have printf, gdb cannot find the debug message.of printf.
But current gdb way cannot get the solib message.
For example:
gdb ./a.out ./gdb_record.8810
[New Thread 8810]
Core was generated by `/home/teawater/gdb/a.out'.
Program terminated with signal 5, Trace/breakpoint trap.
#0 main () at 1.c:20
20 int b = 0;
(gdb) record
Restored records from core file /home/teawater/gdb/./gdb_record.8810.
#0 main () at 1.c:20
20 int b = 0;
(gdb) set solib-search-path
(gdb)
Not any output is because gdb cannot get any message of solib.
To get solib message need .dynamic section in
"solib-svr4.c:scan_dyntag", but this section's flags is:
[21] .dynamic DYNAMIC 0000000000600e40 00000e40
00000000000001a0 0000000000000010 WA 6 0 8
It just alloc when inferior exec. And gcore didn't save the memory of .dynamic.
So when prec restore (inferior didn't exec) cannot get the the solib message.
I found that kernel coredump have the .dynamic message:
./a.out
a.out: 2.c:5: main: Assertion `0' failed.
(core dumped)
gdb ./a.out core
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x00007fcc52666230 0x00007fcc5276b0e8 Yes (*) /lib/libc.so.6
0x00007fcc529baa90 0x00007fcc529d3334 Yes (*) /lib64/ld-linux-x86-64.so.2
(*): Shared library is missing debugging information.
Core file of gcore didn't make gdb auto load solib because in
"solib-svr4.c:scan_dyntag" get value from .dynamic section.
635 dyn_ptr = extract_typed_address (ptr_buf, ptr_type);
(gdb) x ptr_addr
0x600ed8
(gdb) p ptr_buf
$20 = "\000\000\000\000\000\000\000"
Then gdb
But when gcore didn't save the value from this section in "gcore_copy_callback":
/* Read-only sections are marked; we don't have to copy their contents. */
if ((bfd_get_section_flags (obfd, osec) & SEC_LOAD) == 0)
return;
cat /proc/7122/maps
00400000-00401000 r-xp 00000000 08:06 4980746
/home/teawater/gdb/a.out
00600000-00601000 r--p 00000000 08:06 4980746
/home/teawater/gdb/a.out
00601000-00602000 rw-p 00001000 08:06 4980746
/home/teawater/gdb/a.out
7ffff7a6c000-7ffff7bd4000 r-xp 00000000 08:06 3022954
/lib/libc-2.9.so
7ffff7bd4000-7ffff7dd4000 ---p 00168000 08:06 3022954
/lib/libc-2.9.so
7ffff7dd4000-7ffff7dd8000 r--p 00168000 08:06 3022954
/lib/libc-2.9.so
7ffff7dd8000-7ffff7dd9000 rw-p 0016c000 08:06 3022954
/lib/libc-2.9.so
7ffff7dd9000-7ffff7dde000 rw-p 7ffff7dd9000 00:00 0
7ffff7dde000-7ffff7dfe000 r-xp 00000000 08:06 3022858
/lib/ld-2.9.so
7ffff7fd5000-7ffff7fd7000 rw-p 7ffff7fd5000 00:00 0
7ffff7ff9000-7ffff7ffc000 rw-p 7ffff7ff9000 00:00 0
7ffff7ffc000-7ffff7ffd000 r-xp 7ffff7ffc000 00:00 0 [vdso]
7ffff7ffd000-7ffff7ffe000 r--p 0001f000 08:06 3022858
/lib/ld-2.9.so
7ffff7ffe000-7ffff7fff000 rw-p 00020000 08:06 3022858
/lib/ld-2.9.so
7ffffffea000-7ffffffff000 rw-p 7ffffffea000 00:00 0 [stack]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
[vsyscall]
I think this is the root cause of this issue. Sorry guys, I use a
long mail to show it.
Do you have some comment with it?
Thanks,
Hui
next reply other threads:[~2009-10-31 17:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-31 17:41 Hui Zhu [this message]
[not found] ` <4AEC74B8.9090908@vmware.com>
2009-11-04 6:56 ` Hui Zhu
2009-11-04 18:29 ` Michael Snyder
2009-11-05 2:24 ` Hui Zhu
2009-11-05 2:26 ` Hui Zhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=daef60380910311006q688effcfge410d6405d4ab315@mail.gmail.com \
--to=teawater@gmail.com \
--cc=gdb@sourceware.org \
--cc=msnyder@vmware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox