HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Nougat 7.0
|
7.0.0_r31
下载
查看原文件
收藏
根目录
external
v8
src
debug
debug.h
// Copyright 2012 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_DEBUG_DEBUG_H_ #define V8_DEBUG_DEBUG_H_ #include "src/allocation.h" #include "src/arguments.h" #include "src/assembler.h" #include "src/base/atomicops.h" #include "src/base/platform/platform.h" #include "src/debug/liveedit.h" #include "src/execution.h" #include "src/factory.h" #include "src/flags.h" #include "src/frames.h" #include "src/hashmap.h" #include "src/runtime/runtime.h" #include "src/string-stream.h" #include "src/v8threads.h" #include "include/v8-debug.h" namespace v8 { namespace internal { // Forward declarations. class DebugScope; // Step actions. NOTE: These values are in macros.py as well. enum StepAction : int8_t { StepNone = -1, // Stepping not prepared. StepOut = 0, // Step out of the current function. StepNext = 1, // Step to the next statement in the current function. StepIn = 2, // Step into new functions invoked or the next statement // in the current function. StepFrame = 3 // Step into a new frame or return to previous frame. }; // Type of exception break. NOTE: These values are in macros.py as well. enum ExceptionBreakType { BreakException = 0, BreakUncaughtException = 1 }; // Type of exception break. enum BreakLocatorType { ALL_BREAK_LOCATIONS, CALLS_AND_RETURNS }; // The different types of breakpoint position alignments. // Must match Debug.BreakPositionAlignment in debug.js enum BreakPositionAlignment { STATEMENT_ALIGNED = 0, BREAK_POSITION_ALIGNED = 1 }; class BreakLocation { public: // Find the break point at the supplied address, or the closest one before // the address. static BreakLocation FromAddress(Handle
debug_info, Address pc); static void FromAddressSameStatement(Handle
debug_info, Address pc, List
* result_out); static BreakLocation FromPosition(Handle
debug_info, int position, BreakPositionAlignment alignment); bool IsDebugBreak() const; inline bool IsReturn() const { return RelocInfo::IsDebugBreakSlotAtReturn(rmode_); } inline bool IsCall() const { return RelocInfo::IsDebugBreakSlotAtCall(rmode_); } inline bool HasBreakPoint() const { return debug_info_->HasBreakPoint(pc_offset_); } Handle
BreakPointObjects() const; void SetBreakPoint(Handle
break_point_object); void ClearBreakPoint(Handle
break_point_object); void SetOneShot(); void ClearOneShot(); inline RelocInfo rinfo() const { return RelocInfo(debug_info_->GetIsolate(), pc(), rmode(), data_, code()); } inline int position() const { return position_; } inline int statement_position() const { return statement_position_; } inline Address pc() const { return code()->entry() + pc_offset_; } inline RelocInfo::Mode rmode() const { return rmode_; } inline Code* code() const { return debug_info_->code(); } private: BreakLocation(Handle
debug_info, RelocInfo* rinfo, int position, int statement_position); class Iterator { public: Iterator(Handle
debug_info, BreakLocatorType type); BreakLocation GetBreakLocation() { return BreakLocation(debug_info_, rinfo(), position(), statement_position()); } inline bool Done() const { return reloc_iterator_.done(); } void Next(); void SkipTo(int count) { while (count-- > 0) Next(); } inline RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } inline RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } inline Address pc() { return rinfo()->pc(); } int break_index() const { return break_index_; } inline int position() const { return position_; } inline int statement_position() const { return statement_position_; } private: static int GetModeMask(BreakLocatorType type); Handle
debug_info_; RelocIterator reloc_iterator_; int break_index_; int position_; int statement_position_; DisallowHeapAllocation no_gc_; DISALLOW_COPY_AND_ASSIGN(Iterator); }; friend class Debug; static int BreakIndexFromAddress(Handle
debug_info, Address pc); void SetDebugBreak(); void ClearDebugBreak(); inline bool IsDebuggerStatement() const { return RelocInfo::IsDebuggerStatement(rmode_); } inline bool IsDebugBreakSlot() const { return RelocInfo::IsDebugBreakSlot(rmode_); } Handle
debug_info_; int pc_offset_; RelocInfo::Mode rmode_; intptr_t data_; int position_; int statement_position_; }; // Linked list holding debug info objects. The debug info objects are kept as // weak handles to avoid a debug info object to keep a function alive. class DebugInfoListNode { public: explicit DebugInfoListNode(DebugInfo* debug_info); ~DebugInfoListNode(); DebugInfoListNode* next() { return next_; } void set_next(DebugInfoListNode* next) { next_ = next; } Handle
debug_info() { return Handle
(debug_info_); } private: // Global (weak) handle to the debug info object. DebugInfo** debug_info_; // Next pointer for linked list. DebugInfoListNode* next_; }; // Message delivered to the message handler callback. This is either a debugger // event or the response to a command. class MessageImpl: public v8::Debug::Message { public: // Create a message object for a debug event. static MessageImpl NewEvent(DebugEvent event, bool running, Handle
exec_state, Handle
event_data); // Create a message object for the response to a debug command. static MessageImpl NewResponse(DebugEvent event, bool running, Handle
exec_state, Handle
event_data, Handle
response_json, v8::Debug::ClientData* client_data); // Implementation of interface v8::Debug::Message. virtual bool IsEvent() const; virtual bool IsResponse() const; virtual DebugEvent GetEvent() const; virtual bool WillStartRunning() const; virtual v8::Local
GetExecutionState() const; virtual v8::Local
GetEventData() const; virtual v8::Local
GetJSON() const; virtual v8::Local
GetEventContext() const; virtual v8::Debug::ClientData* GetClientData() const; virtual v8::Isolate* GetIsolate() const; private: MessageImpl(bool is_event, DebugEvent event, bool running, Handle
exec_state, Handle
event_data, Handle
response_json, v8::Debug::ClientData* client_data); bool is_event_; // Does this message represent a debug event? DebugEvent event_; // Debug event causing the break. bool running_; // Will the VM start running after this event? Handle
exec_state_; // Current execution state. Handle
event_data_; // Data associated with the event. Handle
response_json_; // Response JSON if message holds a response. v8::Debug::ClientData* client_data_; // Client data passed with the request. }; // Details of the debug event delivered to the debug event listener. class EventDetailsImpl : public v8::Debug::EventDetails { public: EventDetailsImpl(DebugEvent event, Handle
exec_state, Handle
event_data, Handle
callback_data, v8::Debug::ClientData* client_data); virtual DebugEvent GetEvent() const; virtual v8::Local
GetExecutionState() const; virtual v8::Local
GetEventData() const; virtual v8::Local
GetEventContext() const; virtual v8::Local
GetCallbackData() const; virtual v8::Debug::ClientData* GetClientData() const; private: DebugEvent event_; // Debug event causing the break. Handle
exec_state_; // Current execution state. Handle
event_data_; // Data associated with the event. Handle
callback_data_; // User data passed with the callback // when it was registered. v8::Debug::ClientData* client_data_; // Data passed to DebugBreakForCommand. }; // Message send by user to v8 debugger or debugger output message. // In addition to command text it may contain a pointer to some user data // which are expected to be passed along with the command reponse to message // handler. class CommandMessage { public: static CommandMessage New(const Vector
& command, v8::Debug::ClientData* data); CommandMessage(); // Deletes user data and disposes of the text. void Dispose(); Vector
text() const { return text_; } v8::Debug::ClientData* client_data() const { return client_data_; } private: CommandMessage(const Vector
& text, v8::Debug::ClientData* data); Vector
text_; v8::Debug::ClientData* client_data_; }; // A Queue of CommandMessage objects. A thread-safe version is // LockingCommandMessageQueue, based on this class. class CommandMessageQueue BASE_EMBEDDED { public: explicit CommandMessageQueue(int size); ~CommandMessageQueue(); bool IsEmpty() const { return start_ == end_; } CommandMessage Get(); void Put(const CommandMessage& message); void Clear() { start_ = end_ = 0; } // Queue is empty after Clear(). private: // Doubles the size of the message queue, and copies the messages. void Expand(); CommandMessage* messages_; int start_; int end_; int size_; // The size of the queue buffer. Queue can hold size-1 messages. }; // LockingCommandMessageQueue is a thread-safe circular buffer of CommandMessage // messages. The message data is not managed by LockingCommandMessageQueue. // Pointers to the data are passed in and out. Implemented by adding a // Mutex to CommandMessageQueue. Includes logging of all puts and gets. class LockingCommandMessageQueue BASE_EMBEDDED { public: LockingCommandMessageQueue(Logger* logger, int size); bool IsEmpty() const; CommandMessage Get(); void Put(const CommandMessage& message); void Clear(); private: Logger* logger_; CommandMessageQueue queue_; mutable base::Mutex mutex_; DISALLOW_COPY_AND_ASSIGN(LockingCommandMessageQueue); }; class DebugFeatureTracker { public: enum Feature { kActive = 1, kBreakPoint = 2, kStepping = 3, kHeapSnapshot = 4, kAllocationTracking = 5, kProfiler = 6, kLiveEdit = 7, }; explicit DebugFeatureTracker(Isolate* isolate) : isolate_(isolate), bitfield_(0) {} void Track(Feature feature); private: Isolate* isolate_; uint32_t bitfield_; }; // This class contains the debugger support. The main purpose is to handle // setting break points in the code. // // This class controls the debug info for all functions which currently have // active breakpoints in them. This debug info is held in the heap root object // debug_info which is a FixedArray. Each entry in this list is of class // DebugInfo. class Debug { public: // Debug event triggers. void OnDebugBreak(Handle
break_points_hit, bool auto_continue); void OnThrow(Handle
exception); void OnPromiseReject(Handle
promise, Handle
value); void OnCompileError(Handle
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册