c++ - holes

容易 Core Dump 的情形

容器重新分配内存导致的非法内存访问

1
2
3
4
5
6
7
// 定义结构
struct Biz {...};
// 定义容器
std::vector<Biz> bizes;
bizes.emplace_back(); // 添加一个元素
auto p_biz = &bizes.back(); // 保存指针
bizes.emplace_back(); // 添加一个元素. 该操作可能会使指针 p_biz 失效, 因为内存重新分配

模板

类似需要在编译期展开的代码实现,不能放在 cpp 文件中,而应该放在 header 中

静态变量初始化

1
2
3
4
5
6
7
8
// s.h
#ifndef S_H
#define S_H
class S {
static int v;
};
int S::v = 0;
#endif

上面的代码在链接时会报错。声明保护(gragma once 或使用 ifndef 判断)可以解决单个编译单元(单个源文件)的重复声明错误,但不能避免多个编译单元在链接时的重复定义错误。要解决这个问题,需要把静态变量的声明和初始化放在不同的文件里面。

1
2
3
4
5
6
7
8
9
10
// s.h
#ifndef S_H
#define S_H
class S {
static int v;
};
#endif

// s.cpp
int S::v = 0;

undefined reference to

  • 未连接库

  • 编译库的编译器版本不一致,ABI 不兼容

    • 尤其注意,多个库之间使用的 gcc/++ 不一致
  • find_package 的顺序,在某些情况下也有可能会导致这个问题

    • 被依赖先调用 find_package

编译 C 库使用 C++ 语法

1
gcc -lstdc++ code.c

c++ - perf

工具

gprof、perf、gperftools、valgrind。

Perf

perf 工具默认生成记录文件 perf.data,读写路径是 pwd。

安装

1
2
3
4
5
# ubuntu
sudo apt install linux-tools-common linux-tools-generic linux-tools-`uname -r` -y

# centos
sudo yum install perf -y
1
2
3
4
5
6
7
# source code
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.134.tar.gz
tar -xf linux-5.10.134.tar.gz
cd linux-5.10.134/tools/perf

make # 如果编译出错,可以尝试修改 Makefile.config 里面的 FLAGS, 移除 -Werror
cp perf /usr/bin/

工具

bpftrace

1
bpftrace -e 'profile:hz:99 /pid == 1/ { @[ustack] = count(); }'

google-perftools + brpc

1
apt install google-gperftools
1
2
pprof-symbolize --text 0.0.0.0:9500 --seconds=5
pprof-symbolize 0.0.0.0:9500 --seconds=5

brpc/tools/pporf

./brpc/tools/pprof 是一个 prel 脚本文件,不需要编译

1
./brpc/tools/pprof --text localhost:9500/pprof/profile

top

系统性能分析工具。

参数

1
2
-e 指定 event,多个 event 用 , 分隔
-s 指定分类聚合列, 默认是函数,还有 comm(命令)、pid 等

使用

1
2
3
4
# 所有进程
$ perf top
# 指定进程
$ perf top -p <pid>

stat

运行命令 / 指定 pid,并收集性能统计数据。

record

运行命令 / 指定 pid,并收集分析数据至 perf.data。

1
2
3
4
5
# 指定 pid
$ pid=$(pgrep <program-name>)

# 查看报告
$ perf report --show-total-period

report

读取 perf.data,展示分析结果。

1
2
3
4
5
$ perf report 

# 参数
--show-total-period 展示总耗时列
-a 统计系统范围内数据

diff

对比两个 perf.data 内容的区别,使用场景比如对比改动前后的变化。

archive

用来打包 perf.data 中使用到的环境数据,用于离线分析。

1
2
3
4
5
# 打包
$ perf archieve

# 分析
$ tar xvf perf.data.tar.bz2 -C ~/.debug

使用

1
2
3
4
5
6
7
8
9
10
11
12
# 查看系统全部耗时
$ perf top

# pid
$ pid=$(pgrep <program-name>)

# 记录数据
$ perf record -e cpu-clock -F 99 -p $pid -g -- sleep 60 # 记录 60 秒数据

# 展示记录数据的分析结果
$ perf report --show-total-period
$ perf report --show-total-period$ -i <perf.data> # 指定记录文件

火焰图

使用 这里 生成火焰图。

1
2
3
4
5
# 下载工具
$ git clone https://github.com/brendangregg/FlameGraph

# 生成火焰图
$ sudo perf script | FlameGraph/stackcollapse-perf.pl | FlameGraph/flamegraph.pl > flamegraph.svg

参考

问题

1

性能分析

指标

  • 通量(Throughput,或吞吐量)
  • 时延(Latency)

通量

性能瓶颈排查

  • 处理器占用率

    • 使用 top 命令查看
    • 如果处理器占用率未满,排查网络、任务调度、IO 空洞问题
    • 如果处理器占满,使用 perf、ftrace 等工具进一步排查
  • 流控(网卡)

    • 查看网卡丢包,可以通过增加缓冲区降低丢包率

      1
      2
      3
      4
      5
      6
      7
      8
      wlan0     Link encap:以太网  硬件地址 7c:7a:91:xx:xx:xx  
      inet 地址:192.168.0.103 广播:192.168.0.255 掩码:255.255.255.0
      inet6 地址: fe80::7e7a:91ff:fefe:5a1a/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
      接收数据包:113832 错误:0 丢弃:0 过载:0 帧数:0
      发送数据包:81183 错误:0 丢弃:0 过载:0 载波:0
      碰撞:0 发送队列长度:1000
      接收字节:47850861 (47.8 MB) 发送字节:18914031 (18.9 MB)
  • 任务调度缺陷

    • 线程数远小于核心数,不能充分利用多核
  • IO 空洞

    • 同步等待 IO 操作,可以通过异步解决

参考

性能分析 - dstat

安装

1
2
# centos
sudo yum install -y dstat

命令

1
$ dstat

参数

默认参数为 -cdngy

1
2
3
4
5
6
-c cpu 信息
-C cpu 信息,指定核心,如 -C 0,2,4
-d disk 信息
-n net 信息
-g page 信息
-y system 信息

输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# cpu 相关
usr 用户消耗 cpu 时间占比
sys 系统消耗 cpu 时间占比
idl cpu 空闲时间占比
wai io 等待消耗的 cpu 占比
hiq 硬中断
siq 软中断

# system 相关
int 中断次数
csw 上下文切换次数

# disk
read 读取磁盘总数
write 写入磁盘总数

# net
recv 网络设备结束数据总数
send 网络设备发送数据总数

# page 相关(系统分页活动)
in 换入次数
out 换出次数

性能分析 - vmstat

安装

1
# centos

命令

1
$ vmstat <period> <count>

输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
r 运行队列,分配到 CPU 的进程数
b 堵塞进程数
swpd 使用虚拟内存
free 空闲物理内存
buff 缓冲占用内存
cache 缓存占用内存
si 每秒从磁盘读取虚拟内存大小
so 每秒写入磁盘虚拟内存大小
bi 每秒从块设备接受块数量
bo 每秒发送的块数量
in 每秒 cpu 中断次数,包括时间中断
cs 每秒上下文切换次数
us 用户 cpu 时间
sy 系统 cpu 时间
id 空闲 cpu 时间
wa 等待 io cpu 时间
st 从虚拟机窃取时间

c++ - segmentation fault

原因

  • 访问空指针
  • 访问不可访问的内存
    • 访问不可访问的变量 / 已经不在可访问作用域的变量,即便 gdb 调试可以展示变量值

案例

1
2
3
4
5
6
# 1. 访问已经回收的临时变量
使用 seastar 时,调用返回 future 方法的方法,参数包含局部变量。在执行 then 回调时,局部变量已经不可访问(使用 gdb 调试仍可展示数值)。
解决方法是使用 seastar::do_with(std::move(v), [](V &v) { ... })

# 2. 未加 return 值导致 std::function 析构
定义的方法返回值类型不为 void,但是没有 return 语句,定义 std::function 对象,在析构时报 segmentation fault

Lambda

shared_ptr

shared_ptr 引用导致的内存非法访问

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class A {
public:
int a;
};

std::function<void()> fun() {
std::shared_ptr<A> sa = std::make_shared<A>();
sa->a = 2;
auto f = [&] {
std::cout << "sa-> " << sa->a << std::endl;
sa->a = 1;
};
return f;
}

void test() {
std::cout << "----- in test -----" << std::endl;
fun()();
std::cout << "----- out test -----" << std::endl;
}

调用

1
2
3
4
int main() {
test();
return 0;
}

输出

1
2
3
4
----- in test -----
sa-> 281314120

Process finished with exit code 138 (interrupted by signal 10: SIGBUS)

原因

lambda 表达式使用引用访问局部变量,在 fun() 返回 lambda 表达式对象时,局部变量 sa 已被释放,在 test 中执行 lambda 表达式时会访问已被释放的内存。

解决

使用拷贝替换引用,增加引用计数。

