📄 procfs.c
字号:
static char *sigcodename (sip) siginfo_t *sip;{ struct sigcode *scp; char *name = NULL; static char locbuf[32]; for (scp = siginfo_table; scp -> codename != NULL; scp++) { if ((scp -> signo == sip -> si_signo) && (scp -> code == sip -> si_code)) { name = scp -> codename; break; } } if (name == NULL) { sprintf (locbuf, "sigcode %u", sip -> si_signo); name = locbuf; } return (name);}static char *sigcodedesc (sip) siginfo_t *sip;{ struct sigcode *scp; char *desc = NULL; for (scp = siginfo_table; scp -> codename != NULL; scp++) { if ((scp -> signo == sip -> si_signo) && (scp -> code == sip -> si_code)) { desc = scp -> desc; break; } } if (desc == NULL) { desc = "Unrecognized signal or trap use"; } return (desc);}/*LOCAL FUNCTION syscallname - translate a system call number into a system call nameSYNOPSIS char *syscallname (int syscallnum)DESCRIPTION Given a system call number, translate it into the printable name of a system call, or into "syscall <num>" if it is an unknown number. */static char *syscallname (syscallnum) int syscallnum;{ static char locbuf[32]; char *rtnval; if (syscallnum >= 0 && syscallnum < MAX_SYSCALLS) { rtnval = syscall_table[syscallnum]; } else { sprintf (locbuf, "syscall %u", syscallnum); rtnval = locbuf; } return (rtnval);}/*LOCAL FUNCTION init_syscall_table - initialize syscall translation tableSYNOPSIS void init_syscall_table (void)DESCRIPTION Dynamically initialize the translation table to convert system call numbers into printable system call names. Done once per gdb run, on initialization.NOTES This is awfully ugly, but preprocessor tricks to make it prettier tend to be nonportable. */static voidinit_syscall_table (){#if defined (SYS_exit) syscall_table[SYS_exit] = "exit";#endif#if defined (SYS_fork) syscall_table[SYS_fork] = "fork";#endif#if defined (SYS_read) syscall_table[SYS_read] = "read";#endif#if defined (SYS_write) syscall_table[SYS_write] = "write";#endif#if defined (SYS_open) syscall_table[SYS_open] = "open";#endif#if defined (SYS_close) syscall_table[SYS_close] = "close";#endif#if defined (SYS_wait) syscall_table[SYS_wait] = "wait";#endif#if defined (SYS_creat) syscall_table[SYS_creat] = "creat";#endif#if defined (SYS_link) syscall_table[SYS_link] = "link";#endif#if defined (SYS_unlink) syscall_table[SYS_unlink] = "unlink";#endif#if defined (SYS_exec) syscall_table[SYS_exec] = "exec";#endif#if defined (SYS_execv) syscall_table[SYS_execv] = "execv";#endif#if defined (SYS_execve) syscall_table[SYS_execve] = "execve";#endif#if defined (SYS_chdir) syscall_table[SYS_chdir] = "chdir";#endif#if defined (SYS_time) syscall_table[SYS_time] = "time";#endif#if defined (SYS_mknod) syscall_table[SYS_mknod] = "mknod";#endif#if defined (SYS_chmod) syscall_table[SYS_chmod] = "chmod";#endif#if defined (SYS_chown) syscall_table[SYS_chown] = "chown";#endif#if defined (SYS_brk) syscall_table[SYS_brk] = "brk";#endif#if defined (SYS_stat) syscall_table[SYS_stat] = "stat";#endif#if defined (SYS_lseek) syscall_table[SYS_lseek] = "lseek";#endif#if defined (SYS_getpid) syscall_table[SYS_getpid] = "getpid";#endif#if defined (SYS_mount) syscall_table[SYS_mount] = "mount";#endif#if defined (SYS_umount) syscall_table[SYS_umount] = "umount";#endif#if defined (SYS_setuid) syscall_table[SYS_setuid] = "setuid";#endif#if defined (SYS_getuid) syscall_table[SYS_getuid] = "getuid";#endif#if defined (SYS_stime) syscall_table[SYS_stime] = "stime";#endif#if defined (SYS_ptrace) syscall_table[SYS_ptrace] = "ptrace";#endif#if defined (SYS_alarm) syscall_table[SYS_alarm] = "alarm";#endif#if defined (SYS_fstat) syscall_table[SYS_fstat] = "fstat";#endif#if defined (SYS_pause) syscall_table[SYS_pause] = "pause";#endif#if defined (SYS_utime) syscall_table[SYS_utime] = "utime";#endif#if defined (SYS_stty) syscall_table[SYS_stty] = "stty";#endif#if defined (SYS_gtty) syscall_table[SYS_gtty] = "gtty";#endif#if defined (SYS_access) syscall_table[SYS_access] = "access";#endif#if defined (SYS_nice) syscall_table[SYS_nice] = "nice";#endif#if defined (SYS_statfs) syscall_table[SYS_statfs] = "statfs";#endif#if defined (SYS_sync) syscall_table[SYS_sync] = "sync";#endif#if defined (SYS_kill) syscall_table[SYS_kill] = "kill";#endif#if defined (SYS_fstatfs) syscall_table[SYS_fstatfs] = "fstatfs";#endif#if defined (SYS_pgrpsys) syscall_table[SYS_pgrpsys] = "pgrpsys";#endif#if defined (SYS_xenix) syscall_table[SYS_xenix] = "xenix";#endif#if defined (SYS_dup) syscall_table[SYS_dup] = "dup";#endif#if defined (SYS_pipe) syscall_table[SYS_pipe] = "pipe";#endif#if defined (SYS_times) syscall_table[SYS_times] = "times";#endif#if defined (SYS_profil) syscall_table[SYS_profil] = "profil";#endif#if defined (SYS_plock) syscall_table[SYS_plock] = "plock";#endif#if defined (SYS_setgid) syscall_table[SYS_setgid] = "setgid";#endif#if defined (SYS_getgid) syscall_table[SYS_getgid] = "getgid";#endif#if defined (SYS_signal) syscall_table[SYS_signal] = "signal";#endif#if defined (SYS_msgsys) syscall_table[SYS_msgsys] = "msgsys";#endif#if defined (SYS_sys3b) syscall_table[SYS_sys3b] = "sys3b";#endif#if defined (SYS_acct) syscall_table[SYS_acct] = "acct";#endif#if defined (SYS_shmsys) syscall_table[SYS_shmsys] = "shmsys";#endif#if defined (SYS_semsys) syscall_table[SYS_semsys] = "semsys";#endif#if defined (SYS_ioctl) syscall_table[SYS_ioctl] = "ioctl";#endif#if defined (SYS_uadmin) syscall_table[SYS_uadmin] = "uadmin";#endif#if defined (SYS_utssys) syscall_table[SYS_utssys] = "utssys";#endif#if defined (SYS_fsync) syscall_table[SYS_fsync] = "fsync";#endif#if defined (SYS_umask) syscall_table[SYS_umask] = "umask";#endif#if defined (SYS_chroot) syscall_table[SYS_chroot] = "chroot";#endif#if defined (SYS_fcntl) syscall_table[SYS_fcntl] = "fcntl";#endif#if defined (SYS_ulimit) syscall_table[SYS_ulimit] = "ulimit";#endif#if defined (SYS_rfsys) syscall_table[SYS_rfsys] = "rfsys";#endif#if defined (SYS_rmdir) syscall_table[SYS_rmdir] = "rmdir";#endif#if defined (SYS_mkdir) syscall_table[SYS_mkdir] = "mkdir";#endif#if defined (SYS_getdents) syscall_table[SYS_getdents] = "getdents";#endif#if defined (SYS_sysfs) syscall_table[SYS_sysfs] = "sysfs";#endif#if defined (SYS_getmsg) syscall_table[SYS_getmsg] = "getmsg";#endif#if defined (SYS_putmsg) syscall_table[SYS_putmsg] = "putmsg";#endif#if defined (SYS_poll) syscall_table[SYS_poll] = "poll";#endif#if defined (SYS_lstat) syscall_table[SYS_lstat] = "lstat";#endif#if defined (SYS_symlink) syscall_table[SYS_symlink] = "symlink";#endif#if defined (SYS_readlink) syscall_table[SYS_readlink] = "readlink";#endif#if defined (SYS_setgroups) syscall_table[SYS_setgroups] = "setgroups";#endif#if defined (SYS_getgroups) syscall_table[SYS_getgroups] = "getgroups";#endif#if defined (SYS_fchmod) syscall_table[SYS_fchmod] = "fchmod";#endif#if defined (SYS_fchown) syscall_table[SYS_fchown] = "fchown";#endif#if defined (SYS_sigprocmask) syscall_table[SYS_sigprocmask] = "sigprocmask";#endif#if defined (SYS_sigsuspend) syscall_table[SYS_sigsuspend] = "sigsuspend";#endif#if defined (SYS_sigaltstack) syscall_table[SYS_sigaltstack] = "sigaltstack";#endif#if defined (SYS_sigaction) syscall_table[SYS_sigaction] = "sigaction";#endif#if defined (SYS_sigpending) syscall_table[SYS_sigpending] = "sigpending";#endif#if defined (SYS_context) syscall_table[SYS_context] = "context";#endif#if defined (SYS_evsys) syscall_table[SYS_evsys] = "evsys";#endif#if defined (SYS_evtrapret) syscall_table[SYS_evtrapret] = "evtrapret";#endif#if defined (SYS_statvfs) syscall_table[SYS_statvfs] = "statvfs";#endif#if defined (SYS_fstatvfs) syscall_table[SYS_fstatvfs] = "fstatvfs";#endif#if defined (SYS_nfssys) syscall_table[SYS_nfssys] = "nfssys";#endif#if defined (SYS_waitsys) syscall_table[SYS_waitsys] = "waitsys";#endif#if defined (SYS_sigsendsys) syscall_table[SYS_sigsendsys] = "sigsendsys";#endif#if defined (SYS_hrtsys) syscall_table[SYS_hrtsys] = "hrtsys";#endif#if defined (SYS_acancel) syscall_table[SYS_acancel] = "acancel";#endif#if defined (SYS_async) syscall_table[SYS_async] = "async";#endif#if defined (SYS_priocntlsys) syscall_table[SYS_priocntlsys] = "priocntlsys";#endif#if defined (SYS_pathconf) syscall_table[SYS_pathconf] = "pathconf";#endif#if defined (SYS_mincore) syscall_table[SYS_mincore] = "mincore";#endif#if defined (SYS_mmap) syscall_table[SYS_mmap] = "mmap";#endif#if defined (SYS_mprotect) syscall_table[SYS_mprotect] = "mprotect";#endif#if defined (SYS_munmap) syscall_table[SYS_munmap] = "munmap";#endif#if defined (SYS_fpathconf) syscall_table[SYS_fpathconf] = "fpathconf";#endif#if defined (SYS_vfork) syscall_table[SYS_vfork] = "vfork";#endif#if defined (SYS_fchdir) syscall_table[SYS_fchdir] = "fchdir";#endif#if defined (SYS_readv) syscall_table[SYS_readv] = "readv";#endif#if defined (SYS_writev) syscall_table[SYS_writev] = "writev";#endif#if defined (SYS_xstat) syscall_table[SYS_xstat] = "xstat";#endif#if defined (SYS_lxstat) syscall_table[SYS_lxstat] = "lxstat";#endif#if defined (SYS_fxstat) syscall_table[SYS_fxstat] = "fxstat";#endif#if defined (SYS_xmknod) syscall_table[SYS_xmknod] = "xmknod";#endif#if defined (SYS_clocal) syscall_table[SYS_clocal] = "clocal";#endif#if defined (SYS_setrlimit) syscall_table[SYS_setrlimit] = "setrlimit";#endif#if defined (SYS_getrlimit) syscall_table[SYS_getrlimit] = "getrlimit";#endif#if defined (SYS_lchown) syscall_table[SYS_lchown] = "lchown";#endif#if defined (SYS_memcntl) syscall_table[SYS_memcntl] = "memcntl";#endif#if defined (SYS_getpmsg) syscall_table[SYS_getpmsg] = "getpmsg";#endif#if defined (SYS_putpmsg) syscall_table[SYS_putpmsg] = "putpmsg";#endif#if defined (SYS_rename) syscall_table[SYS_rename] = "rename";#endif#if defined (SYS_uname) syscall_table[SYS_uname] = "uname";#endif#if defined (SYS_setegid) syscall_table[SYS_setegid] = "setegid";#endif#if defined (SYS_sysconfig) syscall_table[SYS_sysconfig] = "sysconfig";#endif#if defined (SYS_adjtime) syscall_table[SYS_adjtime] = "adjtime";#endif#if defined (SYS_systeminfo) syscall_table[SYS_systeminfo] = "systeminfo";#endif#if defined (SYS_seteuid) syscall_table[SYS_seteuid] = "seteuid";#endif}/*GLOBAL FUNCTION ptrace -- override library version to force errors for /proc versionSYNOPSIS int ptrace (int request, int pid, PTRACE_ARG3_TYPE arg3, int arg4)DESCRIPTION When gdb is configured to use /proc, it should not be calling or otherwise attempting to use ptrace. In order to catch errors where use of /proc is configured, but some routine is still calling ptrace, we provide a local version of a function with that name that does nothing but issue an error message.*/intptrace (request, pid, arg3, arg4) int request; int pid; PTRACE_ARG3_TYPE arg3; int arg4;{ error ("internal error - there is a call to ptrace() somewhere"); /*NOTREACHED*/}/*LOCAL FUNCTION procfs_kill_inferior - kill any currently inferiorSYNOPSIS void procfs_kill_inferior (void)DESCRIPTION Kill any current inferior.NOTES Kills even attached inferiors. Presumably the user has already been prompted that the inferior is an attached one rather than one started by gdb. (FIXME?)*/static voidprocfs_kill_inferior (){ if (inferior_pid != 0) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -