2
我的二進制文件使用了許多不同的共享庫。使用gdb附加進程時,大約需要5分鐘才能加載和讀取所有這些庫中的符號。如何在gdb中附加進程時選擇性地讀取和加載符號?
有沒有辦法讀取和加載符號有選擇性地附加與gdb的進程?
我的二進制文件使用了許多不同的共享庫。使用gdb附加進程時,大約需要5分鐘才能加載和讀取所有這些庫中的符號。如何在gdb中附加進程時選擇性地讀取和加載符號?
有沒有辦法讀取和加載符號有選擇性地附加與gdb的進程?
您可以set auto-solib-add off
,然後使用sharedlibrary
命令選擇性加載符號。例如:
$ gdb -e ./a.out
(gdb) set auto-solib-add off
(gdb) file a.out
Reading symbols from a.out...done.
(gdb) start
Temporary breakpoint 1 at 0x4004ba: file sig.c, line 4.
Starting program: /home/a3f/a.out
Temporary breakpoint 1, main() at sig.c:4
4 do();
(gdb) print environ
No symbol "environ" in current context.
(gdb) info shared
From To Syms Read Shared Object Library
0x00007ffff7ddcae0 0x00007ffff7df5130 No /lib64/ld-linux-x86-64.so.2
No linux-vdso.so.1
0x00007ffff7a504a0 0x00007ffff7b7cc73 No /lib/x86_64-linux-gnu/libc.so.6
(gdb) sharedlibrary libc
Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.19.so...done.
done.
Loaded symbols for /lib/x86_64-linux-gnu/libc.so.6
(gdb) print environ
$1 = (char **) 0x7fffffffe3b8
(gdb) print _dl_open
No symbol "_dl_open" in current context.
(gdb) sharedlibrary
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/ld-2.19.so...done.
done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
(gdb) print _dl_open
$1 = {void *(const char *, int, const void *, Lmid_t, int, char **, char **)} 0x7ffff7dee350 <_dl_open>
感謝您的回覆。當我們將一個已經運行的進程附加到gdb時,是否有可能分享一個例子? –
@KushalBansal'gdb -ex'set auto-solib-add off'-p $ PID' –