From 63d5bccf7e3f6a7a660f7f288152ce9c29010053 Mon Sep 17 00:00:00 2001 From: jasper Date: Thu, 2 Sep 2021 17:21:39 +0000 Subject: [PATCH] rename struct dt_evt fields to make it clear this isn't only used for tracing syscalls and adjust btrace(8) accordingly. extracted from a larger diff by Tom Rollet. ok mpi@ --- sys/dev/dt/dt_prov_static.c | 12 ++++++------ sys/dev/dt/dt_prov_syscall.c | 18 +++++++++--------- sys/dev/dt/dtvar.h | 14 +++++++------- usr.sbin/btrace/btrace.c | 12 ++++++------ 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/sys/dev/dt/dt_prov_static.c b/sys/dev/dt/dt_prov_static.c index 05828f036ff..789c2246e14 100644 --- a/sys/dev/dt/dt_prov_static.c +++ b/sys/dev/dt/dt_prov_static.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_prov_static.c,v 1.8 2021/06/07 13:55:54 dv Exp $ */ +/* $OpenBSD: dt_prov_static.c,v 1.9 2021/09/02 17:21:39 jasper Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -163,11 +163,11 @@ dt_prov_static_hook(struct dt_provider *dtpv, ...) if (dtev == NULL) continue; - dtev->dtev_sysargs[0] = args[0]; - dtev->dtev_sysargs[1] = args[1]; - dtev->dtev_sysargs[2] = args[2]; - dtev->dtev_sysargs[3] = args[3]; - dtev->dtev_sysargs[4] = args[4]; + dtev->dtev_args[0] = args[0]; + dtev->dtev_args[1] = args[1]; + dtev->dtev_args[2] = args[2]; + dtev->dtev_args[3] = args[3]; + dtev->dtev_args[4] = args[4]; dt_pcb_ring_consume(dp, dtev); } diff --git a/sys/dev/dt/dt_prov_syscall.c b/sys/dev/dt/dt_prov_syscall.c index b2e82551929..0db59ef1c9a 100644 --- a/sys/dev/dt/dt_prov_syscall.c +++ b/sys/dev/dt/dt_prov_syscall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_prov_syscall.c,v 1.4 2020/07/04 10:19:09 mpi Exp $ */ +/* $OpenBSD: dt_prov_syscall.c,v 1.5 2021/09/02 17:21:39 jasper Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -136,7 +136,7 @@ dt_prov_syscall_entry(struct dt_provider *dtpv, ...) args = va_arg(ap, register_t*); va_end(ap); - KASSERT((argsize / sizeof(register_t)) <= DTMAXSYSARGS); + KASSERT((argsize / sizeof(register_t)) <= DTMAXFUNCARGS); if (sysnum < 0 || sysnum >= dtps_nsysent) return; @@ -154,7 +154,7 @@ dt_prov_syscall_entry(struct dt_provider *dtpv, ...) continue; if (ISSET(dp->dp_evtflags, DTEVT_FUNCARGS)) - memcpy(dtev->dtev_sysargs, args, argsize); + memcpy(dtev->dtev_args, args, argsize); dt_pcb_ring_consume(dp, dtev); } @@ -196,13 +196,13 @@ dt_prov_syscall_return(struct dt_provider *dtpv, ...) continue; if (error) { - dtev->dtev_sysretval[0] = -1; - dtev->dtev_sysretval[1] = 0; - dtev->dtev_syserror = error; + dtev->dtev_retval[0] = -1; + dtev->dtev_retval[1] = 0; + dtev->dtev_error = error; } else { - dtev->dtev_sysretval[0] = retval[0]; - dtev->dtev_sysretval[1] = retval[1]; - dtev->dtev_syserror = 0; + dtev->dtev_retval[0] = retval[0]; + dtev->dtev_retval[1] = retval[1]; + dtev->dtev_error = 0; } dt_pcb_ring_consume(dp, dtev); diff --git a/sys/dev/dt/dtvar.h b/sys/dev/dt/dtvar.h index 3e7985692eb..bea47c2d80e 100644 --- a/sys/dev/dt/dtvar.h +++ b/sys/dev/dt/dtvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dtvar.h,v 1.5 2020/07/04 10:19:09 mpi Exp $ */ +/* $OpenBSD: dtvar.h,v 1.6 2021/09/02 17:21:39 jasper Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -34,9 +34,9 @@ #define DTMAXCOMLEN 16 /* - * Maximum number of arguments passed to a syscall. + * Maximum number of arguments passed to a function. */ -#define DTMAXSYSARGS 10 +#define DTMAXFUNCARGS 10 /* * Event state: where to store information when a probe fires. @@ -54,15 +54,15 @@ struct dt_evt { struct stacktrace dtev_kstack; /* kernel stack frame */ char dtev_comm[DTMAXCOMLEN+1]; /* current pr. name */ union { - register_t E_entry[DTMAXSYSARGS]; + register_t E_entry[DTMAXFUNCARGS]; struct { register_t __retval[2]; int __error; } E_return; } _sys; -#define dtev_sysargs _sys.E_entry /* syscall args. */ -#define dtev_sysretval _sys.E_return.__retval /* syscall retval */ -#define dtev_syserror _sys.E_return.__error /* syscall error */ +#define dtev_args _sys.E_entry /* function args. */ +#define dtev_retval _sys.E_return.__retval /* function retval */ +#define dtev_error _sys.E_return.__error /* function error */ }; diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index 5eca405bcfc..b4bb8864e07 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.45 2021/09/01 13:21:24 mpi Exp $ */ +/* $OpenBSD: btrace.c,v 1.46 2021/09/02 17:21:39 jasper Exp $ */ /* * Copyright (c) 2019 - 2021 Martin Pieuchot @@ -653,7 +653,7 @@ builtin_arg(struct dt_evt *dtev, enum bt_argtype dat) static char buf[sizeof("18446744073709551615")]; /* UINT64_MAX */ snprintf(buf, sizeof(buf), "%lu", - dtev->dtev_sysargs[dat - B_AT_BI_ARG0]); + dtev->dtev_args[dat - B_AT_BI_ARG0]); return buf; } @@ -882,7 +882,7 @@ stmt_store(struct bt_stmt *bs, struct dt_evt *dtev) xabort("store not implemented for type %d", ba->ba_type); } - debug("bv=%p var '%s' store (%p) \n", bv, bv_name(bv), bv->bv_value); + debug("bv=%p var '%s' store (%p)\n", bv, bv_name(bv), bv->bv_value); } /* @@ -1268,10 +1268,10 @@ ba2long(struct bt_arg *ba, struct dt_evt *dtev) val = builtin_nsecs(dtev); break; case B_AT_BI_ARG0 ... B_AT_BI_ARG9: - val = dtev->dtev_sysargs[ba->ba_type - B_AT_BI_ARG0]; + val = dtev->dtev_args[ba->ba_type - B_AT_BI_ARG0]; break; case B_AT_BI_RETVAL: - val = dtev->dtev_sysretval[0]; + val = dtev->dtev_retval[0]; break; case B_AT_OP_PLUS ... B_AT_OP_LOR: val = baexpr2long(ba, dtev); @@ -1331,7 +1331,7 @@ ba2str(struct bt_arg *ba, struct dt_evt *dtev) str = builtin_arg(dtev, ba->ba_type); break; case B_AT_BI_RETVAL: - snprintf(buf, sizeof(buf), "%ld", (long)dtev->dtev_sysretval[0]); + snprintf(buf, sizeof(buf), "%ld", (long)dtev->dtev_retval[0]); str = buf; break; case B_AT_MAP: -- 2.20.1