📄 signal.c
字号:
else if (print_stack_t(tcp, tcp->u_arg[0]) < 0) return -1; } else { tprintf(", "); if (tcp->u_arg[1] == 0) tprintf("NULL"); else if (print_stack_t(tcp, tcp->u_arg[1]) < 0) return -1; } return 0;}#endif#ifdef HAVE_SIGACTIONintsys_sigprocmask(tcp)struct tcb *tcp;{#ifdef ALPHA if (entering(tcp)) { printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); tprintf(", "); printsigmask(tcp->u_arg[1], 0); } else if (!syserror(tcp)) { tcp->auxstr = sprintsigmask("old mask ", tcp->u_rval, 0); return RVAL_HEX | RVAL_STR; }#else /* !ALPHA */ sigset_t sigset; if (entering(tcp)) {#ifdef SVR4 if (tcp->u_arg[0] == 0) tprintf("0"); else#endif /* SVR4 */ printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); tprintf(", "); if (!tcp->u_arg[1]) tprintf("NULL, "); else if (copy_sigset(tcp, tcp->u_arg[1], &sigset) < 0) tprintf("%#lx, ", tcp->u_arg[1]); else { printsigmask(&sigset, 0); tprintf(", "); } } else { if (!tcp->u_arg[2]) tprintf("NULL"); else if (syserror(tcp)) tprintf("%#lx", tcp->u_arg[2]); else if (copy_sigset(tcp, tcp->u_arg[2], &sigset) < 0) tprintf("[?]"); else printsigmask(&sigset, 0); }#endif /* !ALPHA */ return 0;}#endif /* HAVE_SIGACTION */intsys_kill(tcp)struct tcb *tcp;{ if (entering(tcp)) { tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1])); } return 0;}intsys_killpg(tcp)struct tcb *tcp;{ return sys_kill(tcp);}intsys_sigpending(tcp)struct tcb *tcp;{ sigset_t sigset; if (exiting(tcp)) { if (syserror(tcp)) tprintf("%#lx", tcp->u_arg[0]); else if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0) tprintf("[?]"); else printsigmask(&sigset, 0); } return 0;}#ifdef LINUX intsys_rt_sigprocmask(tcp) struct tcb *tcp;{ sigset_t sigset; /* Note: arg[3] is the length of the sigset. */ if (entering(tcp)) { printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); tprintf(", "); if (!tcp->u_arg[1]) tprintf("NULL, "); else if (copy_sigset_len(tcp, tcp->u_arg[1], &sigset, tcp->u_arg[3]) < 0) tprintf("%#lx, ", tcp->u_arg[1]); else { printsigmask(&sigset, 1); tprintf(", "); } } else { if (!tcp->u_arg[2]) tprintf("NULL"); else if (syserror(tcp)) tprintf("%#lx", tcp->u_arg[2]); else if (copy_sigset_len(tcp, tcp->u_arg[2], &sigset, tcp->u_arg[3]) < 0) tprintf("[?]"); else printsigmask(&sigset, 1); tprintf(", %lu", tcp->u_arg[3]); } return 0;}#if __GLIBC_MINOR__ < 1/* Type for data associated with a signal. */typedef union sigval{ int sival_int; void *sival_ptr;} sigval_t;# define __SI_MAX_SIZE 128# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)typedef struct siginfo{ int si_signo; /* Signal number. */ int si_errno; /* If non-zero, an errno value associated with this signal, as defined in <errno.h>. */ int si_code; /* Signal code. */ union { int _pad[__SI_PAD_SIZE]; /* kill(). */ struct { __pid_t si_pid; /* Sending process ID. */ __uid_t si_uid; /* Real user ID of sending process. */ } _kill; /* POSIX.1b timers. */ struct { unsigned int _timer1; unsigned int _timer2; } _timer; /* POSIX.1b signals. */ struct { __pid_t si_pid; /* Sending process ID. */ __uid_t si_uid; /* Real user ID of sending process. */ sigval_t si_sigval; /* Signal value. */ } _rt; /* SIGCHLD. */ struct { __pid_t si_pid; /* Which child. */ int si_status; /* Exit value or signal. */ __clock_t si_utime; __clock_t si_stime; } _sigchld; /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */ struct { void *si_addr; /* Faulting insn/memory ref. */ } _sigfault; /* SIGPOLL. */ struct { int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; } _sifields;} siginfo_t;#endif/* Structure describing the action to be taken when a signal arrives. */struct new_sigaction{ union { __sighandler_t __sa_handler; void (*__sa_sigaction) (int, siginfo_t *, void *); } __sigaction_handler; unsigned long sa_flags; void (*sa_restorer) (void); unsigned long int sa_mask[2];}; intsys_rt_sigaction(tcp) struct tcb *tcp;{ struct new_sigaction sa; sigset_t sigset; long addr; if (entering(tcp)) { printsignal(tcp->u_arg[0]); tprintf(", "); addr = tcp->u_arg[1]; } else addr = tcp->u_arg[2]; if (addr == 0) tprintf("NULL"); else if (!verbose(tcp)) tprintf("%#lx", addr); else if (umove(tcp, addr, &sa) < 0) tprintf("{...}"); else { switch ((long) sa.__sigaction_handler.__sa_handler) { case (long) SIG_ERR: tprintf("{SIG_ERR}"); break; case (long) SIG_DFL: tprintf("{SIG_DFL}"); break; case (long) SIG_IGN: tprintf("{SIG_IGN}"); break; default: tprintf("{%#lx, ", (long) sa.__sigaction_handler.__sa_handler); sigemptyset(&sigset);#ifdef LINUXSPARC if (tcp->u_arg[4] <= sizeof(sigset)) memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);#else if (tcp->u_arg[3] <= sizeof(sigset)) memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);#endif else memcpy(&sigset, &sa.sa_mask, sizeof(sigset)); printsigmask(&sigset, 1); tprintf(", "); if (!printflags(sigact_flags, sa.sa_flags)) tprintf("0"); tprintf("}"); } } if (entering(tcp)) tprintf(", "); else#ifdef LINUXSPARC tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);#elif defined(ALPHA) tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);#else tprintf(", %lu", addr = tcp->u_arg[3]);#endif return 0;} intsys_rt_sigpending(tcp) struct tcb *tcp;{ sigset_t sigset; if (exiting(tcp)) { if (syserror(tcp)) tprintf("%#lx", tcp->u_arg[0]); else if (copy_sigset_len(tcp, tcp->u_arg[0], &sigset, tcp->u_arg[1]) < 0) tprintf("[?]"); else printsigmask(&sigset, 1); } return 0;} intsys_rt_sigsuspend(tcp) struct tcb *tcp;{ if (entering(tcp)) { sigset_t sigm; if (copy_sigset_len(tcp, tcp->u_arg[0], &sigm, tcp->u_arg[1]) < 0) tprintf("[?]"); else printsigmask(&sigm, 1); } return 0;}#ifndef ILL_ILLOPC#define ILL_ILLOPC 1 /* illegal opcode */#define ILL_ILLOPN 2 /* illegal operand */#define ILL_ILLADR 3 /* illegal addressing mode */#define ILL_ILLTRP 4 /* illegal trap */#define ILL_PRVOPC 5 /* privileged opcode */#define ILL_PRVREG 6 /* privileged register */#define ILL_COPROC 7 /* coprocessor error */#define ILL_BADSTK 8 /* internal stack error */#define FPE_INTDIV 1 /* integer divide by zero */#define FPE_INTOVF 2 /* integer overflow */#define FPE_FLTDIV 3 /* floating point divide by zero */#define FPE_FLTOVF 4 /* floating point overflow */#define FPE_FLTUND 5 /* floating point underflow */#define FPE_FLTRES 6 /* floating point inexact result */#define FPE_FLTINV 7 /* floating point invalid operation */#define FPE_FLTSUB 8 /* subscript out of range */#define SEGV_MAPERR 1 /* address not mapped to object */#define SEGV_ACCERR 2 /* invalid permissions for mapped object */#define BUS_ADRALN 1 /* invalid address alignment */#define BUS_ADRERR 2 /* non-existant physical address */#define BUS_OBJERR 3 /* object specific hardware error */#define TRAP_BRKPT 1 /* process breakpoint */#define TRAP_TRACE 2 /* process trace trap */#define CLD_EXITED 1 /* child has exited */#define CLD_KILLED 2 /* child was killed */#define CLD_DUMPED 3 /* child terminated abnormally */#define CLD_TRAPPED 4 /* traced child has trapped */#define CLD_STOPPED 5 /* child has stopped */#define CLD_CONTINUED 6 /* stopped child has continued */#define POLL_IN 1 /* data input available */#define POLL_OUT 2 /* output buffers available */#define POLL_MSG 3 /* input message available */#define POLL_ERR 4 /* i/o error */#define POLL_PRI 5 /* high priority input available */#define POLL_HUP 6 /* device disconnected */#define SI_USER 0 /* sent by kill, sigsend, raise */#define SI_QUEUE -1 /* sent by sigqueue */#define SI_TIMER -2 /* sent by timer expiration */#define SI_MESGQ -3 /* sent by real time mesq state change */#define SI_ASYNCIO -4 /* sent by AIO completion */#else#undef si_pid#undef si_uid#undef si_status#undef si_utime#undef si_stime#undef si_value#undef si_int#undef si_ptr#undef si_addr#undef si_band#undef si_fd#endifstatic struct xlat sigill_flags[] = { {ILL_ILLOPC, "ILL_ILLOPC"}, {ILL_ILLOPN, "ILL_ILLOPN"}, {ILL_ILLADR, "ILL_ILLADR"}, {ILL_ILLTRP, "ILL_ILLTRP"}, {ILL_PRVOPC, "ILL_PRVOPC"}, {ILL_PRVREG, "ILL_PRVREG"}, {ILL_COPROC, "ILL_COPROC"}, {ILL_BADSTK, "ILL_BADSTK"}, {0, NULL}};static struct xlat sigfpe_flags[] = { {FPE_INTDIV, "FPE_INTDIV"}, {FPE_INTOVF, "FPE_INTOVF"}, {FPE_FLTDIV, "FPE_FLTDIV"}, {FPE_FLTOVF, "FPE_FLTOVF"}, {FPE_FLTUND, "FPE_FLTUND"}, {FPE_FLTRES, "FPE_FLTRES"}, {FPE_FLTINV, "FPE_FLTINV"}, {FPE_FLTSUB, "FPE_FLTSUB"}, {0, NULL}};static struct xlat sigsegv_flags[] = { {SEGV_MAPERR, "SEGV_MAPERR"}, {SEGV_ACCERR, "SEGV_ACCERR"}, {0, NULL}};static struct xlat sigbus_flags[] = { {BUS_ADRALN, "BUS_ADRALN"}, {BUS_ADRERR, "BUS_ADRERR"}, {BUS_OBJERR, "BUS_OBJERR"}, {0, NULL}};static struct xlat sigtrap_flags[] = { {TRAP_BRKPT, "TRAP_BRKPT"}, {TRAP_TRACE, "TRAP_TRACE"}, {0, NULL}};static struct xlat sigchld_flags[] = { {CLD_EXITED, "CLD_EXITED"}, {CLD_KILLED, "CLD_KILLED"}, {CLD_DUMPED, "CLD_DUMPED"}, {CLD_TRAPPED, "CLD_TRAPPED"}, {CLD_STOPPED, "CLD_STOPPED"}, {CLD_CONTINUED, "CLD_CONTINUED"}, {0, NULL}};static struct xlat sigpoll_flags[] = { {POLL_IN, "POLL_IN"}, {POLL_OUT, "POLL_OUT"}, {POLL_MSG, "POLL_MSG"}, {POLL_ERR, "POLL_ERR"}, {POLL_PRI, "POLL_PRI"}, {POLL_HUP, "POLL_HUP"}, {0, NULL}};static struct xlat siginfo_flags[] = { {SI_USER, "SI_USER"}, {SI_QUEUE, "SI_QUEUE"}, {SI_TIMER, "SI_TIMER"}, {SI_MESGQ, "SI_MESGQ"}, {SI_ASYNCIO, "SI_ASYNCIO"}, {0, NULL}}; static voidprintsiginfo(tcp, si) struct tcb *tcp; siginfo_t *si;{ tprintf("{si_signo="); printsignal(si->si_signo); tprintf(", si_errno=%d, si_code=", si->si_errno); switch(si->si_signo) { case SIGILL: if (!printflags(sigill_flags, si->si_code)) tprintf("%d /* ILL_??? */", si->si_code); tprintf(", si_addr=%lx", (unsigned long) si->_sifields._sigfault.si_addr); break; case SIGFPE: if (!printflags(sigfpe_flags, si->si_code)) tprintf("%d /* FPE_??? */", si->si_code); tprintf(", si_addr=%lx", (unsigned long) si->_sifields._sigfault.si_addr); break; case SIGSEGV: if (!printflags(sigsegv_flags, si->si_code)) tprintf("%d /* SEGV_??? */", si->si_code); tprintf(", si_addr=%lx", (unsigned long) si->_sifields._sigfault.si_addr); break; case SIGBUS: if (!printflags(sigbus_flags, si->si_code)) tprintf("%d /* BUS_??? */", si->si_code); tprintf(", si_addr=%lx", (unsigned long) si->_sifields._sigfault.si_addr); break; case SIGTRAP: if (!printflags(sigtrap_flags, si->si_code)) tprintf("%d /* TRAP_??? */", si->si_code); break; case SIGCHLD: if (!printflags(sigchld_flags, si->si_code)) tprintf("%d /* CLD_??? */", si->si_code); if (!verbose(tcp)) tprintf(", ..."); else tprintf(", si_pid=%d, si_uid=%d, si_status=%d, si_utime=%lu, si_stime=%lu", si->_sifields._kill.si_pid, si->_sifields._kill.si_uid, si->_sifields._sigchld.si_status, si->_sifields._sigchld.si_utime, si->_sifields._sigchld.si_stime); break; case SIGPOLL: if (!printflags(sigpoll_flags, si->si_code)) tprintf("%d /* POLL_??? */", si->si_code); if (si->si_code == POLL_IN || si->si_code == POLL_OUT || si->si_code == POLL_MSG) tprintf(", si_bind=%lu, si_fd=%d", (unsigned long) si->_sifields._sigpoll.si_band, si->_sifields._sigpoll.si_fd); break; default: if (!printflags(siginfo_flags, si->si_code)) tprintf("%d /* SI_??? */", si->si_code); tprintf(", si_pid=%lu, si_uid=%lu, si_value={", (unsigned long) si->_sifields._rt.si_pid, (unsigned long) si->_sifields._rt.si_uid); if (!verbose(tcp)) tprintf("..."); else { tprintf("sival_int=%u, sival_ptr=%#lx", si->_sifields._rt.si_sigval.sival_int, (unsigned long) si->_sifields._rt.si_sigval.sival_ptr); } tprintf("}"); break; } tprintf("}");} intsys_rt_sigqueueinfo(tcp) struct tcb *tcp;{ if (entering(tcp)) { siginfo_t si; tprintf("%lu, ", tcp->u_arg[0]); printsignal(tcp->u_arg[1]); tprintf(", "); if (umove(tcp, tcp->u_arg[2], &si) < 0) tprintf("%#lx", tcp->u_arg[2]); else printsiginfo(&si); } return 0;}int sys_rt_sigtimedwait(tcp) struct tcb *tcp;{ if (entering(tcp)) { sigset_t sigset; if (copy_sigset_len(tcp, tcp->u_arg[0], &sigset, tcp->u_arg[3]) < 0) tprintf("[?]"); else printsigmask(&sigset, 1); tprintf(", "); } else { if (syserror(tcp)) tprintf("%#lx", tcp->u_arg[0]); else { siginfo_t si; if (umove(tcp, tcp->u_arg[1], &si) < 0) tprintf("%#lx", tcp->u_arg[1]); else printsiginfo(&si); /* XXX For now */ tprintf(", %#lx", tcp->u_arg[2]); tprintf(", %d", (int) tcp->u_arg[3]); } } return 0;};#endif /* LINUX */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -