* [PATCH] vars; ensure 'cwd' and 'root' work and test other inline vars
@ 2025-08-06 22:25 Kris Van Hees
2025-08-06 23:22 ` Eugene Loh
0 siblings, 1 reply; 3+ messages in thread
From: Kris Van Hees @ 2025-08-06 22:25 UTC (permalink / raw)
To: dtrace, dtrace-devel
Inline variable declarations that provide a tstring value were not
ensuring that tstring data got propagated correctly.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
---
libdtrace/dt_cg.c | 8 ++++++
.../variables/inline/tst.procfs-cwd.d | 28 +++++++++++++++++++
.../variables/inline/tst.procfs-root.d | 28 +++++++++++++++++++
.../variables/inline/tst.sched-chip.d | 28 +++++++++++++++++++
.../unittest/variables/inline/tst.sched-cpu.d | 28 +++++++++++++++++++
.../variables/inline/tst.sched-lgrp.d | 28 +++++++++++++++++++
.../variables/inline/tst.sched-pset.d | 28 +++++++++++++++++++
7 files changed, 176 insertions(+)
create mode 100644 test/unittest/variables/inline/tst.procfs-cwd.d
create mode 100644 test/unittest/variables/inline/tst.procfs-root.d
create mode 100644 test/unittest/variables/inline/tst.sched-chip.d
create mode 100644 test/unittest/variables/inline/tst.sched-cpu.d
create mode 100644 test/unittest/variables/inline/tst.sched-lgrp.d
create mode 100644 test/unittest/variables/inline/tst.sched-pset.d
diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 27919bbdf..707c3fbe3 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -6954,7 +6954,15 @@ dt_cg_inline(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
}
dt_cg_node(inp->din_root, dlp, drp);
+
+ /*
+ * Copy the result into dnp (register value and tstring). We need to
+ * clear the tstring from tnp once we move it to dnp.
+ */
dnp->dn_reg = inp->din_root->dn_reg;
+ dnp->dn_tstring = inp->din_root->dn_tstring;
+ inp->din_root->dn_tstring;
+
dt_cg_typecast(inp->din_root, dnp, dlp, drp);
if (idp->di_kind == DT_IDENT_ARRAY) {
diff --git a/test/unittest/variables/inline/tst.procfs-cwd.d b/test/unittest/variables/inline/tst.procfs-cwd.d
new file mode 100644
index 000000000..c8760f676
--- /dev/null
+++ b/test/unittest/variables/inline/tst.procfs-cwd.d
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+
+/*
+ * ASSERTION: The 'cwd' inline variable returns the default value.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ trace(cwd);
+}
+
+BEGIN
+/cwd == "<unknown>"/
+{
+ exit(0);
+}
+
+BEGIN,
+ERROR {
+ exit(1);
+}
diff --git a/test/unittest/variables/inline/tst.procfs-root.d b/test/unittest/variables/inline/tst.procfs-root.d
new file mode 100644
index 000000000..276731c24
--- /dev/null
+++ b/test/unittest/variables/inline/tst.procfs-root.d
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+
+/*
+ * ASSERTION: The 'root' inline variable returns the default value.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ trace(root);
+}
+
+BEGIN
+/root == "<unknown>"/
+{
+ exit(0);
+}
+
+BEGIN,
+ERROR {
+ exit(1);
+}
diff --git a/test/unittest/variables/inline/tst.sched-chip.d b/test/unittest/variables/inline/tst.sched-chip.d
new file mode 100644
index 000000000..c1c314149
--- /dev/null
+++ b/test/unittest/variables/inline/tst.sched-chip.d
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+
+/*
+ * ASSERTION: The 'chip' inline variable returns the correct value.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ trace(chip);
+}
+
+BEGIN
+/chip == curcpu->cpu_chip/
+{
+ exit(0);
+}
+
+BEGIN,
+ERROR {
+ exit(1);
+}
diff --git a/test/unittest/variables/inline/tst.sched-cpu.d b/test/unittest/variables/inline/tst.sched-cpu.d
new file mode 100644
index 000000000..542cad7a1
--- /dev/null
+++ b/test/unittest/variables/inline/tst.sched-cpu.d
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+
+/*
+ * ASSERTION: The 'cpu' inline variable returns the correct value.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ trace(cpu);
+}
+
+BEGIN
+/cpu == curcpu->cpu_id/
+{
+ exit(0);
+}
+
+BEGIN,
+ERROR {
+ exit(1);
+}
diff --git a/test/unittest/variables/inline/tst.sched-lgrp.d b/test/unittest/variables/inline/tst.sched-lgrp.d
new file mode 100644
index 000000000..0ddf20180
--- /dev/null
+++ b/test/unittest/variables/inline/tst.sched-lgrp.d
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+
+/*
+ * ASSERTION: The 'lgrp' inline variable returns the correct value.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ trace(lgrp);
+}
+
+BEGIN
+/lgrp == curcpu->cpu_lgrp/
+{
+ exit(0);
+}
+
+BEGIN,
+ERROR {
+ exit(1);
+}
diff --git a/test/unittest/variables/inline/tst.sched-pset.d b/test/unittest/variables/inline/tst.sched-pset.d
new file mode 100644
index 000000000..a7c946bce
--- /dev/null
+++ b/test/unittest/variables/inline/tst.sched-pset.d
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+
+/*
+ * ASSERTION: The 'pset' inline variable returns the correct value.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ trace(pset);
+}
+
+BEGIN
+/pset == curcpu->cpu_pset/
+{
+ exit(0);
+}
+
+BEGIN,
+ERROR {
+ exit(1);
+}
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vars; ensure 'cwd' and 'root' work and test other inline vars
2025-08-06 22:25 [PATCH] vars; ensure 'cwd' and 'root' work and test other inline vars Kris Van Hees
@ 2025-08-06 23:22 ` Eugene Loh
2025-08-06 23:33 ` Kris Van Hees
0 siblings, 1 reply; 3+ messages in thread
From: Eugene Loh @ 2025-08-06 23:22 UTC (permalink / raw)
To: Kris Van Hees, dtrace, dtrace-devel
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
Should an Orabug: be included? (maybe not... figured I'd ask)
Also...
On 8/6/25 18:25, Kris Van Hees wrote:
> + /*
> + * Copy the result into dnp (register value and tstring). We need to
> + * clear the tstring from tnp once we move it to dnp.
> + */
> dnp->dn_reg = inp->din_root->dn_reg;
> + dnp->dn_tstring = inp->din_root->dn_tstring;
> + inp->din_root->dn_tstring;
That last line should be removed?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vars; ensure 'cwd' and 'root' work and test other inline vars
2025-08-06 23:22 ` Eugene Loh
@ 2025-08-06 23:33 ` Kris Van Hees
0 siblings, 0 replies; 3+ messages in thread
From: Kris Van Hees @ 2025-08-06 23:33 UTC (permalink / raw)
To: Eugene Loh; +Cc: Kris Van Hees, dtrace, dtrace-devel
On Wed, Aug 06, 2025 at 07:22:17PM -0400, Eugene Loh wrote:
> Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
> Should an Orabug: be included? (maybe not... figured I'd ask)
> Also...
>
> On 8/6/25 18:25, Kris Van Hees wrote:
> > + /*
> > + * Copy the result into dnp (register value and tstring). We need to
> > + * clear the tstring from tnp once we move it to dnp.
> > + */
> > dnp->dn_reg = inp->din_root->dn_reg;
> > + dnp->dn_tstring = inp->din_root->dn_tstring;
> > + inp->din_root->dn_tstring;
>
> That last line should be removed?
Woops, that ought to be = NULL; Will fix and send v2.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-06 23:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-06 22:25 [PATCH] vars; ensure 'cwd' and 'root' work and test other inline vars Kris Van Hees
2025-08-06 23:22 ` Eugene Loh
2025-08-06 23:33 ` Kris Van Hees
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).