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