GDB设置程序启动参数

set args 可指定运行时参数。(如:set args 10 20 30 40 50) show args 命令可以查看设置好的运行参数。

GDB调试core dump文件

设置生成core文件的大小:

# ulimit -c unlimited

使用gdb调试core文件:

$gdb ./a.out ./core.7369

使用where命令查看出错点

(gdb) where

或者使用gdb查看core文件信息:

# gdb -c corefile  

readelf应用coredump readelf -h 读取coredump文件头 readelf -wl 读取应用程序debug_line readelf -wf 读取应用程序fde和cie信息

GDB调试多线程

查看线程:

(gdb) info threads

切换线程:

(gdb) thread 3

GDB调试多进程

查看进程:

(gdb) info inferiors

切换进程:

(gdb)  inferior 2

不能加载动态库

不能加载动态库,出现如下错误:

error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory

有两种方法: 一、可以把当前路径加入 /etc/ld.so.conf中然后运行ldconfig,或者以当前路径为参数运行ldconfig(要有root权限才行)。 二、把当前路径加入环境变量LD_LIBRARY_PATH中
当然,如果你觉得不会引起混乱的话,可以直接把该库拷入/lib,/usr/lib/等位置(无可避免,这样做也要有权限),这样链接器和加载器就都可以准确的找到该库了。

我们采用第二种方法:

export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH

这样,再执行就成功了。