[DTrace-devel] [PATCH] Add test for default value of string type TLS variables

Kris Van Hees kris.van.hees at oracle.com
Fri Mar 4 21:00:20 UTC 2022


The default value of any unknosn TLS variable is 0.  This means that
a TLS variable of type string will contain NULL.  THis test verifies
that by detecting the invalid address fault on address 0x0.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 test/unittest/variables/tvar/tst.init-str.d | 28 +++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 test/unittest/variables/tvar/tst.init-str.d

diff --git a/test/unittest/variables/tvar/tst.init-str.d b/test/unittest/variables/tvar/tst.init-str.d
new file mode 100644
index 00000000..47d3eab6
--- /dev/null
+++ b/test/unittest/variables/tvar/tst.init-str.d
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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: Thread-local string variables are initialized to 0.  Trying to
+ *	      trace() it will result in a 'invalid address 0x0' fault.
+ *
+ * SECTION: Variables/Thread-Local Variables
+ */
+
+#pragma D option quiet
+
+self string x;
+
+BEGIN
+{
+	trace(self->x);
+	exit(1);
+}
+
+ERROR
+{
+	exit(arg4 != 1 || arg5 != 0);
+}
-- 
2.34.1




More information about the DTrace-devel mailing list