Hang on, SYSCALL_DEBUG is used to bring up new architectures. That is the only time the #define is enabled.
When you are bringing up a new architecture, bt is useless I don't think this makes sense. Martin Pieuchot <[email protected]> wrote: > Now that dt(4) and btrace(8) are enabled by default and provide a nice > and flexible way to debug syscalls on GENERIC kernels should we get rid > of the SYSCALL_DEBUG mechanism? > > Note that the auto-generated kern/syscalls.c providing the `syscallnames' > array is still needed to build btrace(8). > > ok? > > Index: kern/exec_elf.c > =================================================================== > RCS file: /cvs/src/sys/kern/exec_elf.c,v > retrieving revision 1.160 > diff -u -p -r1.160 exec_elf.c > --- kern/exec_elf.c 10 Mar 2021 10:21:47 -0000 1.160 > +++ kern/exec_elf.c 30 Aug 2021 07:19:33 -0000 > @@ -107,9 +107,6 @@ int elf_os_pt_note_name(Elf_Note *); > int elf_os_pt_note(struct proc *, struct exec_package *, Elf_Ehdr *, int *); > > extern char sigcode[], esigcode[], sigcoderet[]; > -#ifdef SYSCALL_DEBUG > -extern char *syscallnames[]; > -#endif > > /* round up and down to page boundaries. */ > #define ELF_ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1)) > @@ -135,11 +132,7 @@ struct emul emul_elf = { > SYS_syscall, > SYS_MAXSYSCALL, > sysent, > -#ifdef SYSCALL_DEBUG > - syscallnames, > -#else > NULL, > -#endif > (sizeof(AuxInfo) * ELF_AUX_ENTRIES / sizeof(char *)), > elf_copyargs, > setregs, > Index: kern/kern_xxx.c > =================================================================== > RCS file: /cvs/src/sys/kern/kern_xxx.c,v > retrieving revision 1.36 > diff -u -p -r1.36 kern_xxx.c > --- kern/kern_xxx.c 2 Apr 2019 11:00:22 -0000 1.36 > +++ kern/kern_xxx.c 30 Aug 2021 07:19:17 -0000 > @@ -84,75 +84,3 @@ __stack_smash_handler(char func[], int d > panic("smashed stack in %s", func); > } > #endif > - > -#ifdef SYSCALL_DEBUG > -#include <sys/proc.h> > - > -#define SCDEBUG_CALLS 0x0001 /* show calls */ > -#define SCDEBUG_RETURNS 0x0002 /* show returns */ > -#define SCDEBUG_ALL 0x0004 /* even syscalls that are > implemented */ > -#define SCDEBUG_SHOWARGS 0x0008 /* show arguments to calls */ > - > -int scdebug = SCDEBUG_CALLS|SCDEBUG_RETURNS|SCDEBUG_SHOWARGS; > - > -void > -scdebug_call(struct proc *p, register_t code, const register_t args[]) > -{ > - struct process *pr; > - struct sysent *sy; > - struct emul *em; > - int i; > - > - if (!(scdebug & SCDEBUG_CALLS)) > - return; > - > - pr = p->p_p; > - em = pr->ps_emul; > - sy = &em->e_sysent[code]; > - if (!(scdebug & SCDEBUG_ALL || code < 0 || code >= em->e_nsysent || > - sy->sy_call == sys_nosys)) > - return; > - > - printf("proc %d (%s): %s num ", pr->ps_pid, pr->ps_comm, em->e_name); > - if (code < 0 || code >= em->e_nsysent) > - printf("OUT OF RANGE (%ld)", code); > - else { > - printf("%ld call: %s", code, em->e_syscallnames[code]); > - if (scdebug & SCDEBUG_SHOWARGS) { > - printf("("); > - for (i = 0; i < sy->sy_argsize / sizeof(register_t); > - i++) > - printf("%s0x%lx", i == 0 ? "" : ", ", args[i]); > - printf(")"); > - } > - } > - printf("\n"); > -} > - > -void > -scdebug_ret(struct proc *p, register_t code, int error, > - const register_t retval[]) > -{ > - struct process *pr; > - struct sysent *sy; > - struct emul *em; > - > - if (!(scdebug & SCDEBUG_RETURNS)) > - return; > - > - pr = p->p_p; > - em = pr->ps_emul; > - sy = &em->e_sysent[code]; > - if (!(scdebug & SCDEBUG_ALL || code < 0 || code >= em->e_nsysent || > - sy->sy_call == sys_nosys)) > - return; > - > - printf("proc %d (%s): %s num ", pr->ps_pid, pr->ps_comm, em->e_name); > - if (code < 0 || code >= em->e_nsysent) > - printf("OUT OF RANGE (%ld)", code); > - else > - printf("%ld ret: err = %d, rv = 0x%lx,0x%lx", code, > - error, retval[0], retval[1]); > - printf("\n"); > -} > -#endif /* SYSCALL_DEBUG */ > Index: kern/init_main.c > =================================================================== > RCS file: /cvs/src/sys/kern/init_main.c,v > retrieving revision 1.308 > diff -u -p -r1.308 init_main.c > --- kern/init_main.c 30 Jun 2021 12:21:02 -0000 1.308 > +++ kern/init_main.c 30 Aug 2021 07:17:55 -0000 > @@ -155,9 +155,6 @@ void pool_gc_pages(void *); > void percpu_init(void); > > extern char sigcode[], esigcode[], sigcoderet[]; > -#ifdef SYSCALL_DEBUG > -extern char *syscallnames[]; > -#endif > > struct emul emul_native = { > "native", > @@ -165,11 +162,7 @@ struct emul emul_native = { > SYS_syscall, > SYS_MAXSYSCALL, > sysent, > -#ifdef SYSCALL_DEBUG > - syscallnames, > -#else > NULL, > -#endif > 0, > copyargs, > setregs, > Index: sys/systm.h > =================================================================== > RCS file: /cvs/src/sys/sys/systm.h,v > retrieving revision 1.154 > diff -u -p -r1.154 systm.h > --- sys/systm.h 2 Jun 2021 00:39:25 -0000 1.154 > +++ sys/systm.h 30 Aug 2021 07:18:06 -0000 > @@ -131,12 +131,6 @@ extern struct sysent { /* system call t > #error "what byte order is this machine?" > #endif > > -#if defined(_KERNEL) && defined(SYSCALL_DEBUG) > -void scdebug_call(struct proc *p, register_t code, const register_t > retval[]); > -void scdebug_ret(struct proc *p, register_t code, int error, > - const register_t retval[]); > -#endif /* _KERNEL && SYSCALL_DEBUG */ > - > extern int boothowto; /* reboot flags, from console subsystem > */ > > extern void (*v_putc)(int); /* Virtual console putc routine */ > Index: sys/syscall_mi.h > =================================================================== > RCS file: /cvs/src/sys/sys/syscall_mi.h,v > retrieving revision 1.25 > diff -u -p -r1.25 syscall_mi.h > --- sys/syscall_mi.h 21 Jan 2020 16:16:23 -0000 1.25 > +++ sys/syscall_mi.h 30 Aug 2021 07:19:10 -0000 > @@ -60,11 +60,6 @@ mi_syscall(struct proc *p, register_t co > /* refresh the thread's cache of the process's creds */ > refreshcreds(p); > > -#ifdef SYSCALL_DEBUG > - KERNEL_LOCK(); > - scdebug_call(p, code, argp); > - KERNEL_UNLOCK(); > -#endif > TRACEPOINT(raw_syscalls, sys_enter, code, NULL); > #if NDT > 0 > DT_ENTER(syscall, code, callp->sy_argsize, argp); > @@ -113,11 +108,6 @@ static inline void > mi_syscall_return(struct proc *p, register_t code, int error, > const register_t retval[2]) > { > -#ifdef SYSCALL_DEBUG > - KERNEL_LOCK(); > - scdebug_ret(p, code, error, retval); > - KERNEL_UNLOCK(); > -#endif > #if NDT > 0 > DT_LEAVE(syscall, code, error, retval[0], retval[1]); > #endif > @@ -140,7 +130,7 @@ mi_syscall_return(struct proc *p, regist > static inline void > mi_child_return(struct proc *p) > { > -#if defined(SYSCALL_DEBUG) || defined(KTRACE) || NDT > 0 > +#if defined(KTRACE) || NDT > 0 > int code = (p->p_flag & P_THREAD) ? SYS___tfork : > (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork; > const register_t child_retval[2] = { 0, 1 }; > @@ -148,11 +138,6 @@ mi_child_return(struct proc *p) > > TRACEPOINT(sched, on__cpu, NULL); > > -#ifdef SYSCALL_DEBUG > - KERNEL_LOCK(); > - scdebug_ret(p, code, 0, child_retval); > - KERNEL_UNLOCK(); > -#endif > #if NDT > 0 > DT_LEAVE(syscall, code, 0, child_retval[0], child_retval[1]); > #endif >
