V8 Project
v8::StackTrace Class Reference

Representation of a JavaScript stack trace. More...

#include <v8.h>

+ Collaboration diagram for v8::StackTrace:

Public Types

enum  StackTraceOptions {
  kLineNumber = 1 , kColumnOffset = 1 << 1 | kLineNumber , kScriptName = 1 << 2 , kFunctionName = 1 << 3 ,
  kIsEval = 1 << 4 , kIsConstructor = 1 << 5 , kScriptNameOrSourceURL = 1 << 6 , kScriptId = 1 << 7 ,
  kExposeFramesAcrossSecurityOrigins = 1 << 8 , kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName , kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
}
 Flags that determine what information is placed captured for each StackFrame when grabbing the current stack trace. More...
 

Public Member Functions

Local< StackFrameGetFrame (uint32_t index) const
 Returns a StackFrame at a particular index. More...
 
int GetFrameCount () const
 Returns the number of StackFrames. More...
 
Local< ArrayAsArray ()
 Returns StackTrace as a v8::Array that contains StackFrame objects. More...
 

Static Public Member Functions

static Local< StackTraceCurrentStackTrace (Isolate *isolate, int frame_limit, StackTraceOptions options=kOverview)
 Grab a snapshot of the current JavaScript execution stack. More...
 

Detailed Description

Representation of a JavaScript stack trace.

The information collected is a snapshot of the execution stack and the information remains valid after execution continues.

Definition at line 1306 of file v8.h.

Member Enumeration Documentation

◆ StackTraceOptions

Flags that determine what information is placed captured for each StackFrame when grabbing the current stack trace.

Enumerator
kLineNumber 
kColumnOffset 
kScriptName 
kFunctionName 
kIsEval 
kIsConstructor 
kScriptNameOrSourceURL 
kScriptId 
kExposeFramesAcrossSecurityOrigins 
kOverview 
kDetailed 

Definition at line 1312 of file v8.h.

1312  {
1313  kLineNumber = 1,
1314  kColumnOffset = 1 << 1 | kLineNumber,
1315  kScriptName = 1 << 2,
1316  kFunctionName = 1 << 3,
1317  kIsEval = 1 << 4,
1318  kIsConstructor = 1 << 5,
1319  kScriptNameOrSourceURL = 1 << 6,
1320  kScriptId = 1 << 7,
1324  };
@ kLineNumber
Definition: v8.h:1313
@ kScriptNameOrSourceURL
Definition: v8.h:1319
@ kIsConstructor
Definition: v8.h:1318
@ kOverview
Definition: v8.h:1322
@ kFunctionName
Definition: v8.h:1316
@ kColumnOffset
Definition: v8.h:1314
@ kScriptName
Definition: v8.h:1315
@ kExposeFramesAcrossSecurityOrigins
Definition: v8.h:1321
@ kDetailed
Definition: v8.h:1323
@ kScriptId
Definition: v8.h:1320

Member Function Documentation

◆ AsArray()

Local< Array > v8::StackTrace::AsArray ( )

Returns StackTrace as a v8::Array that contains StackFrame objects.

Definition at line 2265 of file api.cc.

2265  {
2266  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2267  ENTER_V8(isolate);
2268  return Utils::ToLocal(Utils::OpenHandle(this));
2269 }
#define ENTER_V8(isolate)
Definition: api.cc:54
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:288

References ENTER_V8, v8::Utils::OpenHandle(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ CurrentStackTrace()

Local< StackTrace > v8::StackTrace::CurrentStackTrace ( Isolate isolate,
int  frame_limit,
StackTraceOptions  options = kOverview 
)
static

Grab a snapshot of the current JavaScript execution stack.

Parameters
frame_limitThe maximum number of stack frames we want to capture.
optionsEnumerates the set of things we will capture for each StackFrame.

Definition at line 2272 of file api.cc.

2275  {
2276  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2277  ENTER_V8(i_isolate);
2278  // TODO(dcarney): remove when ScriptDebugServer is fixed.
2279  options = static_cast<StackTraceOptions>(
2280  static_cast<int>(options) | kExposeFramesAcrossSecurityOrigins);
2281  i::Handle<i::JSArray> stackTrace =
2282  i_isolate->CaptureCurrentStackTrace(frame_limit, options);
2283  return Utils::StackTraceToLocal(stackTrace);
2284 }
StackTraceOptions
Flags that determine what information is placed captured for each StackFrame when grabbing the curren...
Definition: v8.h:1312
static Local< StackTrace > StackTraceToLocal(v8::internal::Handle< v8::internal::JSArray > obj)
Handle< JSArray > CaptureCurrentStackTrace(int frame_limit, StackTrace::StackTraceOptions options)
Definition: isolate.cc:439

References v8::internal::Isolate::CaptureCurrentStackTrace(), ENTER_V8, kExposeFramesAcrossSecurityOrigins, and v8::Utils::StackTraceToLocal().

+ Here is the call graph for this function:

◆ GetFrame()

Local< StackFrame > v8::StackTrace::GetFrame ( uint32_t  index) const

Returns a StackFrame at a particular index.

Definition at line 2246 of file api.cc.

2246  {
2247  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2248  ENTER_V8(isolate);
2249  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2251  i::Handle<i::Object> obj =
2252  i::Object::GetElement(isolate, self, index).ToHandleChecked();
2254  return scope.Escape(Utils::StackFrameToLocal(jsobj));
2255 }
static Local< StackFrame > StackFrameToLocal(v8::internal::Handle< v8::internal::JSObject > obj)
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
static MUST_USE_RESULT MaybeHandle< Object > GetElement(Isolate *isolate, Handle< Object > object, uint32_t index)
Definition: objects-inl.h:1113

References v8::internal::Handle< T >::cast(), ENTER_V8, v8::EscapableHandleScope::Escape(), v8::internal::Object::GetElement(), v8::Utils::OpenHandle(), and v8::Utils::StackFrameToLocal().

+ Here is the call graph for this function:

◆ GetFrameCount()

int v8::StackTrace::GetFrameCount ( ) const

Returns the number of StackFrames.

Definition at line 2258 of file api.cc.

2258  {
2259  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2260  ENTER_V8(isolate);
2261  return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
2262 }

References ENTER_V8, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: