Expose scriptId as integer
Embedders often use integers for representing scriptIds, but the stack trace interface only exposes scriptIds as strings, which introduces the need for parsing the scriptId string to an int in the embedder. This CL also exposes the scriptId as an integer. Bug: chromium:1158782 Change-Id: I7d85ad1497f2eff17f5cd8f9c87f0c72696c1ecf Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2589973 Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#71761}
This commit is contained in:
parent
ef059df6a1
commit
4df69aca81
@ -106,6 +106,7 @@ class V8_EXPORT V8StackTrace {
|
||||
virtual int topLineNumber() const = 0;
|
||||
virtual int topColumnNumber() const = 0;
|
||||
virtual StringView topScriptId() const = 0;
|
||||
virtual int topScriptIdAsInteger() const = 0;
|
||||
virtual StringView topFunctionName() const = 0;
|
||||
|
||||
virtual ~V8StackTrace() = default;
|
||||
|
@ -176,7 +176,8 @@ std::unique_ptr<StringBuffer> V8StackTraceId::ToString() {
|
||||
|
||||
StackFrame::StackFrame(v8::Isolate* isolate, v8::Local<v8::StackFrame> v8Frame)
|
||||
: m_functionName(toProtocolString(isolate, v8Frame->GetFunctionName())),
|
||||
m_scriptId(String16::fromInteger(v8Frame->GetScriptId())),
|
||||
m_scriptId(v8Frame->GetScriptId()),
|
||||
m_scriptIdAsString(String16::fromInteger(v8Frame->GetScriptId())),
|
||||
m_sourceURL(
|
||||
toProtocolString(isolate, v8Frame->GetScriptNameOrSourceURL())),
|
||||
m_lineNumber(v8Frame->GetLineNumber() - 1),
|
||||
@ -189,7 +190,11 @@ StackFrame::StackFrame(v8::Isolate* isolate, v8::Local<v8::StackFrame> v8Frame)
|
||||
|
||||
const String16& StackFrame::functionName() const { return m_functionName; }
|
||||
|
||||
const String16& StackFrame::scriptId() const { return m_scriptId; }
|
||||
int StackFrame::scriptId() const { return m_scriptId; }
|
||||
|
||||
const String16& StackFrame::scriptIdAsString() const {
|
||||
return m_scriptIdAsString;
|
||||
}
|
||||
|
||||
const String16& StackFrame::sourceURL() const { return m_sourceURL; }
|
||||
|
||||
@ -209,7 +214,7 @@ std::unique_ptr<protocol::Runtime::CallFrame> StackFrame::buildInspectorObject(
|
||||
}
|
||||
return protocol::Runtime::CallFrame::create()
|
||||
.setFunctionName(m_functionName)
|
||||
.setScriptId(m_scriptId)
|
||||
.setScriptId(String16::fromInteger(m_scriptId))
|
||||
.setUrl(frameUrl)
|
||||
.setLineNumber(m_lineNumber)
|
||||
.setColumnNumber(m_columnNumber)
|
||||
@ -315,7 +320,11 @@ int V8StackTraceImpl::topColumnNumber() const {
|
||||
}
|
||||
|
||||
StringView V8StackTraceImpl::topScriptId() const {
|
||||
return toStringView(m_frames[0]->scriptId());
|
||||
return toStringView(m_frames[0]->scriptIdAsString());
|
||||
}
|
||||
|
||||
int V8StackTraceImpl::topScriptIdAsInteger() const {
|
||||
return m_frames[0]->scriptId();
|
||||
}
|
||||
|
||||
StringView V8StackTraceImpl::topFunctionName() const {
|
||||
|
@ -26,7 +26,8 @@ class StackFrame {
|
||||
~StackFrame() = default;
|
||||
|
||||
const String16& functionName() const;
|
||||
const String16& scriptId() const;
|
||||
int scriptId() const;
|
||||
const String16& scriptIdAsString() const;
|
||||
const String16& sourceURL() const;
|
||||
int lineNumber() const; // 0-based.
|
||||
int columnNumber() const; // 0-based.
|
||||
@ -36,7 +37,8 @@ class StackFrame {
|
||||
|
||||
private:
|
||||
String16 m_functionName;
|
||||
String16 m_scriptId;
|
||||
int m_scriptId;
|
||||
String16 m_scriptIdAsString;
|
||||
String16 m_sourceURL;
|
||||
int m_lineNumber; // 0-based.
|
||||
int m_columnNumber; // 0-based.
|
||||
@ -74,6 +76,7 @@ class V8StackTraceImpl : public V8StackTrace {
|
||||
int topLineNumber() const override; // 1-based.
|
||||
int topColumnNumber() const override; // 1-based.
|
||||
StringView topScriptId() const override;
|
||||
int topScriptIdAsInteger() const override;
|
||||
StringView topFunctionName() const override;
|
||||
std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject()
|
||||
const override;
|
||||
|
Loading…
Reference in New Issue
Block a user