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