今天给大家分享一个gcore的使用方法!
这里假设gcore生成的文件a已经存在,如果不存在可以使用命令[ gcore pid(pid为进程号)]生成一个,下面简要描述过程:
1. gdb -c a binary(binary为进程的二进制文件)
2.gdb中设置log文件的位置,同时打开log,操作命令如下:
set logging file /tmp/test.txt
set logging on
3.使用命令:thread apply all bt,输出所有的堆栈,结果大致如下:
Thread 2 (Thread 0x41ec5940 (LWP 7312)):
0 0x00002b6370d241c0 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
1 0x00002aaab3bbf229 in ?? () from /usr/lib64/libnspr4.so
2 0x00002aaab3bbfe69 in PR_WaitCondVar () from /usr/lib64/libnspr4.so
3 0x00002aaab3bc51bc in PR_Sleep () from /usr/lib64/libnspr4.so
4 0x00002aaab302750e in ?? () from /usr/lib64/libssl3.so
5 0x00002aaab3bc55cd in ?? () from /usr/lib64/libnspr4.so
6 0x00002b6370d1f77d in start_thread (arg=) at pthread_create.c:301
7 0x00002b637120d9ad in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x2b63731b4360 (LWP 4718)):
0 0x00002b6371206b42 in select () from /lib64/libc.so.6
1 0x00002b6370b10d25 in apr_sleep () from /usr/lib64/libapr-1.so.0
2 0x00002b636f242315 in ap_wait_or_timeout ()
3 0x00002b636f24b79e in ap_mpm_run ()
4 0x00002b636f225fd8 in main ()
接下来就可以在/tmp/test.txt文件中进行信息查找了
网友评论