1
2
3
4
5
6
7
8
9
std::function<void()> fun() {
std::shared_ptr<A> sa = std::make_shared<A>();
sa->a = 2;
auto f = [&, sa] {
std::cout << "sa-> " << sa->a << std::endl;
sa->a = 1;
};
return f;
}

输出

1
2
3
4
5
----- in test -----
sa-> 2
----- out test -----

Process finished with exit code 0

ftp client usage

1
2
3
4
5
6
7
8
9
10
11
Usage: { ftp | pftp } [-46pinegvtd] [hostname]
-4: use IPv4 addresses only
-6: use IPv6, nothing else
-p: enable passive mode (default for pftp)
-i: turn off prompting during mget
-n: inhibit auto-login
-e: disable readline support, if present
-g: disable filename globbing
-v: verbose mode
-t: enable packet tracing [nonfunctional]
-d: enable debugging

登录

1
2
$ ftp
ftp> open {ip}

gdb

忽略 SIGNAL

1
Signal: SIG34 (Real-time event 34)

在使用 gdb 调试时,如果频繁被信号中断,可屏蔽对应信号,以 SIG34 为例。

1
2
# file: ~/.gdbinit
handle SIG34 nostop noprint pass noignore
1
2
handle SIG34 nostop noprint pass noignore
handle SIG35 nostop noprint pass noignore

调试程序

1
2
3
4
$ gdb <program>

# 为程序添加参数
$ gdb --args program <args>

启动程序

1
$ gdb -ex=r --args /path/to/program arg1 arg2 # -ex=r => -ex=run
1
2
$ gdb /path/to/program
(gdb) run {args}

调试 core 文件

1
2
3
4
$ gdb <program> <core-file>
$ gdb <program> -c <core-file>
$ gdb <program>
(gdb) core <core-file>

命令

参考一

常用命令

b

1
2
3
4
5
6
7
8
# b, 断点相关
b main - Puts a breakpoint at the beginning of the program
b - Puts a breakpoint at the current line
b N - Puts a breakpoint at line N
b +N - Puts a breakpoint N lines down from the current line
b fn - Puts a breakpoint at the beginning of function "fn"
d N - Deletes breakpoint number N
info break - list breakpoints
1
2
3
4
5
6
7
8
9
10
11
12
r - Runs the program until a breakpoint or error
c - Continues running the program until the next breakpoint or error
f - Runs until the current function is finished
s - Runs the next line of the program
s N - Runs the next N lines of the program
n - Like s, but it does not step into functions
u N - Runs until you get N lines in front of the current line
p var - Prints the current value of the variable "var"
bt - Prints a stack trace
u - Goes up a level in the stack
d - Goes down a level in the stack
q - Quits gdb

p

打印给定的表达式

1
2
3
4
5
print [Expression]
print $[Previous value number]
print {[Type]}[Address]
print [First element]@[Element count]
print /[Format] [Expression]
  • Expression
    • 变量
    • 寄存器,$eax 等
    • 伪寄存器,$pc 等
  • Format
    • 合法的格式符
      • o - octal
      • x - hexadecimal
      • u - unsigned decimal
      • t - binary
      • f - floating point
      • a - address
      • c - char
      • s - string

注意

  • 打印本地变量时,需要确保选定了正确的帧(frame)

参考一

x

使用指定的格式,打印给定地址的内存内容。

1
2
3
4
x [Address expression]
x /[Format] [Address expression]
x /[Length][Format] [Address expression]
x
  • Address expression
    • 寄存器,$eip
    • 伪寄存器地址,$pc
  • Format
    • 格式
      • o - octal
      • x - hexadecimal
      • d - decimal
      • u - unsigned decimal
      • t - binary
      • f - floating point
      • a - address
      • c - char
      • s - string
      • i - instruction
    • 大小修饰符(size modifiers)
      • b - byte
      • h - halfword (16-bit value)
      • w - word (32-bit value)
      • g - giant word (64-bit value)
  • Length
    • 指定打印的元素个数

参考一

帧相关

1
2
3
(gdb) f n       # 选中第 n 个帧
(gdb) up # 上一个帧
(gdb) down # 下一个帧

打印变量

1
2
3
4
5
6
7
# 查看所有调用栈
bt
# 选中某个栈
select-frame <frame-no>

# 打印变量
display <variable-name>

列出变量

1
2
3
4
5
6
# 查看本地变量
info locals
# 查看全局变量
info variables
# 查看参数
info args

分类型打印

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 打印 char *
(gdb) p *(char**)0x21d4b4910

