53. Debugging in PCA and in Godot
Validate checks the prepared script, including its inherited base and generated record bindings. It is a parser check, not a complete test of every runtime path. A missing record, invalid node or wrong signal argument can still fail during play.
Use Log/print to inspect branches and values. Native breakpoint and the Godot debugger work in an actual Godot debugging session; do not expect PCA Script’s VM watch/step panel to become a full native GDScript debugger.
1. Reproduce the smallest failing interaction. Read the first useful error, including script/function and line information.
2. Log IDs and types before a dynamic call. Check is_instance_valid for nodes and Exists for record proxies.
3. For full native stepping, export/open the editable Godot project and run it under Godot’s debugger. Breakpoints, locals, remote scene tree and the profiler then describe the native execution.
4. Retest after removing diagnostics. Test unsuccessful paths, repeated calls, room changes and save/load.
Generated inheritance/binding lines can affect prepared-source line numbers. Avoid debugging by guessing which invisible line was added; inspect the source preparation/actual debugger location when needed.
A local error should not be “fixed” by replacing every value with Variant. Use the correct type and lifetime, then keep the dynamic boundary explicit where the API actually returns Variant.
