This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Customization of LKET


Li Guanglei 写道:
> 
>   I modified systemtap to make it able to support lket_trace_extra at
> script level. In fact, lket_trace_extra has the same signature as
> printf, the difference is that printf will be turned into
> _stp_printf() in pass 3 while lket_trace_extra will be turned into
> _lket_trace_extra(). Attached is a draft patch against 0527 snapshot
> for this.

  After some testing, I found there are some bugs in this patch. Here
is an updated patch.

  The LKET's tapsets also need some changes. Now if a use want to
append extra trace data, he could use lket_trace_extra() at script
level and he can also call as many times of lket_trace_extra &
lket_backtrace as he want, e.g:

probe addevent.pagefault
{
  lket_trace_extra("%4b%0s", $numa_node, "testing str")
  lket_backtrace()
  lket_trace_extra(%8b", $address)
}

Any comments?

- Guanglei


--- src/parse.cxx	2006-05-25 17:39:37.000000000 -0400
+++ src.mod/parse.cxx	2006-05-31 08:06:58.000000000 -0400
@@ -2082,12 +2082,23 @@ parser::parse_symbol () 
       else if (name.size() > 0 && (name == "print"
 				   || name == "sprint"
 				   || name == "printf"
-				   || name == "sprintf"))
+				   || name == "sprintf"
+				   || name == "lket_trace_extra"))
 	{
 	  print_format *fmt = new print_format;
 	  fmt->tok = t;
 	  fmt->print_with_format = (name[name.size() - 1] == 'f');
 	  fmt->print_to_stream = (name[0] == 'p');
+
+	  fmt->lket_trace_extra = false;
+
+          if(name == "lket_trace_extra")
+            {
+                fmt->print_with_format = true;
+                fmt->print_to_stream = true;
+                fmt->lket_trace_extra = true;
+            }
+
 	  expect_op("(");
 	  if (fmt->print_with_format)
 	    {
--- src/staptree.h	2006-05-18 19:11:22.000000000 -0400
+++ src.mod/staptree.h	2006-05-30 07:13:20.000000000 -0400
@@ -261,6 +261,7 @@ struct print_format: public expression
 {
   bool print_with_format;
   bool print_to_stream;
+  bool lket_trace_extra;
 
   enum format_flag
     {
--- src/staptree.cxx	2006-05-18 19:11:22.000000000 -0400
+++ src.mod/staptree.cxx	2006-05-31 08:05:51.000000000 -0400
@@ -626,6 +626,7 @@ void print_format::print (ostream& o) co
   string name = (string(print_to_stream ? "" : "s") 
 		 + string("print") 
 		 + string(print_with_format ? "f" : ""));
+  if(lket_trace_extra)  name="lket_trace_extra";
   o << name << "(";
   if (print_with_format)
     {
@@ -2203,6 +2204,7 @@ deep_copy_visitor::visit_print_format (p
   n->tok = e->tok;
   n->print_with_format = e->print_with_format;
   n->print_to_stream = e->print_to_stream;
+  n->lket_trace_extra = e->lket_trace_extra;
   n->raw_components = e->raw_components;
   n->components = e->components;
   for (unsigned i = 0; i < e->args.size(); ++i)
--- src/translate.cxx	2006-05-24 22:03:01.000000000 -0400
+++ src.mod/translate.cxx	2006-05-31 08:04:35.000000000 -0400
@@ -3591,7 +3591,10 @@ c_unparser::visit_print_format (print_fo
       if (e->print_to_stream)
         {
           o->newline() << res.qname() << " = 0;";
-          o->newline() << "_stp_printf (";
+          if(e->lket_trace_extra)
+                  o->newline() << "_lket_trace_extra (";
+          else
+                  o->newline() << "_stp_printf (";
         }
       else
 	o->newline() << "_stp_snprintf (" << res.qname() << ", MAXSTRINGLEN, ";

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]