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

* Re: Avoid assertion error for statement probe
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Ch. Eigler @ 2009-08-07 16:59 UTC (permalink / raw)
  To: wenji.huang; +Cc: SystemTAP

Wenji Huang <wenji.huang@oracle.com> writes:

> 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

Wow, I thought this was gone.

> 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

Not a bad idea, but perhaps we don't need that particular "no matched
function" message that covers just this case, considering that the "no
probes found" message can/should be paired with the probe point.


- FChE

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

* Re: Avoid assertion error for statement probe
  2009-08-07 16:59 ` Frank Ch. Eigler
@ 2009-08-10  9:29   ` Wenji Huang
  2009-08-10 18:53     ` Mark Wielaard
  0 siblings, 1 reply; 4+ messages in thread
From: Wenji Huang @ 2009-08-10  9:29 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: SystemTAP

Frank Ch. Eigler wrote:
[...]
>> $ stap -e 'probe process("./stap").statement("foo@main.cxx:*") {}'
>> semantic error: no matched function 'foo' in main.cxx
>> semantic error: no probes found
> 
> Not a bad idea, but perhaps we don't need that particular "no matched
> function" message that covers just this case, considering that the "no
> probes found" message can/should be paired with the probe point.
> 
> 
> - FChE
> 
How about to defer the error to the outer calling ?

$ stap -e 'probe process("./stap").statement("foo@main.cxx:1025-1026") {}'
semantic error: no match while resolving probe point 
process("./stap").statement("foo@main.cxx:1025-1026")
semantic error: no probes found
Pass 2: analysis failed.  Try again with another '--vp 01' option.

diff --git a/dwflpp.cxx b/dwflpp.cxx
index ff62265..d37b5e9 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -794,6 +794,8 @@ dwflpp::iterate_over_srcfile_lines (char const * 
srcfile,
    auto_free_ref<Dwarf_Line**> free_srcsp(srcsp);

    get_module_dwarf();
+  if (!this->function)
+    return;

    if (line_type == RELATIVE)
      {

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

* Re: Avoid assertion error for statement probe
  2009-08-10  9:29   ` Wenji Huang
@ 2009-08-10 18:53     ` Mark Wielaard
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2009-08-10 18:53 UTC (permalink / raw)
  To: wenji.huang; +Cc: Frank Ch. Eigler, SystemTAP

On Mon, 2009-08-10 at 17:25 +0800, Wenji Huang wrote:
> Frank Ch. Eigler wrote:
> [...]
> >> $ stap -e 'probe process("./stap").statement("foo@main.cxx:*") {}'
> >> semantic error: no matched function 'foo' in main.cxx
> >> semantic error: no probes found
> > 
> > Not a bad idea, but perhaps we don't need that particular "no matched
> > function" message that covers just this case, considering that the "no
> > probes found" message can/should be paired with the probe point.

I always found the extra "no probes found" exception error message
confusing. Clearly stap did find a probe, that is why is was giving an
error about it in the first place. Adding "no probes found" after that
is IMHO confusing. It should only say that if there were no other
errors. The following makes it that way:

commit 8c938ec723aad41c6cafcdef24679d40f310396c
Author: Mark Wielaard <mjw@redhat.com>
Date:   Mon Aug 10 17:44:31 2009 +0200

    Only add extra error on no probes found if no previous errors already shown.
    
    * elaborate.cxx (semantic_pass): Don't add "no probes found" if session
      already had other errors.

diff --git a/elaborate.cxx b/elaborate.cxx
index 9350023..1d7f793 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -1455,7 +1455,7 @@ semantic_pass (systemtap_session& s)
       if (rc == 0) rc = semantic_pass_vars (s);
       if (rc == 0) rc = semantic_pass_stats (s);
 
-      if (s.probes.size() == 0 && !s.listing_mode)
+      if (s.num_errors() == 0 && s.probes.size() == 0 && !s.listing_mode)
         throw semantic_error ("no probes found");
     }
   catch (const semantic_error& e)

> How about to defer the error to the outer calling ?
> 
> $ stap -e 'probe process("./stap").statement("foo@main.cxx:1025-1026") {}'
> semantic error: no match while resolving probe point 
> process("./stap").statement("foo@main.cxx:1025-1026")
> semantic error: no probes found
> Pass 2: analysis failed.  Try again with another '--vp 01' option.

Yes, I think this is a more informative error than your first version.

Cheers,

Mark

^ 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).