]> sourceware.org Git - systemtap.git/commitdiff
Fix condition propagation across aliases
authorJosh Stone <jistone@redhat.com>
Wed, 10 Jun 2009 02:58:15 +0000 (19:58 -0700)
committerJosh Stone <jistone@redhat.com>
Wed, 10 Jun 2009 03:08:12 +0000 (20:08 -0700)
When an instance of an alias has a condition, that condition gets
propagated to each of the locations that the alias defines.  However,
the copy of the location list was not a deep copy, and so all other
instances of the alias would also incorrectly receive the condition.

This patch makes the location list copy a little deeper, and adds a
test case which demonstrates the issue.

elaborate.cxx
testsuite/systemtap.base/alias-condition.exp [new file with mode: 0644]
testsuite/systemtap.base/alias-condition.stp [new file with mode: 0644]

index 7c4a5fca6b32e8211c88008e674c64e89750380e..30e9a7757b31ae9f7b48a717598ad6c7a568c731 100644 (file)
@@ -488,11 +488,15 @@ alias_expansion_builder
     alias_derived_probe * n = new alias_derived_probe (use, location /* soon overwritten */, this->alias);
     n->body = new block();
 
-    // The new probe gets the location list of the alias (with incoming condition joined)
-    n->locations = alias->locations;
-    for (unsigned i=0; i<n->locations.size(); i++)
-      n->locations[i]->condition = add_condition (n->locations[i]->condition,
-                                                  location->condition);
+    // The new probe gets a deep copy of the location list of
+    // the alias (with incoming condition joined)
+    n->locations.clear();
+    for (unsigned i=0; i<alias->locations.size(); i++)
+      {
+        probe_point *pp = new probe_point(*alias->locations[i]);
+        pp->condition = add_condition (pp->condition, location->condition);
+        n->locations.push_back(pp);
+      }
 
     // the token location of the alias,
     n->tok = location->tok;
diff --git a/testsuite/systemtap.base/alias-condition.exp b/testsuite/systemtap.base/alias-condition.exp
new file mode 100644 (file)
index 0000000..5843834
--- /dev/null
@@ -0,0 +1,5 @@
+# Check that conditions are copied correctly across aliases
+
+set test "alias-condition"
+
+stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string
diff --git a/testsuite/systemtap.base/alias-condition.stp b/testsuite/systemtap.base/alias-condition.stp
new file mode 100644 (file)
index 0000000..8970888
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * alias-condition.stp
+ *
+ * Check that conditions are copied correctly across aliases
+ */
+
+/* x should be incremented exactly once */
+global x = 0
+probe foo = begin { }
+probe foo if (x < 0), foo { ++x }
+
+probe begin(1)
+{
+    println("systemtap starting probe")
+    exit()
+}
+
+probe end
+{
+    println("systemtap ending probe")
+    if ( x != 1 ) {
+        println("systemtap test failure")
+    } else {
+        println("systemtap test success")
+    }
+}
This page took 0.037787 seconds and 5 git commands to generate.