5#ifndef V8_DEBUG_DEBUG_H_
6#define V8_DEBUG_DEBUG_H_
10#include <unordered_map>
31class InterpretedFrame;
33class JSGeneratorObject;
78 std::vector<BreakLocation>* result_out);
143 bool Done()
const {
return source_position_iterator_.done(); }
148 while (
count-- > 0) Next();
151 int code_offset() {
return source_position_iterator_.code_offset(); }
156 void ClearDebugBreak();
157 void SetDebugBreak();
162 int BreakIndexFromPosition(
int position);
241 std::unordered_map<SFIUniqueId, HandleLocation>
map_;
280 std::optional<Tagged<DebugInfo>> TryGetDebugInfo(
291 int* source_position);
296 void SetTerminateOnResume();
300 int* source_position,
int*
id);
303 BreakPointKind
kind = kRegular);
304 void RemoveBreakpoint(
int id);
305#if V8_ENABLE_WEBASSEMBLY
319 bool* has_break_points);
324 void PrepareStepInSuspendedGenerator();
325 void PrepareStepOnThrow();
326 void ClearStepping();
327 void PrepareRestartFrame(
JavaScriptFrame* frame,
int inlined_frame_index);
329 void SetBreakOnNextFunctionCall();
330 void ClearBreakOnNextFunctionCall();
333 void DiscardAllBaselineCode();
336 void PrepareFunctionForDebugExecution(
338 void InstallDebugBreakTrampoline();
339 bool GetPossibleBreakpoints(
Handle<Script> script,
int start_position,
340 int end_position,
bool restrict_to_function,
341 std::vector<BreakLocation>* locations);
346 bool ShouldBeSkipped();
360 void RemoveAllCoverageInfos();
370 bool FindSharedFunctionInfosIntersectingRange(
384 bool AllFramesOnStackAreBlackboxed();
391 bool preview,
bool allow_top_frame_live_editing,
397 char* ArchiveDebug(
char* to);
398 char* RestoreDebug(
char* from);
399 static int ArchiveSpacePerThread();
406 void StartSideEffectCheckMode();
407 void StopSideEffectCheckMode();
419 void PrepareBuiltinForSideEffectCheck(
Isolate* isolate,
Builtin id);
421 bool PerformSideEffectCheckForAccessor(
425 bool PerformSideEffectCheckForInterceptor(
434 return !!base::Relaxed_Load(&thread_local_.current_debug_scope_);
437 return hook_on_function_call_;
448 thread_local_.return_value_ =
value;
455 return reinterpret_cast<Address
>(&hook_on_function_call_);
459 return reinterpret_cast<Address
>(&thread_local_.suspended_generator_);
464 return thread_local_.break_on_next_function_call_;
468 return thread_local_.scheduled_break_on_next_function_call_;
472 return thread_local_.restart_frame_id_ != StackFrameId::NO_ID;
475 return IsRestartFrameScheduled() && thread_local_.restart_frame_id_ == id;
478 thread_local_.restart_frame_id_ = StackFrameId::NO_ID;
479 thread_local_.restart_inline_frame_index_ = -1;
482 return thread_local_.restart_inline_frame_index_;
489 static const int kBreakAtEntryPosition = 0;
492 static const int kInstrumentationId = -1;
497 void NotifyDebuggerPausedEventSent();
499 static char* Iterate(
RootVisitor* v,
char* thread_storage);
502 void ClearMutedLocation();
503#if V8_ENABLE_WEBASSEMBLY
515 void UpdateDebugInfosForExecutionMode();
517 void UpdateHookOnFunctionCall();
521 int CurrentFrameCount();
524 return is_suppressed_ || !is_active_ ||
525 isolate_->debug_execution_mode() == DebugInfo::kSideEffects;
529 thread_local_.suspended_generator_ = Smi::zero();
533 return thread_local_.suspended_generator_ != Smi::zero();
549 void ClearAllBreakPoints();
552 bool returns_only =
false);
569 bool* has_break_points);
572 bool* has_break_points);
575 const std::vector<BreakLocation>& locations);
576#if V8_ENABLE_WEBASSEMBLY
582 bool is_break_at_entry);
590 void ClearAllDebuggerHints();
596 void SetTemporaryObjectTrackingDisabled(
bool disabled);
597 bool GetTemporaryObjectTrackingDisabled()
const;
611 bool running_live_edit_ =
false;
709#if V8_ENABLE_WEBASSEMBLY
746 void set_terminate_on_resume();
758 bool terminate_on_resume_ =
false;
801 debug->GetTemporaryObjectTrackingDisabled()) {
#define DISALLOW_GARBAGE_COLLECTION(name)
ActionAfterInstrumentation
BreakIterator(const BreakIterator &)=delete
BreakIterator & operator=(const BreakIterator &)=delete
SourcePositionTableIterator source_position_iterator_
Handle< DebugInfo > debug_info_
int statement_position() const
Handle< AbstractCode > abstract_code_
static void AllAtCurrentStatement(Handle< DebugInfo > debug_info, JavaScriptFrame *frame, std::vector< BreakLocation > *result_out)
int generator_suspend_id()
BreakLocation(Handle< AbstractCode > abstract_code, DebugBreakType type, int code_offset, int position, int generator_obj_reg_index, int generator_suspend_id)
static bool IsPausedInJsFunctionEntry(JavaScriptFrame *frame)
int generator_obj_reg_index_
bool IsDebugBreakSlot() const
BreakLocation(int position, DebugBreakType type)
Tagged< JSGeneratorObject > GetGeneratorObjectForSuspendedFrame(JavaScriptFrame *frame) const
static BreakLocation Invalid()
bool IsDebugBreakAtEntry() const
static int BreakIndexFromCodeOffset(Handle< DebugInfo > debug_info, DirectHandle< AbstractCode > abstract_code, int offset)
static BreakLocation FromFrame(Handle< DebugInfo > debug_info, JavaScriptFrame *frame)
bool IsReturnOrSuspend() const
bool HasBreakPoint(Isolate *isolate, Handle< DebugInfo > debug_info) const
bool IsDebuggerStatement() const
int generator_suspend_id_
debug::BreakLocationType type() const
DebugInfoCollection *const collection_
DebugInfoCollection::HandleLocation HandleLocation
Tagged< DebugInfo > Next() const
Iterator(DebugInfoCollection *collection)
void DeleteIndex(size_t index)
void Insert(Tagged< SharedFunctionInfo > sfi, Tagged< DebugInfo > debug_info)
std::unordered_map< SFIUniqueId, HandleLocation > map_
V8_EXPORT_PRIVATE Tagged< DebugInfo > EntryAsDebugInfo(size_t index) const
DebugInfoCollection(Isolate *isolate)
bool Contains(Tagged< SharedFunctionInfo > sfi) const
std::optional< Tagged< DebugInfo > > Find(Tagged< SharedFunctionInfo > sfi) const
std::vector< HandleLocation > list_
void DeleteSlow(Tagged< SharedFunctionInfo > sfi)
StackFrameId break_frame_id_
base::ElapsedTimer timer_
PostponeInterruptsScope no_interrupts_
StepAction last_step_action_
int restart_inline_frame_index_
Tagged< Object > ignore_step_into_function_
Tagged< Object > muted_function_
base::AtomicWord current_debug_scope_
bool scheduled_break_on_next_function_call_
bool fast_forward_to_return_
int last_bytecode_offset_
int last_statement_position_
StackFrameId break_frame_id_
Tagged< Object > return_value_
Tagged< Object > suspended_generator_
bool break_on_next_function_call_
StackFrameId restart_frame_id_
Debug(const Debug &)=delete
DebugInfoCollection debug_infos_
bool break_points_active() const
void clear_restart_frame()
bool CheckExecutionState()
bool ignore_events() const
Debug & operator=(const Debug &)=delete
int restart_inline_frame_index() const
void SetTemporaryObjectTrackingDisabled(bool disabled)
void AssertDebugContext()
Address hook_on_function_call_address()
bool break_disabled() const
void ActivateStepOut(StackFrame *frame)
std::atomic< bool > is_active_
void clear_suspended_generator()
ThreadLocal thread_local_
bool break_on_next_function_call() const
bool break_points_active_
void InitThread(const ExecutionAccess &lock)
friend void CheckDebuggerUnloaded()
void set_break_points_active(bool v)
void SetIsolateId(uint64_t id)
bool side_effect_check_failed_
std::unique_ptr< TemporaryObjectsTracker > temporary_objects_
Address is_active_address()
bool break_on_caught_exception_
StackFrameId break_frame_id()
void FreeThreadResources()
StepAction last_step_action()
bool break_on_uncaught_exception_
bool ShouldRestartFrame(StackFrameId id) const
bool scheduled_break_on_function_call() const
IndirectHandle< FunctionTemplateInfo > ignore_side_effects_for_function_template_info_
Tagged< Object > return_value()
bool has_suspended_generator() const
bool in_debug_scope() const
bool hook_on_function_call_
bool IsRestartFrameScheduled() const
std::function< void(Handle< DebugInfo >)> DebugInfoClearFunction
uint64_t IsolateId() const
void PrintBreakLocation()
Address suspended_generator_address()
bool needs_check_on_function_call() const
friend DirectHandle< FixedArray > GetDebuggedFunctions()
void set_return_value(Tagged< Object > value)
IndirectHandle< RegExpMatchInfo > regexp_match_info_
DisableBreak(const DisableBreak &)=delete
bool previous_break_disabled_
DisableBreak(Debug *debug, bool disable=true)
DisableBreak & operator=(const DisableBreak &)=delete
DisableTemporaryObjectTracking(Debug *debug)
DisableTemporaryObjectTracking & operator=(const DisableTemporaryObjectTracking &)=delete
DisableTemporaryObjectTracking(const DisableTemporaryObjectTracking &)=delete
bool previous_tracking_disabled_
~DisableTemporaryObjectTracking()
Handle< Object > return_value_
SuppressDebug(const SuppressDebug &)=delete
SuppressDebug & operator=(const SuppressDebug &)=delete
SuppressDebug(Debug *debug)
ZoneVector< OpIndex > candidates
DisallowGarbageCollection no_gc_
ZoneVector< RpoNumber > & result
@ kIgnoreIfTopFrameBlackboxed
@ kIgnoreIfAllFramesBlackboxed
@ DEBUG_BREAK_SLOT_AT_CALL
@ DEBUG_BREAK_SLOT_AT_SUSPEND
@ DEBUG_BREAK_SLOT_AT_RETURN
#define DCHECK_NE(v1, v2)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define V8_EXPORT_PRIVATE
#define V8_WARN_UNUSED_RESULT
std::unique_ptr< ValueMirror > value