V8 Project
v8::Debug Class Reference

#include <v8-debug.h>

+ Collaboration diagram for v8::Debug:

Classes

class  ClientData
 A client object passed to the v8 debugger whose ownership will be taken by it. More...
 
class  EventDetails
 An event details object passed to the debug event listener. More...
 
class  Message
 A message object passed to the debug message handler. More...
 

Public Types

typedef void(* EventCallback) (const EventDetails &event_details)
 Debug event callback function. More...
 
typedef void(* MessageHandler) (const Message &message)
 Debug message callback function. More...
 
typedef void(* DebugMessageDispatchHandler) ()
 Callback function for the host to ensure debug messages are processed. More...
 

Static Public Member Functions

static bool SetDebugEventListener (EventCallback that, Handle< Value > data=Handle< Value >())
 
static void DebugBreak (Isolate *isolate)
 
static void CancelDebugBreak (Isolate *isolate)
 
static bool CheckDebugBreak (Isolate *isolate)
 
static void DebugBreakForCommand (Isolate *isolate, ClientData *data)
 
static void SetMessageHandler (MessageHandler handler)
 
static void SendCommand (Isolate *isolate, const uint16_t *command, int length, ClientData *client_data=NULL)
 
static Local< ValueCall (v8::Handle< v8::Function > fun, Handle< Value > data=Handle< Value >())
 Run a JavaScript function in the debugger. More...
 
static Local< ValueGetMirror (v8::Handle< v8::Value > obj)
 Returns a mirror object for the given object. More...
 
static void ProcessDebugMessages ()
 Makes V8 process all pending debug messages. More...
 
static Local< ContextGetDebugContext ()
 Debugger is running in its own context which is entered while debugger messages are being dispatched. More...
 
static void SetLiveEditEnabled (Isolate *isolate, bool enable)
 Enable/disable LiveEdit functionality for the given Isolate (default Isolate if not provided). More...
 

Detailed Description

Definition at line 29 of file v8-debug.h.

Member Typedef Documentation

◆ DebugMessageDispatchHandler

typedef void(* v8::Debug::DebugMessageDispatchHandler) ()

Callback function for the host to ensure debug messages are processed.

Definition at line 157 of file v8-debug.h.

◆ EventCallback

typedef void(* v8::Debug::EventCallback) (const EventDetails &event_details)

Debug event callback function.

Parameters
event_detailsobject providing information about the debug event

A EventCallback2 does not take possession of the event data, and must not rely on the data persisting after the handler returns.

Definition at line 142 of file v8-debug.h.

◆ MessageHandler

typedef void(* v8::Debug::MessageHandler) (const Message &message)

Debug message callback function.

Parameters
messagethe debug message handler message object

A MessageHandler2 does not take possession of the message data, and must not rely on the data persisting after the handler returns.

Definition at line 152 of file v8-debug.h.

Member Function Documentation

◆ Call()

Local< Value > v8::Debug::Call ( v8::Handle< v8::Function fun,
Handle< Value data = Handle<Value>() 
)
static

Run a JavaScript function in the debugger.

Parameters
funthe function to call
datapassed as second argument to the function With this call the debugger is entered and the function specified is called with the execution state as the first argument. This makes it possible to get access to information otherwise not available during normal JavaScript execution e.g. details on stack frames. Receiver of the function call will be the debugger context global object, however this is a subject to change. The following example shows a JavaScript function which when passed to v8::Debug::Call will return the current line of JavaScript execution.
function frame_source_line(exec_state) {
return exec_state.frame(0).sourceLine();
}

Definition at line 6972 of file api.cc.

6973  {
6974  i::Isolate* isolate = i::Isolate::Current();
6975  if (!isolate->IsInitialized()) return Local<Value>();
6976  ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>());
6977  ENTER_V8(isolate);
6978  i::MaybeHandle<i::Object> maybe_result;
6979  EXCEPTION_PREAMBLE(isolate);
6980  if (data.IsEmpty()) {
6981  maybe_result = isolate->debug()->Call(
6982  Utils::OpenHandle(*fun), isolate->factory()->undefined_value());
6983  } else {
6984  maybe_result = isolate->debug()->Call(
6985  Utils::OpenHandle(*fun), Utils::OpenHandle(*data));
6986  }
6987  i::Handle<i::Object> result;
6988  has_pending_exception = !maybe_result.ToHandle(&result);
6989  EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
6990  return Utils::ToLocal(result);
6991 }
#define ON_BAILOUT(isolate, location, code)
Definition: api.cc:60
#define EXCEPTION_BAILOUT_CHECK(isolate, value)
Definition: api.cc:93
#define ENTER_V8(isolate)
Definition: api.cc:54
#define EXCEPTION_PREAMBLE(isolate)
Definition: api.cc:67
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
MUST_USE_RESULT MaybeHandle< Object > Call(Handle< JSFunction > fun, Handle< Object > data)
Definition: debug.cc:3004
Factory * factory()
Definition: isolate.h:982

