MCPcopy Create free account
hub / github.com/GNOME/gjs / gjs_dumpstack_string

Function gjs_dumpstack_string

gjs/stack.cpp:41–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41std::string gjs_dumpstack_string() {
42 std::ostringstream all_traces;
43
44 Gjs::SmartPointer<GList> contexts{gjs_context_get_all()};
45 js::Sprinter printer;
46
47 for (GList* iter = contexts; iter; iter = iter->next) {
48 Gjs::AutoUnref<GjsContext> gjs_context{GJS_CONTEXT(iter->data)};
49 if (!printer.init()) {
50 all_traces << "No stack trace for context " << gjs_context.get()
51 << ": out of memory\n\n";
52 break;
53 }
54 auto* cx = static_cast<JSContext*>(
55 gjs_context_get_native_context(gjs_context));
56 js::DumpBacktrace(cx, printer);
57 JS::UniqueChars trace = printer.release();
58 all_traces << "== Stack trace for context " << gjs_context.get()
59 << " ==\n"
60 << trace.get() << "\n";
61 }
62 std::string out = all_traces.str();
63 // COMPAT: 0zu in C++23
64 out.resize(std::max(out.size() - 2, size_t{0}));
65
66 return out;
67}

Callers 3

marshalMethod · 0.85

Calls 6

gjs_context_get_allFunction · 0.85
initMethod · 0.45
getMethod · 0.45
releaseMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected