]> sourceware.org Git - systemtap.git/commitdiff
Enable variable listing (-L) for dwarf probes
authorJosh Stone <jistone@redhat.com>
Wed, 29 Jul 2009 21:07:37 +0000 (14:07 -0700)
committerJosh Stone <jistone@redhat.com>
Wed, 29 Jul 2009 21:28:46 +0000 (14:28 -0700)
All $target variables and their C-types are now printed in -L mode.

* tapsets.cxx (dwarf_derived_probe::dwarf_derived_probe): Save the local
  arguments while we still have the dwflpp open.
  (dwarf_derived_probe::saveargs): New
  (dwarf_derived_probe::printargs): New

tapsets.cxx

index 4ddf4160d8f705cfbb4746d6836641dc9e02270b..a93c2860cd20ce99812f15c0d686f501558e8321 100644 (file)
@@ -351,6 +351,10 @@ struct dwarf_derived_probe: public derived_probe
   void join_group (systemtap_session& s);
   void emit_probe_local_init(translator_output * o);
 
+  string args;
+  void saveargs(Dwarf_Die* scope_die);
+  void printargs(std::ostream &o) const;
+
   // Pattern registration helpers.
   static void register_statement_variants(match_node * root,
                                          dwarf_builder * dw);
@@ -2046,6 +2050,7 @@ dwarf_var_expanding_visitor::visit_target_symbol_context (target_symbol* e)
   Dwarf_Die *scopes;
   if (dwarf_getscopes_die (scope_die, &scopes) == 0)
     return;
+  auto_free free_scopes(scopes);
 
   target_symbol *tsym = new target_symbol;
   print_format* pf = new print_format;
@@ -2637,6 +2642,10 @@ dwarf_derived_probe::dwarf_derived_probe(const string& funcname,
     }
   // else - null scope_die - $target variables will produce an error during translate phase
 
+  // Save the local variables for listing mode
+  if (q.sess.listing_mode_vars)
+    saveargs(scope_die);
+
   // Reset the sole element of the "locations" vector as a
   // "reverse-engineered" form of the incoming (q.base_loc) probe
   // point.  This allows a user to see what function / file / line
@@ -2701,6 +2710,66 @@ dwarf_derived_probe::dwarf_derived_probe(const string& funcname,
 }
 
 
+static bool dwarf_type_name(Dwarf_Die& type_die, string& c_type);
+
+void
+dwarf_derived_probe::saveargs(Dwarf_Die* scope_die)
+{
+  Dwarf_Die *scopes;
+  if (!null_die(scope_die) && dwarf_getscopes_die (scope_die, &scopes) == 0)
+    return;
+  auto_free free_scopes(scopes);
+
+  stringstream argstream;
+  string type_name;
+  Dwarf_Attribute type_attr;
+  Dwarf_Die type_die;
+
+  if (has_return &&
+      dwarf_attr_integrate (scope_die, DW_AT_type, &type_attr) &&
+      dwarf_formref_die (&type_attr, &type_die) &&
+      dwarf_type_name(type_die, type_name))
+    argstream << " $return:" << type_name;
+
+  Dwarf_Die arg;
+  if (dwarf_child (&scopes[0], &arg) == 0)
+    do
+      {
+        switch (dwarf_tag (&arg))
+          {
+          case DW_TAG_variable:
+          case DW_TAG_formal_parameter:
+            break;
+
+          default:
+            continue;
+          }
+
+        const char *arg_name = dwarf_diename (&arg);
+        if (!arg_name)
+          continue;
+
+        type_name.clear();
+        if (!dwarf_attr_integrate (&arg, DW_AT_type, &type_attr) ||
+            !dwarf_formref_die (&type_attr, &type_die) ||
+            !dwarf_type_name(type_die, type_name))
+          continue;
+
+        argstream << " $" << arg_name << ":" << type_name;
+      }
+    while (dwarf_siblingof (&arg, &arg) == 0);
+
+  args = argstream.str();
+}
+
+
+void
+dwarf_derived_probe::printargs(std::ostream &o) const
+{
+  o << args;
+}
+
+
 void
 dwarf_derived_probe::register_statement_variants(match_node * root,
                                                 dwarf_builder * dw)
This page took 0.032947 seconds and 5 git commands to generate.