public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Avoid assertion error for statement probe
@ 2009-08-07  2:54 Wenji Huang
  2009-08-07 16:59 ` Frank Ch. Eigler
  0 siblings, 1 reply; 4+ messages in thread
From: Wenji Huang @ 2009-08-07  2:54 UTC (permalink / raw)
  To: SystemTAP

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;
  }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-10 18:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-07  2:54 Avoid assertion error for statement probe Wenji Huang
2009-08-07 16:59 ` Frank Ch. Eigler
2009-08-10  9:29   ` Wenji Huang
2009-08-10 18:53     ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).