Jacek Caban : jscript: Added new debug channel printing details and backtrace of unwinded exceptions.
Alexandre Julliard
julliard at winehq.org
Fri May 5 15:05:59 CDT 2017
Module: wine
Branch: master
Commit: 59c39fa1f03235d97882b72d17b0d1a08a1f8472
URL: http://source.winehq.org/git/wine.git/?a=commit;h=59c39fa1f03235d97882b72d17b0d1a08a1f8472
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri May 5 17:22:57 2017 +0200
jscript: Added new debug channel printing details and backtrace of unwinded exceptions.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/engine.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index c9e856c..74d80eb 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -28,6 +28,7 @@
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
+WINE_DECLARE_DEBUG_CHANNEL(jscript_except);
static const WCHAR booleanW[] = {'b','o','o','l','e','a','n',0};
static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0};
@@ -2659,6 +2660,40 @@ static void pop_call_frame(script_ctx_t *ctx)
heap_free(frame);
}
+static void print_backtrace(script_ctx_t *ctx)
+{
+ unsigned depth = 0, i;
+ call_frame_t *frame;
+
+ for(frame = ctx->call_ctx; frame; frame = frame->prev_frame) {
+ TRACE_(jscript_except)("%u\t", depth);
+ depth++;
+
+ if(frame->this_obj && frame->this_obj != to_disp(ctx->global) && frame->this_obj != ctx->host_global)
+ TRACE_(jscript_except)("%p->", frame->this_obj);
+ TRACE_(jscript_except)("%s(", frame->function->name ? debugstr_w(frame->function->name) : "[unnamed]");
+ if(frame->base_scope && frame->base_scope->frame) {
+ for(i=0; i < frame->argc; i++) {
+ if(i < frame->function->param_cnt)
+ TRACE_(jscript_except)("%s%s=%s", i ? ", " : "",
+ debugstr_w(frame->function->params[i]),
+ debugstr_jsval(ctx->stack[local_off(frame, -i-1)]));
+ else
+ TRACE_(jscript_except)("%s%s", i ? ", " : "",
+ debugstr_jsval(ctx->stack[local_off(frame, -i-1)]));
+ }
+ }else {
+ TRACE_(jscript_except)("[detached frame]");
+ }
+ TRACE_(jscript_except)(")\n");
+
+ if(!(frame->flags & EXEC_RETURN_TO_INTERP)) {
+ TRACE_(jscript_except)("%u\t[native code]\n", depth);
+ depth++;
+ }
+ }
+}
+
static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres)
{
except_frame_t *except_frame;
@@ -2667,6 +2702,30 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres)
unsigned catch_off;
HRESULT hres;
+ TRACE("%08x\n", exception_hres);
+
+ if(TRACE_ON(jscript_except)) {
+ jsdisp_t *error_obj;
+ jsval_t msg;
+
+ static const WCHAR messageW[] = {'m','e','s','s','a','g','e',0};
+
+ TRACE_(jscript_except)("Exception %08x %s", exception_hres, debugstr_jsval(ctx->ei.val));
+ if(jsval_type(ctx->ei.val) == JSV_OBJECT) {
+ error_obj = to_jsdisp(get_object(ctx->ei.val));
+ if(error_obj) {
+ hres = jsdisp_propget_name(error_obj, messageW, &msg);
+ if(SUCCEEDED(hres)) {
+ TRACE_(jscript_except)(" (message %s)", debugstr_jsval(msg));
+ jsval_release(msg);
+ }
+ }
+ }
+ TRACE_(jscript_except)(" in:\n");
+
+ print_backtrace(ctx);
+ }
+
for(frame = ctx->call_ctx; !frame->except_frame; frame = ctx->call_ctx) {
DWORD flags;
@@ -2727,8 +2786,6 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, jsval_t *r)
op = frame->bytecode->instrs[frame->ip].op;
hres = op_funcs[op](ctx);
if(FAILED(hres)) {
- TRACE("EXCEPTION %08x\n", hres);
-
hres = unwind_exception(ctx, hres);
if(FAILED(hres))
return hres;
More information about the wine-cvs
mailing list