我正在 armhf Debian 上为 SIGSEGV 编写信号处理程序。似乎 siginfo_t
的 si_trapno
成员在 ARM 上不可用(来自 eglibc 的 /usr/include/asm-generic/siginfo.h
):
[...]
#ifdef __ARCH_SI_TRAPNO
int _trapno; /* TRAP # which caused the signal */
#endif
我的问题是为什么?为什么这个宏没有为 ARM 定义? MMU 是不是太蠢了,无法传递这种信息?
最佳答案
不仅仅是 ARM。来自 sigaction(2)
:
int si_trapno; /* Trap number that caused
hardware-generated signal
(unused on most architectures) */
快速查看内核源代码会发现它仅存在于 Alpha、Sparc 和 Tile 上。 (您正在查看的 header 来自 Linux 内核,/usr/include/asm
、/usr/include/asm-generic
和/usr/include/linux
).
所以,问题不在于为什么这个字段在 ARM 上不存在;问题是为什么它会存在于 ARM 上,因为如您所见,它的默认状态不存在。我猜想在 Alpha 和 Sparc 上添加它是为了与同一硬件上的旧 Unix 变体兼容;我不知道为什么 Tile 决定添加它。
关于linux - ARM 上的 SIGSEGV si_trapno,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8108471/