Skip to content
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

push_error/warning should print GDScript line, not C++ #76770

Open
TokisanGames opened this issue May 6, 2023 · 0 comments · May be fixed by #93648
Open

push_error/warning should print GDScript line, not C++ #76770

TokisanGames opened this issue May 6, 2023 · 0 comments · May be fixed by #93648

Comments

@TokisanGames
Copy link
Contributor

TokisanGames commented May 6, 2023

Godot version

4.0.2

System information

Windows 11/64, RTX 3070, Vulkan

Issue description

These functions should print the GDScript line number, not some random C++ line number. The first is useful for a gdscript developer. The second two are not.

print_debug()

unlock not found in Controls.INPUT_ACTIONS
   At: res://src/ui/hud/Commands.gd:23:_ready()

push_warning()

WARNING: unlock not found in Controls.INPUT_ACTIONS
     at: push_warning (core/variant/variant_utility.cpp:922)

push_error()

ERROR: unlock not found in Controls.INPUT_ACTIONS
   at: push_error (core/variant/variant_utility.cpp:902)

Related to godotengine/godot-proposals#1378, godotengine/godot-proposals#919

Steps to reproduce

See above

Minimal reproduction project

n/a

@clayjohn clayjohn added this to the 4.x milestone May 6, 2023
TV4Fun added a commit to TV4Fun/godot that referenced this issue Jun 27, 2024
Currently, `push_error` and `push_warning` give themselve as the calling
function, which is not useful for debugging. I have altered these to use the
C stacktrace to get the name of the function that called them. This saves
having to turn these functions into macros, which would require recompiling
every single piece of code that uses them. I have also set it to, when debug
symbols are available, use them with `atos` (available on macOS) to find the
exact source file and line being called from. It should be possible to the same
thing on Linux using `addr2line`, but I don't have a Linux box handy to test
that. I am not sure how you would implement this in Windows.

I have tested this on macOS Sonoma 14.5 (23F79). It should work on any *nix
system. I am not sure about Windows.

Fixes godotengine#76770
TV4Fun added a commit to TV4Fun/godot that referenced this issue Jul 3, 2024
Currently, `push_error` and `push_warning` give themselve as the calling
function, which is not useful for debugging. I have altered these to use the
C stacktrace to get the name of the function that called them. This saves
having to turn these functions into macros, which would require recompiling
every single piece of code that uses them. I have also set it to, when debug
symbols are available, use them with `atos` (available on macOS) to find the
exact source file and line being called from. It should be possible to the same
thing on Linux using `addr2line`, but I don't have a Linux box handy to test
that. I am not sure how you would implement this in Windows.

I have tested this on macOS Sonoma 14.5 (23F79). It should work on any *nix
system. I am not sure about Windows.

Fixes godotengine#76770
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants