This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[patch] .statement("function@file.c+5")
- From: Stan Cox <scox at redhat dot com>
- To: Systemtap List <systemtap at sources dot redhat dot com>
- Date: Fri, 06 Jun 2008 09:48:53 -0400
- Subject: [patch] .statement("function@file.c+5")
This supports a relative line offset for .statement. So for example:
.statement("function@file.c:135") would be line 135 of function in
file.c
.statement("function@file.c+3") would be function entry line + 3 in
file.c
So for 2.6.24.5-85.fc8:
kernel.statement("bio_init@fs/bio.c:135")
kernel.statement("bio_init@fs/bio.c+3")
yield the same thing.
A very simple example:
probe kernel.statement("bio_init@fs/bio.c+3") {
printf ("%s -> %s\n", thread_indent(1), probefunc())
print_stack(backtrace())
}
probe timer.ms(2000) {
exit ()
}
yields:
5358 hald-addon-stor(2437): -> bio_init
0xffffffff810c24eb : bio_init+0x19/0x21
0xffffffff810c2521 : bio_alloc_bioset+0x2e/0xd9
0xffffffff810c2619 : bio_alloc+0x10/0x20
0xffffffff810c2666 : bio_map_kern+0x3d/0x103
0xffffffff81116e2b : blk_rq_map_kern+0x2f/0x84
0xffffffff88059413 : scsi_execute+0x57/0xe7 [scsi_mod]
0x00000ffffffff880
(Currently working on test cases.)
/work/scox/systemtap/src /work/scox/systemtap/bld/x86_64-redhat-linux /work/scox/stap
diff --git a/ChangeLog b/ChangeLog
index 313968d..3a50a1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-06-06 Stan Cox <scox@redhat.com>
+
+ * tapsets.cxx (dwflpp::iterate_over_srcfile_lines):
+ Add parameter line_type_relative.
+ (enum line_t): New.
+ (dwarf_query::line_type): New.
+ (dwarf_query::parse_function_spec): Set line_type.
+
2008-05-29 Ananth N Mavinakayanahalli <ananth@in.ibm.com>
PR 6563
diff --git a/tapsets.cxx b/tapsets.cxx
index 151a1c4..b986b2e 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1148,6 +1148,7 @@ struct dwflpp
void iterate_over_srcfile_lines (char const * srcfile,
int lineno,
bool need_single_match,
+ bool line_type_relative,
void (* callback) (Dwarf_Line * line, void * arg),
void *data)
{
@@ -1157,6 +1158,20 @@ struct dwflpp
get_module_dwarf();
+ if (line_type_relative)
+ {
+ Dwarf_Addr addr;
+ Dwarf_Line *line;
+ int line_number;
+ int errno;
+
+ dwarf_assert ("dwarf_entrypc", dwarf_entrypc (this->function, &addr));
+ line = dwarf_getsrc_die (this->cu, addr);
+ dwarf_assert ("dwarf_getsrc_die", line == NULL);
+ dwarf_assert ("dwarf_lineno", dwarf_lineno (line, &line_number));
+ lineno += line_number;
+ }
+
dwarf_assert ("dwarf_getsrc_file",
dwarf_getsrc_file (module_dwarf,
srcfile, lineno, 0,
@@ -2341,6 +2356,8 @@ base_query::get_number_param(map<string, literal *> const & params,
}
+enum line_t { ABSOLUTE, RELATIVE };
+
struct dwarf_query : public base_query
{
dwarf_query(systemtap_session & sess,
@@ -2407,6 +2424,7 @@ struct dwarf_query : public base_query
function_spec_type spec_type;
string function;
string file;
+ line_t line_type;
int line;
bool query_done; // Found exact match
@@ -2878,7 +2896,7 @@ dwarf_query::parse_function_spec(string & spec)
while (i != e && *i != '@')
{
- if (*i == ':')
+ if (*i == ':' || *i == '+')
goto bad;
function += *i++;
}
@@ -2895,8 +2913,12 @@ dwarf_query::parse_function_spec(string & spec)
if (i++ == e)
goto bad;
- while (i != e && *i != ':')
+ while (i != e && *i != ':' && *i != '+')
file += *i++;
+ if (*i == ':')
+ line_type = ABSOLUTE;
+ else if (*i == '+')
+ line_type = RELATIVE;
if (i == e)
{
@@ -3500,7 +3522,7 @@ query_cu (Dwarf_Die * cudie, void * arg)
for (set<char const *>::const_iterator i = q->filtered_srcfiles.begin();
i != q->filtered_srcfiles.end(); ++i)
q->dw.iterate_over_srcfile_lines (*i, q->line, q->has_statement_str,
- query_srcfile_line, q);
+ q->line_type, query_srcfile_line, q);
}
else
{