# map 相关
(gdb) p m._M_h
(gdb) p (m._M_h._M_bbegin._M_node._M_nxt)
(gdb) p m._M_h._M_buckets
(gdb) p m._M_h._M_buckets[0]

# vector 相关
(gdb) p *(v._M_impl._M_start+4)
(gdb) p *(v._M_impl._M_start+4)._M_ptr.name # name: struct field

# 智能指针
(gdb) p sptr._M_ptr->name # name: struct field

Vector

1
p *(*(m._M_impl._M_start+6)._M_impl._M_start) # vector<vector> 打印第 7 个元素 (vector)

Pretty Printer

Pretty Printer 功能是否支持是在 gdb 编译时,根据编译选项决定的。在编译时需要添加编译参数 --with-python 来启用 Pretty Printer。下面的命令可以查看是否开启。

1
2
3
4
5
6
7
$ gdb -config
This GDB was configured as follows:
configure --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
...
--without-python
--without-python-libdir
...

指定自定义的 python 路径,要指定到 python 二进制文件。

1
--without-python=/path/to/python/bin/python3

低版本的 python 在 configure 时会校验不通过,建议使用较新版本的 python3。

pretty printer 使用手册参考这里

多线程

1
2
3
4
(gdb) info threads           # 打印所有线程信息
(gdb) info threads {thread-no}... # 打印指定线程信息
(gdb) thread {thread-no} # 切换到线程
(gdb) thread apply all bt # 在所有线程打印调用栈信息

常见问题

gdb 卡住

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Reading symbols from <bin>...done.
[New LWP 19134]
[New LWP 19669]
[New LWP 19672]
[New LWP 19670]
[New LWP 19200]
[New LWP 19668]
[New LWP 19667]
[New LWP 19673]
[New LWP 19676]
[New LWP 19680]
[New LWP 19197]
[New LWP 19671]
[New LWP 19674]

yum 同样卡住,使用 ps aux | grep yumkill -9 之后,恢复正常。

断点

Attach 方式

1
2
3
4
5
# 定义断点文件 bp.info
break main.cpp:15

# attach 进程
gdb attach 10232 -x bp.info

命令

1

常见问题

value optimized out

1
2
3
4
5
6
# build type = debug
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_DEBUG} -O0")

参考

lldb

配置

忽略 SIGNAL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
process handle -p true -s false -n false SIGINT
process handle -p true -s false -n false SIGUSR1
process handle -p true -s false -n false SIGUSR2
process handle -p false -s false -n false SIGRTMIN
process handle -p false -s false -n false SIGRTMIN+1
process handle -p true -s false -n false SIGRTMIN+11
process handle -p true -s false -n false SIGRTMIN+12
process handle -p true -s false -n false SIGHUP
process handle -p true -s false -n false SIGQUIT
process handle -p true -s false -n false SIGILL
process handle -p true -s false -n false SIGABRT
process handle -p true -s false -n false SIGFPE
process handle -p true -s false -n false SIGSEGV
process handle -p true -s false -n false SIGALRM
process handle -p true -s false -n false SIGCONT
process handle -p true -s false -n false SIGSTOP
process handle -p true -s false -n false SIGTSTP
process handle -p true -s false -n false SIGTTIN
process handle -p true -s false -n false SIGTTOU
process handle -p true -s false -n false SIGTERM
# 或添加在配置文件 ~/.lldbinit 中

Signals

gdb 和 lldb 的 signal 有些差异,比如 gdb 中的 SIG34 在 lldb 中是 SIGRTMIN,SIG35 对应 SIGRTMIN+1。

