1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include <string.h> |
6 | #include <stdio.h> |
7 | #include <stdlib.h> |
8 | #include <signal.h> |
9 | #include <errno.h> |
10 | #if defined(__aarch64__) |
11 | #include "./aarch64/syscall.h" |
12 | #else |
13 | #include <sys/syscall.h> |
14 | #endif |
15 | |
16 | #include <sys/stat.h> |
17 | #include <sys/ptrace.h> |
18 | #include <sys/types.h> |
19 | #include <linux/unistd.h> |
20 | #include <linux/capability.h> |
21 | #include <linux/magic.h> |
22 | |
23 | #include "event_man.h" |
24 | #include "shared_mem_dump.h" |
25 | #include "syscall_name.h" |
26 | |
27 | #define CASE(_id) \ |
28 | case _id: \ |
29 | return #_id; |
30 | |
31 | const char* signal_name(int sig) |
32 | { |
33 | /* strsignal() would be nice to use here, but it provides TMI. */ |
34 | if (32 <= sig && sig <= 64) { |
35 | static char buf[100]; |
36 | snprintf(buf, sizeof(buf) - 1, "SIGRT%d" , sig); |
37 | return buf; |
38 | } |
39 | |
40 | switch (sig) { |
41 | CASE(SIGHUP); |
42 | CASE(SIGINT); |
43 | CASE(SIGQUIT); |
44 | CASE(SIGILL); |
45 | CASE(SIGTRAP); |
46 | CASE(SIGABRT); /*CASE(SIGIOT);*/ |
47 | CASE(SIGBUS); |
48 | CASE(SIGFPE); |
49 | CASE(SIGKILL); |
50 | CASE(SIGUSR1); |
51 | CASE(SIGSEGV); |
52 | CASE(SIGUSR2); |
53 | CASE(SIGPIPE); |
54 | CASE(SIGALRM); |
55 | CASE(SIGTERM); |
56 | #if defined(__i386__) || defined(__x86_64__) |
57 | CASE(SIGSTKFLT); /*CASE(SIGCLD);*/ |
58 | #endif |
59 | CASE(SIGCHLD); |
60 | CASE(SIGCONT); |
61 | CASE(SIGSTOP); |
62 | CASE(SIGTSTP); |
63 | CASE(SIGTTIN); |
64 | CASE(SIGTTOU); |
65 | CASE(SIGURG); |
66 | CASE(SIGXCPU); |
67 | CASE(SIGXFSZ); |
68 | CASE(SIGVTALRM); |
69 | CASE(SIGPROF); |
70 | CASE(SIGWINCH); /*CASE(SIGPOLL);*/ |
71 | CASE(SIGIO); |
72 | CASE(SIGPWR); |
73 | CASE(SIGSYS); |
74 | /* Special-case this so we don't need to sprintf in this common case. |
75 | * This case is common because we often pass signal_name(sig) to assertions |
76 | * when sig is 0. |
77 | */ |
78 | case 0: |
79 | return "signal(0)" ; |
80 | default: { |
81 | static char buf[100]; |
82 | sprintf(buf, "signal(%d)" , sig); |
83 | return (buf); |
84 | } |
85 | } |
86 | } |
87 | |
88 | const char* errno_name(int err) { |
89 | switch (err) { |
90 | case 0: |
91 | return "SUCCESS" ; |
92 | CASE(EPERM); |
93 | CASE(ENOENT); |
94 | CASE(ESRCH); |
95 | CASE(EINTR); |
96 | CASE(EIO); |
97 | CASE(ENXIO); |
98 | CASE(E2BIG); |
99 | CASE(ENOEXEC); |
100 | CASE(EBADF); |
101 | CASE(ECHILD); |
102 | CASE(EAGAIN); |
103 | CASE(ENOMEM); |
104 | CASE(EACCES); |
105 | CASE(EFAULT); |
106 | CASE(ENOTBLK); |
107 | CASE(EBUSY); |
108 | CASE(EEXIST); |
109 | CASE(EXDEV); |
110 | CASE(ENODEV); |
111 | CASE(ENOTDIR); |
112 | CASE(EISDIR); |
113 | CASE(EINVAL); |
114 | CASE(ENFILE); |
115 | CASE(EMFILE); |
116 | CASE(ENOTTY); |
117 | CASE(ETXTBSY); |
118 | CASE(EFBIG); |
119 | CASE(ENOSPC); |
120 | CASE(ESPIPE); |
121 | CASE(EROFS); |
122 | CASE(EMLINK); |
123 | CASE(EPIPE); |
124 | CASE(EDOM); |
125 | CASE(ERANGE); |
126 | CASE(EDEADLK); |
127 | CASE(ENAMETOOLONG); |
128 | CASE(ENOLCK); |
129 | CASE(ENOSYS); |
130 | CASE(ENOTEMPTY); |
131 | CASE(ELOOP); |
132 | CASE(ENOMSG); |
133 | CASE(EIDRM); |
134 | CASE(ECHRNG); |
135 | CASE(EL2NSYNC); |
136 | CASE(EL3HLT); |
137 | CASE(EL3RST); |
138 | CASE(ELNRNG); |
139 | CASE(EUNATCH); |
140 | CASE(ENOCSI); |
141 | CASE(EL2HLT); |
142 | CASE(EBADE); |
143 | CASE(EBADR); |
144 | CASE(EXFULL); |
145 | CASE(ENOANO); |
146 | CASE(EBADRQC); |
147 | CASE(EBADSLT); |
148 | CASE(EBFONT); |
149 | CASE(ENOSTR); |
150 | CASE(ENODATA); |
151 | CASE(ETIME); |
152 | CASE(ENOSR); |
153 | CASE(ENONET); |
154 | CASE(ENOPKG); |
155 | CASE(EREMOTE); |
156 | CASE(ENOLINK); |
157 | CASE(EADV); |
158 | CASE(ESRMNT); |
159 | CASE(ECOMM); |
160 | CASE(EPROTO); |
161 | CASE(EMULTIHOP); |
162 | CASE(EDOTDOT); |
163 | CASE(EBADMSG); |
164 | CASE(EOVERFLOW); |
165 | CASE(ENOTUNIQ); |
166 | CASE(EBADFD); |
167 | CASE(EREMCHG); |
168 | CASE(ELIBACC); |
169 | CASE(ELIBBAD); |
170 | CASE(ELIBSCN); |
171 | CASE(ELIBMAX); |
172 | CASE(ELIBEXEC); |
173 | CASE(EILSEQ); |
174 | CASE(ERESTART); |
175 | CASE(ESTRPIPE); |
176 | CASE(EUSERS); |
177 | CASE(ENOTSOCK); |
178 | CASE(EDESTADDRREQ); |
179 | CASE(EMSGSIZE); |
180 | CASE(EPROTOTYPE); |
181 | CASE(ENOPROTOOPT); |
182 | CASE(EPROTONOSUPPORT); |
183 | CASE(ESOCKTNOSUPPORT); |
184 | CASE(EOPNOTSUPP); |
185 | CASE(EPFNOSUPPORT); |
186 | CASE(EAFNOSUPPORT); |
187 | CASE(EADDRINUSE); |
188 | CASE(EADDRNOTAVAIL); |
189 | CASE(ENETDOWN); |
190 | CASE(ENETUNREACH); |
191 | CASE(ENETRESET); |
192 | CASE(ECONNABORTED); |
193 | CASE(ECONNRESET); |
194 | CASE(ENOBUFS); |
195 | CASE(EISCONN); |
196 | CASE(ENOTCONN); |
197 | CASE(ESHUTDOWN); |
198 | CASE(ETOOMANYREFS); |
199 | CASE(ETIMEDOUT); |
200 | CASE(ECONNREFUSED); |
201 | CASE(EHOSTDOWN); |
202 | CASE(EHOSTUNREACH); |
203 | CASE(EALREADY); |
204 | CASE(EINPROGRESS); |
205 | CASE(ESTALE); |
206 | CASE(EUCLEAN); |
207 | CASE(ENOTNAM); |
208 | CASE(ENAVAIL); |
209 | CASE(EISNAM); |
210 | CASE(EREMOTEIO); |
211 | CASE(EDQUOT); |
212 | CASE(ENOMEDIUM); |
213 | CASE(EMEDIUMTYPE); |
214 | CASE(ECANCELED); |
215 | CASE(ENOKEY); |
216 | CASE(EKEYEXPIRED); |
217 | CASE(EKEYREVOKED); |
218 | CASE(EKEYREJECTED); |
219 | CASE(EOWNERDEAD); |
220 | CASE(ENOTRECOVERABLE); |
221 | CASE(ERFKILL); |
222 | CASE(EHWPOISON); |
223 | default: { |
224 | static char buf[100]; |
225 | sprintf(buf, "errno(%d)" , err); |
226 | return (buf); |
227 | } |
228 | } |
229 | } |
230 | |
231 | const char* sicode_name(int code, int sig) { |
232 | switch (code) { |
233 | CASE(SI_USER); |
234 | CASE(SI_KERNEL); |
235 | CASE(SI_QUEUE); |
236 | CASE(SI_TIMER); |
237 | CASE(SI_MESGQ); |
238 | CASE(SI_ASYNCIO); |
239 | CASE(SI_SIGIO); |
240 | CASE(SI_TKILL); |
241 | CASE(SI_ASYNCNL); |
242 | } |
243 | |
244 | switch (sig) { |
245 | case SIGSEGV: |
246 | switch (code) { |
247 | CASE(SEGV_MAPERR); |
248 | CASE(SEGV_ACCERR); |
249 | } |
250 | break; |
251 | case SIGTRAP: |
252 | switch (code) { |
253 | CASE(TRAP_BRKPT); |
254 | CASE(TRAP_TRACE); |
255 | } |
256 | break; |
257 | case SIGILL: |
258 | switch (code) { |
259 | CASE(ILL_ILLOPC); |
260 | CASE(ILL_ILLOPN); |
261 | CASE(ILL_ILLADR); |
262 | CASE(ILL_ILLTRP); |
263 | CASE(ILL_PRVOPC); |
264 | CASE(ILL_PRVREG); |
265 | CASE(ILL_COPROC); |
266 | CASE(ILL_BADSTK); |
267 | } |
268 | break; |
269 | case SIGFPE: |
270 | switch (code) { |
271 | CASE(FPE_INTDIV); |
272 | CASE(FPE_INTOVF); |
273 | CASE(FPE_FLTDIV); |
274 | CASE(FPE_FLTOVF); |
275 | CASE(FPE_FLTUND); |
276 | CASE(FPE_FLTRES); |
277 | CASE(FPE_FLTINV); |
278 | CASE(FPE_FLTSUB); |
279 | } |
280 | break; |
281 | case SIGBUS: |
282 | switch (code) { |
283 | CASE(BUS_ADRALN); |
284 | CASE(BUS_ADRERR); |
285 | CASE(BUS_OBJERR); |
286 | CASE(BUS_MCEERR_AR); |
287 | CASE(BUS_MCEERR_AO); |
288 | } |
289 | break; |
290 | case SIGCHLD: |
291 | switch (code) { |
292 | CASE(CLD_EXITED); |
293 | CASE(CLD_KILLED); |
294 | CASE(CLD_DUMPED); |
295 | CASE(CLD_TRAPPED); |
296 | CASE(CLD_STOPPED); |
297 | CASE(CLD_CONTINUED); |
298 | } |
299 | break; |
300 | case SIGPOLL: |
301 | switch (code) { |
302 | CASE(POLL_IN); |
303 | CASE(POLL_OUT); |
304 | CASE(POLL_MSG); |
305 | CASE(POLL_ERR); |
306 | CASE(POLL_PRI); |
307 | CASE(POLL_HUP); |
308 | } |
309 | break; |
310 | } |
311 | |
312 | static char buf[100]; |
313 | sprintf(buf, "sicode(%d)" , code); |
314 | return (buf); |
315 | } |
316 | |
317 | // see /usr/include/x86_64-linux-gnu/asm/unistd_64.h |
318 | const char* syscall_name(long call) |
319 | { |
320 | switch(call) { |
321 | CASE(SYS_read); |
322 | CASE(SYS_write); |
323 | CASE(SYS_open); |
324 | CASE(SYS_close); |
325 | CASE(SYS_stat); |
326 | CASE(SYS_fstat); |
327 | CASE(SYS_lstat); |
328 | CASE(SYS_poll); |
329 | CASE(SYS_lseek); |
330 | CASE(SYS_mmap); |
331 | CASE(SYS_mprotect); |
332 | CASE(SYS_munmap); |
333 | CASE(SYS_brk); |
334 | CASE(SYS_rt_sigaction); |
335 | CASE(SYS_rt_sigprocmask); |
336 | CASE(SYS_rt_sigreturn); |
337 | CASE(SYS_ioctl); |
338 | CASE(SYS_pread64); |
339 | CASE(SYS_pwrite64); |
340 | CASE(SYS_readv); |
341 | CASE(SYS_writev); |
342 | CASE(SYS_access); |
343 | CASE(SYS_pipe); |
344 | CASE(SYS_sched_yield); |
345 | CASE(SYS_mremap); |
346 | CASE(SYS_msync); |
347 | CASE(SYS_mincore); |
348 | CASE(SYS_madvise); |
349 | CASE(SYS_shmget); |
350 | CASE(SYS_shmctl); |
351 | CASE(SYS_dup); |
352 | CASE(SYS_dup2); |
353 | CASE(SYS_nanosleep); |
354 | CASE(SYS_getitimer); |
355 | CASE(SYS_setitimer); |
356 | CASE(SYS_sendfile); |
357 | CASE(SYS_socket); |
358 | CASE(SYS_connect); |
359 | CASE(SYS_accept); |
360 | CASE(SYS_sendto); |
361 | CASE(SYS_recvfrom); |
362 | CASE(SYS_sendmsg); |
363 | CASE(SYS_recvmsg); |
364 | CASE(SYS_shutdown); |
365 | CASE(SYS_bind); |
366 | CASE(SYS_listen); |
367 | CASE(SYS_getsockname); |
368 | CASE(SYS_getpeername); |
369 | CASE(SYS_socketpair); |
370 | CASE(SYS_setsockopt); |
371 | CASE(SYS_getsockopt); |
372 | CASE(SYS_clone); |
373 | CASE(SYS_fork); |
374 | CASE(SYS_execve); |
375 | CASE(SYS_exit); |
376 | CASE(SYS_wait4); |
377 | CASE(SYS_kill); |
378 | CASE(SYS_uname); |
379 | CASE(SYS_semget); |
380 | CASE(SYS_semop); |
381 | CASE(SYS_semctl); |
382 | CASE(SYS_shmdt); |
383 | CASE(SYS_msgget); |
384 | CASE(SYS_msgsnd); |
385 | CASE(SYS_msgrcv); |
386 | CASE(SYS_msgctl); |
387 | CASE(SYS_fcntl); |
388 | CASE(SYS_flock); |
389 | CASE(SYS_fsync); |
390 | CASE(SYS_fdatasync); |
391 | CASE(SYS_truncate); |
392 | CASE(SYS_ftruncate); |
393 | CASE(SYS_getdents); |
394 | CASE(SYS_getcwd); |
395 | CASE(SYS_chdir); |
396 | CASE(SYS_fchdir); |
397 | CASE(SYS_rename); |
398 | CASE(SYS_mkdir); |
399 | CASE(SYS_rmdir); |
400 | CASE(SYS_link); |
401 | CASE(SYS_unlink); |
402 | CASE(SYS_symlink); |
403 | CASE(SYS_readlink); |
404 | CASE(SYS_chmod); |
405 | CASE(SYS_fchmod); |
406 | CASE(SYS_chown); |
407 | CASE(SYS_fchown); |
408 | CASE(SYS_lchown); |
409 | CASE(SYS_umask); |
410 | CASE(SYS_gettimeofday); |
411 | CASE(SYS_getrlimit); |
412 | CASE(SYS_getrusage); |
413 | CASE(SYS_sysinfo); |
414 | CASE(SYS_times); |
415 | CASE(SYS_ptrace); |
416 | CASE(SYS_syslog); |
417 | CASE(SYS_setuid); |
418 | CASE(SYS_setgid); |
419 | CASE(SYS_setpgid); |
420 | CASE(SYS_getpgrp); |
421 | CASE(SYS_setsid); |
422 | CASE(SYS_setreuid); |
423 | CASE(SYS_setregid); |
424 | CASE(SYS_getgroups); |
425 | CASE(SYS_setgroups); |
426 | CASE(SYS_setresuid); |
427 | CASE(SYS_getresuid); |
428 | CASE(SYS_setresgid); |
429 | CASE(SYS_getresgid); |
430 | CASE(SYS_getpgid); |
431 | CASE(SYS_setfsuid); |
432 | CASE(SYS_setfsgid); |
433 | CASE(SYS_getsid); |
434 | CASE(SYS_capget); |
435 | CASE(SYS_capset); |
436 | CASE(SYS_rt_sigpending); |
437 | CASE(SYS_rt_sigtimedwait); |
438 | CASE(SYS_rt_sigqueueinfo); |
439 | CASE(SYS_rt_sigsuspend); |
440 | CASE(SYS_sigaltstack); |
441 | CASE(SYS_mknod); |
442 | CASE(SYS_personality); |
443 | CASE(SYS_ustat); |
444 | CASE(SYS_statfs); |
445 | CASE(SYS_fstatfs); |
446 | CASE(SYS_getpriority); |
447 | CASE(SYS_setpriority); |
448 | CASE(SYS_sched_setparam); |
449 | CASE(SYS_sched_getparam); |
450 | CASE(SYS_sched_setscheduler); |
451 | CASE(SYS_sched_getscheduler); |
452 | CASE(SYS_sched_get_priority_max); |
453 | CASE(SYS_sched_get_priority_min); |
454 | CASE(SYS_sched_rr_get_interval); |
455 | CASE(SYS_mlock); |
456 | CASE(SYS_munlock); |
457 | CASE(SYS_mlockall); |
458 | CASE(SYS_munlockall); |
459 | CASE(SYS_vhangup); |
460 | CASE(SYS_pivot_root); |
461 | CASE(SYS__sysctl); |
462 | CASE(SYS_prctl); |
463 | CASE(SYS_adjtimex); |
464 | CASE(SYS_setrlimit); |
465 | CASE(SYS_chroot); |
466 | CASE(SYS_sync); |
467 | CASE(SYS_acct); |
468 | CASE(SYS_settimeofday); |
469 | CASE(SYS_mount); |
470 | CASE(SYS_swapon); |
471 | CASE(SYS_swapoff); |
472 | CASE(SYS_reboot); |
473 | CASE(SYS_sethostname); |
474 | CASE(SYS_setdomainname); |
475 | CASE(SYS_init_module); |
476 | CASE(SYS_delete_module); |
477 | CASE(SYS_quotactl); |
478 | CASE(SYS_nfsservctl); |
479 | CASE(SYS_gettid); |
480 | CASE(SYS_readahead); |
481 | CASE(SYS_setxattr); |
482 | CASE(SYS_lsetxattr); |
483 | CASE(SYS_fsetxattr); |
484 | CASE(SYS_getxattr); |
485 | CASE(SYS_lgetxattr); |
486 | CASE(SYS_fgetxattr); |
487 | CASE(SYS_listxattr); |
488 | CASE(SYS_llistxattr); |
489 | CASE(SYS_flistxattr); |
490 | CASE(SYS_removexattr); |
491 | CASE(SYS_lremovexattr); |
492 | CASE(SYS_fremovexattr); |
493 | CASE(SYS_tkill); |
494 | CASE(SYS_futex); |
495 | CASE(SYS_sched_setaffinity); |
496 | CASE(SYS_sched_getaffinity); |
497 | CASE(SYS_io_setup); |
498 | CASE(SYS_io_destroy); |
499 | CASE(SYS_io_getevents); |
500 | CASE(SYS_io_submit); |
501 | CASE(SYS_io_cancel); |
502 | CASE(SYS_lookup_dcookie); |
503 | CASE(SYS_epoll_create); |
504 | CASE(SYS_remap_file_pages); |
505 | CASE(SYS_getdents64); |
506 | CASE(SYS_set_tid_address); |
507 | CASE(SYS_restart_syscall); |
508 | CASE(SYS_semtimedop); |
509 | CASE(SYS_fadvise64); |
510 | CASE(SYS_timer_create); |
511 | CASE(SYS_timer_settime); |
512 | CASE(SYS_timer_gettime); |
513 | CASE(SYS_timer_getoverrun); |
514 | CASE(SYS_timer_delete); |
515 | CASE(SYS_clock_settime); |
516 | CASE(SYS_clock_gettime); |
517 | CASE(SYS_clock_getres); |
518 | CASE(SYS_clock_nanosleep); |
519 | CASE(SYS_exit_group); |
520 | CASE(SYS_epoll_wait); |
521 | CASE(SYS_epoll_ctl); |
522 | CASE(SYS_tgkill); |
523 | CASE(SYS_mbind); |
524 | CASE(SYS_set_mempolicy); |
525 | CASE(SYS_get_mempolicy); |
526 | CASE(SYS_mq_open); |
527 | CASE(SYS_mq_unlink); |
528 | CASE(SYS_mq_timedsend); |
529 | CASE(SYS_mq_timedreceive); |
530 | CASE(SYS_mq_notify); |
531 | CASE(SYS_mq_getsetattr); |
532 | CASE(SYS_kexec_load); |
533 | CASE(SYS_waitid); |
534 | CASE(SYS_add_key); |
535 | CASE(SYS_request_key); |
536 | CASE(SYS_keyctl); |
537 | CASE(SYS_ioprio_set); |
538 | CASE(SYS_ioprio_get); |
539 | CASE(SYS_inotify_init); |
540 | CASE(SYS_inotify_add_watch); |
541 | CASE(SYS_inotify_rm_watch); |
542 | CASE(SYS_migrate_pages); |
543 | CASE(SYS_openat); |
544 | CASE(SYS_mkdirat); |
545 | CASE(SYS_mknodat); |
546 | CASE(SYS_fchownat); |
547 | CASE(SYS_futimesat); |
548 | CASE(SYS_unlinkat); |
549 | CASE(SYS_renameat); |
550 | CASE(SYS_linkat); |
551 | CASE(SYS_symlinkat); |
552 | CASE(SYS_readlinkat); |
553 | CASE(SYS_fchmodat); |
554 | CASE(SYS_faccessat); |
555 | CASE(SYS_pselect6); |
556 | CASE(SYS_ppoll); |
557 | CASE(SYS_unshare); |
558 | CASE(SYS_set_robust_list); |
559 | CASE(SYS_get_robust_list); |
560 | CASE(SYS_splice); |
561 | CASE(SYS_tee); |
562 | CASE(SYS_sync_file_range); |
563 | CASE(SYS_vmsplice); |
564 | CASE(SYS_move_pages); |
565 | CASE(SYS_epoll_pwait); |
566 | CASE(SYS_signalfd); |
567 | CASE(SYS_timerfd_create); |
568 | CASE(SYS_eventfd); |
569 | CASE(SYS_fallocate); |
570 | CASE(SYS_timerfd_settime); |
571 | CASE(SYS_timerfd_gettime); |
572 | CASE(SYS_accept4); |
573 | CASE(SYS_signalfd4); |
574 | CASE(SYS_eventfd2); |
575 | CASE(SYS_epoll_create1); |
576 | CASE(SYS_dup3); |
577 | CASE(SYS_pipe2); |
578 | CASE(SYS_inotify_init1); |
579 | CASE(SYS_preadv); |
580 | CASE(SYS_pwritev); |
581 | CASE(SYS_rt_tgsigqueueinfo); |
582 | CASE(SYS_perf_event_open); |
583 | CASE(SYS_recvmmsg); |
584 | CASE(SYS_fanotify_init); |
585 | CASE(SYS_fanotify_mark); |
586 | CASE(SYS_prlimit64); |
587 | CASE(SYS_name_to_handle_at); |
588 | CASE(SYS_open_by_handle_at); |
589 | CASE(SYS_clock_adjtime); |
590 | CASE(SYS_syncfs); |
591 | CASE(SYS_sendmmsg); |
592 | CASE(SYS_setns); |
593 | CASE(SYS_getcpu); |
594 | CASE(SYS_process_vm_readv); |
595 | CASE(SYS_process_vm_writev); |
596 | CASE(SYS_kcmp); |
597 | CASE(SYS_finit_module); |
598 | |
599 | #ifndef KYLIN_MIPS64 |
600 | CASE(SYS_sched_setattr); |
601 | CASE(SYS_sched_getattr); |
602 | CASE(SYS_renameat2); |
603 | CASE(SYS_getrandom); |
604 | CASE(SYS_memfd_create); |
605 | CASE(SYS_execveat); |
606 | #endif |
607 | |
608 | CASE(SYS_init_buffers); |
609 | CASE(SYS_flush_buffers); |
610 | CASE(SYS_share_name); |
611 | CASE(SYS_enable_dump); |
612 | CASE(SYS_update_maps); |
613 | CASE(SYS_dump_x11); |
614 | CASE(SYS_dump_dbus); |
615 | |
616 | #if !defined(__aarch64__) |
617 | CASE(SYS_sysfs); |
618 | CASE(SYS_get_kernel_syms); |
619 | CASE(SYS_query_module); |
620 | CASE(SYS_afs_syscall); |
621 | CASE(SYS_vserver); |
622 | #endif |
623 | |
624 | #if defined(__aarch64__) |
625 | CASE(SYS_fstatat); |
626 | #elif defined(__x86_64__) || defined(__mips64) |
627 | CASE(SYS_shmat); |
628 | CASE(SYS_pause); |
629 | CASE(SYS_alarm); |
630 | CASE(SYS_getpid); |
631 | CASE(SYS_creat); |
632 | CASE(SYS_getuid); |
633 | CASE(SYS_getgid); |
634 | CASE(SYS_geteuid); |
635 | CASE(SYS_getegid); |
636 | CASE(SYS_getppid); |
637 | CASE(SYS_utime); |
638 | CASE(SYS_umount2); |
639 | CASE(SYS_create_module); |
640 | CASE(SYS_getpmsg); |
641 | CASE(SYS_putpmsg); |
642 | CASE(SYS_set_thread_area); |
643 | CASE(SYS_utimes); |
644 | CASE(SYS_newfstatat); |
645 | CASE(SYS_utimensat); |
646 | |
647 | #ifndef KYLIN_MIPS64 |
648 | CASE(SYS_seccomp); |
649 | CASE(SYS_bpf); |
650 | CASE(SYS_userfaultfd); |
651 | CASE(SYS_membarrier); |
652 | CASE(SYS_mlock2); |
653 | #endif |
654 | |
655 | #elif defined(__sw_64) |
656 | CASE(SYS_bdflush); |
657 | CASE(SYS_create_module); |
658 | CASE(SYS_dipc); |
659 | CASE(SYS_exec_with_loader); |
660 | CASE(SYS_fstat64); |
661 | CASE(SYS_fstatat64); |
662 | CASE(SYS_getdtablesize); |
663 | CASE(SYS_gethostname); |
664 | CASE(SYS_getpagesize); |
665 | CASE(SYS_getxgid); |
666 | CASE(SYS_getxpid); |
667 | CASE(SYS_getxuid); |
668 | CASE(SYS_lstat64); |
669 | CASE(SYS_old_adjtimex); |
670 | CASE(SYS_oldumount); |
671 | CASE(SYS_osf_adjtime); |
672 | CASE(SYS_osf_afs_syscall); |
673 | CASE(SYS_osf_alt_plock); |
674 | CASE(SYS_osf_alt_setsid); |
675 | CASE(SYS_osf_alt_sigpending); |
676 | CASE(SYS_osf_asynch_daemon); |
677 | CASE(SYS_osf_audcntl); |
678 | CASE(SYS_osf_audgen); |
679 | CASE(SYS_osf_chflags); |
680 | CASE(SYS_osf_execve); |
681 | CASE(SYS_osf_exportfs); |
682 | CASE(SYS_osf_fchflags); |
683 | CASE(SYS_osf_fdatasync); |
684 | CASE(SYS_osf_fpathconf); |
685 | CASE(SYS_osf_fstat); |
686 | CASE(SYS_osf_fstatfs); |
687 | CASE(SYS_osf_fstatfs64); |
688 | CASE(SYS_osf_fuser); |
689 | CASE(SYS_osf_getaddressconf); |
690 | CASE(SYS_osf_getdirentries); |
691 | CASE(SYS_osf_getdomainname); |
692 | CASE(SYS_osf_getfh); |
693 | CASE(SYS_osf_getfsstat); |
694 | CASE(SYS_osf_gethostid); |
695 | CASE(SYS_osf_getitimer); |
696 | CASE(SYS_osf_getlogin); |
697 | CASE(SYS_osf_getmnt); |
698 | CASE(SYS_osf_getrusage); |
699 | CASE(SYS_osf_getsysinfo); |
700 | CASE(SYS_osf_gettimeofday); |
701 | CASE(SYS_osf_kloadcall); |
702 | CASE(SYS_osf_kmodcall); |
703 | CASE(SYS_osf_lstat); |
704 | CASE(SYS_osf_memcntl); |
705 | CASE(SYS_osf_mincore); |
706 | CASE(SYS_osf_mount); |
707 | CASE(SYS_osf_mremap); |
708 | CASE(SYS_osf_msfs_syscall); |
709 | CASE(SYS_osf_msleep); |
710 | CASE(SYS_osf_mvalid); |
711 | CASE(SYS_osf_mwakeup); |
712 | CASE(SYS_osf_naccept); |
713 | CASE(SYS_osf_nfssvc); |
714 | CASE(SYS_osf_ngetpeername); |
715 | CASE(SYS_osf_ngetsockname); |
716 | CASE(SYS_osf_nrecvfrom); |
717 | CASE(SYS_osf_nrecvmsg); |
718 | CASE(SYS_osf_nsendmsg); |
719 | CASE(SYS_osf_ntp_adjtime); |
720 | CASE(SYS_osf_ntp_gettime); |
721 | CASE(SYS_osf_old_creat); |
722 | CASE(SYS_osf_old_fstat); |
723 | CASE(SYS_osf_old_getpgrp); |
724 | CASE(SYS_osf_old_killpg); |
725 | CASE(SYS_osf_old_lstat); |
726 | CASE(SYS_osf_old_open); |
727 | CASE(SYS_osf_old_sigaction); |
728 | CASE(SYS_osf_old_sigblock); |
729 | CASE(SYS_osf_old_sigreturn); |
730 | CASE(SYS_osf_old_sigsetmask); |
731 | CASE(SYS_osf_old_sigvec); |
732 | CASE(SYS_osf_old_stat); |
733 | CASE(SYS_osf_old_vadvise); |
734 | CASE(SYS_osf_old_vtrace); |
735 | CASE(SYS_osf_old_wait); |
736 | CASE(SYS_osf_oldquota); |
737 | CASE(SYS_osf_pathconf); |
738 | CASE(SYS_osf_pid_block); |
739 | CASE(SYS_osf_pid_unblock); |
740 | CASE(SYS_osf_plock); |
741 | CASE(SYS_osf_priocntlset); |
742 | CASE(SYS_osf_profil); |
743 | CASE(SYS_osf_proplist_syscall); |
744 | CASE(SYS_osf_reboot); |
745 | CASE(SYS_osf_revoke); |
746 | CASE(SYS_osf_sbrk); |
747 | CASE(SYS_osf_security); |
748 | CASE(SYS_osf_select); |
749 | CASE(SYS_osf_set_program_attributes); |
750 | CASE(SYS_osf_set_speculative); |
751 | CASE(SYS_osf_sethostid); |
752 | CASE(SYS_osf_setitimer); |
753 | CASE(SYS_osf_setlogin); |
754 | CASE(SYS_osf_setsysinfo); |
755 | CASE(SYS_osf_settimeofday); |
756 | CASE(SYS_osf_shmat); |
757 | CASE(SYS_osf_signal); |
758 | CASE(SYS_osf_sigprocmask); |
759 | CASE(SYS_osf_sigsendset); |
760 | CASE(SYS_osf_sigstack); |
761 | CASE(SYS_osf_sigwaitprim); |
762 | CASE(SYS_osf_sstk); |
763 | CASE(SYS_osf_stat); |
764 | CASE(SYS_osf_statfs); |
765 | CASE(SYS_osf_statfs64); |
766 | CASE(SYS_osf_subsys_info); |
767 | CASE(SYS_osf_swapctl); |
768 | CASE(SYS_osf_swapon); |
769 | CASE(SYS_osf_syscall); |
770 | CASE(SYS_osf_sysinfo); |
771 | CASE(SYS_osf_table); |
772 | CASE(SYS_osf_uadmin); |
773 | CASE(SYS_osf_usleep_thread); |
774 | CASE(SYS_osf_uswitch); |
775 | CASE(SYS_osf_utc_adjtime); |
776 | CASE(SYS_osf_utc_gettime); |
777 | CASE(SYS_osf_utimes); |
778 | CASE(SYS_osf_utsname); |
779 | CASE(SYS_osf_wait4); |
780 | CASE(SYS_osf_waitid); |
781 | CASE(SYS_pciconfig_iobase); |
782 | CASE(SYS_pciconfig_read); |
783 | CASE(SYS_pciconfig_write); |
784 | CASE(SYS_recv); |
785 | CASE(SYS_select); |
786 | CASE(SYS_send); |
787 | CASE(SYS_sethae); |
788 | CASE(SYS_setpgrp); |
789 | CASE(SYS_sigaction); |
790 | CASE(SYS_sigpending); |
791 | CASE(SYS_sigreturn); |
792 | CASE(SYS_sigsuspend); |
793 | CASE(SYS_stat64); |
794 | CASE(SYS_timerfd); |
795 | CASE(SYS_tuxcall); |
796 | CASE(SYS_umount); |
797 | CASE(SYS_uselib); |
798 | CASE(SYS_utimensat); |
799 | CASE(SYS_utimes); |
800 | CASE(SYS_vfork); |
801 | #endif |
802 | |
803 | default: |
804 | { |
805 | static char buf[32]; |
806 | sprintf(buf, "UNKN:%ld" , call); |
807 | return buf; |
808 | } |
809 | } |
810 | } |
811 | |
812 | static const char* x11_event_name[] = { |
813 | #if 0 // Must implement |
814 | "KeyPress" , |
815 | "KeyRelease" , |
816 | "ButtonPress" , |
817 | "ButtonRelease" , |
818 | "MotionNotify" , |
819 | "FocusIn" , |
820 | "FocusOut" , |
821 | "CreateNotify" , |
822 | "DestroyNotify" , |
823 | "MapNotify" , |
824 | "UnmapNotify" , |
825 | #else // see /usr/include/X11/X.h |
826 | "Error" , |
827 | "Reply" , |
828 | "KeyPress" , //2 |
829 | "KeyRelease" , //3 |
830 | "ButtonPress" , //4 |
831 | "ButtonRelease" , //5 |
832 | "MotionNotify" , //6 |
833 | "EnterNotify" , //7 |
834 | "LeaveNotify" , //8 |
835 | "FocusIn" , //9 |
836 | "FocusOut" , //10 |
837 | "KeymapNotify" , //11 |
838 | "Expose" , //12 |
839 | "GraphicsExpose" , //13 |
840 | "NoExpose" , //14 |
841 | "VisibilityNotify" , //15 |
842 | "CreateNotify" , //16 |
843 | "DestroyNotify" , //17 |
844 | "UnmapNotify" , //18 |
845 | "MapNotify" , //19 |
846 | #endif |
847 | }; |
848 | |
849 | static const char* dbus_msg_name[] = { |
850 | "invalid-message" , |
851 | "method-call" , |
852 | "method-return" , |
853 | "method-error" , |
854 | "send-signal" , |
855 | "receive-signal" , |
856 | }; |
857 | |
858 | const char* get_event_name(int type) |
859 | { |
860 | if (type < __NR_Linux) { |
861 | return syscall_name(type - DUMP_REASON_syscall_exit); |
862 | } |
863 | else if ( type < DUMP_REASON_signal) { |
864 | return syscall_name(type); |
865 | } |
866 | else if ( type < DUMP_REASON_dbus) { |
867 | int sig = type - DUMP_REASON_signal; |
868 | return signal_name(sig); |
869 | } |
870 | else if ( type < DUMP_REASON_x11) { |
871 | unsigned int msg = type - DUMP_REASON_dbus; |
872 | if (msg < sizeof(dbus_msg_name)/sizeof(dbus_msg_name[0])) |
873 | return dbus_msg_name[msg]; |
874 | else |
875 | return dbus_msg_name[0]; |
876 | } |
877 | else if ( type < DUMP_REASON_ptrace) { |
878 | unsigned int x11 = type - DUMP_REASON_x11; |
879 | if (x11 < sizeof(x11_event_name)/sizeof(x11_event_name[0])) |
880 | return x11_event_name[x11]; |
881 | else |
882 | return x11_event_name[0]; |
883 | } |
884 | else { |
885 | return "Unknown" ; |
886 | } |
887 | |
888 | return nullptr; |
889 | } |
890 | |