Add V8StackFrame export
To be able to retrieve structured stacktrace information like the functionName of single stack frames outsite of v8, this cl adds a V8StackFrame class and a function to retrieve them from V8StacKFrames. Bug: chromium:1393317 Change-Id: Idae150aeb03f7b65294c4c6a6979c298a569e6d2 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4067040 Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Judith Hemp <hempjudith@google.com> Cr-Commit-Position: refs/heads/main@{#84676}
This commit is contained in:
parent
4b565358d6
commit
8ef8a016dc
@ -32,19 +32,19 @@ namespace Debugger {
|
|||||||
namespace API {
|
namespace API {
|
||||||
class SearchMatch;
|
class SearchMatch;
|
||||||
}
|
}
|
||||||
}
|
} // namespace Debugger
|
||||||
namespace Runtime {
|
namespace Runtime {
|
||||||
namespace API {
|
namespace API {
|
||||||
class RemoteObject;
|
class RemoteObject;
|
||||||
class StackTrace;
|
class StackTrace;
|
||||||
class StackTraceId;
|
class StackTraceId;
|
||||||
}
|
} // namespace API
|
||||||
}
|
} // namespace Runtime
|
||||||
namespace Schema {
|
namespace Schema {
|
||||||
namespace API {
|
namespace API {
|
||||||
class Domain;
|
class Domain;
|
||||||
}
|
}
|
||||||
}
|
} // namespace Schema
|
||||||
} // namespace protocol
|
} // namespace protocol
|
||||||
|
|
||||||
class V8_EXPORT StringView {
|
class V8_EXPORT StringView {
|
||||||
@ -134,6 +134,13 @@ class V8_EXPORT V8DebuggerId {
|
|||||||
int64_t m_second = 0;
|
int64_t m_second = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct V8_EXPORT V8StackFrame {
|
||||||
|
StringView sourceURL;
|
||||||
|
StringView functionName;
|
||||||
|
int lineNumber;
|
||||||
|
int columnNumber;
|
||||||
|
};
|
||||||
|
|
||||||
class V8_EXPORT V8StackTrace {
|
class V8_EXPORT V8StackTrace {
|
||||||
public:
|
public:
|
||||||
virtual StringView firstNonEmptySourceURL() const = 0;
|
virtual StringView firstNonEmptySourceURL() const = 0;
|
||||||
@ -151,6 +158,8 @@ class V8_EXPORT V8StackTrace {
|
|||||||
|
|
||||||
// Safe to pass between threads, drops async chain.
|
// Safe to pass between threads, drops async chain.
|
||||||
virtual std::unique_ptr<V8StackTrace> clone() = 0;
|
virtual std::unique_ptr<V8StackTrace> clone() = 0;
|
||||||
|
|
||||||
|
virtual std::vector<V8StackFrame> frames() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class V8_EXPORT V8InspectorSession {
|
class V8_EXPORT V8InspectorSession {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Copyright 2016 the V8 project authors. All rights reserved.
|
// Copyright 2016 the V8 project authors. All rights reserved.
|
||||||
|
//
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
@ -10,6 +11,8 @@
|
|||||||
#include "src/inspector/v8-stack-trace-impl.h"
|
#include "src/inspector/v8-stack-trace-impl.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "../../third_party/inspector_protocol/crdtp/json.h"
|
#include "../../third_party/inspector_protocol/crdtp/json.h"
|
||||||
#include "src/debug/debug-interface.h"
|
#include "src/debug/debug-interface.h"
|
||||||
@ -313,6 +316,21 @@ StringView V8StackTraceImpl::topFunctionName() const {
|
|||||||
return toStringView(m_frames[0]->functionName());
|
return toStringView(m_frames[0]->functionName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<V8StackFrame> V8StackTraceImpl::frames() const {
|
||||||
|
std::vector<V8StackFrame> ret;
|
||||||
|
ret.reserve(m_frames.size());
|
||||||
|
|
||||||
|
for (const auto& frame : m_frames) {
|
||||||
|
if (frame) {
|
||||||
|
ret.emplace_back(V8StackFrame{
|
||||||
|
toStringView(frame->sourceURL()), toStringView(frame->functionName()),
|
||||||
|
frame->lineNumber() + 1, frame->columnNumber() + 1});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<protocol::Runtime::StackTrace>
|
std::unique_ptr<protocol::Runtime::StackTrace>
|
||||||
V8StackTraceImpl::buildInspectorObjectImpl(V8Debugger* debugger) const {
|
V8StackTraceImpl::buildInspectorObjectImpl(V8Debugger* debugger) const {
|
||||||
return buildInspectorObjectImpl(debugger, m_maxAsyncDepth);
|
return buildInspectorObjectImpl(debugger, m_maxAsyncDepth);
|
||||||
|
@ -84,6 +84,8 @@ class V8StackTraceImpl : public V8StackTrace {
|
|||||||
|
|
||||||
bool isEqualIgnoringTopFrame(V8StackTraceImpl* stackTrace) const;
|
bool isEqualIgnoringTopFrame(V8StackTraceImpl* stackTrace) const;
|
||||||
|
|
||||||
|
std::vector<V8StackFrame> frames() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
V8StackTraceImpl(std::vector<std::shared_ptr<StackFrame>> frames,
|
V8StackTraceImpl(std::vector<std::shared_ptr<StackFrame>> frames,
|
||||||
int maxAsyncDepth,
|
int maxAsyncDepth,
|
||||||
|
Loading…
Reference in New Issue
Block a user