[gjs/wip/ptomato/develop: 1/11] stack: Use js::DumpBacktrace() for gjs_dumpstack()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/develop: 1/11] stack: Use js::DumpBacktrace() for gjs_dumpstack()
- Date: Mon, 18 Sep 2017 08:13:13 +0000 (UTC)
commit f460a94382f8d4e618a61050261cf9459b0de50f
Author: Philip Chimento <philip chimento gmail com>
Date: Thu Sep 7 21:11:14 2017 -0700
stack: Use js::DumpBacktrace() for gjs_dumpstack()
It would be nice to be able to print a JS stack even if the JS engine is
in the middle of a garbage collection. I have tested and
js::DumpBacktrace() can do this. The output format is slightly less nice
but that's OK because gjs_dumpstack() is only for debugging.
https://bugzilla.gnome.org/show_bug.cgi?id=786186
gi/function.cpp | 6 +-----
gi/value.cpp | 6 +-----
gjs/stack.cpp | 13 +------------
3 files changed, 3 insertions(+), 22 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 21b104d..9a8e72e 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -197,11 +197,7 @@ gjs_callback_closure(ffi_cif *cif,
g_critical("The offending callback was %s()%s.", name,
trampoline->is_vfunc ? ", a vfunc" : "");
}
- /* A gjs_dumpstack() would be nice here, but we can't,
- because that works by creating a new Error object and
- reading the stack property, which is the worst possible
- idea during a GC session.
- */
+ gjs_dumpstack();
gjs_callback_trampoline_unref(trampoline);
return;
}
diff --git a/gi/value.cpp b/gi/value.cpp
index bf2ed75..9a4ba93 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -154,11 +154,7 @@ closure_marshal(GClosure *closure,
g_critical("The offending signal was %s on %s %p.", signal_query.signal_name,
g_type_name(G_TYPE_FROM_INSTANCE(instance)), instance);
}
- /* A gjs_dumpstack() would be nice here, but we can't,
- because that works by creating a new Error object and
- reading the stack property, which is the worst possible
- idea during a GC session.
- */
+ gjs_dumpstack();
return;
}
diff --git a/gjs/stack.cpp b/gjs/stack.cpp
index f71f852..c2c6c0f 100644
--- a/gjs/stack.cpp
+++ b/gjs/stack.cpp
@@ -51,20 +51,9 @@ void
gjs_context_print_stack_stderr(GjsContext *context)
{
JSContext *cx = (JSContext*) gjs_context_get_native_context(context);
- JS::RootedObject frame(cx);
- JS::AutoSaveExceptionState exc(cx);
- GjsAutoChar stack;
g_printerr("== Stack trace for context %p ==\n", context);
-
- if (!JS::CaptureCurrentStack(cx, &frame) ||
- !(stack = gjs_format_stack_trace(cx, frame))) {
- g_printerr("No stack trace available\n");
- exc.restore();
- return;
- }
-
- g_printerr("%s\n", stack.get());
+ js::DumpBacktrace(cx, stderr);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]