[DTrace-devel] [PATCH 2/2] Make stack trace use dctx->mem to store stack trace data
Kris Van Hees
kris.van.hees at oracle.com
Fri Aug 27 17:53:40 PDT 2021
The stack trace implementation was using an offset into the dctx->buf
memory space to store the stack trace data. Now that we have a generic
scratch memory area that can be referenced as dctx->mem, the stack
trace implementation has been adjusted to make use of that.
This patch also contains a tiny fix to the tst.stack_fbt.x script to
use /bin/bash because it depends on bash specific features.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
bpf/get_bvar.c | 3 +--
libdtrace/dt_bpf.h | 5 ++---
libdtrace/dt_cc.c | 3 ---
libdtrace/dt_dlibs.c | 1 -
test/unittest/stack/tst.stack_fbt.x | 2 +-
5 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/bpf/get_bvar.c b/bpf/get_bvar.c
index 26b8737e..ddada70e 100644
--- a/bpf/get_bvar.c
+++ b/bpf/get_bvar.c
@@ -25,7 +25,6 @@ extern struct bpf_map_def probes;
extern struct bpf_map_def state;
extern uint64_t STBSZ;
-extern uint64_t STKOFF;
extern uint64_t STKSIZ;
extern uint64_t BOOTTM;
@@ -60,7 +59,7 @@ noinline uint64_t dt_get_bvar(dt_dctx_t *dctx, uint32_t id)
case DIF_VAR_USTACKDEPTH: {
uint32_t bufsiz = (uint32_t) (uint64_t) (&STKSIZ);
uint64_t flags = 0 & BPF_F_SKIP_FIELD_MASK;
- char *buf = ((char *) dctx->buf) + ((uint64_t) &STKOFF);
+ char *buf = dctx->mem;
uint64_t stacksize;
if (id == DIF_VAR_USTACKDEPTH)
diff --git a/libdtrace/dt_bpf.h b/libdtrace/dt_bpf.h
index 68e4aa07..2882520f 100644
--- a/libdtrace/dt_bpf.h
+++ b/libdtrace/dt_bpf.h
@@ -24,9 +24,8 @@ extern "C" {
#define DT_CONST_ARGC 4
#define DT_CONST_STBSZ 5
#define DT_CONST_STRSZ 6
-#define DT_CONST_STKOFF 7
-#define DT_CONST_STKSIZ 8
-#define DT_CONST_BOOTTM 9
+#define DT_CONST_STKSIZ 7
+#define DT_CONST_BOOTTM 8
extern int perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu,
int group_fd, unsigned long flags);
diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
index f69c750d..97c7d5e2 100644
--- a/libdtrace/dt_cc.c
+++ b/libdtrace/dt_cc.c
@@ -2352,9 +2352,6 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
nrp->dofr_data =
dtp->dt_options[DTRACEOPT_STRSIZE];
continue;
- case DT_CONST_STKOFF:
- nrp->dofr_data = roundup(dtp->dt_maxreclen, 8);
- continue;
case DT_CONST_STKSIZ:
nrp->dofr_data = sizeof(uint64_t)
* dtp->dt_options[DTRACEOPT_MAXFRAMES];
diff --git a/libdtrace/dt_dlibs.c b/libdtrace/dt_dlibs.c
index 5980768b..04becfa6 100644
--- a/libdtrace/dt_dlibs.c
+++ b/libdtrace/dt_dlibs.c
@@ -78,7 +78,6 @@ static const dt_ident_t dt_bpf_symbols[] = {
DT_BPF_SYMBOL_ID(ARGC, DT_IDENT_SCALAR, DT_CONST_ARGC),
DT_BPF_SYMBOL_ID(STBSZ, DT_IDENT_SCALAR, DT_CONST_STBSZ),
DT_BPF_SYMBOL_ID(STRSZ, DT_IDENT_SCALAR, DT_CONST_STRSZ),
- DT_BPF_SYMBOL_ID(STKOFF, DT_IDENT_SCALAR, DT_CONST_STKOFF),
DT_BPF_SYMBOL_ID(STKSIZ, DT_IDENT_SCALAR, DT_CONST_STKSIZ),
DT_BPF_SYMBOL_ID(BOOTTM, DT_IDENT_SCALAR, DT_CONST_BOOTTM),
/* End-of-list marker */
diff --git a/test/unittest/stack/tst.stack_fbt.x b/test/unittest/stack/tst.stack_fbt.x
index e3c12e6a..0bbc4706 100755
--- a/test/unittest/stack/tst.stack_fbt.x
+++ b/test/unittest/stack/tst.stack_fbt.x
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
read MAJOR MINOR <<< `uname -r | awk -F. '{print $1, $2}'`
--
2.33.0
More information about the DTrace-devel
mailing list