Commit ba2d0019 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

Add trace events for stack trace capturing and symbolization

R=petermarshall@chromium.org, yangguo@chromium.org

Change-Id: I3d1cb354f6aeae10fda56f4c51bcb43c9fa5462c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2491028Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70710}
parent bc0bfbe8
...@@ -1020,6 +1020,9 @@ Handle<Object> CaptureStackTrace(Isolate* isolate, Handle<Object> caller, ...@@ -1020,6 +1020,9 @@ Handle<Object> CaptureStackTrace(Isolate* isolate, Handle<Object> caller,
CaptureStackTraceOptions options) { CaptureStackTraceOptions options) {
DisallowJavascriptExecution no_js(isolate); DisallowJavascriptExecution no_js(isolate);
TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
"CaptureStackTrace", "maxFrameCount", options.limit);
wasm::WasmCodeRefScope code_ref_scope; wasm::WasmCodeRefScope code_ref_scope;
FrameArrayBuilder builder(isolate, options.skip_mode, options.limit, caller, FrameArrayBuilder builder(isolate, options.skip_mode, options.limit, caller,
options.filter_mode); options.filter_mode);
...@@ -1141,7 +1144,10 @@ Handle<Object> CaptureStackTrace(Isolate* isolate, Handle<Object> caller, ...@@ -1141,7 +1144,10 @@ Handle<Object> CaptureStackTrace(Isolate* isolate, Handle<Object> caller,
} }
} }
return builder.GetElementsAsStackTraceFrameArray(); Handle<FixedArray> stack_trace = builder.GetElementsAsStackTraceFrameArray();
TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
"CaptureStackTrace", "frameCount", stack_trace->length());
return stack_trace;
} }
} // namespace } // namespace
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "../../third_party/inspector_protocol/crdtp/json.h" #include "../../third_party/inspector_protocol/crdtp/json.h"
#include "src/inspector/v8-debugger.h" #include "src/inspector/v8-debugger.h"
#include "src/inspector/v8-inspector-impl.h" #include "src/inspector/v8-inspector-impl.h"
#include "src/tracing/trace-event.h"
using v8_crdtp::SpanFrom; using v8_crdtp::SpanFrom;
using v8_crdtp::json::ConvertCBORToJSON; using v8_crdtp::json::ConvertCBORToJSON;
...@@ -34,6 +35,10 @@ std::vector<std::shared_ptr<StackFrame>> toFramesVector( ...@@ -34,6 +35,10 @@ std::vector<std::shared_ptr<StackFrame>> toFramesVector(
int maxStackSize) { int maxStackSize) {
DCHECK(debugger->isolate()->InContext()); DCHECK(debugger->isolate()->InContext());
int frameCount = std::min(v8StackTrace->GetFrameCount(), maxStackSize); int frameCount = std::min(v8StackTrace->GetFrameCount(), maxStackSize);
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
"SymbolizeStackTrace", "frameCount", frameCount);
std::vector<std::shared_ptr<StackFrame>> frames(frameCount); std::vector<std::shared_ptr<StackFrame>> frames(frameCount);
for (int i = 0; i < frameCount; ++i) { for (int i = 0; i < frameCount; ++i) {
frames[i] = frames[i] =
...@@ -253,6 +258,10 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( ...@@ -253,6 +258,10 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(
std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(
V8Debugger* debugger, int contextGroupId, int maxStackSize) { V8Debugger* debugger, int contextGroupId, int maxStackSize) {
DCHECK(debugger); DCHECK(debugger);
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
"V8StackTraceImpl::capture", "maxFrameCount", maxStackSize);
v8::Isolate* isolate = debugger->isolate(); v8::Isolate* isolate = debugger->isolate();
v8::HandleScope handleScope(isolate); v8::HandleScope handleScope(isolate);
v8::Local<v8::StackTrace> v8StackTrace; v8::Local<v8::StackTrace> v8StackTrace;
...@@ -404,6 +413,9 @@ std::shared_ptr<AsyncStackTrace> AsyncStackTrace::capture( ...@@ -404,6 +413,9 @@ std::shared_ptr<AsyncStackTrace> AsyncStackTrace::capture(
int maxStackSize) { int maxStackSize) {
DCHECK(debugger); DCHECK(debugger);
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
"AsyncStackTrace::capture", "maxFrameCount", maxStackSize);
v8::Isolate* isolate = debugger->isolate(); v8::Isolate* isolate = debugger->isolate();
v8::HandleScope handleScope(isolate); v8::HandleScope handleScope(isolate);
......
...@@ -196,6 +196,9 @@ Handle<StackFrameInfo> StackTraceFrame::GetFrameInfo( ...@@ -196,6 +196,9 @@ Handle<StackFrameInfo> StackTraceFrame::GetFrameInfo(
// static // static
void StackTraceFrame::InitializeFrameInfo(Handle<StackTraceFrame> frame) { void StackTraceFrame::InitializeFrameInfo(Handle<StackTraceFrame> frame) {
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
"SymbolizeStackFrame", "frameIndex", frame->frame_index());
Isolate* isolate = frame->GetIsolate(); Isolate* isolate = frame->GetIsolate();
Handle<StackFrameInfo> frame_info = isolate->factory()->NewStackFrameInfo( Handle<StackFrameInfo> frame_info = isolate->factory()->NewStackFrameInfo(
handle(FrameArray::cast(frame->frame_array()), isolate), handle(FrameArray::cast(frame->frame_array()), isolate),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment