Bug 11772 - listing_mode_vars are empty with debuginfoless SDT
Summary: listing_mode_vars are empty with debuginfoless SDT
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Stan Cox
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-30 16:43 UTC by Josh Stone
Modified: 2010-07-28 18:04 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Stone 2010-06-30 16:43:47 UTC
As noted in bug 11769 comment 1, we rely on derived_probe::getargs() to list the
available args, but uprobe_derived_probe doesn't know about SDT's debuginfoless
$arg1, $arg2.  (Nor $$name or $$provider, for that matter).  The args still work
in a normal script though.

$ stap -L 'process("stap").mark("*")'process("stap").mark("cache__add__module")
process("stap").mark("cache__add__source")
process("stap").mark("cache__clean")
process("stap").mark("cache__get")
process("stap").mark("pass0__end")
process("stap").mark("pass0__start")
process("stap").mark("pass1__end")
process("stap").mark("pass1a__start")
process("stap").mark("pass1b__start")
process("stap").mark("pass2__end")
process("stap").mark("pass2__start")
process("stap").mark("pass3__end")
process("stap").mark("pass3__start")
process("stap").mark("pass4__end")
process("stap").mark("pass4__start")
process("stap").mark("pass5__end")
process("stap").mark("pass5__start")
process("stap").mark("pass6__end")
process("stap").mark("pass6__start")
process("stap").mark("stap_system__complete")
process("stap").mark("stap_system__spawn")
process("stap").mark("stap_system__start")
Comment 1 Stan Cox 2010-07-26 21:50:30 UTC
How about this?

--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -396,2 +396,3 @@ struct dwarf_derived_probe: public derived_probe
   void print_dupe_stamp(ostream& o);
+  void savesdtargs(int nargs);
 
@@ -3914,2 +3915,10 @@ dwarf_derived_probe::saveargs(dwarf_query& q, Dwarf_Die*
scope_die, dwarf_var_ex
 void
+dwarf_derived_probe::savesdtargs(int nargs)
+{
+  for (int i = 1; i <= nargs; i++)
+    args.push_back("$arg" + lex_cast (i) + ":long");
+}
+
+
+void
 dwarf_derived_probe::getargs(std::list<std::string> &arg_set) const
@@ -5111,2 +5120,3 @@ sdt_query::handle_query_module()
 					  q.statement_num_val, reloc_addr, q, 0);
+	      p->savesdtargs (arg_count);
 	      results.push_back (p);

stap -L 'process("../../install/bin/stap").mark("*")'
process("../../install/bin/stap").mark("cache__add__module") $arg1:long $arg2:long
process("../../install/bin/stap").mark("cache__add__source") $arg1:long $arg2:long
process("../../install/bin/stap").mark("cache__clean") $arg1:long
...
Comment 2 Frank Ch. Eigler 2010-07-27 11:07:55 UTC
> How about this?

A good start, but "savesdtargs" is an awfully specific hook for
what is a general dwarf class, and it is not clear whether these
$arg* vars are resolvability-checked properly.  A $argN that is
unresolvable in the current case should not be listed.
Comment 3 Stan Cox 2010-07-27 15:57:48 UTC
Similar but handled in the more apropos uprobe_derived_probe. 
uprobe_derived_probe.args is set from sdt_query.arg_count which is the number of
asm operands defined for a probe.

stap -L 'process("../../install/bin/stap").mark("*")'
process("../../install/bin/stap").mark("cache__add__module") $arg1:long $arg2:long
process("../../install/bin/stap").mark("cache__add__source") $arg1:long $arg2:long
process("../../install/bin/stap").mark("cache__clean") $arg1:long
process("../../install/bin/stap").mark("cache__get") $arg1:long $arg2:long
process("../../install/bin/stap").mark("client__end") $arg1:long
...


diff --git a/tapsets.cxx b/tapsets.cxx
@@ -455,2 +455,6 @@ struct uprobe_derived_probe: public dwarf_derived_probe
   void print_dupe_stamp(ostream& o) {
print_dupe_stamp_unprivileged_process_owner (o); }
+  void getargs(std::list<std::string> &arg_set) const;
+  void savesdtargs(int nargs);
+private:
+  list<string> args;
 };
@@ -5111,2 +5115,3 @@ sdt_query::handle_query_module()
 					  q.statement_num_val, reloc_addr, q, 0);
+	      p->savesdtargs (arg_count);
 	      results.push_back (p);
@@ -5956,2 +5961,16 @@ uprobe_derived_probe::emit_unprivileged_assertion
(translator_output* o)
 
+void
+uprobe_derived_probe::getargs(std::list<std::string> &arg_set) const
+{
+  arg_set.insert(arg_set.end(), args.begin(), args.end());
+}
+
+void
+uprobe_derived_probe::savesdtargs(int nargs)
+{
+  for (int i = 1; i <= nargs; i++)
+    args.push_back("$arg" + lex_cast (i) + ":long");
+}

Comment 4 Josh Stone 2010-07-27 16:42:32 UTC
uprobe_derived_probe::getargs needs to also call the parent dwarf_derived_probe,
or else normal uprobes won't get any arg listing.

Perhaps instead of getting more specific, we could make this more generic by
adding derived_probe::saveargs(list<string>).  Then derived_probe::getargs would
have something to return.  Don't forget to make each *_derived_probe subclass
with their own getargs still call the parent class.  Bonus points for only
building the args when listing_mode_vars is true.
Comment 5 Stan Cox 2010-07-28 18:04:14 UTC
commit: c0f84e7bdb
Support -L for nodebuginfo sdt.