LLDB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
AddSignal(1,      "SIGHUP",       false,    true,   true,   "hangup");
AddSignal(2, "SIGINT", true, true, true, "interrupt");
AddSignal(3, "SIGQUIT", false, true, true, "quit");
AddSignal(4, "SIGILL", false, true, true, "illegal instruction");
AddSignal(5, "SIGTRAP", true, true, true, "trace trap (not reset when caught)");
AddSignal(6, "SIGABRT", false, true, true, "abort()/IOT trap", "SIGIOT");
AddSignal(7, "SIGBUS", false, true, true, "bus error");
AddSignal(8, "SIGFPE", false, true, true, "floating point exception");
AddSignal(9, "SIGKILL", false, true, true, "kill");
AddSignal(10, "SIGUSR1", false, true, true, "user defined signal 1");
AddSignal(11, "SIGSEGV", false, true, true, "segmentation violation");
AddSignal(12, "SIGUSR2", false, true, true, "user defined signal 2");
AddSignal(13, "SIGPIPE", false, true, true, "write to pipe with reading end closed");
AddSignal(14, "SIGALRM", false, false, false, "alarm");
AddSignal(15, "SIGTERM", false, true, true, "termination requested");
AddSignal(16, "SIGSTKFLT", false, true, true, "stack fault");
AddSignal(17, "SIGCHLD", false, false, true, "child status has changed", "SIGCLD");
AddSignal(18, "SIGCONT", false, false, true, "process continue");
AddSignal(19, "SIGSTOP", true, true, true, "process stop");
AddSignal(20, "SIGTSTP", false, true, true, "tty stop");
AddSignal(21, "SIGTTIN", false, true, true, "background tty read");
AddSignal(22, "SIGTTOU", false, true, true, "background tty write");
AddSignal(23, "SIGURG", false, true, true, "urgent data on socket");
AddSignal(24, "SIGXCPU", false, true, true, "CPU resource exceeded");
AddSignal(25, "SIGXFSZ", false, true, true, "file size limit exceeded");
AddSignal(26, "SIGVTALRM", false, true, true, "virtual time alarm");
AddSignal(27, "SIGPROF", false, false, false, "profiling time alarm");
AddSignal(28, "SIGWINCH", false, true, true, "window size changes");
AddSignal(29, "SIGIO", false, true, true, "input/output ready/Pollable event", "SIGPOLL");
AddSignal(30, "SIGPWR", false, true, true, "power failure");
AddSignal(31, "SIGSYS", false, true, true, "invalid system call");
AddSignal(32, "SIG32", false, false, false, "threading library internal signal 1");
AddSignal(33, "SIG33", false, false, false, "threading library internal signal 2");
AddSignal(34, "SIGRTMIN", false, false, false, "real time signal 0");
AddSignal(35, "SIGRTMIN+1", false, false, false, "real time signal 1");
AddSignal(36, "SIGRTMIN+2", false, false, false, "real time signal 2");
AddSignal(37, "SIGRTMIN+3", false, false, false, "real time signal 3");
AddSignal(38, "SIGRTMIN+4", false, false, false, "real time signal 4");
AddSignal(39, "SIGRTMIN+5", false, false, false, "real time signal 5");
AddSignal(40, "SIGRTMIN+6", false, false, false, "real time signal 6");
AddSignal(41, "SIGRTMIN+7", false, false, false, "real time signal 7");
AddSignal(42, "SIGRTMIN+8", false, false, false, "real time signal 8");
AddSignal(43, "SIGRTMIN+9", false, false, false, "real time signal 9");
AddSignal(44, "SIGRTMIN+10", false, false, false, "real time signal 10");
AddSignal(45, "SIGRTMIN+11", false, false, false, "real time signal 11");
AddSignal(46, "SIGRTMIN+12", false, false, false, "real time signal 12");
AddSignal(47, "SIGRTMIN+13", false, false, false, "real time signal 13");
AddSignal(48, "SIGRTMIN+14", false, false, false, "real time signal 14");
AddSignal(49, "SIGRTMIN+15", false, false, false, "real time signal 15");
AddSignal(50, "SIGRTMAX-14", false, false, false, "real time signal 16"); // switching to SIGRTMAX-xxx to match "kill -l" output
AddSignal(51, "SIGRTMAX-13", false, false, false, "real time signal 17");
AddSignal(52, "SIGRTMAX-12", false, false, false, "real time signal 18");
AddSignal(53, "SIGRTMAX-11", false, false, false, "real time signal 19");
AddSignal(54, "SIGRTMAX-10", false, false, false, "real time signal 20");
AddSignal(55, "SIGRTMAX-9", false, false, false, "real time signal 21");
AddSignal(56, "SIGRTMAX-8", false, false, false, "real time signal 22");
AddSignal(57, "SIGRTMAX-7", false, false, false, "real time signal 23");
AddSignal(58, "SIGRTMAX-6", false, false, false, "real time signal 24");
AddSignal(59, "SIGRTMAX-5", false, false, false, "real time signal 25");
AddSignal(60, "SIGRTMAX-4", false, false, false, "real time signal 26");
AddSignal(61, "SIGRTMAX-3", false, false, false, "real time signal 27");
AddSignal(62, "SIGRTMAX-2", false, false, false, "real time signal 28");
AddSignal(63, "SIGRTMAX-1", false, false, false, "real time signal 29");
AddSignal(64, "SIGRTMAX", false, false, false, "real time signal 30");

