forked from uazo/cromite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnables-deactivation-of-the-js-debugger-statement.patch
335 lines (314 loc) · 18.8 KB
/
Enables-deactivation-of-the-js-debugger-statement.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
From: uazo <[email protected]>
Date: Wed, 10 Jan 2024 13:42:27 +0000
Subject: Enables deactivation of the js debugger statement
enables a new option in the developer tools settings for
deactivating the debugger javascript statement
License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
---
.../src/front_end/core/sdk/DebuggerModel.ts | 9 ++++++++
.../src/front_end/core/sdk/sdk-meta.ts | 23 +++++++++++++++++++
.../generated/InspectorBackendCommands.js | 4 ++++
.../front_end/generated/protocol-mapping.d.ts | 4 ++++
.../generated/protocol-proxy-api.d.ts | 2 ++
.../src/front_end/generated/protocol.ts | 4 ++++
.../devtools_protocol/browser_protocol.json | 15 +++++++++---
v8/include/js_protocol.pdl | 4 ++++
v8/src/common/message-template.h | 1 +
v8/src/debug/debug-interface.cc | 5 ++++
v8/src/debug/debug-interface.h | 3 +++
v8/src/debug/debug.h | 5 ++++
v8/src/execution/messages.cc | 1 +
v8/src/inspector/v8-debugger-agent-impl.cc | 8 +++++++
v8/src/inspector/v8-debugger-agent-impl.h | 1 +
v8/src/runtime/runtime-debug.cc | 17 ++++++++++++--
16 files changed, 101 insertions(+), 5 deletions(-)
diff --git a/third_party/devtools-frontend/src/front_end/core/sdk/DebuggerModel.ts b/third_party/devtools-frontend/src/front_end/core/sdk/DebuggerModel.ts
--- a/third_party/devtools-frontend/src/front_end/core/sdk/DebuggerModel.ts
+++ b/third_party/devtools-frontend/src/front_end/core/sdk/DebuggerModel.ts
@@ -216,6 +216,9 @@ export class DebuggerModel extends SDKModel<EventTypes> {
Common.Settings.Settings.instance()
.moduleSetting('disable-async-stack-traces')
.addChangeListener(this.asyncStackTracesStateChanged, this);
+ Common.Settings.Settings.instance()
+ .moduleSetting('disableDebuggerStatement')
+ .addChangeListener(this.DebuggerStatementChanged, this);
Common.Settings.Settings.instance()
.moduleSetting('breakpoints-active')
.addChangeListener(this.breakpointsActiveChanged, this);
@@ -229,6 +232,7 @@ export class DebuggerModel extends SDKModel<EventTypes> {
Common.Settings.Settings.instance()
.moduleSetting('js-source-maps-enabled')
.addChangeListener(event => this.#sourceMapManagerInternal.setEnabled((event.data as boolean)));
+ this.DebuggerStatementChanged();
const resourceTreeModel = (target.model(ResourceTreeModel) as ResourceTreeModel);
if (resourceTreeModel) {
@@ -386,6 +390,11 @@ export class DebuggerModel extends SDKModel<EventTypes> {
return this.agent.invoke_setAsyncCallStackDepth({maxDepth});
}
+ private DebuggerStatementChanged(): Promise<Protocol.ProtocolResponseWithError> {
+ const enabled = !Common.Settings.Settings.instance().moduleSetting('disableDebuggerStatement').get();
+ return this.agent.invoke_setDebuggerStatementEnabled({enabled});
+ }
+
private breakpointsActiveChanged(): void {
void this.agent.invoke_setBreakpointsActive(
{active: Common.Settings.Settings.instance().moduleSetting('breakpoints-active').get()});
diff --git a/third_party/devtools-frontend/src/front_end/core/sdk/sdk-meta.ts b/third_party/devtools-frontend/src/front_end/core/sdk/sdk-meta.ts
--- a/third_party/devtools-frontend/src/front_end/core/sdk/sdk-meta.ts
+++ b/third_party/devtools-frontend/src/front_end/core/sdk/sdk-meta.ts
@@ -34,6 +34,10 @@ const UIStrings = {
*@description Title of a setting under the Debugger category in Settings
*/
disableAsyncStackTraces: 'Disable async stack traces',
+ /**
+ *@description Title of a setting under the Debugger category in Settings
+ */
+ disableDebuggerStatement: 'Disable debugger statement',
/**
*@description Title of a setting under the Debugger category that can be invoked through the Command Menu
*/
@@ -374,6 +378,25 @@ Common.Settings.registerSettingExtension({
],
});
+Common.Settings.registerSettingExtension({
+ category: Common.Settings.SettingCategory.DEBUGGER,
+ title: i18nLazyString(UIStrings.disableDebuggerStatement),
+ settingName: 'disableDebuggerStatement',
+ settingType: Common.Settings.SettingType.BOOLEAN,
+ defaultValue: false,
+ order: 999,
+ options: [
+ {
+ value: true,
+ title: i18nLazyString(UIStrings.doNotCaptureAsyncStackTraces),
+ },
+ {
+ value: false,
+ title: i18nLazyString(UIStrings.captureAsyncStackTraces),
+ },
+ ],
+});
+
Common.Settings.registerSettingExtension({
category: Common.Settings.SettingCategory.DEBUGGER,
settingName: 'pause-on-exception-enabled',
diff --git a/third_party/devtools-frontend/src/front_end/generated/InspectorBackendCommands.js b/third_party/devtools-frontend/src/front_end/generated/InspectorBackendCommands.js
--- a/third_party/devtools-frontend/src/front_end/generated/InspectorBackendCommands.js
+++ b/third_party/devtools-frontend/src/front_end/generated/InspectorBackendCommands.js
@@ -1309,6 +1309,10 @@ inspectorBackend.registerCommand("Debugger.restartFrame", [{"name": "callFrameId
inspectorBackend.registerCommand("Debugger.resume", [{"name": "terminateOnResume", "type": "boolean", "optional": true, "description": "Set to true to terminate execution upon resuming execution. In contrast to Runtime.terminateExecution, this will allows to execute further JavaScript (i.e. via evaluation) until execution of the paused code is actually resumed, at which point termination is triggered. If execution is currently not paused, this parameter has no effect.", "typeRef": null}], [], "Resumes JavaScript execution.");
inspectorBackend.registerCommand("Debugger.searchInContent", [{"name": "scriptId", "type": "string", "optional": false, "description": "Id of the script to search in.", "typeRef": "Runtime.ScriptId"}, {"name": "query", "type": "string", "optional": false, "description": "String to search for.", "typeRef": null}, {"name": "caseSensitive", "type": "boolean", "optional": true, "description": "If true, search is case sensitive.", "typeRef": null}, {"name": "isRegex", "type": "boolean", "optional": true, "description": "If true, treats string parameter as regex.", "typeRef": null}], ["result"], "Searches for given string in script content.");
inspectorBackend.registerCommand("Debugger.setAsyncCallStackDepth", [{"name": "maxDepth", "type": "number", "optional": false, "description": "Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async call stacks (default).", "typeRef": null}], [], "Enables or disables async call stacks tracking.");
+inspectorBackend.registerCommand("Debugger.setDebuggerStatementEnabled", [
+ {"name": "value", "type": "boolean", "optional": false,
+ "description": "",
+ "typeRef": null}], [], "");
inspectorBackend.registerCommand("Debugger.setBlackboxPatterns", [{"name": "patterns", "type": "array", "optional": false, "description": "Array of regexps that will be used to check script url for blackbox state.", "typeRef": "string"}], [], "Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful.");
inspectorBackend.registerCommand("Debugger.setBlackboxedRanges", [{"name": "scriptId", "type": "string", "optional": false, "description": "Id of the script.", "typeRef": "Runtime.ScriptId"}, {"name": "positions", "type": "array", "optional": false, "description": "", "typeRef": "Debugger.ScriptPosition"}], [], "Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted.");
inspectorBackend.registerCommand("Debugger.setBreakpoint", [{"name": "location", "type": "object", "optional": false, "description": "Location to set breakpoint in.", "typeRef": "Debugger.Location"}, {"name": "condition", "type": "string", "optional": true, "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.", "typeRef": null}], ["breakpointId", "actualLocation"], "Sets JavaScript breakpoint at a given location.");
diff --git a/third_party/devtools-frontend/src/front_end/generated/protocol-mapping.d.ts b/third_party/devtools-frontend/src/front_end/generated/protocol-mapping.d.ts
--- a/third_party/devtools-frontend/src/front_end/generated/protocol-mapping.d.ts
+++ b/third_party/devtools-frontend/src/front_end/generated/protocol-mapping.d.ts
@@ -4447,6 +4447,10 @@ export namespace ProtocolMapping {
paramsType: [Protocol.Debugger.SetAsyncCallStackDepthRequest];
returnType: void;
};
+ 'Debugger.setDebuggerStatementEnabled': {
+ paramsType: [Protocol.Debugger.setDebuggerStatementEnabledRequest];
+ returnType: void;
+ };
/**
* Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in
* scripts with url matching one of the patterns. VM will try to leave blackboxed script by
diff --git a/third_party/devtools-frontend/src/front_end/generated/protocol-proxy-api.d.ts b/third_party/devtools-frontend/src/front_end/generated/protocol-proxy-api.d.ts
--- a/third_party/devtools-frontend/src/front_end/generated/protocol-proxy-api.d.ts
+++ b/third_party/devtools-frontend/src/front_end/generated/protocol-proxy-api.d.ts
@@ -3936,6 +3936,8 @@ declare namespace ProtocolProxyApi {
*/
invoke_setAsyncCallStackDepth(params: Protocol.Debugger.SetAsyncCallStackDepthRequest): Promise<Protocol.ProtocolResponseWithError>;
+ invoke_setDebuggerStatementEnabled(params: Protocol.Debugger.SetDebuggerStatementEnabledRequest): Promise<Protocol.ProtocolResponseWithError>;
+
/**
* Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in
* scripts with url matching one of the patterns. VM will try to leave blackboxed script by
diff --git a/third_party/devtools-frontend/src/front_end/generated/protocol.ts b/third_party/devtools-frontend/src/front_end/generated/protocol.ts
--- a/third_party/devtools-frontend/src/front_end/generated/protocol.ts
+++ b/third_party/devtools-frontend/src/front_end/generated/protocol.ts
@@ -17335,6 +17335,10 @@ export namespace Debugger {
maxDepth: integer;
}
+ export interface SetDebuggerStatementEnabledRequest {
+ enabled: boolean;
+ }
+
export interface SetBlackboxPatternsRequest {
/**
* Array of regexps that will be used to check script url for blackbox state.
diff --git a/third_party/devtools-frontend/src/third_party/blink/public/devtools_protocol/browser_protocol.json b/third_party/devtools-frontend/src/third_party/blink/public/devtools_protocol/browser_protocol.json
--- a/third_party/devtools-frontend/src/third_party/blink/public/devtools_protocol/browser_protocol.json
+++ b/third_party/devtools-frontend/src/third_party/blink/public/devtools_protocol/browser_protocol.json
@@ -26059,8 +26059,17 @@
"$ref": "WasmDisassemblyChunk"
}
]
- },
- {
+ },{
+ "name": "setDebuggerStatementEnabled",
+ "description": "Enables or disables debugger javascript statement.",
+ "parameters": [
+ {
+ "name": "enabled",
+ "description": "Enables or disables debugger javascript statement",
+ "type": "boolean"
+ }
+ ]
+ },{
"name": "nextWasmDisassemblyChunk",
"description": "Disassemble the next chunk of lines for the module corresponding to the\nstream. If disassembly is complete, this API will invalidate the streamId\nand return an empty chunk. Any subsequent calls for the now invalid stream\nwill return errors.",
"experimental": true,
@@ -29186,4 +29195,4 @@
]
}
]
-}
\ No newline at end of file
+}
diff --git a/v8/include/js_protocol.pdl b/v8/include/js_protocol.pdl
--- a/v8/include/js_protocol.pdl
+++ b/v8/include/js_protocol.pdl
@@ -362,6 +362,10 @@ domain Debugger
# List of search matches.
array of SearchMatch result
+ command setDebuggerStatementEnabled
+ parameters
+ boolean enabled
+
# Enables or disables async call stacks tracking.
command setAsyncCallStackDepth
parameters
diff --git a/v8/src/common/message-template.h b/v8/src/common/message-template.h
--- a/v8/src/common/message-template.h
+++ b/v8/src/common/message-template.h
@@ -738,6 +738,7 @@ namespace internal {
/* AggregateError */ \
T(AllPromisesRejected, "All promises were rejected") \
T(CannotDeepFreezeObject, "Cannot DeepFreeze object of type %") \
+ T(DebuggerStatementSuppressed, "debugger statement suppressed") \
T(CannotDeepFreezeValue, "Cannot DeepFreeze non-const value %")
enum class MessageTemplate {
diff --git a/v8/src/debug/debug-interface.cc b/v8/src/debug/debug-interface.cc
--- a/v8/src/debug/debug-interface.cc
+++ b/v8/src/debug/debug-interface.cc
@@ -1020,6 +1020,11 @@ void SetAsyncEventDelegate(Isolate* v8_isolate, AsyncEventDelegate* delegate) {
reinterpret_cast<i::Isolate*>(v8_isolate)->set_async_event_delegate(delegate);
}
+void SetDebuggerStatementEnabled(Isolate* v8_isolate, bool in_enabled) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
+ isolate->debug()->SetDebuggerStatementEnabled(in_enabled);
+}
+
void ResetBlackboxedStateCache(Isolate* v8_isolate, Local<Script> script) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
diff --git a/v8/src/debug/debug-interface.h b/v8/src/debug/debug-interface.h
--- a/v8/src/debug/debug-interface.h
+++ b/v8/src/debug/debug-interface.h
@@ -351,6 +351,9 @@ class AsyncEventDelegate {
V8_EXPORT_PRIVATE void SetAsyncEventDelegate(Isolate* isolate,
AsyncEventDelegate* delegate);
+V8_EXPORT_PRIVATE void SetDebuggerStatementEnabled(Isolate* isolate,
+ bool enabled);
+
void ResetBlackboxedStateCache(Isolate* isolate,
v8::Local<debug::Script> script);
diff --git a/v8/src/debug/debug.h b/v8/src/debug/debug.h
--- a/v8/src/debug/debug.h
+++ b/v8/src/debug/debug.h
@@ -429,6 +429,9 @@ class V8_EXPORT_PRIVATE Debug {
void set_break_points_active(bool v) { break_points_active_ = v; }
bool break_points_active() const { return break_points_active_; }
+ inline bool debugger_statement_enabled() const { return debugger_statement_enabled_; }
+ void SetDebuggerStatementEnabled(bool enabled) { debugger_statement_enabled_ = enabled; }
+
StackFrameId break_frame_id() { return thread_local_.break_frame_id_; }
Handle<Object> return_value_handle();
@@ -588,6 +591,8 @@ class V8_EXPORT_PRIVATE Debug {
// Termination exception because side effect check has failed.
bool side_effect_check_failed_;
+ bool debugger_statement_enabled_ = true;
+
// List of active debug info objects.
DebugInfoCollection debug_infos_;
diff --git a/v8/src/execution/messages.cc b/v8/src/execution/messages.cc
--- a/v8/src/execution/messages.cc
+++ b/v8/src/execution/messages.cc
@@ -492,6 +492,7 @@ MaybeHandle<String> MessageFormatter::TryFormat(
MessageTemplate::kUndefinedOrNullToObject,
MessageTemplate::kUnexpectedStrictReserved,
MessageTemplate::kUnexpectedTokenIdentifier,
+ MessageTemplate::kDebuggerStatementSuppressed,
MessageTemplate::kWeakRefsCleanupMustBeCallable};
base::Vector<const Handle<String>> remaining_args = args;
diff --git a/v8/src/inspector/v8-debugger-agent-impl.cc b/v8/src/inspector/v8-debugger-agent-impl.cc
--- a/v8/src/inspector/v8-debugger-agent-impl.cc
+++ b/v8/src/inspector/v8-debugger-agent-impl.cc
@@ -1664,6 +1664,14 @@ Response V8DebuggerAgentImpl::setAsyncCallStackDepth(int depth) {
return Response::Success();
}
+Response V8DebuggerAgentImpl::setDebuggerStatementEnabled(bool in_enabled) {
+ if (!enabled() && !m_session->runtimeAgent()->enabled()) {
+ return Response::ServerError(kDebuggerNotEnabled);
+ }
+ v8::debug::SetDebuggerStatementEnabled(m_debugger->isolate(), in_enabled);
+ return Response::Success();
+}
+
Response V8DebuggerAgentImpl::setBlackboxPatterns(
std::unique_ptr<protocol::Array<String16>> patterns) {
if (patterns->empty()) {
diff --git a/v8/src/inspector/v8-debugger-agent-impl.h b/v8/src/inspector/v8-debugger-agent-impl.h
--- a/v8/src/inspector/v8-debugger-agent-impl.h
+++ b/v8/src/inspector/v8-debugger-agent-impl.h
@@ -138,6 +138,7 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
Response setReturnValue(
std::unique_ptr<protocol::Runtime::CallArgument> newValue) override;
Response setAsyncCallStackDepth(int depth) override;
+ Response setDebuggerStatementEnabled(bool in_enabled) override;
Response setBlackboxPatterns(
std::unique_ptr<protocol::Array<String16>> patterns) override;
Response setBlackboxedRanges(
diff --git a/v8/src/runtime/runtime-debug.cc b/v8/src/runtime/runtime-debug.cc
--- a/v8/src/runtime/runtime-debug.cc
+++ b/v8/src/runtime/runtime-debug.cc
@@ -132,9 +132,10 @@ RUNTIME_FUNCTION(Runtime_DebugBreakAtEntry) {
}
RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) {
- SealHandleScope shs(isolate);
+ HandleScope scope(isolate);
DCHECK_EQ(0, args.length());
- if (isolate->debug()->break_points_active()) {
+ if (isolate->debug()->break_points_active() &&
+ isolate->debug()->debugger_statement_enabled()) {
isolate->debug()->HandleDebugBreak(
kIgnoreIfTopFrameBlackboxed,
v8::debug::BreakReasons({v8::debug::BreakReason::kDebuggerStatement}));
@@ -142,6 +143,18 @@ RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) {
return isolate->TerminateExecution();
}
}
+ if (!isolate->debug()->debugger_statement_enabled()) {
+ MessageLocation* location = nullptr;
+ MessageLocation computed_location;
+ if (isolate->ComputeLocation(&computed_location))
+ location = &computed_location;
+ Handle<JSMessageObject> message =
+ MessageHandler::MakeMessageObject(
+ isolate, MessageTemplate::kDebuggerStatementSuppressed, location,
+ isolate->factory()->null_value(), Handle<i::FixedArray>::null());
+ message->set_error_level(v8::Isolate::kMessageWarning);
+ MessageHandler::ReportMessage(isolate, location, message);
+ }
return isolate->stack_guard()->HandleInterrupts();
}
--