proc-events.c revision 1.8
1/* Machine-independent support for Solaris /proc (process file system) 2 3 Copyright (C) 1999-2019 Free Software Foundation, Inc. 4 5 Written by Michael Snyder at Cygnus Solutions. 6 Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 3 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 20 21/* Pretty-print "events of interest". 22 23 This module includes pretty-print routines for: 24 * faults (hardware exceptions) 25 * signals (software interrupts) 26 * syscalls 27 28 FIXME: At present, the syscall translation table must be 29 initialized, which is not true of the other translation tables. */ 30 31#include "defs.h" 32 33#define _STRUCTURED_PROC 1 34 35#include <sys/types.h> 36#include <sys/procfs.h> 37#include <sys/syscall.h> 38#include <sys/fault.h> 39 40#include "proc-utils.h" 41 42/* Much of the information used in the /proc interface, particularly 43 for printing status information, is kept as tables of structures of 44 the following form. These tables can be used to map numeric values 45 to their symbolic names and to a string that describes their 46 specific use. */ 47 48struct trans 49{ 50 int value; /* The numeric value. */ 51 const char *name; /* The equivalent symbolic value. */ 52 const char *desc; /* Short description of value. */ 53}; 54 55 56/* Pretty print syscalls. */ 57 58/* Syscall translation table. */ 59 60#define MAX_SYSCALLS 262 /* Pretty arbitrary. */ 61static const char *syscall_table[MAX_SYSCALLS]; 62 63static void 64init_syscall_table (void) 65{ 66 syscall_table[SYS_accept] = "accept"; 67#ifdef SYS_access 68 syscall_table[SYS_access] = "access"; 69#endif 70 syscall_table[SYS_acct] = "acct"; 71 syscall_table[SYS_acctctl] = "acctctl"; 72 syscall_table[SYS_acl] = "acl"; 73#ifdef SYS_adi 74 syscall_table[SYS_adi] = "adi"; 75#endif 76 syscall_table[SYS_adjtime] = "adjtime"; 77 syscall_table[SYS_alarm] = "alarm"; 78 syscall_table[SYS_auditsys] = "auditsys"; 79 syscall_table[SYS_autofssys] = "autofssys"; 80 syscall_table[SYS_bind] = "bind"; 81 syscall_table[SYS_brand] = "brand"; 82 syscall_table[SYS_brk] = "brk"; 83 syscall_table[SYS_chdir] = "chdir"; 84#ifdef SYS_chmod 85 syscall_table[SYS_chmod] = "chmod"; 86#endif 87#ifdef SYS_chown 88 syscall_table[SYS_chown] = "chown"; 89#endif 90 syscall_table[SYS_chroot] = "chroot"; 91 syscall_table[SYS_cladm] = "cladm"; 92 syscall_table[SYS_clock_getres] = "clock_getres"; 93 syscall_table[SYS_clock_gettime] = "clock_gettime"; 94 syscall_table[SYS_clock_settime] = "clock_settime"; 95 syscall_table[SYS_close] = "close"; 96 syscall_table[SYS_connect] = "connect"; 97 syscall_table[SYS_context] = "context"; 98 syscall_table[SYS_corectl] = "corectl"; 99 syscall_table[SYS_cpc] = "cpc"; 100#ifdef SYS_creat 101 syscall_table[SYS_creat] = "creat"; 102#endif 103#ifdef SYS_creat64 104 syscall_table[SYS_creat64] = "creat64"; 105#endif 106 syscall_table[SYS_door] = "door"; 107#ifdef SYS_dup 108 syscall_table[SYS_dup] = "dup"; 109#endif 110#ifdef SYS_evsys 111 syscall_table[SYS_evsys] = "evsys"; 112#endif 113#ifdef SYS_evtrapret 114 syscall_table[SYS_evtrapret] = "evtrapret"; 115#endif 116 syscall_table[SYS_exacctsys] = "exacctsys"; 117#ifdef SYS_exec 118 syscall_table[SYS_exec] = "exec"; 119#endif 120 syscall_table[SYS_execve] = "execve"; 121 syscall_table[SYS_exit] = "exit"; 122#ifdef SYS_faccessat 123 syscall_table[SYS_faccessat] = "faccessat"; 124#endif 125 syscall_table[SYS_facl] = "facl"; 126 syscall_table[SYS_fchdir] = "fchdir"; 127#ifdef SYS_fchmod 128 syscall_table[SYS_fchmod] = "fchmod"; 129#endif 130#ifdef SYS_fchmodat 131 syscall_table[SYS_fchmodat] = "fchmodat"; 132#endif 133#ifdef SYS_fchown 134 syscall_table[SYS_fchown] = "fchown"; 135#endif 136#ifdef SYS_fchownat 137 syscall_table[SYS_fchownat] = "fchownat"; 138#endif 139 syscall_table[SYS_fchroot] = "fchroot"; 140 syscall_table[SYS_fcntl] = "fcntl"; 141 syscall_table[SYS_fdsync] = "fdsync"; 142#ifdef SYS_fork1 143 syscall_table[SYS_fork1] = "fork1"; 144#endif 145#ifdef SYS_forkall 146 syscall_table[SYS_forkall] = "forkall"; 147#endif 148#ifdef SYS_forksys 149 syscall_table[SYS_forksys] = "forksys"; 150#endif 151 syscall_table[SYS_fpathconf] = "fpathconf"; 152#ifdef SYS_frealpathat 153 syscall_table[SYS_frealpathat] = "frealpathat"; 154#endif 155#ifdef SYS_fsat 156 syscall_table[SYS_fsat] = "fsat"; 157#endif 158#ifdef SYS_fstat 159 syscall_table[SYS_fstat] = "fstat"; 160#endif 161#ifdef SYS_fstat64 162 syscall_table[SYS_fstat64] = "fstat64"; 163#endif 164#ifdef SYS_fstatat 165 syscall_table[SYS_fstatat] = "fstatat"; 166#endif 167#ifdef SYS_fstatat64 168 syscall_table[SYS_fstatat64] = "fstatat64"; 169#endif 170 syscall_table[SYS_fstatfs] = "fstatfs"; 171 syscall_table[SYS_fstatvfs] = "fstatvfs"; 172 syscall_table[SYS_fstatvfs64] = "fstatvfs64"; 173#ifdef SYS_fxstat 174 syscall_table[SYS_fxstat] = "fxstat"; 175#endif 176 syscall_table[SYS_getcwd] = "getcwd"; 177 syscall_table[SYS_getdents] = "getdents"; 178 syscall_table[SYS_getdents64] = "getdents64"; 179 syscall_table[SYS_getgid] = "getgid"; 180 syscall_table[SYS_getgroups] = "getgroups"; 181 syscall_table[SYS_getitimer] = "getitimer"; 182 syscall_table[SYS_getloadavg] = "getloadavg"; 183 syscall_table[SYS_getmsg] = "getmsg"; 184 syscall_table[SYS_getpagesizes] = "getpagesizes"; 185 syscall_table[SYS_getpeername] = "getpeername"; 186 syscall_table[SYS_getpid] = "getpid"; 187 syscall_table[SYS_getpmsg] = "getpmsg"; 188#ifdef SYS_getrandom 189 syscall_table[SYS_getrandom] = "getrandom"; 190#endif 191 syscall_table[SYS_getrlimit] = "getrlimit"; 192 syscall_table[SYS_getrlimit64] = "getrlimit64"; 193 syscall_table[SYS_getsockname] = "getsockname"; 194 syscall_table[SYS_getsockopt] = "getsockopt"; 195 syscall_table[SYS_gettimeofday] = "gettimeofday"; 196 syscall_table[SYS_getuid] = "getuid"; 197 syscall_table[SYS_gtty] = "gtty"; 198 syscall_table[SYS_hrtsys] = "hrtsys"; 199 syscall_table[SYS_inst_sync] = "inst_sync"; 200 syscall_table[SYS_install_utrap] = "install_utrap"; 201 syscall_table[SYS_ioctl] = "ioctl"; 202#ifdef SYS_issetugid 203 syscall_table[SYS_issetugid] = "issetugid"; 204#endif 205 syscall_table[SYS_kaio] = "kaio"; 206 syscall_table[SYS_kill] = "kill"; 207 syscall_table[SYS_labelsys] = "labelsys"; 208#ifdef SYS_lchown 209 syscall_table[SYS_lchown] = "lchown"; 210#endif 211 syscall_table[SYS_lgrpsys] = "lgrpsys"; 212#ifdef SYS_link 213 syscall_table[SYS_link] = "link"; 214#endif 215#ifdef SYS_linkat 216 syscall_table[SYS_linkat] = "linkat"; 217#endif 218 syscall_table[SYS_listen] = "listen"; 219 syscall_table[SYS_llseek] = "llseek"; 220 syscall_table[SYS_lseek] = "lseek"; 221#ifdef SYS_lstat 222 syscall_table[SYS_lstat] = "lstat"; 223#endif 224#ifdef SYS_lstat64 225 syscall_table[SYS_lstat64] = "lstat64"; 226#endif 227 syscall_table[SYS_lwp_cond_broadcast] = "lwp_cond_broadcast"; 228 syscall_table[SYS_lwp_cond_signal] = "lwp_cond_signal"; 229 syscall_table[SYS_lwp_cond_wait] = "lwp_cond_wait"; 230 syscall_table[SYS_lwp_continue] = "lwp_continue"; 231 syscall_table[SYS_lwp_create] = "lwp_create"; 232 syscall_table[SYS_lwp_detach] = "lwp_detach"; 233 syscall_table[SYS_lwp_exit] = "lwp_exit"; 234 syscall_table[SYS_lwp_info] = "lwp_info"; 235#ifdef SYS_lwp_kill 236 syscall_table[SYS_lwp_kill] = "lwp_kill"; 237#endif 238#ifdef SYS_lwp_mutex_lock 239 syscall_table[SYS_lwp_mutex_lock] = "lwp_mutex_lock"; 240#endif 241 syscall_table[SYS_lwp_mutex_register] = "lwp_mutex_register"; 242 syscall_table[SYS_lwp_mutex_timedlock] = "lwp_mutex_timedlock"; 243 syscall_table[SYS_lwp_mutex_trylock] = "lwp_mutex_trylock"; 244 syscall_table[SYS_lwp_mutex_unlock] = "lwp_mutex_unlock"; 245 syscall_table[SYS_lwp_mutex_wakeup] = "lwp_mutex_wakeup"; 246#ifdef SYS_lwp_name 247 syscall_table[SYS_lwp_name] = "lwp_name"; 248#endif 249 syscall_table[SYS_lwp_park] = "lwp_park"; 250 syscall_table[SYS_lwp_private] = "lwp_private"; 251 syscall_table[SYS_lwp_rwlock_sys] = "lwp_rwlock_sys"; 252 syscall_table[SYS_lwp_self] = "lwp_self"; 253 syscall_table[SYS_lwp_sema_post] = "lwp_sema_post"; 254 syscall_table[SYS_lwp_sema_timedwait] = "lwp_sema_timedwait"; 255 syscall_table[SYS_lwp_sema_trywait] = "lwp_sema_trywait"; 256#ifdef SYS_lwp_sema_wait 257 syscall_table[SYS_lwp_sema_wait] = "lwp_sema_wait"; 258#endif 259 syscall_table[SYS_lwp_sigmask] = "lwp_sigmask"; 260#ifdef SYS_lwp_sigqueue 261 syscall_table[SYS_lwp_sigqueue] = "lwp_sigqueue"; 262#endif 263 syscall_table[SYS_lwp_suspend] = "lwp_suspend"; 264 syscall_table[SYS_lwp_wait] = "lwp_wait"; 265#ifdef SYS_lxstat 266 syscall_table[SYS_lxstat] = "lxstat"; 267#endif 268 syscall_table[SYS_memcntl] = "memcntl"; 269#ifdef SYS_memsys 270 syscall_table[SYS_memsys] = "memsys"; 271#endif 272 syscall_table[SYS_mincore] = "mincore"; 273#ifdef SYS_mkdir 274 syscall_table[SYS_mkdir] = "mkdir"; 275#endif 276#ifdef SYS_mkdirat 277 syscall_table[SYS_mkdirat] = "mkdirat"; 278#endif 279#ifdef SYS_mknod 280 syscall_table[SYS_mknod] = "mknod"; 281#endif 282#ifdef SYS_mknodat 283 syscall_table[SYS_mknodat] = "mknodat"; 284#endif 285 syscall_table[SYS_mmap] = "mmap"; 286 syscall_table[SYS_mmap64] = "mmap64"; 287#ifdef SYS_mmapobj 288 syscall_table[SYS_mmapobj] = "mmapobj"; 289#endif 290 syscall_table[SYS_modctl] = "modctl"; 291 syscall_table[SYS_mount] = "mount"; 292 syscall_table[SYS_mprotect] = "mprotect"; 293 syscall_table[SYS_msgsys] = "msgsys"; 294 syscall_table[SYS_munmap] = "munmap"; 295 syscall_table[SYS_nanosleep] = "nanosleep"; 296 syscall_table[SYS_nfssys] = "nfssys"; 297 syscall_table[SYS_nice] = "nice"; 298 syscall_table[SYS_ntp_adjtime] = "ntp_adjtime"; 299 syscall_table[SYS_ntp_gettime] = "ntp_gettime"; 300#ifdef SYS_open 301 syscall_table[SYS_open] = "open"; 302#endif 303#ifdef SYS_open64 304 syscall_table[SYS_open64] = "open64"; 305#endif 306#ifdef SYS_openat 307 syscall_table[SYS_openat] = "openat"; 308#endif 309#ifdef SYS_openat64 310 syscall_table[SYS_openat64] = "openat64"; 311#endif 312 syscall_table[SYS_p_online] = "p_online"; 313 syscall_table[SYS_pathconf] = "pathconf"; 314 syscall_table[SYS_pause] = "pause"; 315 syscall_table[SYS_pcsample] = "pcsample"; 316 syscall_table[SYS_pgrpsys] = "pgrpsys"; 317 syscall_table[SYS_pipe] = "pipe"; 318#ifdef SYS_plock 319 syscall_table[SYS_plock] = "plock"; 320#endif 321#ifdef SYS_poll 322 syscall_table[SYS_poll] = "poll"; 323#endif 324 syscall_table[SYS_pollsys] = "pollsys"; 325 syscall_table[SYS_port] = "port"; 326 syscall_table[SYS_pread] = "pread"; 327 syscall_table[SYS_pread64] = "pread64"; 328 syscall_table[SYS_priocntlsys] = "priocntlsys"; 329 syscall_table[SYS_privsys] = "privsys"; 330#ifdef SYS_processor_bind 331 syscall_table[SYS_processor_bind] = "processor_bind"; 332#endif 333#ifdef SYS_processor_info 334 syscall_table[SYS_processor_info] = "processor_info"; 335#endif 336#ifdef SYS_processor_sys 337 syscall_table[SYS_processor_sys] = "processor_sys"; 338#endif 339 syscall_table[SYS_profil] = "profil"; 340 syscall_table[SYS_pset] = "pset"; 341 syscall_table[SYS_putmsg] = "putmsg"; 342 syscall_table[SYS_putpmsg] = "putpmsg"; 343 syscall_table[SYS_pwrite] = "pwrite"; 344 syscall_table[SYS_pwrite64] = "pwrite64"; 345 syscall_table[SYS_rctlsys] = "rctlsys"; 346 syscall_table[SYS_read] = "read"; 347#ifdef SYS_readlink 348 syscall_table[SYS_readlink] = "readlink"; 349#endif 350#ifdef SYS_readlinkat 351 syscall_table[SYS_readlinkat] = "readlinkat"; 352#endif 353 syscall_table[SYS_readv] = "readv"; 354 syscall_table[SYS_recv] = "recv"; 355 syscall_table[SYS_recvfrom] = "recvfrom"; 356#ifdef SYS_recvmmsg 357 syscall_table[SYS_recvmmsg] = "recvmmsg"; 358#endif 359 syscall_table[SYS_recvmsg] = "recvmsg"; 360#ifdef SYS_reflinkat 361 syscall_table[SYS_reflinkat] = "reflinkat"; 362#endif 363#ifdef SYS_rename 364 syscall_table[SYS_rename] = "rename"; 365#endif 366#ifdef SYS_renameat 367 syscall_table[SYS_renameat] = "renameat"; 368#endif 369 syscall_table[SYS_resolvepath] = "resolvepath"; 370#ifdef SYS_rmdir 371 syscall_table[SYS_rmdir] = "rmdir"; 372#endif 373 syscall_table[SYS_rpcsys] = "rpcsys"; 374 syscall_table[SYS_rusagesys] = "rusagesys"; 375 syscall_table[SYS_schedctl] = "schedctl"; 376#ifdef SYS_secsys 377 syscall_table[SYS_secsys] = "secsys"; 378#endif 379 syscall_table[SYS_semsys] = "semsys"; 380 syscall_table[SYS_send] = "send"; 381 syscall_table[SYS_sendfilev] = "sendfilev"; 382#ifdef SYS_sendmmsg 383 syscall_table[SYS_sendmmsg] = "sendmmsg"; 384#endif 385 syscall_table[SYS_sendmsg] = "sendmsg"; 386 syscall_table[SYS_sendto] = "sendto"; 387 syscall_table[SYS_setegid] = "setegid"; 388 syscall_table[SYS_seteuid] = "seteuid"; 389 syscall_table[SYS_setgid] = "setgid"; 390 syscall_table[SYS_setgroups] = "setgroups"; 391 syscall_table[SYS_setitimer] = "setitimer"; 392 syscall_table[SYS_setregid] = "setregid"; 393 syscall_table[SYS_setreuid] = "setreuid"; 394 syscall_table[SYS_setrlimit] = "setrlimit"; 395 syscall_table[SYS_setrlimit64] = "setrlimit64"; 396 syscall_table[SYS_setsockopt] = "setsockopt"; 397 syscall_table[SYS_setuid] = "setuid"; 398 syscall_table[SYS_sharefs] = "sharefs"; 399 syscall_table[SYS_shmsys] = "shmsys"; 400 syscall_table[SYS_shutdown] = "shutdown"; 401#ifdef SYS_sidsys 402 syscall_table[SYS_sidsys] = "sidsys"; 403#endif 404 syscall_table[SYS_sigaction] = "sigaction"; 405 syscall_table[SYS_sigaltstack] = "sigaltstack"; 406#ifdef SYS_signal 407 syscall_table[SYS_signal] = "signal"; 408#endif 409 syscall_table[SYS_signotify] = "signotify"; 410 syscall_table[SYS_sigpending] = "sigpending"; 411 syscall_table[SYS_sigprocmask] = "sigprocmask"; 412 syscall_table[SYS_sigqueue] = "sigqueue"; 413#ifdef SYS_sigresend 414 syscall_table[SYS_sigresend] = "sigresend"; 415#endif 416 syscall_table[SYS_sigsendsys] = "sigsendsys"; 417 syscall_table[SYS_sigsuspend] = "sigsuspend"; 418 syscall_table[SYS_sigtimedwait] = "sigtimedwait"; 419 syscall_table[SYS_so_socket] = "so_socket"; 420 syscall_table[SYS_so_socketpair] = "so_socketpair"; 421 syscall_table[SYS_sockconfig] = "sockconfig"; 422#ifdef SYS_sparc_fixalign 423 syscall_table[SYS_sparc_fixalign] = "sparc_fixalign"; 424#endif 425 syscall_table[SYS_sparc_utrap_install] = "sparc_utrap_install"; 426#ifdef SYS_spawn 427 syscall_table[SYS_spawn] = "spawn"; 428#endif 429#ifdef SYS_stat 430 syscall_table[SYS_stat] = "stat"; 431#endif 432#ifdef SYS_stat64 433 syscall_table[SYS_stat64] = "stat64"; 434#endif 435 syscall_table[SYS_statfs] = "statfs"; 436 syscall_table[SYS_statvfs] = "statvfs"; 437 syscall_table[SYS_statvfs64] = "statvfs64"; 438 syscall_table[SYS_stime] = "stime"; 439 syscall_table[SYS_stty] = "stty"; 440#ifdef SYS_symlink 441 syscall_table[SYS_symlink] = "symlink"; 442#endif 443#ifdef SYS_symlinkat 444 syscall_table[SYS_symlinkat] = "symlinkat"; 445#endif 446 syscall_table[SYS_sync] = "sync"; 447 syscall_table[SYS_syscall] = "syscall"; 448 syscall_table[SYS_sysconfig] = "sysconfig"; 449 syscall_table[SYS_sysfs] = "sysfs"; 450 syscall_table[SYS_sysi86] = "sysi86"; 451#ifdef SYS_syssun 452 syscall_table[SYS_syssun] = "syssun"; 453#endif 454#ifdef SYS_system_stats 455 syscall_table[SYS_system_stats] = "system_stats"; 456#endif 457 syscall_table[SYS_systeminfo] = "systeminfo"; 458 syscall_table[SYS_tasksys] = "tasksys"; 459 syscall_table[SYS_time] = "time"; 460 syscall_table[SYS_timer_create] = "timer_create"; 461 syscall_table[SYS_timer_delete] = "timer_delete"; 462 syscall_table[SYS_timer_getoverrun] = "timer_getoverrun"; 463 syscall_table[SYS_timer_gettime] = "timer_gettime"; 464 syscall_table[SYS_timer_settime] = "timer_settime"; 465 syscall_table[SYS_times] = "times"; 466 syscall_table[SYS_uadmin] = "uadmin"; 467 syscall_table[SYS_ucredsys] = "ucredsys"; 468 syscall_table[SYS_ulimit] = "ulimit"; 469 syscall_table[SYS_umask] = "umask"; 470#ifdef SYS_umount 471 syscall_table[SYS_umount] = "umount"; 472#endif 473 syscall_table[SYS_umount2] = "umount2"; 474 syscall_table[SYS_uname] = "uname"; 475#ifdef SYS_unlink 476 syscall_table[SYS_unlink] = "unlink"; 477#endif 478#ifdef SYS_unlinkat 479 syscall_table[SYS_unlinkat] = "unlinkat"; 480#endif 481#ifdef SYS_utime 482 syscall_table[SYS_utime] = "utime"; 483#endif 484#ifdef SYS_utimensat 485 syscall_table[SYS_utimensat] = "utimensat"; 486#endif 487#ifdef SYS_utimes 488 syscall_table[SYS_utimes] = "utimes"; 489#endif 490#ifdef SYS_utimesys 491 syscall_table[SYS_utimesys] = "utimesys"; 492#endif 493 syscall_table[SYS_utssys] = "utssys"; 494 syscall_table[SYS_uucopy] = "uucopy"; 495 syscall_table[SYS_uucopystr] = "uucopystr"; 496#ifdef SYS_uuidsys 497 syscall_table[SYS_uuidsys] = "uuidsys"; 498#endif 499#ifdef SYS_va_mask 500 syscall_table[SYS_va_mask] = "va_mask"; 501#endif 502 syscall_table[SYS_vfork] = "vfork"; 503 syscall_table[SYS_vhangup] = "vhangup"; 504#ifdef SYS_wait 505 syscall_table[SYS_wait] = "wait"; 506#endif 507#ifdef SYS_waitid 508 syscall_table[SYS_waitid] = "waitid"; 509#endif 510#ifdef SYS_waitsys 511 syscall_table[SYS_waitsys] = "waitsys"; 512#endif 513 syscall_table[SYS_write] = "write"; 514 syscall_table[SYS_writev] = "writev"; 515#ifdef SYS_xmknod 516 syscall_table[SYS_xmknod] = "xmknod"; 517#endif 518#ifdef SYS_xstat 519 syscall_table[SYS_xstat] = "xstat"; 520#endif 521 syscall_table[SYS_yield] = "yield"; 522 syscall_table[SYS_zone] = "zone"; 523} 524 525/* Prettyprint syscall NUM. */ 526 527void 528proc_prettyfprint_syscall (FILE *file, int num, int verbose) 529{ 530 if (syscall_table[num]) 531 fprintf (file, "SYS_%s ", syscall_table[num]); 532 else 533 fprintf (file, "<Unknown syscall %d> ", num); 534} 535 536void 537proc_prettyprint_syscall (int num, int verbose) 538{ 539 proc_prettyfprint_syscall (stdout, num, verbose); 540} 541 542/* Prettyprint all syscalls in SYSSET. */ 543 544void 545proc_prettyfprint_syscalls (FILE *file, sysset_t *sysset, int verbose) 546{ 547 int i; 548 549 for (i = 0; i < MAX_SYSCALLS; i++) 550 if (prismember (sysset, i)) 551 { 552 proc_prettyfprint_syscall (file, i, verbose); 553 } 554 fprintf (file, "\n"); 555} 556 557void 558proc_prettyprint_syscalls (sysset_t *sysset, int verbose) 559{ 560 proc_prettyfprint_syscalls (stdout, sysset, verbose); 561} 562 563/* Prettyprint signals. */ 564 565/* Signal translation table, ordered ANSI-standard signals first, 566 other signals second, with signals in each block ordered by their 567 numerical values on a typical POSIX platform. */ 568 569static struct trans signal_table[] = 570{ 571 { 0, "<no signal>", "no signal" }, 572 573 /* SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM 574 are ANSI-standard signals and are always available. */ 575 576 { SIGINT, "SIGINT", "Interrupt (rubout)" }, 577 { SIGILL, "SIGILL", "Illegal instruction" }, /* not reset when caught */ 578 { SIGABRT, "SIGABRT", "used by abort()" }, /* replaces SIGIOT */ 579 { SIGFPE, "SIGFPE", "Floating point exception" }, 580 { SIGSEGV, "SIGSEGV", "Segmentation violation" }, 581 { SIGTERM, "SIGTERM", "Software termination signal from kill" }, 582 583 /* All other signals need preprocessor conditionals. */ 584 585 { SIGHUP, "SIGHUP", "Hangup" }, 586 { SIGQUIT, "SIGQUIT", "Quit (ASCII FS)" }, 587 { SIGTRAP, "SIGTRAP", "Trace trap" }, /* not reset when caught */ 588 { SIGIOT, "SIGIOT", "IOT instruction" }, 589 { SIGEMT, "SIGEMT", "EMT instruction" }, 590 { SIGKILL, "SIGKILL", "Kill" }, /* Solaris: cannot be caught/ignored */ 591 { SIGBUS, "SIGBUS", "Bus error" }, 592 { SIGSYS, "SIGSYS", "Bad argument to system call" }, 593 { SIGPIPE, "SIGPIPE", "Write to pipe with no one to read it" }, 594 { SIGALRM, "SIGALRM", "Alarm clock" }, 595 { SIGUSR1, "SIGUSR1", "User defined signal 1" }, 596 { SIGUSR2, "SIGUSR2", "User defined signal 2" }, 597 { SIGCHLD, "SIGCHLD", "Child status changed" }, /* Posix version */ 598 { SIGCLD, "SIGCLD", "Child status changed" }, /* Solaris version */ 599 { SIGPWR, "SIGPWR", "Power-fail restart" }, 600 { SIGWINCH, "SIGWINCH", "Window size change" }, 601 { SIGURG, "SIGURG", "Urgent socket condition" }, 602 { SIGPOLL, "SIGPOLL", "Pollable event" }, 603 { SIGIO, "SIGIO", "Socket I/O possible" }, /* alias for SIGPOLL */ 604 { SIGSTOP, "SIGSTOP", "Stop, not from tty" }, /* cannot be caught or 605 ignored */ 606 { SIGTSTP, "SIGTSTP", "User stop from tty" }, 607 { SIGCONT, "SIGCONT", "Stopped process has been continued" }, 608 { SIGTTIN, "SIGTTIN", "Background tty read attempted" }, 609 { SIGTTOU, "SIGTTOU", "Background tty write attempted" }, 610 { SIGVTALRM, "SIGVTALRM", "Virtual timer expired" }, 611 { SIGPROF, "SIGPROF", "Profiling timer expired" }, 612 { SIGXCPU, "SIGXCPU", "Exceeded CPU limit" }, 613 { SIGXFSZ, "SIGXFSZ", "Exceeded file size limit" }, 614 { SIGWAITING, "SIGWAITING", "Process's LWPs are blocked" }, 615 { SIGLWP, "SIGLWP", "Used by thread library" }, 616 { SIGFREEZE, "SIGFREEZE", "Used by CPR" }, 617 { SIGTHAW, "SIGTHAW", "Used by CPR" }, 618 { SIGCANCEL, "SIGCANCEL", "Used by libthread" }, 619 { SIGLOST, "SIGLOST", "Resource lost" }, 620 621 /* FIXME: add real-time signals. */ 622}; 623 624/* Prettyprint signal number SIGNO. */ 625 626void 627proc_prettyfprint_signal (FILE *file, int signo, int verbose) 628{ 629 int i; 630 631 for (i = 0; i < sizeof (signal_table) / sizeof (signal_table[0]); i++) 632 if (signo == signal_table[i].value) 633 { 634 fprintf (file, "%s", signal_table[i].name); 635 if (verbose) 636 fprintf (file, ": %s\n", signal_table[i].desc); 637 else 638 fprintf (file, " "); 639 return; 640 } 641 fprintf (file, "Unknown signal %d%c", signo, verbose ? '\n' : ' '); 642} 643 644void 645proc_prettyprint_signal (int signo, int verbose) 646{ 647 proc_prettyfprint_signal (stdout, signo, verbose); 648} 649 650/* Prettyprint all signals in SIGSET. */ 651 652void 653proc_prettyfprint_signalset (FILE *file, sigset_t *sigset, int verbose) 654{ 655 int i; 656 657 /* Loop over all signal numbers from 0 to NSIG, using them as the 658 index to prismember. The signal table had better not contain 659 aliases, for if it does they will both be printed. */ 660 661 for (i = 0; i < NSIG; i++) 662 if (prismember (sigset, i)) 663 proc_prettyfprint_signal (file, i, verbose); 664 665 if (!verbose) 666 fprintf (file, "\n"); 667} 668 669void 670proc_prettyprint_signalset (sigset_t *sigset, int verbose) 671{ 672 proc_prettyfprint_signalset (stdout, sigset, verbose); 673} 674 675 676/* Prettyprint faults. */ 677 678/* Fault translation table. */ 679 680static struct trans fault_table[] = 681{ 682 { FLTILL, "FLTILL", "Illegal instruction" }, 683 { FLTPRIV, "FLTPRIV", "Privileged instruction" }, 684 { FLTBPT, "FLTBPT", "Breakpoint trap" }, 685 { FLTTRACE, "FLTTRACE", "Trace trap" }, 686 { FLTACCESS, "FLTACCESS", "Memory access fault" }, 687 { FLTBOUNDS, "FLTBOUNDS", "Memory bounds violation" }, 688 { FLTIOVF, "FLTIOVF", "Integer overflow" }, 689 { FLTIZDIV, "FLTIZDIV", "Integer zero divide" }, 690 { FLTFPE, "FLTFPE", "Floating-point exception" }, 691 { FLTSTACK, "FLTSTACK", "Unrecoverable stack fault" }, 692 { FLTPAGE, "FLTPAGE", "Recoverable page fault" }, 693 { FLTWATCH, "FLTWATCH", "User watchpoint" }, 694}; 695 696/* Work horse. Accepts an index into the fault table, prints it 697 pretty. */ 698 699static void 700prettyfprint_faulttable_entry (FILE *file, int i, int verbose) 701{ 702 fprintf (file, "%s", fault_table[i].name); 703 if (verbose) 704 fprintf (file, ": %s\n", fault_table[i].desc); 705 else 706 fprintf (file, " "); 707} 708 709/* Prettyprint hardware fault number FAULTNO. */ 710 711void 712proc_prettyfprint_fault (FILE *file, int faultno, int verbose) 713{ 714 int i; 715 716 for (i = 0; i < ARRAY_SIZE (fault_table); i++) 717 if (faultno == fault_table[i].value) 718 { 719 prettyfprint_faulttable_entry (file, i, verbose); 720 return; 721 } 722 723 fprintf (file, "Unknown hardware fault %d%c", 724 faultno, verbose ? '\n' : ' '); 725} 726 727void 728proc_prettyprint_fault (int faultno, int verbose) 729{ 730 proc_prettyfprint_fault (stdout, faultno, verbose); 731} 732 733/* Prettyprint all faults in FLTSET. */ 734 735void 736proc_prettyfprint_faultset (FILE *file, fltset_t *fltset, int verbose) 737{ 738 int i; 739 740 /* Loop through the fault table, using the value field as the index 741 to prismember. The fault table had better not contain aliases, 742 for if it does they will both be printed. */ 743 744 for (i = 0; i < ARRAY_SIZE (fault_table); i++) 745 if (prismember (fltset, fault_table[i].value)) 746 prettyfprint_faulttable_entry (file, i, verbose); 747 748 if (!verbose) 749 fprintf (file, "\n"); 750} 751 752void 753proc_prettyprint_faultset (fltset_t *fltset, int verbose) 754{ 755 proc_prettyfprint_faultset (stdout, fltset, verbose); 756} 757 758/* TODO: actions, holds... */ 759 760void 761proc_prettyprint_actionset (struct sigaction *actions, int verbose) 762{ 763} 764 765void 766_initialize_proc_events (void) 767{ 768 init_syscall_table (); 769} 770