proc-events.c 23 KB

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