References v8::internal::Debug::Call(), v8::internal::Isolate::debug(), ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Isolate::factory(), v8::Handle< T >::IsEmpty(), v8::internal::Isolate::IsInitialized(), ON_BAILOUT, v8::Utils::OpenHandle(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ CancelDebugBreak()

void v8::Debug::CancelDebugBreak ( Isolate isolate)
static

Definition at line 6937 of file api.cc.

6937  {
6938  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6939  internal_isolate->stack_guard()->ClearDebugBreak();
6940 }
StackGuard * stack_guard()
Definition: isolate.h:872

References v8::internal::Isolate::stack_guard().

+ Here is the call graph for this function:

◆ CheckDebugBreak()

bool v8::Debug::CheckDebugBreak ( Isolate isolate)
static

Definition at line 6943 of file api.cc.

6943  {
6944  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6945  return internal_isolate->stack_guard()->CheckDebugBreak();
6946 }

References v8::internal::Isolate::stack_guard().

+ Here is the call graph for this function:

◆ DebugBreak()

void v8::Debug::DebugBreak ( Isolate isolate)
static

Definition at line 6932 of file api.cc.

6932  {
6933  reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak();
6934 }

◆ DebugBreakForCommand()

void v8::Debug::DebugBreakForCommand ( Isolate isolate,
ClientData data 
)
static

Definition at line 6949 of file api.cc.

6949  {
6950  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6951  internal_isolate->debug()->EnqueueDebugCommand(data);
6952 }
void EnqueueDebugCommand(v8::Debug::ClientData *client_data=NULL)
Definition: debug.cc:2995

References v8::internal::Isolate::debug(), and v8::internal::Debug::EnqueueDebugCommand().

+ Here is the call graph for this function:

◆ GetDebugContext()

Local< Context > v8::Debug::GetDebugContext ( )
static

Debugger is running in its own context which is entered while debugger messages are being dispatched.

This is an explicit getter for this debugger context. Note that the content of the debugger context is subject to change.

Definition at line 7028 of file api.cc.

7028  {
7029  i::Isolate* isolate = i::Isolate::Current();
7030  ENTER_V8(isolate);
7031  return Utils::ToLocal(i::Isolate::Current()->debug()->GetDebugContext());
7032 }
static Local< Context > GetDebugContext()
Debugger is running in its own context which is entered while debugger messages are being dispatched.
Definition: api.cc:7028

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

+ Here is the call graph for this function:

◆ GetMirror()

Local< Value > v8::Debug::GetMirror ( v8::Handle< v8::Value obj)
static

Returns a mirror object for the given object.

Definition at line 6994 of file api.cc.

6994  {
6995  i::Isolate* isolate = i::Isolate::Current();
6996  if (!isolate->IsInitialized()) return Local<Value>();
6997  ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>());
6998  ENTER_V8(isolate);
6999  v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
7000  i::Debug* isolate_debug = isolate->debug();
7001  EXCEPTION_PREAMBLE(isolate);
7002  has_pending_exception = !isolate_debug->Load();
7003  v8::Local<v8::Value> result;
7004  if (!has_pending_exception) {
7005  i::Handle<i::JSObject> debug(
7006  isolate_debug->debug_context()->global_object());
7007  i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString(
7008  STATIC_CHAR_VECTOR("MakeMirror"));
7009  i::Handle<i::Object> fun_obj =
7010  i::Object::GetProperty(debug, name).ToHandleChecked();
7013  const int kArgc = 1;
7014  v8::Handle<v8::Value> argv[kArgc] = { obj };
7015  result = v8_fun->Call(Utils::ToLocal(debug), kArgc, argv);
7016  has_pending_exception = result.IsEmpty();
7017  }
7018  EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
7019  return scope.Escape(result);
7020 }
A HandleScope which first allocates a handle in the current scope which will be later filled with the...
Definition: v8.h:855
An object reference managed by the v8 garbage collector.
Definition: v8.h:198
bool IsEmpty() const
Returns true if the handle is empty.
Definition: v8.h:228
A light-weight stack-allocated object handle.
Definition: v8.h:334
Handle< Context > debug_context()
Definition: debug.h:459
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
static MUST_USE_RESULT MaybeHandle< Object > GetProperty(LookupIterator *it)
Definition: objects.cc:109
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
#define STATIC_CHAR_VECTOR(x)
Definition: vector.h:154

