cpp_debug_tools

C++ Debug命令和工具

readelf

查看可执行文件或库的符号表

1
readelf -s ./a.out
查看可执行文件或库的动态库表
1
readelf -d ./a.out

objdump

查看汇编情况

1
objdump -d ./a.out
查看是否带有调试符号 objdump --debugging libvoidincr.a

nm

查看符号类型 nm -a xxx 查看所有符号 nm -D xxx 查看动态库符号 https://linux.die.net/man/1/nm

ldd

查看动态库的链接情况

1
ldd ./a.out

LD_PRELOAD

在执行该文件前预加载库,要加具体的库名,LD_PRELOAD的值只在当前语句生效

1
env LD_PRELOAD=/home/fenggq/libutil.so ./a.out

查看系统默认链接的库路径

1
2
3
4
cat /etc/ld.so.conf
# output: include /etc/ld.so.conf.d/*.conf
cat /etc/ld.so.conf.d/*.conf
# output: 所有的默认库路径

gdb

  • 使用gdb调试带输入参数的程序

    1
    gdb --args ./a.out args

  • attach 到正在运行的程序

    1
    gdb --pid PID

  • 查看所有线程的栈帧

    1
    thread apply all bt

  • 记录gdb 操作过程到日志文件

    1
    set logging on

  • 断点调试时只运行当前线程,其他线程挂起

    1
    set scheduler-locking on

file查看文件属性

1
2
$ file msf
msf: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, stripped

该文件被stripped ,去除掉了符号表信息

strip 命令

去掉符号表和调试等信息 https://blog.51cto.com/u_15614325/5272498

符号表和strip https://xuanxuanblingbling.github.io/ctf/tools/2019/09/06/symbol/

tmp_LD_PRELOAD=\({LD_PRELOAD} unset LD_PRELOAD nohup cyber_launch start fusion_tracker.launch & export LD_PRELOAD=\){tmp_LD_PRELOAD}

core文件去哪了

core 文件设置 core文件去哪了


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!