GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — deps: cherry-pick dbfcc48 from upstream V8 · nodejs/node@e668815

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • common.gypi
  • deps/v8
    • include
      • v8-inspector.h
    • src/inspector
      • v8-debugger-agent-impl.cc
      • v8-debugger-script.cc
      • v8-debugger-script.h
      • v8-debugger.cc
      • v8-profiler-agent-impl.cc
      • v8-stack-trace-impl.cc
      • v8-stack-trace-impl.h
    • test/inspector
      • debugger
        • resource-name-to-url-expected.txt
        • resource-name-to-url.js
      • inspector-test.cc
      • isolate-data.cc
      • isolate-data.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
# Reset this number to 0 on major V8 upgrades.
3131
# Increment by one for each non-official patch applied to deps/v8.
32-
'v8_embedder_string': '-node.29',
32+
'v8_embedder_string': '-node.30',
3333

3434
# Enable disassembler for `--print-code` v8 options
3535
'v8_enable_disassembler': 1,
Collapse file

‎deps/v8/include/v8-inspector.h‎

Copy file name to clipboardExpand all lines: deps/v8/include/v8-inspector.h
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ class V8_EXPORT V8InspectorClient {
214214
virtual bool canExecuteScripts(int contextGroupId) { return true; }
215215

216216
virtual void maxAsyncCallStackDepthChanged(int depth) {}
217+
218+
virtual std::unique_ptr<StringBuffer> resourceNameToUrl(
219+
const StringView& resourceName) {
220+
return nullptr;
221+
}
217222
};
218223

219224
// These stack trace ids are intended to be passed between debuggers and be
Collapse file

‎deps/v8/src/inspector/v8-debugger-agent-impl.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/inspector/v8-debugger-agent-impl.cc
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ void V8DebuggerAgentImpl::didParseSource(
14441444
protocol::StringUtil::parseJSON(inspected->auxData()));
14451445
}
14461446
bool isLiveEdit = script->isLiveEdit();
1447-
bool hasSourceURL = script->hasSourceURL();
1447+
bool hasSourceURLComment = script->hasSourceURLComment();
14481448
bool isModule = script->isModule();
14491449
String16 scriptId = script->scriptId();
14501450
String16 scriptURL = script->sourceURL();
@@ -1464,7 +1464,8 @@ void V8DebuggerAgentImpl::didParseSource(
14641464
Maybe<protocol::DictionaryValue> executionContextAuxDataParam(
14651465
std::move(executionContextAuxData));
14661466
const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr;
1467-
const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
1467+
const bool* hasSourceURLParam =
1468+
hasSourceURLComment ? &hasSourceURLComment : nullptr;
14681469
const bool* isModuleParam = isModule ? &isModule : nullptr;
14691470
std::unique_ptr<V8StackTraceImpl> stack =
14701471
V8StackTraceImpl::capture(m_inspector->debugger(), contextGroupId, 1);
Collapse file

‎deps/v8/src/inspector/v8-debugger-script.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/inspector/v8-debugger-script.cc
+57-45Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "src/inspector/inspected-context.h"
88
#include "src/inspector/string-util.h"
9+
#include "src/inspector/v8-inspector-impl.h"
910
#include "src/inspector/wasm-translation.h"
1011
#include "src/utils.h"
1112

@@ -110,41 +111,11 @@ class ActualScript : public V8DebuggerScript {
110111

111112
public:
112113
ActualScript(v8::Isolate* isolate, v8::Local<v8::debug::Script> script,
113-
bool isLiveEdit)
114+
bool isLiveEdit, V8InspectorClient* client)
114115
: V8DebuggerScript(isolate, String16::fromInteger(script->Id()),
115-
GetNameOrSourceUrl(script)),
116+
GetScriptURL(script, client)),
116117
m_isLiveEdit(isLiveEdit) {
117-
v8::Local<v8::String> tmp;
118-
if (script->SourceURL().ToLocal(&tmp)) m_sourceURL = toProtocolString(tmp);
119-
if (script->SourceMappingURL().ToLocal(&tmp))
120-
m_sourceMappingURL = toProtocolString(tmp);
121-
m_startLine = script->LineOffset();
122-
m_startColumn = script->ColumnOffset();
123-
std::vector<int> lineEnds = script->LineEnds();
124-
CHECK(lineEnds.size());
125-
int source_length = lineEnds[lineEnds.size() - 1];
126-
if (lineEnds.size()) {
127-
m_endLine = static_cast<int>(lineEnds.size()) + m_startLine - 1;
128-
if (lineEnds.size() > 1) {
129-
m_endColumn = source_length - lineEnds[lineEnds.size() - 2] - 1;
130-
} else {
131-
m_endColumn = source_length + m_startColumn;
132-
}
133-
} else {
134-
m_endLine = m_startLine;
135-
m_endColumn = m_startColumn;
136-
}
137-
138-
USE(script->ContextId().To(&m_executionContextId));
139-
140-
if (script->Source().ToLocal(&tmp)) {
141-
m_source = toProtocolString(tmp);
142-
}
143-
144-
m_isModule = script->IsModule();
145-
146-
m_script.Reset(m_isolate, script);
147-
m_script.AnnotateStrongRetainer(kGlobalDebuggerScriptHandleLabel);
118+
Initialize(script);
148119
}
149120

