Re: Kill SYSCALL_DEBUG
> From: "Theo de Raadt" > Date: Mon, 30 Aug 2021 01:47:43 -0600 > > 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. Indeed. This needs to stay. > Martin Pieuchot 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 - 1.160 > > +++ kern/exec_elf.c 30 Aug 2021 07:19:33 - > > @@ -107,9 +107,6 @@ int elf_os_pt_note_name(Elf_Note *); > > intelf_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 - 1.36 > > +++ kern/kern_xxx.c 30 Aug 2021 07:19:17 - > > @@ -84,75 +84,3 @@ __stack_smash_handler(char func[], int d > > panic("smashed stack in %s", func); > > } > > #endif > > - > > -#ifdef SYSCALL_DEBUG > > -#include > > - > > -#defineSCDEBUG_CALLS 0x0001 /* show calls */ > > -#defineSCDEBUG_RETURNS 0x0002 /* show returns */ > > -#defineSCDEBUG_ALL 0x0004 /* even syscalls that are > > implemented */ > > -#defineSCDEBUG_SHOWARGS0x0008 /* show arguments to calls */ > > - > > -intscdebug = 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 = >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 = >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.c30 Jun 2021 12:21:02 - 1.308 > > +++ kern/init_main.c30 Aug 2021 07:17:55 - > > @@ -155,9 +155,6 @@ voidpool_gc_pages(void *); > >
Re: Kill SYSCALL_DEBUG
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 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 - 1.160 > +++ kern/exec_elf.c 30 Aug 2021 07:19:33 - > @@ -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 - 1.36 > +++ kern/kern_xxx.c 30 Aug 2021 07:19:17 - > @@ -84,75 +84,3 @@ __stack_smash_handler(char func[], int d > panic("smashed stack in %s", func); > } > #endif > - > -#ifdef SYSCALL_DEBUG > -#include > - > -#define SCDEBUG_CALLS 0x0001 /* show calls */ > -#define SCDEBUG_RETURNS 0x0002 /* show returns */ > -#define SCDEBUG_ALL 0x0004 /* even syscalls that are > implemented */ > -#define SCDEBUG_SHOWARGS0x0008 /* 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 = >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 = >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 - 1.308 > +++ kern/init_main.c 30 Aug 2021 07:17:55 - > @@ -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, >
Kill SYSCALL_DEBUG
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 - 1.160 +++ kern/exec_elf.c 30 Aug 2021 07:19:33 - @@ -107,9 +107,6 @@ int elf_os_pt_note_name(Elf_Note *); intelf_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 - 1.36 +++ kern/kern_xxx.c 30 Aug 2021 07:19:17 - @@ -84,75 +84,3 @@ __stack_smash_handler(char func[], int d panic("smashed stack in %s", func); } #endif - -#ifdef SYSCALL_DEBUG -#include - -#defineSCDEBUG_CALLS 0x0001 /* show calls */ -#defineSCDEBUG_RETURNS 0x0002 /* show returns */ -#defineSCDEBUG_ALL 0x0004 /* even syscalls that are implemented */ -#defineSCDEBUG_SHOWARGS0x0008 /* show arguments to calls */ - -intscdebug = 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 = >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 = >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.c30 Jun 2021 12:21:02 - 1.308 +++ kern/init_main.c30 Aug 2021 07:17:55 - @@ -155,9 +155,6 @@ voidpool_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