如何在gdb中附加进程时选择性地读取和加载符号? [英] How to read and load symbols selectively while attaching a process in gdb?

查看:616
本文介绍了如何在gdb中附加进程时选择性地读取和加载符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的二进制文件使用了许多不同的共享库。使用gdb附加进程时,大约需要5分钟才能加载和读取所有这些库中的符号。



有没有一种方法可以选择性地读取和加载符号一个使用gdb的进程?

解决方案

您可以 设置auto-solib-add off ,然后使用 sharedlibrary 命令来选择性地加载符号。示例:

  $ gdb -e ./a.out 
(gdb)set auto-solib-add off
(gdb)文件a.out
读取a.out ... done中的符号。
(gdb)start
临时断点1在0x4004ba:文件sig.c,第4行。
启动程序:/home/a3f/a.out

临时断点1,main()在sig.c:4
4 do();
(gdb)print environ
在当前上下文中没有符号environ。
(gdb)info共享
从To Syms读共享对象库
0x00007ffff7ddcae0 0x00007ffff7df5130否/lib64/ld-linux-x86-64.so.2
没有linux-vdso。 so.1
0x00007ffff7a504a0 0x00007ffff7b7cc73否/lib/x86_64-linux-gnu/libc.so.6
(gdb)sharedlibrary libc
读取/ lib / x86_64-linux-gnu / libc中的符号.so.6 ...从/usr/lib/debug//lib/x86_64-linux-gnu/libc-2.19.so...done中读取符号。
完成。
加载符号/lib/x86_64-linux-gnu/libc.so.6
(gdb)print environ
$ 1 =(char **)0x7fffffffe3b8
(gdb)print _dl_open
在当前上下文中没有符号_dl_open。
(gdb)sharedlibrary
读取/lib64/ld-linux-x86-64.so.2...中的符号从/ usr / lib / debug中读取符号// lib / x86_64-linux-gnu /ld-2.19.so...done。
完成。
加载符号为/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>


My binary uses a number of different shared libraries. While attaching the process with gdb, it takes around 5 minutes to load and read symbols from all of these libraries.

Is there a way to read and load symbols selectively while attaching a process with gdb?

解决方案

You can set auto-solib-add off and then use the sharedlibrary command to selectively load symbols. Example:

$ 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中附加进程时选择性地读取和加载符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