References v8::internal::Handle< T >::cast(), v8::internal::Isolate::debug(), v8::internal::Debug::debug_context(), ENTER_V8, v8::EscapableHandleScope::Escape(), EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Isolate::factory(), v8::internal::Object::GetProperty(), v8::Handle< T >::IsEmpty(), v8::internal::Isolate::IsInitialized(), v8::internal::Debug::Load(), name, ON_BAILOUT, STATIC_CHAR_VECTOR, and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ ProcessDebugMessages()

void v8::Debug::ProcessDebugMessages ( )
static

Makes V8 process all pending debug messages.

From V8 point of view all debug messages come asynchronously (e.g. from remote debugger) but they all must be handled synchronously: V8 cannot do 2 things at one time so normal script execution must be interrupted for a while.

Generally when message arrives V8 may be in one of 3 states:

  1. V8 is running script; V8 will automatically interrupt and process all pending messages;
  2. V8 is suspended on debug breakpoint; in this state V8 is dedicated to reading and processing debug messages;
  3. V8 is not running at all or has called some long-working C++ function; by default it means that processing of all debug messages will be deferred until V8 gets control again; however, embedding application may improve this by manually calling this method.

Technically this method in many senses is equivalent to executing empty script:

  1. It does nothing except for processing all pending debug messages.
  2. It should be invoked with the same precautions and from the same context as V8 script would be invoked from, because: a. with "evaluate" command it can do whatever normal script can do, including all native calls; b. no other thread should call V8 while this method is running (v8::Locker may be used here).

"Evaluate" debug command behavior currently is not specified in scope of this method.

Definition at line 7023 of file api.cc.

7023  {
7024  i::Isolate::Current()->debug()->ProcessDebugMessages(true);
7025 }

◆ SendCommand()

void v8::Debug::SendCommand ( Isolate isolate,
const uint16_t *  command,
int  length,
ClientData client_data = NULL 
)
static

Definition at line 6962 of file api.cc.

6965  {
6966  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6967  internal_isolate->debug()->EnqueueCommandMessage(
6968  i::Vector<const uint16_t>(command, length), client_data);
6969 }
void EnqueueCommandMessage(Vector< const uint16_t > command, v8::Debug::ClientData *client_data=NULL)
Definition: debug.cc:2979

References v8::internal::Isolate::debug(), and v8::internal::Debug::EnqueueCommandMessage().

+ Here is the call graph for this function:

◆ SetDebugEventListener()

bool v8::Debug::SetDebugEventListener ( EventCallback  that,
Handle< Value data = Handle<Value>() 
)
static

Definition at line 6917 of file api.cc.

6917  {
6918  i::Isolate* isolate = i::Isolate::Current();
6919  ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
6920  ENTER_V8(isolate);
6921  i::HandleScope scope(isolate);
6922  i::Handle<i::Object> foreign = isolate->factory()->undefined_value();
6923  if (that != NULL) {
6924  foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that));
6925  }
6926  isolate->debug()->SetEventListener(foreign,
6927  Utils::OpenHandle(*data, true));
6928  return true;
6929 }
void SetEventListener(Handle< Object > callback, Handle< Object > data)
Definition: debug.cc:2921
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define FUNCTION_ADDR(f)
Definition: globals.h:195

References v8::internal::Isolate::debug(), ENTER_V8, v8::internal::Isolate::factory(), FUNCTION_ADDR, NULL, ON_BAILOUT, v8::Utils::OpenHandle(), and v8::internal::Debug::SetEventListener().

Referenced by v8::Shell::InstallUtilityScript().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetLiveEditEnabled()

void v8::Debug::SetLiveEditEnabled ( Isolate isolate,
bool  enable 
)
static

Enable/disable LiveEdit functionality for the given Isolate (default Isolate if not provided).

V8 will abort if LiveEdit is unexpectedly used. LiveEdit is enabled by default.

Definition at line 7035 of file api.cc.

7035  {
7036  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
7037  internal_isolate->debug()->set_live_edit_enabled(enable);
7038 }
void set_live_edit_enabled(bool v)
Definition: debug.h:460

References v8::internal::Isolate::debug(), and v8::internal::Debug::set_live_edit_enabled().

+ Here is the call graph for this function:

◆ SetMessageHandler()

void v8::Debug::SetMessageHandler ( MessageHandler  handler)
static

Definition at line 6955 of file api.cc.

6955  {
6956  i::Isolate* isolate = i::Isolate::Current();
6957  ENTER_V8(isolate);
6958  isolate->debug()->SetMessageHandler(handler);
6959 }
void SetMessageHandler(v8::Debug::MessageHandler handler)
Definition: debug.cc:2942

References v8::internal::Isolate::debug(), ENTER_V8, and v8::internal::Debug::SetMessageHandler().

+ Here is the call graph for this function:

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