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 #ifndef js_OldDebugAPI_h
8 #define js_OldDebugAPI_h
14 #include "mozilla/NullPtr.h"
17 #include "jsbytecode.h"
19 #include "js/CallArgs.h"
20 #include "js/TypeDecls.h"
26 class InterpreterFrame
;
34 extern JS_PUBLIC_API(char*)
35 FormatStackDump(JSContext
* cx
, char* buf
, bool showArgs
, bool showLocals
, bool showThisProps
);
40 JS_FRIEND_API(void) js_DumpValue(const JS::Value
& val
);
41 JS_FRIEND_API(void) js_DumpId(jsid id
);
42 JS_FRIEND_API(void) js_DumpInterpreterFrame(JSContext
* cx
, js::InterpreterFrame
* start
= nullptr);
46 js_DumpBacktrace(JSContext
* cx
);
48 typedef enum JSTrapStatus
{
56 extern JS_PUBLIC_API(JSString
*)
57 JS_DecompileScript(JSContext
* cx
, JS::HandleScript script
, const char* name
, unsigned indent
);
60 * Currently, we only support runtime-wide debugging. In the future, we should
61 * be able to support compartment-wide debugging.
63 extern JS_PUBLIC_API(void)
64 JS_SetRuntimeDebugMode(JSRuntime
* rt
, bool debug
);
67 * Debug mode is a compartment-wide mode that enables a debugger to attach
68 * to and interact with running methodjit-ed frames. In particular, it causes
69 * every function to be compiled as if an eval was present (so eval-in-frame)
70 * can work, and it ensures that functions can be re-JITed for other debug
71 * features. In general, it is not safe to interact with frames that were live
72 * before debug mode was enabled. For this reason, it is also not safe to
73 * enable debug mode while frames are live.
76 /* Get current state of debugging mode. */
77 extern JS_PUBLIC_API(bool)
78 JS_GetDebugMode(JSContext
* cx
);
81 * Turn on/off debugging mode for all compartments. This returns false if any code
82 * from any of the runtime's compartments is running or on the stack.
85 JS_SetDebugModeForAllCompartments(JSContext
* cx
, bool debug
);
88 * Turn on/off debugging mode for a single compartment. This should only be
89 * used when no code from this compartment is running or on the stack in any
93 JS_SetDebugModeForCompartment(JSContext
* cx
, JSCompartment
* comp
, bool debug
);
96 * Turn on/off debugging mode for a context's compartment.
99 JS_SetDebugMode(JSContext
* cx
, bool debug
);
102 /************************************************************************/
104 // Raw JSScript* because this needs to be callable from a signal handler.
105 extern JS_PUBLIC_API(unsigned)
106 JS_PCToLineNumber(JSContext
* cx
, JSScript
* script
, jsbytecode
* pc
);
108 extern JS_PUBLIC_API(jsbytecode
*)
109 JS_LineNumberToPC(JSContext
* cx
, JSScript
* script
, unsigned lineno
);
111 extern JS_PUBLIC_API(JSScript
*)
112 JS_GetFunctionScript(JSContext
* cx
, JS::HandleFunction fun
);
115 /************************************************************************/
117 extern JS_PUBLIC_API(const char*)
118 JS_GetScriptFilename(JSScript
* script
);
120 extern JS_PUBLIC_API(const jschar
*)
121 JS_GetScriptSourceMap(JSContext
* cx
, JSScript
* script
);
123 extern JS_PUBLIC_API(unsigned)
124 JS_GetScriptBaseLineNumber(JSContext
* cx
, JSScript
* script
);
126 extern JS_PUBLIC_API(unsigned)
127 JS_GetScriptLineExtent(JSContext
* cx
, JSScript
* script
);
130 /************************************************************************/
133 * Add various profiling-related functions as properties of the given object.
135 extern JS_PUBLIC_API(bool)
136 JS_DefineProfilingFunctions(JSContext
* cx
, JSObject
* obj
);
138 /* Defined in vm/Debugger.cpp. */
139 extern JS_PUBLIC_API(bool)
140 JS_DefineDebuggerObject(JSContext
* cx
, JS::HandleObject obj
);
142 extern JS_PUBLIC_API(void)
143 JS_DumpPCCounts(JSContext
* cx
, JS::HandleScript script
);
145 extern JS_PUBLIC_API(void)
146 JS_DumpCompartmentPCCounts(JSContext
* cx
);
148 #endif /* js_OldDebugAPI_h */