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

Add a way to print a backtrace without stopping/crashing Godot #3062

Open
qarmin opened this issue Jul 30, 2021 · 4 comments
Open

Add a way to print a backtrace without stopping/crashing Godot #3062

qarmin opened this issue Jul 30, 2021 · 4 comments

Comments

@qarmin
Copy link

qarmin commented Jul 30, 2021

Describe the project you are working on

Godot Engine

Describe the problem or limitation you are having in your project

For now Godot print some error messages when starts godotengine/godot#49623 so checking each error with gdb or Qt Creator is slow.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Function like print_backtrace() could print exactly same backtrace as in crash e.g.

[1] /usr/bin/godots() [0x174c080] (/mnt/Miecz/godot3.2/platform/x11/crash_handler_x11.cpp:54)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x41040) [0x7fece20b9040] (??:0)
[3] Object::get(StringName const&, bool*) const (/mnt/Miecz/godot3.2/core/object.cpp:488)
[4] Viewport::_notification(int) (/mnt/Miecz/godot3.2/scene/main/viewport.cpp:401 (discriminator 2))
[5] Viewport::_notificationv(int, bool) (/mnt/Miecz/godot3.2/scene/main/viewport.h:89 (discriminator 14))
[6] Object::notification(int, bool) (/mnt/Miecz/godot3.2/core/object.cpp:929)
[7] SceneTree::_notify_group_pause(StringName const&, int) (/mnt/Miecz/godot3.2/scene/main/scene_tree.cpp:969)
[8] SceneTree::iteration(float) (/mnt/Miecz/godot3.2/scene/main/scene_tree.cpp:478 (discriminator 2))
[9] Main::iteration() (/mnt/Miecz/godot3.2/main/main.cpp:2075)
[10] OS_X11::run() (/mnt/Miecz/godot3.2/platform/x11/os_x11.cpp:3626)
[11] /usr/bin/godots(main+0x326) [0x1742d0c] (/mnt/Miecz/godot3.2/platform/x11/godot_x11.cpp:57)
[12] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xd5) [0x7fece20a0565] (??:0)
[13] /usr/bin/godots(_start+0x2e) [0x174292e] (??:?)

but without crashing entire app, to help find functions which executed current one.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Not sure but maybe extracting code from crash handler should be enough(this needs to be done for each platform)
https://github.com/godotengine/godot/blob/8f7f5846397297fff6e8a08f89bc60ce658699cc/platform/linuxbsd/crash_handler_linuxbsd.cpp#L48-L121

https://www.gnu.org/software/libc/manual/html_node/Backtraces.html

If this enhancement will not be used often, can it be worked around with a few lines of script?

Cannot print C++ backtrace from GDScript(but with this feature this could be possible but probably useless)

Is there a reason why this should be core and not an add-on in the asset library?

This cannot be added as addon

@Calinou
Copy link
Member

Calinou commented Jul 30, 2021

You can use CRASH_NOW() to do this in C++, but it can't be done from scripting (or without crashing the engine).
Edit (December 2021): OS.crash() is now exposed to scripting by godotengine/godot#55603.

@timothyqiu
Copy link
Member

For now Godot print some error messages when starts godotengine/godot#49623 so checking each error with gdb or Qt Creator is slow.

I think you can try conditional breakpoints.

@qarmin
Copy link
Author

qarmin commented Jul 30, 2021

Simple patch which works only for Linux(I have no idea if this code should be inside OS class or somewhere else) patch.txt

@Calinou Calinou changed the title Add posibility to print backtrace without stopping Godot Add a way to print a backtrace without stopping/crashing Godot Aug 1, 2021
@Calinou
Copy link
Member

Calinou commented Aug 16, 2024

godotengine/godot#91006 implements the ability to print GDScript backtraces at any time, but it won't print the C++ side of the backtrace.

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

No branches or pull requests

3 participants