1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

GDScript: Update get_stack(), print_stack(), and print_debug()

This commit is contained in:
Danil Alexeev
2025-04-26 21:10:41 +03:00
parent 28089c40c1
commit 2bacfc8b59
4 changed files with 48 additions and 31 deletions

View File

@@ -84,7 +84,7 @@
<method name="get_stack">
<return type="Array" />
<description>
Returns an array of dictionaries representing the current call stack. See also [method print_stack].
Returns an array of dictionaries representing the current call stack.
[codeblock]
func _ready():
foo()
@@ -99,8 +99,8 @@
[codeblock lang=text]
[{function:bar, line:12, source:res://script.gd}, {function:foo, line:9, source:res://script.gd}, {function:_ready, line:6, source:res://script.gd}]
[/codeblock]
[b]Note:[/b] This function only works if the running instance is connected to a debugging server (i.e. an editor instance). [method get_stack] will not work in projects exported in release mode, or in projects exported in debug mode if not connected to a debugging server.
[b]Note:[/b] Calling this function from a [Thread] is not supported. Doing so will return an empty array.
See also [method print_debug], [method print_stack], and [method Engine.capture_script_backtraces].
[b]Note:[/b] By default, backtraces are only available in editor builds and debug builds. To enable them for release builds as well, you need to enable [member ProjectSettings.debug/settings/gdscript/always_track_call_stacks].
</description>
</method>
<method name="inst_to_dict" deprecated="Consider using [method JSON.from_native] or [method Object.get_property_list] instead.">
@@ -197,19 +197,20 @@
Test print
At: res://test.gd:15:_process()
[/codeblock]
[b]Note:[/b] Calling this function from a [Thread] is not supported. Doing so will instead print the thread ID.
See also [method print_stack], [method get_stack], and [method Engine.capture_script_backtraces].
[b]Note:[/b] By default, backtraces are only available in editor builds and debug builds. To enable them for release builds as well, you need to enable [member ProjectSettings.debug/settings/gdscript/always_track_call_stacks].
</description>
</method>
<method name="print_stack">
<return type="void" />
<description>
Prints a stack trace at the current code location. See also [method get_stack].
Prints a stack trace at the current code location.
The output in the console may look like the following:
[codeblock lang=text]
Frame 0 - res://test.gd:16 in function '_process'
[/codeblock]
[b]Note:[/b] This function only works if the running instance is connected to a debugging server (i.e. an editor instance). [method print_stack] will not work in projects exported in release mode, or in projects exported in debug mode if not connected to a debugging server.
[b]Note:[/b] Calling this function from a [Thread] is not supported. Doing so will instead print the thread ID.
See also [method print_debug], [method get_stack], and [method Engine.capture_script_backtraces].
[b]Note:[/b] By default, backtraces are only available in editor builds and debug builds. To enable them for release builds as well, you need to enable [member ProjectSettings.debug/settings/gdscript/always_track_call_stacks].
</description>
</method>
<method name="range" qualifiers="vararg" keywords="seq">