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]

Avoid assertion error for statement probe


Hi,

Current stap will reach assertion error when no matched function
is found in source file. For example,

$ stap -e 'probe process("./stap").statement("foo@main.cxx:*") {}'
stap: dwflpp.cxx:1276: void dwflpp::function_line(int*): Assertion `function' failed.
Aborted


I think it's better to give explicit description if no matched
function is resolved in CU. Like,

$ stap -e 'probe process("./stap").statement("foo@main.cxx:*") {}'
semantic error: no matched function 'foo' in main.cxx
semantic error: no probes found
Pass 2: analysis failed.  Try again with another '--vp 01' option.

The following patch can make that.

diff --git a/dwflpp.cxx b/dwflpp.cxx
index ff62265..c7879ae 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -634,6 +634,7 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query *
{
// track addresses we've already seen
set<Dwarf_Addr> alias_dupes;
+ bool found_match = false;


for (it = v->begin(); it != v->end(); it++)
{
@@ -645,7 +646,7 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query *
if (sess.verbose > 4)
clog << "function cache " << key << " match " << func_name << " vs "
<< function << endl;
-
+ found_match = true;
// make sure that this function address hasn't
// already been matched under an aliased name
Dwarf_Addr addr;
@@ -657,6 +658,8 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query *
if (rc != DWARF_CB_OK) break;
}
}
+ if (!found_match)
+ throw semantic_error ("no matched function '"+ function + "' in " +cu_name);
}
else if (has_statement_num) // searching all for kernel.statement
{
@@ -669,7 +672,7 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query *
}
else // not a wildcard and no match in this CU
{
- // do nothing
+ throw semantic_error ("no matched function '"+ function + "' in " +cu_name);
}
return rc;
}



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