GDB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
AddSignal(1,      "SIGHUP",       false,    true,   true,   "hangup");
AddSignal(2, "SIGINT", true, true, true, "interrupt");
AddSignal(3, "SIGQUIT", false, true, true, "quit");
AddSignal(4, "SIGILL", false, true, true, "illegal instruction");
AddSignal(5, "SIGTRAP", true, true, true, "trace trap (not reset when caught)");
AddSignal(6, "SIGABRT", false, true, true, "abort()/IOT trap", "SIGIOT");
AddSignal(7, "SIGEMT", false, true, true, "emulation trap");
AddSignal(8, "SIGFPE", false, true, true, "floating point exception");
AddSignal(9, "SIGKILL", false, true, true, "kill");
AddSignal(10, "SIGBUS", false, true, true, "bus error");
AddSignal(11, "SIGSEGV", false, true, true, "segmentation violation");
AddSignal(12, "SIGSYS", false, true, true, "invalid system call");
AddSignal(13, "SIGPIPE", false, true, true, "write to pipe with reading end closed");
AddSignal(14, "SIGALRM", false, false, false, "alarm");
AddSignal(15, "SIGTERM", false, true, true, "termination requested");
AddSignal(16, "SIGURG", false, true, true, "urgent data on socket");
AddSignal(17, "SIGSTOP", true, true, true, "process stop");
AddSignal(18, "SIGTSTP", false, true, true, "tty stop");
AddSignal(19, "SIGCONT", false, false, true, "process continue");
AddSignal(20, "SIGCHLD", false, false, true, "child status has changed", "SIGCLD");
AddSignal(21, "SIGTTIN", false, true, true, "background tty read");
AddSignal(22, "SIGTTOU", false, true, true, "background tty write");
AddSignal(23, "SIGIO", false, true, true, "input/output ready/Pollable event");
AddSignal(24, "SIGXCPU", false, true, true, "CPU resource exceeded");
AddSignal(25, "SIGXFSZ", false, true, true, "file size limit exceeded");
AddSignal(26, "SIGVTALRM", false, true, true, "virtual time alarm");
AddSignal(27, "SIGPROF", false, false, false, "profiling time alarm");
AddSignal(28, "SIGWINCH", false, true, true, "window size changes");
AddSignal(29, "SIGLOST", false, true, true, "resource lost");
AddSignal(30, "SIGUSR1", false, true, true, "user defined signal 1");
AddSignal(31, "SIGUSR2", false, true, true, "user defined signal 2");
AddSignal(32, "SIGPWR", false, true, true, "power failure");
AddSignal(33, "SIGPOLL", false, true, true, "pollable event");
AddSignal(34, "SIGWIND", false, true, true, "SIGWIND");
AddSignal(35, "SIGPHONE", false, true, true, "SIGPHONE");
AddSignal(36, "SIGWAITING", false, true, true, "process's LWPs are blocked");
AddSignal(37, "SIGLWP", false, true, true, "signal LWP");
AddSignal(38, "SIGDANGER", false, true, true, "swap space dangerously low");
AddSignal(39, "SIGGRANT", false, true, true, "monitor mode granted");
AddSignal(40, "SIGRETRACT", false, true, true, "need to relinquish monitor mode");
AddSignal(41, "SIGMSG", false, true, true, "monitor mode data available");
AddSignal(42, "SIGSOUND", false, true, true, "sound completed");
AddSignal(43, "SIGSAK", false, true, true, "secure attention");
AddSignal(44, "SIGPRIO", false, true, true, "SIGPRIO");
AddSignal(45, "SIG33", false, false, false, "real-time event 33");
AddSignal(46, "SIG34", false, false, false, "real-time event 34");
AddSignal(47, "SIG35", false, false, false, "real-time event 35");
AddSignal(48, "SIG36", false, false, false, "real-time event 36");
AddSignal(49, "SIG37", false, false, false, "real-time event 37");
AddSignal(50, "SIG38", false, false, false, "real-time event 38");
AddSignal(51, "SIG39", false, false, false, "real-time event 39");
AddSignal(52, "SIG40", false, false, false, "real-time event 40");
AddSignal(53, "SIG41", false, false, false, "real-time event 41");
AddSignal(54, "SIG42", false, false, false, "real-time event 42");
AddSignal(55, "SIG43", false, false, false, "real-time event 43");
AddSignal(56, "SIG44", false, false, false, "real-time event 44");
AddSignal(57, "SIG45", false, false, false, "real-time event 45");
AddSignal(58, "SIG46", false, false, false, "real-time event 46");
AddSignal(59, "SIG47", false, false, false, "real-time event 47");
AddSignal(60, "SIG48", false, false, false, "real-time event 48");
AddSignal(61, "SIG49", false, false, false, "real-time event 49");
AddSignal(62, "SIG50", false, false, false, "real-time event 50");
AddSignal(63, "SIG51", false, false, false, "real-time event 51");
AddSignal(64, "SIG52", false, false, false, "real-time event 52");
AddSignal(65, "SIG53", false, false, false, "real-time event 53");
AddSignal(66, "SIG54", false, false, false, "real-time event 54");
AddSignal(67, "SIG55", false, false, false, "real-time event 55");
AddSignal(68, "SIG56", false, false, false, "real-time event 56");
AddSignal(69, "SIG57", false, false, false, "real-time event 57");
AddSignal(70, "SIG58", false, false, false, "real-time event 58");
AddSignal(71, "SIG59", false, false, false, "real-time event 59");
AddSignal(72, "SIG60", false, false, false, "real-time event 60");
AddSignal(73, "SIG61", false, false, false, "real-time event 61");
AddSignal(74, "SIG62", false, false, false, "real-time event 62");
AddSignal(75, "SIG63", false, false, false, "real-time event 63");
AddSignal(76, "SIGCANCEL", false, true, true, "LWP internal signal");
AddSignal(77, "SIG32", false, false, false, "real-time event 32");
AddSignal(78, "SIG64", false, false, false, "real-time event 64");
AddSignal(79, "SIG65", false, false, false, "real-time event 65");
AddSignal(80, "SIG66", false, false, false, "real-time event 66");
AddSignal(81, "SIG67", false, false, false, "real-time event 67");
AddSignal(82, "SIG68", false, false, false, "real-time event 68");
AddSignal(83, "SIG69", false, false, false, "real-time event 69");
AddSignal(84, "SIG70", false, false, false, "real-time event 70");
AddSignal(85, "SIG71", false, false, false, "real-time event 71");
AddSignal(86, "SIG72", false, false, false, "real-time event 72");
AddSignal(87, "SIG73", false, false, false, "real-time event 73");
AddSignal(88, "SIG74", false, false, false, "real-time event 74");
AddSignal(89, "SIG75", false, false, false, "real-time event 75");
AddSignal(90, "SIG76", false, false, false, "real-time event 76");
AddSignal(91, "SIG77", false, false, false, "real-time event 77");
AddSignal(92, "SIG78", false, false, false, "real-time event 78");
AddSignal(93, "SIG79", false, false, false, "real-time event 79");
AddSignal(94, "SIG80", false, false, false, "real-time event 80");
AddSignal(95, "SIG81", false, false, false, "real-time event 81");
AddSignal(96, "SIG82", false, false, false, "real-time event 82");
AddSignal(97, "SIG83", false, false, false, "real-time event 83");
AddSignal(98, "SIG84", false, false, false, "real-time event 84");
AddSignal(99, "SIG85", false, false, false, "real-time event 85");
AddSignal(100, "SIG86", false, false, false, "real-time event 86");
AddSignal(101, "SIG87", false, false, false, "real-time event 87");
AddSignal(102, "SIG88", false, false, false, "real-time event 88");
AddSignal(103, "SIG89", false, false, false, "real-time event 89");
AddSignal(104, "SIG90", false, false, false, "real-time event 90");
AddSignal(105, "SIG91", false, false, false, "real-time event 91");
AddSignal(106, "SIG92", false, false, false, "real-time event 92");
AddSignal(107, "SIG93", false, false, false, "real-time event 93");
AddSignal(108, "SIG94", false, false, false, "real-time event 94");
AddSignal(109, "SIG95", false, false, false, "real-time event 95");
AddSignal(110, "SIG96", false, false, false, "real-time event 96");
AddSignal(111, "SIG97", false, false, false, "real-time event 97");
AddSignal(112, "SIG98", false, false, false, "real-time event 98");
AddSignal(113, "SIG99", false, false, false, "real-time event 99");
AddSignal(114, "SIG100", false, false, false, "real-time event 100");
AddSignal(115, "SIG101", false, false, false, "real-time event 101");
AddSignal(116, "SIG102", false, false, false, "real-time event 102");
AddSignal(117, "SIG103", false, false, false, "real-time event 103");
AddSignal(118, "SIG104", false, false, false, "real-time event 104");
AddSignal(119, "SIG105", false, false, false, "real-time event 105");
AddSignal(120, "SIG106", false, false, false, "real-time event 106");
AddSignal(121, "SIG107", false, false, false, "real-time event 107");
AddSignal(122, "SIG108", false, false, false, "real-time event 108");
AddSignal(123, "SIG109", false, false, false, "real-time event 109");
AddSignal(124, "SIG110", false, false, false, "real-time event 110");
AddSignal(125, "SIG111", false, false, false, "real-time event 111");
AddSignal(126, "SIG112", false, false, false, "real-time event 112");
AddSignal(127, "SIG113", false, false, false, "real-time event 113");
AddSignal(128, "SIG114", false, false, false, "real-time event 114");
AddSignal(129, "SIG115", false, false, false, "real-time event 115");
AddSignal(130, "SIG116", false, false, false, "real-time event 116");
AddSignal(131, "SIG117", false, false, false, "real-time event 117");
AddSignal(132, "SIG118", false, false, false, "real-time event 118");
AddSignal(133, "SIG119", false, false, false, "real-time event 119");
AddSignal(134, "SIG120", false, false, false, "real-time event 120");
AddSignal(135, "SIG121", false, false, false, "real-time event 121");
AddSignal(136, "SIG122", false, false, false, "real-time event 122");
AddSignal(137, "SIG123", false, false, false, "real-time event 123");
AddSignal(138, "SIG124", false, false, false, "real-time event 124");
AddSignal(139, "SIG125", false, false, false, "real-time event 125");
AddSignal(140, "SIG126", false, false, false, "real-time event 126");
AddSignal(141, "SIG127", false, false, false, "real-time event 127");
AddSignal(142, "SIGINFO", false, true, true, "information request");
AddSignal(143, "unknown", false, true, true, "unknown signal");
AddSignal(145, "EXC_BAD_ACCESS", false, true, true, "could not access memory");
AddSignal(146, "EXC_BAD_INSTRUCTION", false, true, true, "illegal instruction/operand");
AddSignal(147, "EXC_ARITHMETIC", false, true, true, "arithmetic exception");
AddSignal(148, "EXC_EMULATION", false, true, true, "emulation instruction");
AddSignal(149, "EXC_SOFTWARE", false, true, true, "software generated exception");
AddSignal(150, "EXC_BREAKPOINT", false, true, true, "breakpoint");
AddSignal(151, "SIGLIBRT", false, true, true, "librt internal signal");

