diff options
author | Josh Stone <jistone@redhat.com> | 2009-08-26 20:09:48 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2009-08-26 20:09:48 -0700 |
commit | 8096dd7dbc7bc5712da58a6f9bcb90c0b74c10db (patch) | |
tree | cbc805e5827d0826e46f42ce9bdd97b98175eb08 /tapsets.cxx | |
parent | 546499713651809f026e118f81b9c52f01c895f6 (diff) | |
download | systemtap-steved-8096dd7dbc7bc5712da58a6f9bcb90c0b74c10db.tar.gz systemtap-steved-8096dd7dbc7bc5712da58a6f9bcb90c0b74c10db.tar.xz systemtap-steved-8096dd7dbc7bc5712da58a6f9bcb90c0b74c10db.zip |
Reorganize iterate_over_labels
I noticed that iterate_over_labels was using a static variable as a
recursion variable, which isn't a safe thing to do since it will only be
initialized once. While fixing that, I also reorganized the function
quite a bit.
* dwflpp.cxx (dwflpp::iterate_over_labels): Take the current function as
a parameter instead of using a static local. Rewrite some of the code
as well to try to make it more obvious.
* tapsets.cxx (add_label_name): Remove in favor of query_label.
(query_label): New, to check decl_file and fix probe listing.
(query_srcfile_label, query_cu): Adjust to iterate_over_labels change
and start using query_label as the callback.
Diffstat (limited to 'tapsets.cxx')
-rw-r--r-- | tapsets.cxx | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/tapsets.cxx b/tapsets.cxx index 9f21bb20..9651426e 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -714,16 +714,6 @@ get_filtered_inlines(dwarf_query *q) void -add_label_name(dwarf_query *q, const char *name) -{ - // this is a kludge to let the listing mode show labels to the user - if (q->sess.listing_mode) - q->results.back()->locations[0]->components.push_back - (new probe_point::component(TOK_LABEL, new literal_string (name))); -} - - -void dwarf_query::query_module_dwarf() { if (has_function_num || has_statement_num) @@ -1114,6 +1104,33 @@ query_statement (string const & func, } static void +query_label (string const & func, + char const * label, + char const * file, + int line, + Dwarf_Die *scope_die, + Dwarf_Addr stmt_addr, + dwarf_query * q) +{ + size_t i = q->results.size(); + + // weed out functions whose decl_file isn't one of + // the source files that we actually care about + if ((q->has_statement_str || q->has_function_str) && + q->spec_type != function_alone && + q->filtered_srcfiles.count(file) == 0) + return; + + query_statement(func, file, line, scope_die, stmt_addr, q); + + // this is a kludge to let the listing mode show labels to the user + if (q->sess.listing_mode) + for (; i < q->results.size(); ++i) + q->results[i]->locations[0]->components.push_back + (new probe_point::component(TOK_LABEL, new literal_string (label))); +} + +static void query_inline_instance_info (inline_instance_info & ii, dwarf_query * q) { @@ -1184,8 +1201,8 @@ query_srcfile_label (const dwarf_line_t& line, void * arg) for (func_info_map_t::iterator i = q->filtered_functions.begin(); i != q->filtered_functions.end(); ++i) if (q->dw.die_has_pc (i->die, addr)) - q->dw.iterate_over_labels (&i->die, q->label_val.c_str(), q->function.c_str(), - q, query_statement); + q->dw.iterate_over_labels (&i->die, q->label_val, q->function, + q, query_label, i->name); } static void @@ -1280,7 +1297,7 @@ query_dwarf_func (Dwarf_Die * func, base_query * bq) if ((q->has_statement_str || q->has_function_str) && q->spec_type != function_alone && q->filtered_srcfiles.count(dwarf_decl_file(func)?:"") == 0) - return DWARF_CB_OK; + return DWARF_CB_OK; try { @@ -1468,8 +1485,8 @@ query_cu (Dwarf_Die * cudie, void * arg) if (q->has_label) { if (q->line[0] == 0) // No line number specified - q->dw.iterate_over_labels (q->dw.cu, q->label_val.c_str(), q->function.c_str(), - q, query_statement); + q->dw.iterate_over_labels (q->dw.cu, q->label_val, q->function, + q, query_label, ""); else for (set<string>::const_iterator i = q->filtered_srcfiles.begin(); i != q->filtered_srcfiles.end(); ++i) |