Watch-points for variables #11994
Replies: 2 comments 2 replies
-
See: |
Beta Was this translation helpful? Give feedback.
-
I'm not against watchpoints, I'm just pointing out a workaround. You can use a breakpoint inside the setter and watch the caller in the call stack, you don't have to put a breakpoint on every assignment. Also, you can wrap the breakpoint in some condition, including checking where the setter is called from with var _temp_my_var_setter_trigger_count: int = 0
var my_var: int:
set(value):
_temp_my_var_trigger_count += 1
var stack: Array = get_stack()
if (
value > 10
and stack.size() > 1
and stack[1].source != "res://definitely_unrelated.gd"
and _temp_my_var_setter_trigger_count > 3
):
breakpoint
my_var = value |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm new to Godot (I've been learning it for about three months), but as far as I know, there is no way to create a watch-point for a variable. Please correct me if I'm wrong.
I have experience programming in SAP with ABAP, where we can set watch-points on variables. These watch-points allow execution to pause at a breakpoint exactly when the variable changes. We can also specify that execution should stop only if the variable takes on a specific value. The debugger then halts on the line immediately after the change occurs.
In Godot, I haven't found a way to achieve this directly. As a workaround, I end up placing breakpoints at every assignment to the variable, which can be tedious when debugging complex cases. I know there are alternatives, such as using a setter with a breakpoint, but as far as I can tell, there isn't a straightforward way to stop execution precisely on the line where the variable's value is modified.
Would it be possible to add native support for watch-points in the debugger? I think this would be a valuable feature for debugging in Godot.
Beta Was this translation helpful? Give feedback.
All reactions