1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set ts=8 sts=4 et sw=4 tw=99: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "xpcprivate.h"
9 #include "js/OldDebugAPI.h"
15 static void DebugDump(const char* fmt
, ...)
21 _vsnprintf(buffer
, sizeof(buffer
), fmt
, ap
);
23 vsnprintf(buffer
, sizeof(buffer
), fmt
, ap
);
25 buffer
[sizeof(buffer
)-1] = '\0';
28 if (IsDebuggerPresent()) {
29 OutputDebugStringA(buffer
);
36 xpc_DumpJSStack(JSContext
* cx
, bool showArgs
, bool showLocals
, bool showThisProps
)
38 if (char* buf
= xpc_PrintJSStack(cx
, showArgs
, showLocals
, showThisProps
)) {
39 DebugDump("%s\n", buf
);
40 JS_smprintf_free(buf
);
46 xpc_PrintJSStack(JSContext
* cx
, bool showArgs
, bool showLocals
,
49 JS::AutoSaveExceptionState
state(cx
);
51 char* buf
= JS::FormatStackDump(cx
, nullptr, showArgs
, showLocals
, showThisProps
);
53 DebugDump("%s", "Failed to format JavaScript stack for dump\n");