]> sourceware.org Git - systemtap.git/commitdiff
Add STAP_ERROR macro
authorAaron Tomlin <atomlin@redhat.com>
Fri, 22 Nov 2013 15:03:02 +0000 (15:03 +0000)
committerFrank Ch. Eigler <fche@redhat.com>
Fri, 22 Nov 2013 17:09:57 +0000 (12:09 -0500)
Instead of CONTEXT->last_error = "foo"; goto out; in an embedded-C
function, a newly defined macro STAP_ERROR(str) should be used.
The script can catch the exception with try { } catch { }.

Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
translate.cxx

index b52f4f154e2879c33c641f076a7c21901e610ba2..f99e0d7aa05462439bd3584d648e5f521a9defb3 100644 (file)
@@ -2119,6 +2119,7 @@ c_unparser::emit_function (functiondecl* v)
       o->newline() << retvalue.init();
     }
 
+  o->newline() << "#define STAP_ERROR(...) do { snprintf(CONTEXT->error_buffer, MAXSTRINGLEN, __VA_ARGS__); CONTEXT->last_error = CONTEXT->error_buffer; goto out; } while (0)";
   o->newline() << "#define return goto out"; // redirect embedded-C return
   v->body->visit (this);
   o->newline() << "#undef return";
@@ -2143,6 +2144,7 @@ c_unparser::emit_function (functiondecl* v)
     o->newline() << c_arg_undef(v->locals[i]->name); // #undef STAP_ARG_foo
   }
   o->newline() << "#undef STAP_RETVALUE";
+  o->newline() << "#undef STAP_ERROR";
   o->newline(-1) << "}\n";
 }
 
This page took 0.040923 seconds and 5 git commands to generate.