150121
bool isLiveEdit() const override { return m_isLiveEdit; }
@@ -248,17 +219,60 @@ class ActualScript : public V8DebuggerScript {
248219
}
249220

250221
private:
251-
String16 GetNameOrSourceUrl(v8::Local<v8::debug::Script> script) {
252-
v8::Local<v8::String> name;
253-
if (script->Name().ToLocal(&name) || script->SourceURL().ToLocal(&name))
254-
return toProtocolString(name);
222+
String16 GetScriptURL(v8::Local<v8::debug::Script> script,
223+
V8InspectorClient* client) {
224+
v8::Local<v8::String> sourceURL;
225+
if (script->SourceURL().ToLocal(&sourceURL) && sourceURL->Length() > 0)
226+
return toProtocolString(sourceURL);
227+
v8::Local<v8::String> v8Name;
228+
if (script->Name().ToLocal(&v8Name) && v8Name->Length() > 0) {
229+
String16 name = toProtocolString(v8Name);
230+
std::unique_ptr<StringBuffer> url =
231+
client->resourceNameToUrl(toStringView(name));
232+
return url ? toString16(url->string()) : name;
233+
}
255234
return String16();
256235
}
257236

258237
v8::Local<v8::debug::Script> script() const override {
259238
return m_script.Get(m_isolate);
260239
}
261240

241+
void Initialize(v8::Local<v8::debug::Script> script) {
242+
v8::Local<v8::String> tmp;
243+
m_hasSourceURLComment =
244+
script->SourceURL().ToLocal(&tmp) && tmp->Length() > 0;
245+
if (script->SourceMappingURL().ToLocal(&tmp))
246+
m_sourceMappingURL = toProtocolString(tmp);
247+
m_startLine = script->LineOffset();
248+
m_startColumn = script->ColumnOffset();
249+
std::vector<int> lineEnds = script->LineEnds();
250+
CHECK(lineEnds.size());
251+
int source_length = lineEnds[lineEnds.size() - 1];
252+
if (lineEnds.size()) {
253+
m_endLine = static_cast<int>(lineEnds.size()) + m_startLine - 1;
254+
if (lineEnds.size() > 1) {
255+
m_endColumn = source_length - lineEnds[lineEnds.size() - 2] - 1;
256+
} else {
257+
m_endColumn = source_length + m_startColumn;
258+
}
259+
} else {
260+
m_endLine = m_startLine;
261+
m_endColumn = m_startColumn;
262+
}
263+
264+
USE(script->ContextId().To(&m_executionContextId));
265+
266+
if (script->Source().ToLocal(&tmp)) {
267+
m_source = toProtocolString(tmp);
268+
}
269+
270+
m_isModule = script->IsModule();
271+
272+
m_script.Reset(m_isolate, script);
273+
m_script.AnnotateStrongRetainer(kGlobalDebuggerScriptHandleLabel);
274+
}
275+
262276
String16 m_sourceMappingURL;
263277
bool m_isLiveEdit = false;
264278
bool m_isModule = false;
@@ -392,9 +406,9 @@ class WasmVirtualScript : public V8DebuggerScript {
392406

393407
std::unique_ptr<V8DebuggerScript> V8DebuggerScript::Create(
394408
v8::Isolate* isolate, v8::Local<v8::debug::Script> scriptObj,
395-
bool isLiveEdit) {
409+
bool isLiveEdit, V8InspectorClient* client) {
396410
return std::unique_ptr<ActualScript>(
397-
new ActualScript(isolate, scriptObj, isLiveEdit));
411+
new ActualScript(isolate, scriptObj, isLiveEdit, client));
398412
}
399413

400414
std::unique_ptr<V8DebuggerScript> V8DebuggerScript::CreateWasm(
@@ -412,18 +426,16 @@ V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate, String16 id,
412426

413427
V8DebuggerScript::~V8DebuggerScript() {}
414428

415-
const String16& V8DebuggerScript::sourceURL() const {
416-
return m_sourceURL.isEmpty() ? m_url : m_sourceURL;
417-
}
418-
419429
void V8DebuggerScript::setSourceURL(const String16& sourceURL) {
420-
m_sourceURL = sourceURL;
430+
if (sourceURL.length() > 0) {
431+
m_hasSourceURLComment = true;
432+
m_url = sourceURL;
433+
}
421434
}
422435

423436
bool V8DebuggerScript::setBreakpoint(const String16& condition,
424437
v8::debug::Location* loc, int* id) const {
425438
v8::HandleScope scope(m_isolate);
426439
return script()->SetBreakpoint(toV8String(m_isolate, condition), loc, id);
427440
}
428-
429441
} // namespace v8_inspector
Collapse file

‎deps/v8/src/inspector/v8-debugger-script.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/inspector/v8-debugger-script.h
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@
4040
namespace v8_inspector {
4141

4242
// Forward declaration.
43+
class V8InspectorClient;
4344
class WasmTranslation;
4445

4546
class V8DebuggerScript {
4647
public:
4748
static std::unique_ptr<V8DebuggerScript> Create(
4849
v8::Isolate* isolate, v8::Local<v8::debug::Script> script,
49-
bool isLiveEdit);
50+
bool isLiveEdit, V8InspectorClient* client);
5051
static std::unique_ptr<V8DebuggerScript> CreateWasm(
5152
v8::Isolate* isolate, WasmTranslation* wasmTranslation,
5253
v8::Local<v8::debug::WasmScript> underlyingScript, String16 id,
@@ -55,9 +56,9 @@ class V8DebuggerScript {
5556
virtual ~V8DebuggerScript();
5657

5758
const String16& scriptId() const { return m_id; }
58-
const String16& url() const { return m_url; }
59-
bool hasSourceURL() const { return !m_sourceURL.isEmpty(); }
60-
const String16& sourceURL() const;
59+
bool hasSourceURLComment() const { return m_hasSourceURLComment; }
60+
const String16& sourceURL() const { return m_url; }
61+
6162
virtual const String16& sourceMappingURL() const = 0;
6263
virtual const String16& source() const = 0;
6364
virtual const String16& hash() const = 0;
@@ -95,7 +96,7 @@ class V8DebuggerScript {
9596

9697
String16 m_id;
9798
String16 m_url;
98-
String16 m_sourceURL;
99+
bool m_hasSourceURLComment = false;
99100
int m_executionContextId = 0;
100101

101102
v8::Isolate* m_isolate;
Collapse file

‎deps/v8/src/inspector/v8-debugger.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/inspector/v8-debugger.cc
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,15 @@ void V8Debugger::getCompiledScripts(
227227
v8::Local<v8::debug::Script> script = scripts.Get(i);
228228
if (!script->WasCompiled()) continue;
229229
if (script->IsEmbedded()) {
230-
result.push_back(V8DebuggerScript::Create(m_isolate, script, false));
230+
result.push_back(V8DebuggerScript::Create(m_isolate, script, false,
231+
m_inspector->client()));
231232
continue;
232233
}
233234
int contextId;
234235
if (!script->ContextId().To(&contextId)) continue;
235236
if (m_inspector->contextGroupId(contextId) != contextGroupId) continue;
236-
result.push_back(V8DebuggerScript::Create(m_isolate, script, false));
237+
result.push_back(V8DebuggerScript::Create(m_isolate, script, false,
238+
m_inspector->client()));
237239
}
238240
}
239241

@@ -542,13 +544,14 @@ void V8Debugger::ScriptCompiled(v8::Local<v8::debug::Script> script,
542544
});
543545
} else if (m_ignoreScriptParsedEventsCounter == 0) {
544546
v8::Isolate* isolate = m_isolate;
547+
V8InspectorClient* client = m_inspector->client();
545548
m_inspector->forEachSession(
546549
m_inspector->contextGroupId(contextId),
547-
[&isolate, &script, &has_compile_error,
548-
&is_live_edited](V8InspectorSessionImpl* session) {
550+
[&isolate, &script, &has_compile_error, &is_live_edited,
551+
&client](V8InspectorSessionImpl* session) {
549552
if (!session->debuggerAgent()->enabled()) return;
550553
session->debuggerAgent()->didParseSource(
551-
V8DebuggerScript::Create(isolate, script, is_live_edited),
554+
V8DebuggerScript::Create(isolate, script, is_live_edited, client),
552555
!has_compile_error);
553556
});
554557
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.