Expose `ScriptDebugger::get_breakpoints`

This commit is contained in:
voidedWarranties 2024-08-17 02:09:59 -07:00
parent 1bd740d18d
commit 75ca145ac1
3 changed files with 24 additions and 0 deletions

View File

@ -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<int, HashSet<StringName>> &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);

View File

@ -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();

View File

@ -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.
</description>
</method>
<method name="get_breakpoints" qualifiers="const">
<return type="Dictionary" />
<description>
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.
</description>
</method>
<method name="get_depth" qualifiers="const" experimental="">
<return type="int" />
<description>