命令

查看所有 handle

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(lldb) process handle
NAME PASS STOP NOTIFY
=========== ===== ===== ======
SIGHUP true true true
SIGINT true false true
SIGQUIT true true true
SIGILL true true true
SIGTRAP false true true
SIGABRT true true true
SIGBUS true false true
SIGFPE true true true
SIGKILL true true true
SIGUSR1 true false true
SIGSEGV true true true
SIGUSR2 true false true
SIGPIPE true true true
SIGALRM true false false
SIGTERM true true true
SIGSTKFLT true true true
SIGCHLD true false true
SIGCONT true false true
SIGSTOP false true true
SIGTSTP true true true
SIGTTIN true true true
SIGTTOU true true true
SIGURG true true true
SIGXCPU true true true
SIGXFSZ true true true
SIGVTALRM true true true
SIGPROF true false false
SIGWINCH true true true
SIGIO true true true
SIGPWR true true true
SIGSYS true true true
SIG32 true false false
SIG33 true false false
SIGRTMIN true false false
SIGRTMIN+1 true false false
SIGRTMIN+2 true false false
SIGRTMIN+3 true false false
SIGRTMIN+4 true false false
SIGRTMIN+5 true false false
SIGRTMIN+6 true false false
SIGRTMIN+7 true false false
SIGRTMIN+8 true false false
SIGRTMIN+9 true false false
SIGRTMIN+10 true false false
SIGRTMIN+11 true false false
SIGRTMIN+12 true false false
SIGRTMIN+13 true false false
SIGRTMIN+14 true false false
SIGRTMIN+15 true false false
SIGRTMAX-14 true false false
SIGRTMAX-13 true false false
SIGRTMAX-12 true false false
SIGRTMAX-11 true false false
SIGRTMAX-10 true false false
SIGRTMAX-9 true false false
SIGRTMAX-8 true false false
SIGRTMAX-7 true false false
SIGRTMAX-6 true false false
SIGRTMAX-5 true false false
SIGRTMAX-4 true false false
SIGRTMAX-3 true false false
SIGRTMAX-2 true false false
SIGRTMAX-1 true false false
SIGRTMAX true false false