Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/gdscript/gdscript.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,13 @@ class GDScriptLanguage : public ScriptLanguage {
_call_stack.stack_pos--;
}

_FORCE_INLINE_ void notify_resumed_function_finished(int *p_line) {
if (track_call_stack) {
// Update line pointer to extend its lifetime.
_call_stack.levels[_call_stack.stack_pos - 1].line = p_line;
}
}

virtual Vector<StackInfo> debug_get_current_stack_info() override {
Vector<StackInfo> csi;
csi.resize(_call_stack.stack_pos);
Expand Down
6 changes: 6 additions & 0 deletions modules/gdscript/gdscript_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3874,6 +3874,12 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
for (int i = FIXED_ADDRESSES_MAX; i < _stack_size; i++) {
stack[i].~Variant();
}
} else if (p_state) {
// This means we have finished executing a resumed function and it was not awaited again.
// We update CallLevel::line pointer to CallState::line since local `line` variable will be popped from stack.
// This ensures frame lines are correctly reported in the debugger and backtrace.
p_state->line = line;
GDScriptLanguage::get_singleton()->notify_resumed_function_finished(&p_state->line);
}

// Always free reserved addresses, since they are never copied.
Expand Down