From 75ca145ac1e111f870a6ca8de9f5d1c4b5555ca3 Mon Sep 17 00:00:00 2001 From: voidedWarranties Date: Sat, 17 Aug 2024 02:09:59 -0700 Subject: [PATCH] Expose `ScriptDebugger::get_breakpoints` --- core/core_bind.cpp | 17 +++++++++++++++++ core/core_bind.h | 1 + doc/classes/EngineDebugger.xml | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/core/core_bind.cpp b/core/core_bind.cpp index a15085bcde5..f1eabf78972 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -2005,6 +2005,22 @@ bool EngineDebugger::is_skipping_breakpoints() const { return ::EngineDebugger::get_script_debugger()->is_skipping_breakpoints(); } +Dictionary EngineDebugger::get_breakpoints() const { + ERR_FAIL_COND_V_MSG(!::EngineDebugger::get_script_debugger(), Dictionary(), "Can't get breakpoints. No active debugger"); + + Dictionary d; + for (const KeyValue> &E : ::EngineDebugger::get_script_debugger()->get_breakpoints()) { + Array a; + for (const StringName &F : E.value) { + a.push_back(F); + } + + d[E.key] = a; + } + + return d; +} + void EngineDebugger::insert_breakpoint(int p_line, const StringName &p_source) { ERR_FAIL_COND_MSG(!::EngineDebugger::get_script_debugger(), "Can't insert breakpoint. No active debugger"); ::EngineDebugger::get_script_debugger()->insert_breakpoint(p_line, p_source); @@ -2059,6 +2075,7 @@ void EngineDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("is_breakpoint", "line", "source"), &EngineDebugger::is_breakpoint); ClassDB::bind_method(D_METHOD("is_skipping_breakpoints"), &EngineDebugger::is_skipping_breakpoints); + ClassDB::bind_method(D_METHOD("get_breakpoints"), &EngineDebugger::get_breakpoints); ClassDB::bind_method(D_METHOD("insert_breakpoint", "line", "source"), &EngineDebugger::insert_breakpoint); ClassDB::bind_method(D_METHOD("remove_breakpoint", "line", "source"), &EngineDebugger::remove_breakpoint); ClassDB::bind_method(D_METHOD("clear_breakpoints"), &EngineDebugger::clear_breakpoints); diff --git a/core/core_bind.h b/core/core_bind.h index 69a359e4ed5..430efd36766 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -596,6 +596,7 @@ public: bool is_breakpoint(int p_line, const StringName &p_source) const; bool is_skipping_breakpoints() const; + Dictionary get_breakpoints() const; void insert_breakpoint(int p_line, const StringName &p_source); void remove_breakpoint(int p_line, const StringName &p_source); void clear_breakpoints(); diff --git a/doc/classes/EngineDebugger.xml b/doc/classes/EngineDebugger.xml index 7583520da0d..c80bcb63cdf 100644 --- a/doc/classes/EngineDebugger.xml +++ b/doc/classes/EngineDebugger.xml @@ -23,6 +23,12 @@ Starts a debug break in script execution, optionally specifying whether the program can continue based on [param can_continue] and whether the break was due to a breakpoint. + + + + Gets all breakpoints in the debugging session. Returns a [Dictionary] mapping [int] line numbers to [Array]s of [StringName] representing the paths to the scripts where the breakpoints are set. + +