-
-
Notifications
You must be signed in to change notification settings - Fork 22.2k
GDScript: Update get_stack()
, print_stack()
, and print_debug()
#105801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
[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]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know what you mean, but maybe it's worth being just a bit more specific, and maybe slightly less technical?
This makes me notice how rarely the three terms are used. "debug build", "editor build", "release build". I've more often seen "when running the project in [...]" and similar (basically expanding the meaning of a "build"), but it's harder to keep count of them.
[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]. | |
[b]Note:[/b] By default, this function is only available when running the project in the editor or in debug builds. To enable them for release builds, [member ProjectSettings.debug/settings/gdscript/always_track_call_stacks] must be enabled. |
Mmmm...
Also applies for the other descriptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Borrowed from here:
Lines 12 to 21 in e37c626
<method name="capture_script_backtraces" qualifiers="const"> | |
<return type="ScriptBacktrace[]" /> | |
<param index="0" name="include_variables" type="bool" default="false" /> | |
<description> | |
Captures and returns backtraces from all registered script languages. | |
By default, the returned [ScriptBacktrace] will only contain stack frames 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]. | |
If [param include_variables] is [code]true[/code], the backtrace will also include the names and values of any global variables (e.g. autoload singletons) at the point of the capture, as well as local variables and class member variables at each stack frame. This will however will only be respected when running the game with a debugger attached, like when running the game from the editor. To enable it for export builds as well, you need to enable [member ProjectSettings.debug/settings/gdscript/always_track_local_variables]. | |
[b]Warning:[/b] When [param include_variables] is [code]true[/code], any captured variables can potentially (e.g. with GDScript backtraces) be their actual values, including any object references. This means that storing such a [ScriptBacktrace] will prevent those objects from being deallocated, so it's generally recommended not to do so. | |
</description> | |
</method> |
By default, this function is only available
I would avoid such wording. These functions are available and work in all builds without any errors or warnings, it's just that the result differs depending on the build and project settings.
Initially I suggested deprecating these functions, but now I think it makes sense to have shorthands for simple scenarios. We just need to add a reference to
Engine.capture_script_backtraces()
for advanced scenarios.Engine.capture_script_backtraces()
, since the stack information is stored inthread_local
variables.Engine.capture_script_backtraces()
use the same mechanism, so the same rules apply to them.Utils.check()
, see the comment.