added stacktrace to perl errors

This commit is contained in:
roberto@precise64
2012-02-16 11:31:52 +01:00
parent 5236c58255
commit c072e9b609
3 changed files with 28 additions and 3 deletions
+3
View File
@@ -19,6 +19,9 @@ struct uwsgi_perl {
// perl argv for initialization
char *embedding[3];
// check for Devel::StackTrace
int stacktrace_available;
// this is a pointer to the main list of interpreters (required for signals, rpc....);
PerlInterpreter **main;
+23
View File
@@ -189,6 +189,21 @@ XS(XS_error_print) {
XSRETURN(0);
}
XS(XS_uwsgi_stacktrace) {
dXSARGS;
psgi_check_args(0);
uwsgi_log("*** uWSGI perl stacktrace ***\n");
SV *ret = perl_eval_pv("Devel::StackTrace->new->as_string;", 0);
uwsgi_log("%s", SvPV_nolen(ret));
uwsgi_log("*** end of perl stacktrace ***\n\n");
XSRETURN(0);
}
/* automatically generated */
EXTERN_C void xs_init (pTHX);
@@ -219,6 +234,9 @@ xs_init(pTHX)
newXS("uwsgi::streaming::write", XS_streaming_write, "uwsgi::streaming");
newXS("uwsgi::streaming::close", XS_streaming_close, "uwsgi::streaming");
newXS("uwsgi::stacktrace", XS_uwsgi_stacktrace, "uwsgi");
uperl.tmp_streaming_stash[uperl.tmp_current_i] = gv_stashpv("uwsgi::streaming", 0);
#ifdef UWSGI_EMBEDDED
@@ -364,6 +382,11 @@ int init_psgi_app(struct wsgi_request *wsgi_req, char *app, uint16_t app_len, Pe
perl_eval_pv("use IO::Handle;", 0);
perl_eval_pv("use IO::File;", 0);
perl_eval_pv("use Devel::StackTrace;", 0);
if (!SvTRUE(ERRSV)) {
uperl.stacktrace_available = 1;
perl_eval_pv("$SIG{__DIE__} = \\&uwsgi::stacktrace;", 0);
}
SV *dollar_zero = get_sv("0", GV_ADD);
sv_setsv(dollar_zero, newSVpv(app, app_len));
+2 -3
View File
@@ -61,7 +61,7 @@ SV *uwsgi_perl_call_stream(SV *func) {
SPAGAIN;
if(SvTRUE(ERRSV)) {
uwsgi_log("%s\n", SvPV_nolen(ERRSV));
uwsgi_log("[uwsgi-perl error] %s\n", SvPV_nolen(ERRSV));
}
else {
ret = SvREFCNT_inc(POPs);
@@ -100,7 +100,6 @@ int uwsgi_perl_obj_can(SV *obj, char *method, size_t len) {
}
SV *uwsgi_perl_obj_call(SV *obj, char *method) {
SV *ret = NULL;
@@ -152,7 +151,7 @@ AV *psgi_call(struct wsgi_request *wsgi_req, SV *psgi_func, SV *env) {
if(SvTRUE(ERRSV)) {
internal_server_error(wsgi_req, "exception raised");
uwsgi_log("%s\n", SvPV_nolen(ERRSV));
uwsgi_log("[uwsgi-perl error] %s\n", SvPV_nolen(ERRSV));
}
else {
ret = (AV *) SvREFCNT_inc(SvRV(POPs));