gpt4 book ai didi

c++ - siginfo 匿名 union 体

转载 作者:行者123 更新时间:2023-11-30 17:53:12 28 4
gpt4 key购买 nike

我正在尝试获取生成 sigsys 信号的系统调用的地址!但我从 gcc 收到以下错误:

gcc emulator.c -fms-extensions
error: ‘siginfo_t’ has no member named ‘si_call_addr’

我使用的代码是:

static void emulator(int nr, siginfo_t *siginfo, void *void_context)
{
ucontext_t *ctx = (ucontext_t *)(void_context);
int syscall;
char *buf;
ssize_t bytes;
size_t len;


if (siginfo->si_code != SYS_SECCOMP)
return;
if (!ctx)
return;


syscall = ctx->uc_mcontext.gregs[REG_SYSCALL];
printf("System call %d ADDR %X\n", syscall, siginfo->si_call_addr);

setcontext(ctx);

return;
}

si_call_addr 在 siginfo_t 中定义为匿名结构。

最佳答案

siginfo_t 中没有 si_call_addr。您可能正在寻找 si_addr 成员。

这是linux提供的siginfo_t:

 siginfo_t {
int si_signo; /* Signal number */
int si_errno; /* An errno value */
int si_code; /* Signal code */
int si_trapno; /* Trap number that caused
hardware-generated signal
(unused on most architectures) */
pid_t si_pid; /* Sending process ID */
uid_t si_uid; /* Real user ID of sending process */
int si_status; /* Exit value or signal */
clock_t si_utime; /* User time consumed */
clock_t si_stime; /* System time consumed */
sigval_t si_value; /* Signal value */
int si_int; /* POSIX.1b signal */
void *si_ptr; /* POSIX.1b signal */
int si_overrun; /* Timer overrun count; POSIX.1b timers */
int si_timerid; /* Timer ID; POSIX.1b timers */
void *si_addr; /* Memory location which caused fault */
long si_band; /* Band event (was int in
glibc 2.3.2 and earlier) */
int si_fd; /* File descriptor */
short si_addr_lsb; /* Least significant bit of address
(since kernel 2.6.32) */
}

关于c++ - siginfo 匿名 union 体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15753339/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com