当前位置:网站首页>GDB debugging practice (7) signal processing
GDB debugging practice (7) signal processing
2022-06-21 22:18:00 【Wonderful binary】
List of articles
GDB Sending signal
stay GDB Debugging status , You can enter... At the command number signal Signal name To send a signal to the program .
Input signal Press down tab The signal name is displayed :
(gdb) signal
Display all 152 possibilities? (y or n)
32 SIG108 SIG125 SIG46 SIG63 SIG80 SIG97 SIGIO SIGSTOP
33 SIG109 SIG126 SIG47 SIG64 SIG81 SIG98 SIGKILL SIGSYS
34 SIG110 SIG127 SIG48 SIG65 SIG82 SIG99 SIGLIBRT SIGTERM
EXC_ARITHMETIC SIG111 SIG32 SIG49 SIG66 SIG83 SIGABRT SIGLOST SIGTRAP
EXC_BAD_ACCESS SIG112 SIG33 SIG50 SIG67 SIG84 SIGALRM SIGLWP SIGTSTP
EXC_BAD_INSTRUCTION SIG113 SIG34 SIG51 SIG68 SIG85 SIGBUS SIGMSG SIGTTIN
EXC_BREAKPOINT SIG114 SIG35 SIG52 SIG69 SIG86 SIGCANCEL SIGPHONE SIGTTOU
EXC_EMULATION SIG115 SIG36 SIG53 SIG70 SIG87 SIGCHLD SIGPIPE SIGURG
EXC_SOFTWARE SIG116 SIG37 SIG54 SIG71 SIG88 SIGCONT SIGPOLL SIGUSR1
SIG100 SIG117 SIG38 SIG55 SIG72 SIG89 SIGDANGER SIGPRIO SIGUSR2
SIG101 SIG118 SIG39 SIG56 SIG73 SIG90 SIGEMT SIGPROF SIGVTALRM
SIG102 SIG119 SIG40 SIG57 SIG74 SIG91 SIGFPE SIGPWR SIGWAITING
SIG103 SIG120 SIG41 SIG58 SIG75 SIG92 SIGGRANT SIGQUIT SIGWINCH
SIG104 SIG121 SIG42 SIG59 SIG76 SIG93 SIGHUP SIGRETRACT SIGWIND
SIG105 SIG122 SIG43 SIG60 SIG77 SIG94 SIGILL SIGSAK SIGXCPU
SIG106 SIG123 SIG44 SIG61 SIG78 SIG95 SIGINFO SIGSEGV SIGXFSZ
SIG107 SIG124 SIG45 SIG62 SIG79 SIG96 SIGINT SIGSOUND
GDB Processing signals
background :gdb The default behavior of is to capture the signal , Instead of passing it to the debugger , We can change this behavior through command configuration
stay GDB in handle The command is used to set GDB For signal processing , You can enter help handle Check it out. .
(gdb) help handle
Specify how to handle signals.
Usage: handle SIGNAL [ACTIONS]
Args are signals and actions to apply to those signals.
If no actions are specified, the current settings for the specified signals
will be displayed instead.
Symbolic signals (e.g. SIGSEGV) are recommended but numeric signals
from 1-15 are allowed for compatibility with old versions of GDB.
Numeric ranges may be specified with the form LOW-HIGH (e.g. 1-5).
The special arg "all" is recognized to mean all signals except those
used by the debugger, typically SIGTRAP and SIGINT.
Recognized actions include "stop", "nostop", "print", "noprint",
"pass", "nopass", "ignore", or "noignore".
Stop means reenter debugger if this signal happens (implies print).
Print means print a message if this signal happens.
Pass means let program see this signal; otherwise program doesn't know.
Ignore is a synonym for nopass and noignore is a synonym for pass.
Pass and Stop may be combined.
Multiple signals may be specified. Signal numbers and signal names
may be interspersed with actions, with the actions being performed for
all signals cumulatively specified.
Summarize the general meaning :
- nostop
When the debugged program receives a signal ,GDB It won't stop the program , But a message will be sent to tell you that you receive this signal . - stop
When the debugged program receives a signal ,GDB Will stop your program . - print
When the debugged program receives a signal ,GDB A message will be displayed . - noprint
When the debugged program receives a signal ,GDB Will not tell you the message of the signal . - pass 、noignore
When the debugged program receives a signal ,GDB Do not process signals . This means ,GDB Will give this signal to the debugged program to process . - nopass、ignore
When the debugged program receives a signal ,GDB The debugged program will not be allowed to process this signal .
above 6 Item Configuration , Actually, it should be divided into 3 A state in which groups can be superimposed on each other . namely :
stop/nostop
print/noprint
pass/nopass
stay GDB Can be used in info signals and info handle To see what signals are being GDB Detection neutralization GDB Treatment of it :
(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
SIGBUS Yes Yes Yes Bus error
SIGSEGV Yes Yes Yes Segmentation fault
SIGSYS Yes Yes Yes Bad system call
SIGPIPE Yes Yes Yes Broken pipe
SIGALRM No No Yes Alarm clock
...
actual combat
#include <signal.h>
#include <stdio.h>
void signalHandle(int para)
{
printf("in signal handle,signal num:%d\n", para);
}
void signalHandle2(int para)
{
printf("in signal handle,signal num:%d\n", para);
exit(0);
}
int main(void)
{
signal(SIGUSR1, signalHandle);
signal(SIGUSR2, signalHandle2);
while(1)
{
printf("press any key to send a signal\n");
getchar();
raise(SIGUSR1);
}
return 0;
}
For better results , Run the program first , then gdb attach To the process , Get into gdb Debug mode
(gdb) c
Continuing.
Program received signal SIGUSR1, User defined signal 1.
0x00007fd1f1ec9337 in raise () from /lib64/libc.so.6
(gdb) c
Continuing.
You can find that when you press enter in the program , The process sent itself SIGUSR1 The signal , also GDB When the signal is captured, stop , We continue to run ,
take GDB Yes SIGUSR1 The signal processing is set to nostop
(gdb) handle SIGUSR1 nostop
Signal Stop Print Pass to program Description
SIGUSR1 No Yes Yes User defined signal 1
(gdb) c
Continuing.
Program received signal SIGUSR1, User defined signal 1
You can see that only , and gdb Won't stop , Next
take GDB Yes SIGUSR1 The signal processing is set to noprint
(gdb) handle SIGUSR1 noprint
Signal Stop Print Pass to program Description
SIGUSR1 No No Yes User defined signal 1
(gdb) c
Continuing
here GDB Neither print nor stop .
边栏推荐
- How to associate the QR code of wechat applet to realize the integration of two codes
- 【深入理解TcaplusDB技术】单据受理之表管理
- pi4j gpio针脚上拉电阻,下拉电阻概念
- Worthington trypsin solution
- 利用BioEdit做多序列一致性比对
- Advanced packaging, the beginning of a big cycle -- a symposium on semiconductor equipment
- Communication failure between botu simulation HMI and real 1200plc
- GDB调试实战(7)信号处理
- Notes on question brushing (17) -- binary search tree: about attribute problems
- B2B mall website helps enterprises speed up distribution and build an efficient and intelligent B2B online distribution platform
猜你喜欢

提升方法(下)提升树

How C # aboutbox displays its defined interface

从-1开始实现一个中间件

HIC Pro | HIC data processing tool

自制C#编译器

British teddy bear joins the pubg mobile game

使用StreamAPI 断言组合,结合本地缓存做模糊查询(比mysql效率提升近1000倍)

How to associate the QR code of wechat applet to realize the integration of two codes

Characteristics and experimental suggestions of abbkine cell cycle Staining Kit

赋·新生,链·未来!城链科技产业赋能创新发展大会隆重举行
随机推荐
Supplier management system of digital commerce cloud Paper Group: promote enterprise information construction and comprehensively improve supplier management efficiency
pi4j针脚模拟总线,进行控制传输和数据传输的几种思路
提升方法(上)AdaBoost
Leetcode508- the most frequent subtree elements and - deep search
AWS CloudWatch
A callback was made to a garbage collected delegate of type "xxx:: invoke". This can cause application crashes, corruption, and data loss. When passing delegates to unmanaged code, the managed applica
【深入理解TcaplusDB技术】TcaplusDB构造数据
British teddy bear joins the pubg mobile game
Beijing accelerates ecological construction, Medtronic Internet and Moore thread complete product compatibility and mutual certification
Mafft|multi sequence alignment tool
刷题笔记(十七)--二叉搜索树:关于属性问题
Notes on question brushing (17) -- binary search tree: about attribute problems
Paml| Shengxin software for calculating dn/ds value
Using bioedit to do multiple sequence consistency alignment
Luogu p1535 [usaco08mar]cow traveling s problem solution
What is the execution order of JS asynchronism
【深入理解TcaplusDB技术】Tmonitor后台一键安装
北京 加速生态建设 迈动互联与摩尔线程完成产品兼容互认证
利用BioEdit做多序列一致性比对
Dotter| dot method sequence pairwise comparison software