GDB使用实例

常用命令

/ 调用函数
gdb attach 28462 
set height 0 
handle SIGUSR2 SIG43 SIG39 SIGCONT noprint nostop
info line *(set_specpara_tick+0x3ec)
b preprocess_ip_addr
info locals
p g_worker_wall_ctx.seq_num=18·
call http_perf_add_metirc(0, 0, 99)·
call get_node_metirc_value(0,0)·
get_node_metirc_value+0xdd· 
$2 = (uint64_t *) 0x7efbd07eb400
p PERF_STAT_SHM_KEY=0

// 断点
gdb attach 28465 
set height 0 
handle SIGUSR2 SIG43 SIG39 SIGCONT noprint nostop
b handle_peerip_2_perfctx_delete

// 抓信号量
gdb attach ${th}
set height 0
///handle SIG6 stop
handle SIGABRT stop
c
bt

信号量

root@bogon demo]# kill -l
1) SIGHUP  2) SIGINT  3) SIGQUIT  4) SIGILL  5) SIGTRAP
6) SIGABRT  7) SIGBUS  8) SIGFPE  9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
.......   <-- 省略部分输出


(gdb) info signals
Signal        Stop Print  Pass to program  Description

SIGHUP        Yes  Yes    Yes              Hangup
SIGINT        Yes  Yes    No               Interrupt
SIGQUIT       Yes  Yes    Yes              Quit
SIGILL        Yes  Yes    Yes              Illegal instruction
SIGTRAP       Yes  Yes    No               Trace/breakpoint trap
SIGABRT       Yes  Yes    Yes              Aborted
SIGEMT        Yes  Yes    Yes              Emulation trap
SIGFPE        Yes  Yes    Yes              Arithmetic exception
SIGKILL       Yes  Yes    Yes              Killed

参考文献

Linux GDB调试基础:https://bbs.huaweicloud.com/blogs/308343
GDB调试指南:https://blog.csdn.net/chen1415886044/article/details/105094688
GDB调试教程:http://c.biancheng.net/view/8123.html
信号量:http://c.biancheng.net/view/8291.html

posted @ 2024-07-27 10:15  ·面具·  阅读(48)  评论(0)    收藏  举报