This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] support lookup table for regular kernel markers
- From: Masami Hiramatsu <mhiramat at redhat dot com>
- To: Mathieu Desnoyers <mathieu dot desnoyers at polymtl dot ca>, Peter Zijlstra <peterz at infradead dot org>, Steven Rostedt <rostedt at goodmis dot org>, "Frank Ch. Eigler" <fche at redhat dot com>, Ingo Molnar <mingo at elte dot hu>
- Cc: Hideo AOKI <haoki at redhat dot com>, systemtap-ml <systemtap at sources dot redhat dot com>
- Date: Fri, 20 Jun 2008 13:05:22 -0400
- Subject: [PATCH] support lookup table for regular kernel markers
Hi,
Here is a patch for supporting regular kernel markers
which I posted on LKML. This is for explaining how
new c-style format can be used on systemtap/other tracers.
runtime/regular-marker.format is a lookup table for
regular kernel markers. This file has pairs of
c-style format and printf-style format as below;
<marker name><c-style format>:<printf-style format>
Module.markers provides marker names and c-style formats,
so systemtap can look up corresponding printf-style formats
from this file. So, we can use printf-format parser for
regular kernel markers.
Even if the kernel updates its format, what we have to do is
just add new pairs.
Thank you,
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
---
Makefile.am | 2 -
Makefile.in | 2 -
runtime/regular-marker.format | 2 +
tapsets.cxx | 60 +++++++++++++++++++++++++++++++++++++-----
4 files changed, 57 insertions(+), 9 deletions(-)
Index: systemtap/runtime/regular-marker.format
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ systemtap/runtime/regular-marker.format 2008-06-13 16:49:51.000000000 -0400
@@ -0,0 +1,2 @@
+irq_entry(int irq_id, int kernel_mode):irq_id %d kernel_mode %d
+irq_exit(void):
Index: systemtap/tapsets.cxx
===================================================================
--- systemtap.orig/tapsets.cxx 2008-06-13 16:49:39.000000000 -0400
+++ systemtap/tapsets.cxx 2008-06-13 16:52:48.000000000 -0400
@@ -6765,10 +6765,11 @@
{
mark_derived_probe (systemtap_session &s,
const string& probe_name, const string& probe_format,
+ const string& probe_signature,
probe* base_probe, probe_point* location);
systemtap_session& sess;
- string probe_name, probe_format;
+ string probe_name, probe_format, probe_signature;
vector <struct mark_arg *> mark_args;
bool target_symbol_seen;
@@ -6980,9 +6981,10 @@
mark_derived_probe::mark_derived_probe (systemtap_session &s,
const string& p_n,
const string& p_f,
+ const string& p_s,
probe* base, probe_point* loc):
derived_probe (base, new probe_point(*loc) /* .components soon rewritten */),
- sess (s), probe_name (p_n), probe_format (p_f),
+ sess (s), probe_name (p_n), probe_format (p_f), probe_signature (p_s),
target_symbol_seen (false)
{
// create synthetic probe point name; preserve condition
@@ -7001,8 +7003,14 @@
target_symbol_seen = v.target_symbol_seen;
if (sess.verbose > 2)
- clog << "marker-based " << name << " mark=" << probe_name
- << " fmt='" << probe_format << "'" << endl;
+ {
+ clog << "marker-based " << name << " mark=" << probe_name
+ << " fmt='" << probe_format << "'";
+ if (probe_signature != probe_format)
+ clog << " sig='" << probe_signature << "'" << endl;
+ else
+ clog << endl;
+ }
}
@@ -7253,7 +7261,7 @@
s.op->newline () << "{";
s.op->line() << " .name=" << lex_cast_qstring(probes[i]->probe_name)
<< ",";
- s.op->line() << " .format=" << lex_cast_qstring(probes[i]->probe_format)
+ s.op->line() << " .format=" << lex_cast_qstring(probes[i]->probe_signature)
<< ",";
s.op->line() << " .pp=" << lex_cast_qstring (*probes[i]->sole_location())
<< ",";
@@ -7329,6 +7337,7 @@
typedef pair<mark_cache_const_iterator_t, mark_cache_const_iterator_t>
mark_cache_const_iterator_pair_t;
mark_cache_t mark_cache;
+ map<string, string> regular_mark;
public:
mark_builder(): cache_initialized(false) {}
@@ -7340,6 +7349,7 @@
if (s.verbose > 3)
clog << "mark_builder releasing cache" << endl;
mark_cache.clear();
+ regular_mark.clear();
}
}
@@ -7370,6 +7380,7 @@
cache_initialized = true;
string module_markers_path = "/lib/modules/" + sess.kernel_release
+ "/build/Module.markers";
+ string regular_format_path = sess.runtime_path + "/regular-marker.format";
ifstream module_markers;
module_markers.open(module_markers_path.c_str(), ifstream::in);
@@ -7381,6 +7392,33 @@
return;
}
+ // read regular format database
+ ifstream regular_format;
+ regular_format.open(regular_format_path.c_str(), ifstream::in);
+ if (regular_format)
+ {
+ string format;
+ do
+ {
+ getline(regular_format, format);
+ string::size_type idx = format.find(":");
+ if (idx != string::npos)
+ {
+ regular_mark[format.substr(0, idx)] =
+ format.substr(idx + 1);
+ }
+ }
+ while (! regular_format.eof());
+ regular_format.close();
+ if (sess.verbose>3)
+ {
+ map<string, string>::iterator p;
+ for (p = regular_mark.begin(); p != regular_mark.end(); p++)
+ clog << "format:'" << p->first << "'->'"<< p->second
+ << "'" << endl;
+ }
+ }
+
string name, module, format;
do
{
@@ -7439,17 +7477,25 @@
if (! rc)
{
bool add_result = true;
+ map<string, string>::iterator p;
+ string format;
+ // search regular format
+ p = regular_mark.find(it->first + it->second);
+ if (p != regular_mark.end())
+ format = p->second;
+ else
+ format = it->second;
// Match format strings (if the user specified one)
if (has_mark_format && fnmatch(mark_format_val.c_str(),
- it->second.c_str(), 0))
+ format.c_str(), 0))
add_result = false;
if (add_result)
{
derived_probe *dp
= new mark_derived_probe (sess,
- it->first, it->second,
+ it->first, format, it->second,
base, loc);
finished_results.push_back (dp);
}
Index: systemtap/Makefile.am
===================================================================
--- systemtap.orig/Makefile.am 2008-06-13 16:49:39.000000000 -0400
+++ systemtap/Makefile.am 2008-06-13 16:49:51.000000000 -0400
@@ -186,7 +186,7 @@
find $(distdir) -name 'stap' -o -name '*.log' -o -name '*.sum' -o -name 'site.exp' | xargs rm -rf
install-data-local:
- (cd $(srcdir)/runtime; for f in *.[ch]; do $(INSTALL_DATA) -D $$f $(DESTDIR)$(pkgdatadir)/runtime/$$f; done)
+ (cd $(srcdir)/runtime; for f in *.[ch] regular-marker.format; do $(INSTALL_DATA) -D $$f $(DESTDIR)$(pkgdatadir)/runtime/$$f; done)
(cd $(srcdir)/runtime/unwind; find . \( -name '*.[ch]' \) -print \
| while read f; do $(INSTALL_DATA) -D $$f $(DESTDIR)$(pkgdatadir)/runtime/unwind/$$f; done)
(cd $(srcdir)/runtime/transport; for f in *.[ch]; \
Index: systemtap/Makefile.in
===================================================================
--- systemtap.orig/Makefile.in 2008-06-13 16:49:39.000000000 -0400
+++ systemtap/Makefile.in 2008-06-13 16:49:51.000000000 -0400
@@ -1555,7 +1555,7 @@
find $(distdir) -name 'stap' -o -name '*.log' -o -name '*.sum' -o -name 'site.exp' | xargs rm -rf
install-data-local:
- (cd $(srcdir)/runtime; for f in *.[ch]; do $(INSTALL_DATA) -D $$f $(DESTDIR)$(pkgdatadir)/runtime/$$f; done)
+ (cd $(srcdir)/runtime; for f in *.[ch] regular-marker.format; do $(INSTALL_DATA) -D $$f $(DESTDIR)$(pkgdatadir)/runtime/$$f; done)
(cd $(srcdir)/runtime/unwind; find . \( -name '*.[ch]' \) -print \
| while read f; do $(INSTALL_DATA) -D $$f $(DESTDIR)$(pkgdatadir)/runtime/unwind/$$f; done)
(cd $(srcdir)/runtime/transport; for f in *.[ch]; \