usdt typed args, translators and arg mapping
v7 cover usdt typed args, translators and arg mapping
This series adds back support for the probe foo (...) : (...) syntax in USDT provider definitions. The dtprobed side is routine, pulling in the DOF and adding it to a new set of dof_parser.h records fed through to the DOF stash and ultimately to dt_pid.c and eventually dt_prov_uprobe.c: the end result is that the DOF for a given probe's mappings ends up in the dt_uprobe_t in more or less the same form as it was in the DOF.
After that things get tricky, because we want to map not only arg[N] but also argN references (the single existing test for USDT arg mapping verifies that this works), but the SDT machinery depends on argN being left unchanged! So we do the mapping in dt_prov_uprobe.c while reshuffling things into dt_argdesc_t's, and tell the higher layers that no arg mapping is ever being performed, then do the actual movement of args in the trampoline by physically reshuffling the arguments. This seems to work without breaking SDT on all supported architectures, and is surprisingly simple (at least, it surprised me: multiple places where I thought I'd need hundreds of lines of complex code turned out to need only three or four lines).
New tests are added to verify that USDT translators work when types change, when arg counts change, and when there are no args at all, and that dtrace -vln produces the right output (all previous tests for USDT -vln, translated or not, are currently disabled because they all use wildcards: this new one doesn't).
We also add new tests to test that pid/USDT interoperability does not break arg mapping and USDT args in general (deferred args are coming, but are trickier to get working). That's in a separate commit because it renames and modifies an existing test significantly (it still does the same thing).
We also fix a tiny error-path-related bug in usdt encountered in the course of development.
Changes since v6:
Move all references to DTPPT_USDT into the patch that defines it (one slipped into the first patch by mistake).
Changes since v5:
Moved a couple of mispositioned hunks between patches. Rephrased a couple of terrible comments.
A few formatting fixes.
(No conditional added around call to populate_args(), since populate_args() doesn't care if the probe is USDT or not: if the probe has args, it'll populate them.)
Changes since v4:
Moved the arg saving into the dt_prov_uprobe trampoline. Store the args in one contiguous strtab rather than two distinct ones.
Drop some unnecessary "no xargs, fall back to nargs" code (there are always xargs if there are any user-visible args at all, the nargs are not user-visible).
Set up the arguments even if USDT probes with args find that their underlying probe is already in place for a pid probe. Identify USDT probes reliably and use this to prevent creation of multiple USDT probes at the same locus (new DTPPT_USDT probe type:
DTPPT_OFFSETS is now reserved for pid offset probes). Fixed up a few bad comments.
Added test/unittest/usdt/tst.pid*sh, out of the guts of tst.pidprobes.sh, which is renamed and modified to pidprobes.sh and called by all three tests.
Changes since v3:
Rebase against latest dev, adjusting the trampoline: we should now handle the overlapping pid and usdt case, though this still being verified.
Eliminate remaining references to 'remapping'.
Move mis-merged hunk of dt_cg.c changes into the right commit. Drop showUSDT arg stuff in favour of Kris's improved version.
Changes since v2:
Populate dt_argdesc_t's in USDT probe discovery rather than in probe_info.
Changes since v1:
Adapted to review comments (all comments but the stuff around trampolines and arg mapping, which I don't understand well enough to implement); in particular track xlated args and mappings together, and move from a flags word in the dof_parser struct's DIT_PROBE record to an arg count
Nick Alcock (6):
usdt: get arg types and xlations into DTrace from the DOF
dtprobed: stop skipping zero-tracepoint probes in dof_stash.c
cg: add argument mapping in the trampoline
usdt: typed args and arg mapping
usdt: new tests for USDT arg sanity with overlapping pid probes
usdt: fix create_underlying error path
dtprobed/dof_stash.c | 21 +-
dtprobed/dtprobed.c | 10 +-
include/dtrace/pid.h | 8 +
libcommon/dof_parser.c | 150 ++++++++++----
libcommon/dof_parser.h | 64 +++++-
libdtrace/dt_cg.c | 25 +++
libdtrace/dt_cg.h | 1 +
libdtrace/dt_pid.c | 62 +++++-
libdtrace/dt_prov_uprobe.c | 186 ++++++++++++++++--
test/triggers/usdt-tst-argmap-prov.d | 5 +-
test/triggers/usdt-tst-argmap.c | 5 +-
.../dtrace-util/tst.ListProbesArgsUSDT.r | 130 ++++++++++++
.../dtrace-util/tst.ListProbesArgsUSDT.r.p | 2 +
.../dtrace-util/tst.ListProbesArgsUSDT.sh | 89 +++++++++
test/unittest/usdt/err.argmap-null.d | 41 ++++
test/unittest/usdt/err.argmap-null.r | 2 +
test/unittest/usdt/err.argmap-null.r.p | 2 +
.../usdt/{tst.pidprobes.sh => pidprobes.sh} | 56 ++++--
test/unittest/usdt/tst.argmap-null.d | 32 +++
test/unittest/usdt/tst.argmap-typed-partial.d | 49 +++++
test/unittest/usdt/tst.argmap-typed.d | 48 +++++
test/unittest/usdt/tst.argmap.d | 5 +-
test/unittest/usdt/tst.pidargmap.sh | 11 ++
test/unittest/usdt/tst.pidargs.sh | 11 ++
24 files changed, 929 insertions(+), 86 deletions(-)
create mode 100644 test/unittest/dtrace-util/tst.ListProbesArgsUSDT.r
create mode 100755 test/unittest/dtrace-util/tst.ListProbesArgsUSDT.r.p
create mode 100755 test/unittest/dtrace-util/tst.ListProbesArgsUSDT.sh
create mode 100644 test/unittest/usdt/err.argmap-null.d
create mode 100644 test/unittest/usdt/err.argmap-null.r
create mode 100755 test/unittest/usdt/err.argmap-null.r.p
rename test/unittest/usdt/{tst.pidprobes.sh => pidprobes.sh} (82%)
create mode 100644 test/unittest/usdt/tst.argmap-null.d
create mode 100644 test/unittest/usdt/tst.argmap-typed-partial.d
create mode 100644 test/unittest/usdt/tst.argmap-typed.d
create mode 100755 test/unittest/usdt/tst.pidargmap.sh
create mode 100755 test/unittest/usdt/tst.pidargs.shSignature · 1 line
2.46.0.278.g36e3a12567
PATCH v7 1/6 usdt: get arg types and xlations into DTrace from the DOF
This change propagates native and xlated arg types and mapping info all the way from the DOF, through the parser and dtprobed and the DOF stash, into DTrace, where they end up in the pid_probespec_t for USDT probes. We don't do anything with them once they get there in this commit: no user-visible impacts expected.
We bump the DOF_PARSED_VERSION since we add three new types of record to the dof_parser_t, all optional, covering native and xlated args and arg mapping tables; to make life easier for consumers we emit them in a defined order (documented in dof_parser.h), and add arg counts to the DIT_PROBE record that precedes them indicating which will be present and how many args are in them. This means we retain the property that you can always tell which records within a provider are coming next purely from records you already
have: there's no need to make decisions once the records turn up. The DOF stash hardly changes: all that happens is that the parsed data written to each per-probe file gains some extra types of record (it can have DIT_ARGS_NATIVE, DIT_ARGS_XLAT and DIT_ARGS_MAP entries following the DIT_PROBE record now).
As usual with DOF_PARSED_VERSION bumps, DTraces that cross this change will refuse to read probes added by dtprobeds that are on the other side of it. (Restarting dtprobed will reparse all the probes in the stash to match the new layout, and newly-started DTraces will pick that up -- so this only affects running DTraces picking up new probes, which DTrace cannot do yet:
so no visible effects are expected.)
The code is a bit repetitive, with nargs, xargs and arg mapping all handled separately even though the code is very similar. In future maybe we could unify them (but my attempts led to code that was much harder to read than the original).
--- dtprobed/dof_stash.c | 15 +++-- dtprobed/dtprobed.c | 10 ++- include/dtrace/pid.h | 7 ++ libcommon/dof_parser.c | 150 +++++++++++++++++++++++++++++++---------- libcommon/dof_parser.h | 64 ++++++++++++++++-- libdtrace/dt_pid.c | 60 +++++++++++++++++ 6 files changed, 257 insertions(+), 49 deletions(-)
dtprobed/dof_stash.c +11 -4
@@ -59,8 +59,10 @@* startup if the dof_parsed_t structure changed. The file consists of a * uint64_t version number (DOF_PARSED_VERSION), then a stream of * dof_parsed_t records, the first of type DIT_PROVIDER, the second -* DIT_PROBE, then as many struct dof_parsed_t's of type DIT_TRACEPOINT as -* the DIT_PROBE record specifies. +* DIT_PROBE, then optionally some DIT_*ARGS records (if the count of native +* args in the probe is >0, you get a DIT_NATIVE_ARGS: if the count of xlated +* args is >0, you get DIT_XLAT_ARGS and DIT_MAP_ARGS), then as many struct +* dof_parsed_t's of type DIT_TRACEPOINT as the DIT_PROBE record specifies. * * /run/dtrace/probes/: Per-probe info, written by dtprobed, read by DTrace. *
@@ -640,9 +642,14 @@ dof_stash_write_parsed(pid_t pid, dev_t dev, ino_t ino, dt_list_t *accum)break ; } -/* Tracepoint: add to already-open file. */ +/* Args info or tracepoint: add to already-open file. */ +case DIT_ARGS_NATIVE : +case DIT_ARGS_XLAT : +case DIT_ARGS_MAP :case DIT_TRACEPOINT : -assert (state ==DIT_PROBE || state ==DIT_TRACEPOINT ); +assert (state ==DIT_PROBE || state ==DIT_ARGS_NATIVE || + state ==DIT_ARGS_XLAT || state ==DIT_ARGS_MAP || + state ==DIT_TRACEPOINT ); state = accump->parsed->type;if (write_chunk (parsed_fd, accump->parsed, accump->parsed->size) <0 )
dtprobed/dtprobed.c +7 -3
@@ -791,16 +791,20 @@ process_dof(pid_t pid, int out, int in, dev_t dev, ino_t inum, dev_t exec_dev,if (dof_stash_push_parsed (&accum, probe) <0 ) goto oom; -for (j =0 ; j < probe->probe.ntp; j++) { + j =0 ; +do {dof_parsed_t *tp =dof_read (pid, in); errmsg ="no tracepoints in a probe, or parse state corrupt" ; -if (!tp || tp->type !=DIT_TRACEPOINT ) +if (!tp || tp->type ==DIT_PROVIDER || tp->type ==DIT_PROBE ) goto err;if (dof_stash_push_parsed (&accum, tp) <0 ) goto oom; - } + +if (tp->type ==DIT_TRACEPOINT ) + j++; + }while (j < probe->probe.ntp); }if (!reparsing)
include/dtrace/pid.h +7 -0
@@ -35,6 +35,13 @@ typedef struct pid_probespec {ino_t pps_inum;/* object inode */ char *pps_fn;/* object full filename */ uint64_t pps_off;/* probe offset (in object) */ +int pps_nargc;/* number of native args */ +int pps_xargc;/* number of xlated and mapped args */ +char *pps_nargv;/* array of native args */ +size_t pps_nargvlen;/* (high estimate of) length of array */ +char *pps_xargv;/* array of xlated args */ +size_t pps_xargvlen;/* (high estimate of) length of array */ +int8_t *pps_argmap;/* mapped arg indexes */ /* * Fields below this point do not apply to underlying probes.
libcommon/dof_parser.c +114 -36
189 lines not on this page · raw message
libcommon/dof_parser.h +58 -6
100 lines not on this page · raw message
libdtrace/dt_pid.c +60 -0
78 lines not on this page · raw message
Signature · 1 line
2.46.0.278.g36e3a12567
PATCH v7 2/6 dtprobed: stop skipping zero-tracepoint probes in dof_stash.c
In reply to Nick AlcockWe already validate that they don't exist in dof_parser.c, so no such probes can ever get here. Handling this impossible, untestable case has just got harder, because we'd have to skip DIT_ARGS_{NATIVE,XLAT,MAP} records too. Just stop considering it.
--- dtprobed/dof_stash.c | 6 ------ 1 file changed, 6 deletions(-)
dtprobed/dof_stash.c +0 -6
@@ -586,12 +586,6 @@ dof_stash_write_parsed(pid_t pid, dev_t dev, ino_t ino, dt_list_t *accum)if (err !=0 ) goto err_provider; -/* -* Skip probes with zero tracepoints entirely. -*/ -if (accump->parsed->probe.ntp ==0 ) -break ; - mod = accump->parsed->probe.name;assert (accump->parsed->size > (mod - (char *) accump->parsed)); fun = mod +strlen (mod) +1 ;
Signature · 1 line
2.46.0.278.g36e3a12567
PATCH v7 3/6 cg: add argument mapping in the trampoline
In reply to Nick AlcockBefore now, argument mapping was restricted to the args[] array, and was implemented in dt_cg_array_op in the same place where we decide whether to automatically copyin() userspace strings.
But existing DTrace testcases suggest that arg mapping is also applied to argN for USDT, even though this is inconsistent with SDT and arguably less flexible than having argN be the unmapped arguments in all cases. Add a new function dt_cg_tramp_map_args(), which can be called from trampolines to apply mappings (destructively, but it keeps a copy of the old args in the save area so you can unapply them if you need to). No existing providers do any mapping, so this is not yet called, but it's about to be.
--- libdtrace/dt_cg.c | 25 +++++++++++++++++++++++++ libdtrace/dt_cg.h | 1 + 2 files changed, 26 insertions(+)
libdtrace/dt_cg.c +25 -0
@@ -831,6 +831,29 @@ dt_cg_tramp_restore_args(dt_pcb_t *pcb) } } +/* +* Populate the probe arguments based on the provided dt_argdesc_t array. The +* caller must save the arguments because argument mapping copies values from +* the saved arguments to the current arguments. After this function returns, +* the caller should adjust the mapping to reflect that shuffling has been done. +* +* The caller must ensure that %r7 contains the value set by the +* dt_cg_tramp_prologue*() functions. +*/ +void +dt_cg_tramp_map_args (dt_pcb_t *pcb,dt_argdesc_t *args,size_t nargs) +{ +dt_irlist_t *dlp = &pcb->pcb_ir; +int i; + +for (i =0 ; i < nargs; i++) { +if (args[i].mapping != i) { +emit (dlp,BPF_LOAD (BPF_DW ,BPF_REG_0 ,BPF_REG_7 ,DMST_ORIG_ARG (args[i].mapping))); +emit (dlp,BPF_STORE (BPF_DW ,BPF_REG_7 ,DMST_ARG (i),BPF_REG_0 )); + } + } +} + typedef struct { dt_irlist_t *dlp; dt_activity_t act;
@@ -5061,6 +5084,8 @@ dt_cg_array_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)* unless the argument reference is provided by a dynamic translator. * If we're using a dynamic translator for args[], then just set dn_reg * to an invalid reg and return: DIF_OP_XLARG will fetch the arg later. +* +* If this is a userland variable, note that we need to copy it in. */ if (idp->di_id ==DIF_VAR_ARGS ) { if ((idp->di_kind == DT_IDENT_XLPTR ||
libdtrace/dt_cg.h +1 -0
@@ -34,6 +34,7 @@ extern void dt_cg_tramp_get_var(dt_pcb_t *pcb, const char *name, int isstore,extern void dt_cg_tramp_del_var (dt_pcb_t *pcb,const char *name);extern void dt_cg_tramp_save_args (dt_pcb_t *pcb);extern void dt_cg_tramp_restore_args (dt_pcb_t *pcb); +extern void dt_cg_tramp_map_args (dt_pcb_t *pcb,dt_argdesc_t *args,size_t nargs);extern void dt_cg_tramp_call_clauses (dt_pcb_t *pcb,const dt_probe_t *prp,dt_activity_t act);extern void dt_cg_tramp_return (dt_pcb_t *pcb);
Signature · 1 line
2.46.0.278.g36e3a12567
PATCH v7 4/6 usdt: typed args and arg mapping
In reply to Nick AlcockThis change propagates the arg type and mapping info we just got into the pid_probespec_t onward into the underlying dt_uprobe_t and shuffles the argument values by calling dt_cg_tramp_map_args(). With this, USDT probes should now have visible types which obey the :-notation translators specified in their .d file (this is now tested).
The probe_info hook has been moved from the underlying probe to the overlying one as part of this: underlying probes don't have any user-visible args to get info for, and their probe_info functions are never called. We populate the dt_argdesc_t in a function ultimately called from USDT probe discovery via provide_underlying, so it predates trampoline setup let alone probe_info on the overlying probe and all the args info is present before it is needed.
--- include/dtrace/pid.h | 1 + libdtrace/dt_pid.c | 2 +- libdtrace/dt_prov_uprobe.c | 184 ++++++++++++++++-- test/triggers/usdt-tst-argmap-prov.d | 5 +- test/triggers/usdt-tst-argmap.c | 5 +- .../dtrace-util/tst.ListProbesArgsUSDT.r | 130 +++++++++++++ .../dtrace-util/tst.ListProbesArgsUSDT.r.p | 2 + .../dtrace-util/tst.ListProbesArgsUSDT.sh | 89 +++++++++ test/unittest/usdt/err.argmap-null.d | 41 ++++ test/unittest/usdt/err.argmap-null.r | 2 + test/unittest/usdt/err.argmap-null.r.p | 2 + test/unittest/usdt/tst.argmap-null.d | 32 +++ test/unittest/usdt/tst.argmap-typed-partial.d | 49 +++++ test/unittest/usdt/tst.argmap-typed.d | 48 +++++ test/unittest/usdt/tst.argmap.d | 5 +- 15 files changed, 578 insertions(+), 19 deletions(-) create mode 100644 test/unittest/dtrace-util/tst.ListProbesArgsUSDT.r create mode 100755 test/unittest/dtrace-util/tst.ListProbesArgsUSDT.r.p create mode 100755 test/unittest/dtrace-util/tst.ListProbesArgsUSDT.sh create mode 100644 test/unittest/usdt/err.argmap-null.d create mode 100644 test/unittest/usdt/err.argmap-null.r create mode 100755 test/unittest/usdt/err.argmap-null.r.p create mode 100644 test/unittest/usdt/tst.argmap-null.d create mode 100644 test/unittest/usdt/tst.argmap-typed-partial.d create mode 100644 test/unittest/usdt/tst.argmap-typed.d
include/dtrace/pid.h +1 -0
@@ -22,6 +22,7 @@ typedef enum pid_probetype {DTPPT_ENTRY ,DTPPT_RETURN ,DTPPT_OFFSETS , +DTPPT_USDT , DTPPT_IS_ENABLED } pid_probetype_t;
libdtrace/dt_pid.c +1 -1
@@ -1001,7 +1001,7 @@ dt_pid_create_usdt_probes_proc(dtrace_hdl_t *dtp, dt_proc_t *dpr, goto oom; } - psp.pps_type = tp->tracepoint.is_enabled ?DTPPT_IS_ENABLED :DTPPT_OFFSETS ; + psp.pps_type = tp->tracepoint.is_enabled ?DTPPT_IS_ENABLED :DTPPT_USDT ; psp.pps_prv = prv; psp.pps_mod = mod; psp.pps_fun = fun;
libdtrace/dt_prov_uprobe.c +171 -13
295 lines not on this page · raw message
test/triggers/usdt-tst-argmap-prov.d +4 -1
@@ -1,10 +1,13 @@ /* * Oracle Linux DTrace. - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ provider test_prov { probe place(int i, int j) : (int j, int i, int i, int j); + probe place2(int i, char *j) : (char *j, int i, int i, char *j); + probe place3(int i, char *j) : (char *j); + probe place4(int i, char *j) : (); };
test/triggers/usdt-tst-argmap.c +4 -1
@@ -1,6 +1,6 @@/* * Oracle Linux DTrace. -* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */
@@ -12,6 +12,9 @@ main(int argc, char **argv) {for (;;) {DTRACE_PROBE2 (test_prov, place,10 ,4 ); +DTRACE_PROBE (test_prov, place2,255 ,"foo" ); +DTRACE_PROBE (test_prov, place3,126 ,"bar" ); +DTRACE_PROBE (test_prov, place4,204 ,"baz" ); }return 0 ;
test/unittest/dtrace-util/tst.ListProbesArgsUSDT.r new file +130 -0
130 lines not on this page · raw message
test/unittest/dtrace-util/tst.ListProbesArgsUSDT.r.p new file +2 -0
@@ -0,0 +1,2 @@ +#!/bin/sed -rf +s,test_prov[0-9]*,test_provXXXX,g; s,^ *[0-9]+, XX,g;
test/unittest/dtrace-util/tst.ListProbesArgsUSDT.sh new file +89 -0
89 lines not on this page · raw message
test/unittest/usdt/err.argmap-null.d new file +41 -0
41 lines not on this page · raw message
test/unittest/usdt/err.argmap-null.r new file +2 -0
@@ -0,0 +1,2 @@ +-- @@stderr -- +dtrace: failed to compile script test/unittest/usdt/err.argmap-null.d: line 24: index 0 is out of range for test_provXXXX:::place4 args[ ]
test/unittest/usdt/err.argmap-null.r.p new file +2 -0
@@ -0,0 +1,2 @@ +#!/bin/sed -rf +s,test_prov[0-9]*,test_provXXXX,g; s,^ *[0-9]+, XX,g;
test/unittest/usdt/tst.argmap-null.d new file +32 -0
@@ -0,0 +1,32 @@ +/* + * Oracle Linux DTrace. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Licensed under the Universal Permissive License v 1.0 as shown at + * http://oss.oracle.com/licenses/upl. + */ + +/* @@trigger: usdt-tst-argmap */ +/* @@trigger-timing: before */ +/* @@runtest-opts: $_pid */ + +/* + * ASSERTION: Verify that you can map to no args at all. + */ + +BEGIN +{ + /* Timeout after 5 seconds */ + timeout = timestamp + 5000000000; +} + +test_prov$1:::place4 +{ + exit(0); +} + +profile:::tick-1 +/timestamp > timeout/ +{ + trace("test timed out"); + exit(1); +}
test/unittest/usdt/tst.argmap-typed-partial.d new file +49 -0
49 lines not on this page · raw message
test/unittest/usdt/tst.argmap-typed.d new file +48 -0
48 lines not on this page · raw message
test/unittest/usdt/tst.argmap.d +2 -3
@@ -1,17 +1,16 @@ /* * Oracle Linux DTrace. - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* @@trigger: usdt-tst-argmap */ /* @@trigger-timing: before */ /* @@runtest-opts: $_pid */ /* - * ASSERTION: Verify that argN and args[N] variables are properly remapped. + * ASSERTION: Verify that argN and args[N] variables are properly mapped. */ BEGIN
Signature · 1 line
2.46.0.278.g36e3a12567
PATCH v7 5/6 usdt: new tests for USDT arg sanity with overlapping pid probes
In reply to Nick AlcockThis generalizes the existing tst.pidprobes.sh to check the args reported by the probe both with and without arg mapping in place.
Everything seems to work.
---
.../usdt/{tst.pidprobes.sh => pidprobes.sh} | 56 +++++++++++++++----
test/unittest/usdt/tst.pidargmap.sh | 11 ++++
test/unittest/usdt/tst.pidargs.sh | 11 ++++
3 files changed, 67 insertions(+), 11 deletions(-)
rename test/unittest/usdt/{tst.pidprobes.sh => pidprobes.sh} (82%)
create mode 100755 test/unittest/usdt/tst.pidargmap.sh
create mode 100755 test/unittest/usdt/tst.pidargs.shtest/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +45 -11
@@ -5,9 +5,12 @@ # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. # -# This test verifies that USDT and pid probes can share underlying probes. +# This test verifies various properties of USDT and pid probes sharing +# underlying probes. dtrace=$1 +usdt=$2 +mapping=$3 # Set up test directory.
@@ -17,13 +20,21 @@ cd $DIRNAME # Create test source files. -cat > prov.d <<EOF +if [[ -z $mapping ]]; then + cat > prov.d <<EOF provider pyramid { probe entry(int, char, int, int); }; EOF +else + cat > prov.d <<EOF +provider pyramid { + probe entry(int a, char b, int c, int d) : (int c, int d, int a, char b); +}; +EOF +fi -cat > main.c <<EOF +cat > main.c <<'EOF' #include <stdio.h> #include "prov.h"
@@ -48,7 +59,7 @@ EOF # Build the test program. -$dtrace -h -s prov.d +$dtrace $dt_flags -h -s prov.d if [ $? -ne 0 ]; then echo "failed to generate header file" >&2 exit 1
@@ -61,12 +72,12 @@ fi if [[ `uname -m` = "aarch64" ]]; then objdump -d main.o > disasm_foo.txt.before fi -$dtrace -G -64 -s prov.d main.o +$dtrace $dt_flags -G -64 -s prov.d main.o if [ $? -ne 0 ]; then echo "failed to create DOF" >&2 exit 1 fi -cc $test_cppflags -o main main.o prov.o +cc $test_ldflags -o main main.o prov.o if [ $? -ne 0 ]; then echo "failed to link final executable" >&2 exit 1
@@ -75,7 +86,7 @@ fi # Check that the program output is 0 when the USDT probe is not enabled. # That is, the PYRAMID_ENTRY_ENABLED() is-enabled checks should not pass. -./main > main.out +./main standalone > main.out echo "my result: 0" > main.out.expected if ! diff -q main.out main.out.expected > /dev/null; then echo '"my result"' looks wrong when not using DTrace
@@ -88,11 +99,25 @@ fi # Run dtrace. -$dtrace $dt_flags -q -c ./main -o dtrace.out -n ' +cat >> pidprobes.d <<'EOF' p*d$target::foo: { printf("%d %s:%s:%s:%s %x\n", pid, probeprov, probemod, probefunc, probename, uregs[R_PC]); -}' > main.out2 +} +EOF + +if [[ -n $usdt ]]; then + echo 'pyramid$target::foo: {' >> pidprobes.d + + if [[ -n $mapping ]]; then + echo 'printf("%d %s:%s:%s:%s %i %i %i %c\n", pid, probeprov, probemod, probefunc, probename, args[0], args[1], args[2], args[3]);' >> pidprobes.d + else + echo 'printf("%d %s:%s:%s:%s %i %c %i %i\n", pid, probeprov, probemod, probefunc, probename, args[0], args[1], args[2], args[3]);' >> pidprobes.d + fi + echo '}' >> pidprobes.d +fi + +$dtrace $dt_flags -q -c ./main -o dtrace.out -s pidprobes.d > main.out2 if [ $? -ne 0 ]; then echo "failed to run dtrace" >&2 cat main.out2
@@ -106,7 +131,7 @@ fi echo "my result: 10" > main.out2.expected if ! diff -q main.out2 main.out2.expected > /dev/null; then - echo '"my result"' looks wrong when using DTrace + echo '"my result"' looks wrong echo === got === cat main.out2 echo === expected ===
@@ -262,8 +287,17 @@ for pc in $pcs; do done echo $usdt_pcs | awk '{printf("'$pid' pyramid'$pid':main:foo:entry %x\n", $1);}' >> dtrace.out.expected echo $usdt_pcs | awk '{printf("'$pid' pyramid'$pid':main:foo:entry %x\n", $2);}' >> dtrace.out.expected +if [[ -n $usdt ]]; then + if [[ -z $mapping ]]; then + echo "$pid pyramid$pid:main:foo:entry 2 a 16 128" >> dtrace.out.expected + echo "$pid pyramid$pid:main:foo:entry 4 b 32 256" >> dtrace.out.expected + else + echo "$pid pyramid$pid:main:foo:entry 16 128 2 a" >> dtrace.out.expected + echo "$pid pyramid$pid:main:foo:entry 32 256 4 b" >> dtrace.out.expected + fi +fi -# Sort and check. +# Sort and check (dropping any wake-up firings from deferred probing). sort dtrace.out > dtrace.out.sorted sort dtrace.out.expected > dtrace.out.expected.sorted
test/unittest/usdt/tst.pidargmap.sh new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/bash +# +# Oracle Linux DTrace. +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# +# This test verifies that USDT and pid probes that share underlying probes +# do not apply arg mappings (incorrectly) to the pid probes. + +exec $(dirname $_test)/pidprobes.sh $1 t t
test/unittest/usdt/tst.pidargs.sh new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/bash +# +# Oracle Linux DTrace. +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# +# This test verifies that USDT and pid probes that share underlying probes +# get the arguments correct for the USDT probes. + +exec $(dirname $_test)/pidprobes.sh $1 t ""
Signature · 1 line
2.46.0.278.g36e3a12567
Re: [PATCH v7 5/6] usdt: new tests for USDT arg sanity with overlapping pid probes
Quoted 4 lines · Nick Alcock
This generalizes the existing
tst.pidprobes.shto check the args reported by the probe both with and without arg mapping in place.Everything seems to work.
That comment seems to be unnecessary.
Also, is there a "dtrace -lv" test for USDT args? (I'm not even sure if that question makes sense.)
Quoted 3 lines
Signed-off-by Nick Alcock <[email protected]>--- .../usdt/{tst.pidprobes.sh => pidprobes.sh} | 56 +++++++++++++++----
Why the renaming? And, will "./runtest.sh" run pidprobes.sh without any command-line args?
Quoted 15 lines
test/unittest/usdt/tst.pidargmap.sh | 11 ++++ test/unittest/usdt/tst.pidargs.sh | 11 ++++ 3 files changed, 67 insertions(+), 11 deletions(-)rename
test/unittest/usdt/{tst.pidprobes.sh=>pidprobes.sh} (82%) create mode 100755test/unittest/usdt/tst.pidargmap.shcreate mode 100755test/unittest/usdt/tst.pidargs.shtest/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +0
-0
test/unittest/usdt/pidprobes.sh line 12
Quoted 9 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +3
-1@@ -5,9 +5,12 @@ # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. # -# This test verifies that USDT and pid probes can share underlying probes. +# This test verifies various properties of USDT and pid probes sharing +# underlying probes. dtrace=$1 +usdt=$2
Why is there a usdt=$2? It seems that usdt is always "t" and you'd expect that in test/unittest/usdt.
Quoted 53 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +14
-5+mapping=$3 # Set up test directory.@@ -17,13 +20,21 @@ cd $DIRNAME # Create test source files. -cat > prov.d <<EOF +if [[ -z $mapping ]]; then + cat > prov.d <<EOF provider pyramid { probe entry(int, char, int, int); }; EOF +else + cat > prov.d <<EOF +provider pyramid { + probe entry(int a, char b, int c, int d) : (int c, int d, int a, char b); +}; +EOF +fi -cat > main.c <<EOF +cat > main.c <<'EOF' #include <stdio.h> #include "prov.h"@@ -48,7 +59,7 @@ EOF # Build the test program. -$dtrace -h -s prov.d +$dtrace $dt_flags -h -s prov.d if [ $? -ne 0 ]; then echo "failed to generate header file" >&2 exit 1@@ -61,12 +72,12 @@ fi if [[ `uname -m` = "aarch64" ]]; then objdump -d main.o > disasm_foo.txt.before fi -$dtrace -G -64 -s prov.d main.o +$dtrace $dt_flags -G -64 -s prov.d main.o if [ $? -ne 0 ]; then echo "failed to create DOF" >&2 exit 1 fi -cc $test_cppflags -o main main.o prov.o +cc $test_ldflags -o main main.o prov.o if [ $? -ne 0 ]; then echo "failed to link final executable" >&2 exit 1
test/unittest/usdt/pidprobes.sh fi · line 89
Quoted 5 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +1
-1@@ -75,7 +86,7 @@ fi # Check that the program output is 0 when the USDT probe is not enabled. # That is, the PYRAMID_ENTRY_ENABLED() is-enabled checks should not pass. -./main > main.out +./main standalone > main.out
I'd vote against this change. Introducing a command-line arg that is not used? Or, add it as a comment? But there is already a comment.
Quoted 32 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +16
-2echo "my result: 0" > main.out.expected if ! diff -q main.out main.out.expected > /dev/null; then echo '"my result"' looks wrong when not using DTrace@@ -88,11 +99,25 @@ fi # Run dtrace. -$dtrace $dt_flags -q -c ./main -o dtrace.out -n ' +cat >> pidprobes.d <<'EOF' p*d$target::foo: { printf("%d %s:%s:%s:%s %x\n", pid, probeprov, probemod, probefunc, probename, uregs[R_PC]); -}' > main.out2 +} +EOF + +if [[ -n $usdt ]]; then + echo 'pyramid$target::foo: {' >> pidprobes.d + + if [[ -n $mapping ]]; then + echo 'printf("%d %s:%s:%s:%s %i %i %i %c\n", pid, probeprov, probemod, probefunc, probename, args[0], args[1], args[2], args[3]);' >> pidprobes.d + else + echo 'printf("%d %s:%s:%s:%s %i %c %i %i\n", pid, probeprov, probemod, probefunc, probename, args[0], args[1], args[2], args[3]);' >> pidprobes.d + fi + echo '}' >> pidprobes.d +fi + +$dtrace $dt_flags -q -c ./main -o dtrace.out -s pidprobes.d > main.out2 if [ $? -ne 0 ]; then echo "failed to run dtrace" >&2 cat main.out2
test/unittest/usdt/pidprobes.sh fi · line 134
Quoted 5 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +1
-1@@ -106,7 +131,7 @@ fi echo "my result: 10" > main.out2.expected if ! diff -q main.out2 main.out2.expected > /dev/null; then - echo '"my result"' looks wrong when using DTrace + echo '"my result"' looks wrong
Why? In particular, "when using DTrace" stands in contrast to the earlier message 'echo '"my result"' looks wrong when not using DTrace'.
Quoted 9 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +2
-0echo === got === cat main.out2 echo === expected ===@@ -262,8 +287,17 @@ for pc in $pcs; do done echo $usdt_pcs | awk '{printf("'$pid' pyramid'$pid':main:foo:entry %x\n", $1);}' >> dtrace.out.expected echo $usdt_pcs | awk '{printf("'$pid' pyramid'$pid':main:foo:entry %x\n", $2);}' >> dtrace.out.expected +if [[ -n $usdt ]]; then + if [[ -z $mapping ]]; then
test/unittest/usdt/pidprobes.sh for pc in $pcs; do · line 300
Quoted 10 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +8
-1+ echo "$pid pyramid$pid:main:foo:entry 2 a 16 128" >> dtrace.out.expected + echo "$pid pyramid$pid:main:foo:entry 4 b 32 256" >> dtrace.out.expected + else + echo "$pid pyramid$pid:main:foo:entry 16 128 2 a" >> dtrace.out.expected + echo "$pid pyramid$pid:main:foo:entry 32 256 4 b" >> dtrace.out.expected + fi +fi -# Sort and check. +# Sort and check (dropping any wake-up firings from deferred probing).
I guess I do not get this. Where does any "dropping" take place?
Quoted 9 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +0
-0sort dtrace.out > dtrace.out.sorted sort dtrace.out.expected > dtrace.out.expected.sortedtest/unittest/usdt/tst.pidargmap.sh new file +0
-0
test/unittest/usdt/tst.pidargmap.sh line 9
Quoted 9 lines
test/unittest/usdt/tst.pidargmap.sh new file +9
-0@@ -0,0 +1,11 @@ +#!/bin/bash +# +# Oracle Linux DTrace. +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# +# This test verifies that USDT and pid probes that share underlying probes +# do not apply arg mappings (incorrectly) to the pid probes.
How do we verify that mappings do not apply (incorrectly) to pid probes? Is there supposed to be a check on pid probe args?
Quoted 19 lines
test/unittest/usdt/tst.pidargmap.sh new file +2
-0+ +exec $(dirname $_test)/pidprobes.sh $1 t ttest/unittest/usdt/tst.pidargs.sh new file +11
-0@@ -0,0 +1,11 @@ +#!/bin/bash +# +# Oracle Linux DTrace. +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# +# This test verifies that USDT and pid probes that share underlying probes +# get the arguments correct for the USDT probes. + +exec $(dirname $_test)/pidprobes.sh $1 t ""
Re: [PATCH v7 5/6] usdt: new tests for USDT arg sanity with overlapping pid probes
On 7 Nov 2024, Eugene Loh uttered the following:
Quoted 8 lines · Nick Alcock
Quoted 5 lines
This generalizes the existing
tst.pidprobes.shto check the args reported by the probe both with and without arg mapping in place.Everything seems to work.
That comment seems to be unnecessary.
I think it's worth noting that all this arg-mapping infrastructure (mostly entirely untested for fifteen years) still works :)
Quoted 1 line
Also, is there a "dtrace -lv" test for USDT args? (I'm not even sure if that question makes sense.)
Yep. See the previous patch. (Multiple, actually, Kris had me add a few more.)
Quoted 5 lines
Quoted 3 lines
Signed-off-by Nick Alcock <[email protected]>--- .../usdt/{tst.pidprobes.sh => pidprobes.sh} | 56 +++++++++++++++----Why the renaming? And, will "./runtest.sh" run
pidprobes.shwithout any command-line args?
Nope! It's a library now, called by tst.pid*sh, including, uh, the new tst.pidprobes.sh I meant to keep around and call it. Oops!
Quoted 5 lines
Quoted 5 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +0
-0@@ -5,9 +5,12 @@ # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl.
Quoted 8 lines
test/unittest/usdt/pidprobes.sh line 12
Quoted 6 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +3
-1# -# This test verifies that USDT and pid probes can share underlying probes. +# This test verifies various properties of USDT and pid probes sharing +# underlying probes. dtrace=$1 +usdt=$2Why is there a usdt=$2? It seems that usdt is always "t" and you'd expect that in test/unittest/usdt.
Oh crap. Sorry sorry this is a bug -- I lost the tst.pidprobes.sh I meant to add back. Will fix and repush this patch.
-- which reads, in entirety
exec $(dirname $_test)/pidprobes.sh $1 "" ""
Quoted 8 lines
test/unittest/usdt/pidprobes.sh fi · line 89
Quoted 5 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +1
-0@@ -75,7 +86,7 @@ fi # Check that the program output is 0 when the USDT probe is not enabled. # That is, the PYRAMID_ENTRY_ENABLED() is-enabled checks should not pass. -./main > main.out +./main standalone > main.outI'd vote against this change. Introducing a command-line arg that is not used? Or, add it as a comment? But there is already a comment.
I... think that was fallout from my attempt to add deferred support that I forgot to clean out again. Dropped.
Quoted 7 lines
test/unittest/usdt/pidprobes.sh fi · line 134
Quoted 4 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +1
-1echo "my result: 10" > main.out2.expected if ! diff -q main.out2 main.out2.expected > /dev/null; then - echo '"my result"' looks wrong when using DTrace + echo '"my result"' looks wrongWhy? In particular, "when using DTrace" stands in contrast to the earlier message 'echo '"my result"' looks wrong when not using DTrace'.
Sorry! I didn't notice that the previous stanza existed and thought "well of course we're using DTrace, that's redundant". Dropped.
Quoted 4 lines
Quoted 2 lines
-# Sort and check.
+# Sort and check (dropping any wake-up firings from deferred probing).I guess I do not get this. Where does any "dropping" take place?
In the deferred patch that caused massive ructions here and then I tried to drop by hand very late at night and clearly didn't do as good a job at as I thought I did. Dropped this reference to, uh, dropping.
Quoted 11 lines
Quoted 11 lines
sort dtrace.out > dtrace.out.sorted
sort dtrace.out.expected > dtrace.out.expected.sortedtest/unittest/usdt/tst.pidargmap.sh new file +3
-0@@ -0,0 +1,11 @@ +#!/bin/bash +# +# Oracle Linux DTrace.
Quoted 8 lines
test/unittest/usdt/tst.pidargmap.sh line 9
Quoted 6 lines
test/unittest/usdt/tst.pidargmap.sh new file +6
-0+# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# +# This test verifies that USDT and pid probes that share underlying probes +# do not apply arg mappings (incorrectly) to the pid probes.How do we verify that mappings do not apply (incorrectly) to pid probes? Is there supposed to be a check on pid probe args?
Yeah, that's back now, apologies :) verified that it still works, too. Will send as a followup to this reply in a mo.
Signature · 1 line
NULL && (void)
PATCH v8 5/6 usdt: new tests for USDT arg sanity with overlapping pid probes
This generalizes the existing tst.pidprobes.sh to check the args reported by the probe both with and without arg mapping in place.
Everything seems to work.
---
.../usdt/{tst.pidprobes.sh => pidprobes.sh} | 50 +++-
test/unittest/usdt/tst.pidargmap.sh | 11 +
test/unittest/usdt/tst.pidargs.sh | 11 +
test/unittest/usdt/tst.pidprobes.sh | 275 +-----------------
4 files changed, 65 insertions(+), 282 deletions(-)
copy test/unittest/usdt/{tst.pidprobes.sh => pidprobes.sh} (84%)
create mode 100755 test/unittest/usdt/tst.pidargmap.sh
create mode 100755 test/unittest/usdt/tst.pidargs.shtest/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +42 -8
@@ -5,9 +5,12 @@ # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. # -# This test verifies that USDT and pid probes can share underlying probes. +# This test verifies various properties of USDT and pid probes sharing +# underlying probes. dtrace=$1 +usdt=$2 +mapping=$3 # Set up test directory.
@@ -17,13 +20,21 @@ cd $DIRNAME # Create test source files. -cat > prov.d <<EOF +if [[ -z $mapping ]]; then + cat > prov.d <<EOF provider pyramid { probe entry(int, char, int, int); }; EOF +else + cat > prov.d <<EOF +provider pyramid { + probe entry(int a, char b, int c, int d) : (int c, int d, int a, char b); +}; +EOF +fi -cat > main.c <<EOF +cat > main.c <<'EOF' #include <stdio.h> #include "prov.h"
@@ -48,7 +59,7 @@ EOF # Build the test program. -$dtrace -h -s prov.d +$dtrace $dt_flags -h -s prov.d if [ $? -ne 0 ]; then echo "failed to generate header file" >&2 exit 1
@@ -61,12 +72,12 @@ fi if [[ `uname -m` = "aarch64" ]]; then objdump -d main.o > disasm_foo.txt.before fi -$dtrace -G -64 -s prov.d main.o +$dtrace $dt_flags -G -64 -s prov.d main.o if [ $? -ne 0 ]; then echo "failed to create DOF" >&2 exit 1 fi -cc $test_cppflags -o main main.o prov.o +cc $test_ldflags -o main main.o prov.o if [ $? -ne 0 ]; then echo "failed to link final executable" >&2 exit 1
@@ -88,11 +99,25 @@ fi # Run dtrace. -$dtrace $dt_flags -q -c ./main -o dtrace.out -n ' +cat >> pidprobes.d <<'EOF' p*d$target::foo: { printf("%d %s:%s:%s:%s %x\n", pid, probeprov, probemod, probefunc, probename, uregs[R_PC]); -}' > main.out2 +} +EOF + +if [[ -n $usdt ]]; then + echo 'pyramid$target::foo: {' >> pidprobes.d + + if [[ -n $mapping ]]; then + echo 'printf("%d %s:%s:%s:%s %i %i %i %c\n", pid, probeprov, probemod, probefunc, probename, args[0], args[1], args[2], args[3]);' >> pidprobes.d + else + echo 'printf("%d %s:%s:%s:%s %i %c %i %i\n", pid, probeprov, probemod, probefunc, probename, args[0], args[1], args[2], args[3]);' >> pidprobes.d + fi + echo '}' >> pidprobes.d +fi + +$dtrace $dt_flags -q -c ./main -o dtrace.out -s pidprobes.d > main.out2 if [ $? -ne 0 ]; then echo "failed to run dtrace" >&2 cat main.out2
@@ -262,6 +287,15 @@ for pc in $pcs; do done echo $usdt_pcs | awk '{printf("'$pid' pyramid'$pid':main:foo:entry %x\n", $1);}' >> dtrace.out.expected echo $usdt_pcs | awk '{printf("'$pid' pyramid'$pid':main:foo:entry %x\n", $2);}' >> dtrace.out.expected +if [[ -n $usdt ]]; then + if [[ -z $mapping ]]; then + echo "$pid pyramid$pid:main:foo:entry 2 a 16 128" >> dtrace.out.expected + echo "$pid pyramid$pid:main:foo:entry 4 b 32 256" >> dtrace.out.expected + else + echo "$pid pyramid$pid:main:foo:entry 16 128 2 a" >> dtrace.out.expected + echo "$pid pyramid$pid:main:foo:entry 32 256 4 b" >> dtrace.out.expected + fi +fi # Sort and check.
test/unittest/usdt/tst.pidargmap.sh new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/bash +# +# Oracle Linux DTrace. +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# +# This test verifies that USDT and pid probes that share underlying probes +# do not apply arg mappings (incorrectly) to the pid probes. + +exec $(dirname $_test)/pidprobes.sh $1 t t
test/unittest/usdt/tst.pidargs.sh new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/bash +# +# Oracle Linux DTrace. +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# +# This test verifies that USDT and pid probes that share underlying probes +# get the arguments correct for the USDT probes. + +exec $(dirname $_test)/pidprobes.sh $1 t ""
test/unittest/usdt/tst.pidprobes.sh +1 -274
278 lines not on this page · raw message
Signature · 1 line
2.46.0.278.g36e3a12567
Re: [PATCH v7 5/6] usdt: new tests for USDT arg sanity with overlapping pid probes
In reply to Nick AlcockQuoted 9 lines · Nick Alcock
On 7 Nov 2024, Eugene Loh uttered the following:
Quoted 5 lines · Nick Alcock
Quoted 3 lines
Signed-off-by Nick Alcock <[email protected]>--- .../usdt/{tst.pidprobes.sh => pidprobes.sh} | 56 +++++++++++++++----Why the renaming? And, will "./runtest.sh" run
pidprobes.shwithout any command-line args?Nope! It's a library now, called by tst.pid*sh, including, uh, the new
tst.pidprobes.shI meant to keep around and call it. Oops!
"Nope"? It seems to me that runtest.sh does indeed call pidprobes.sh without any command-line args. It looks in test/unittest/usdt and sees a .sh file and runs it. The fact that the .sh does not start with "tst." is irrelevant. Indeed, we have lots of tests that do not start with "tst." (nor "err." nor "drp." etc.). So if pidprobes.sh is not supposed to be run by runtest.sh directly, it has to be hidden better than simply by stripping tst. from its name.
I suppose there is no harm in runtest.sh running pidprobes.sh directly (with no command-line arguments) except generations from now someone will be wondering what it's supposed to do.
Incidentally, there is an orphaned tst.pidprobes.r file.
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +0
-0@@ -5,9 +5,12 @@ # Licensed under the Universal Permissive License v 1.0 as shown atQuoted 8 lines
test/unittest/usdt/pidprobes.sh line 12
Quoted 7 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +3
-1# http://oss.oracle.com/licenses/upl. # -# This test verifies that USDT and pid probes can share underlying probes. +# This test verifies various properties of USDT and pid probes sharing +# underlying probes. dtrace=$1 +usdt=$2Why is there a usdt=$2? It seems that usdt is always "t" and you'd expect that in test/unittest/usdt.
Quoted 2 lines
Oh crap. Sorry sorry this is a bug -- I lost the
tst.pidprobes.shI meant to add back. Will fix and repush this patch.
The patch has perhaps already landed. So, a delta patch might be needed.
Quoted 3 lines
-- which reads, in entirety
exec $(dirname $_test)/pidprobes.sh $1 "" ""
Or, just let runtest.sh call it directly, as it does anyhow.
Re: [PATCH v7 5/6] usdt: new tests for USDT arg sanity with overlapping pid probes
On 8 Nov 2024, Eugene Loh outgrape:
Quoted 12 lines · Nick Alcock
Quoted 10 lines
On 7 Nov 2024, Eugene Loh uttered the following:
Quoted 5 lines · Nick Alcock
Quoted 3 lines
Signed-off-by Nick Alcock <[email protected]>--- .../usdt/{tst.pidprobes.sh => pidprobes.sh} | 56 +++++++++++++++----Why the renaming? And, will "./runtest.sh" run
pidprobes.shwithout any command-line args?Nope! It's a library now, called by tst.pid*sh, including, uh, the new
tst.pidprobes.shI meant to keep around and call it. Oops!
Quoted 7 lines
"Nope"? It seems to me that
runtest.shdoes indeed callpidprobes.shwithout any command-line args. It looks in test/unittest/usdt and sees a .sh file and runs it. The fact that the .sh does not start with "tst." is irrelevant. Indeed, we have lots of tests that do not start with "tst." (nor "err." nor "drp." etc.). So ifpidprobes.shis not supposed to be run byruntest.shdirectly, it has to be hidden better than simply by stripping tst. from its name.
What? That's not what's supposed to happen!
... oh, wait, I'm wrong, I'm thinking of tst.* versus err.*, but of course non-tst stuff runs anyway.
I guess library things have to have non-.sh extensions?
Quoted 1 line
Incidentally, there is an orphaned tst.pidprobes.r file.
Yeah, that's the bug :) there's suppoed to be a tst.pidprobes.sh -- and now (as of my most recent push, and mail here) there is again.
It was not my intention to disappear your test! :)
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
test/unittest/usdt/pidprobes.sh line 11
Quoted 11 lines
test/unittest/usdt/pidprobes.sh renamed from test/unittest/usdt/tst.pidprobes.sh +3
-1@@ -5,9 +5,12 @@ # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. # -# This test verifies that USDT and pid probes can share underlying probes. +# This test verifies various properties of USDT and pid probes sharing +# underlying probes. dtrace=$1 +usdt=$2Why is there a usdt=$2? It seems that usdt is always "t" and you'd expect that in test/unittest/usdt.
Quoted 4 lines
Quoted 2 lines
Oh crap. Sorry sorry this is a bug -- I lost the
tst.pidprobes.shI meant to add back. Will fix and repush this patch.The patch has perhaps already landed. So, a delta patch might be needed.
Sigh.
Quoted 5 lines
Quoted 3 lines
-- which reads, in entirety
exec $(dirname $_test)/pidprobes.sh $1 "" ""
Or, just let
runtest.shcall it directly, as it does anyhow.
In which case I could rename it back to tst.pidprobes.sh and have other things call that (and have it default to the behaviour it had before if called with no args)... does that sound better?
Signature · 1 line
NULL && (void)
PATCH v7 6/6 usdt: fix create_underlying error path
In reply to Nick AlcockOn error, we were destroying the underlying probe using the wrong call, as if it were an overlying probe.
--- libdtrace/dt_prov_uprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libdtrace/dt_prov_uprobe.c +1 -1
@@ -714,7 +714,7 @@ static dt_probe_t *create_underlying(dtrace_hdl_t *dtp, fail:dt_dprintf ("Failed to instantiate %s:%s:%s:%s\n" , psp->pps_prv, psp->pps_mod, psp->pps_fn, psp->pps_prb); -probe_destroy (dtp, upp); +probe_destroy_underlying (dtp, upp);return NULL ; }
Signature · 1 line
2.46.0.278.g36e3a12567