Skip to content

Enable loguru stack traces #2652

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

Merged
merged 1 commit into from
Jun 28, 2023
Merged

Enable loguru stack traces #2652

merged 1 commit into from
Jun 28, 2023

Conversation

kklobe
Copy link
Collaborator

@kklobe kklobe commented Jun 28, 2023

Loguru's autodetect logic for enabling stack traces is not very robust, so add logic to meson.build that checks for the headers included by loguru.cpp if LOGURU_STACKTRACES=1.

Here is the relevant snippet from loguru.cpp

#if LOGURU_STACKTRACES
	#include <cxxabi.h>    // for __cxa_demangle
	#include <dlfcn.h>     // for dladdr
	#include <execinfo.h>  // for backtrace
#endif // LOGURU_STACKTRACES

So I just check for those headers in meson.build and force the flag, since loguru.cpp needs to be compiled with it.

Here's an example trace from an assert:

Assertion failed: (1==0), function increaseticks, file dosbox.cpp, line 186.

Loguru caught a signal: SIGABRT
Stack trace:
18         0x18d68bf28 start + 2236
17         0x1000b2624 main + 36
16         0x1003a3760 sdl_main(int, char**) + 5844
15         0x1001186bc Config::StartUp() + 28
14         0x100626408 SHELL_Init() + 3904
13         0x100623704 DOS_Shell::Run() + 1540
12         0x100647408 DOS_Shell::InputCommand(char*) + 56
11         0x100647984 DOS_Shell::ReadCommand() + 712
10         0x10025a8f0 DOS_ReadFile(unsigned short, unsigned char*, unsigned short*, bool) + 292
9          0x1002551cc DOS_Device::Read(unsigned char*, unsigned short*) + 64
8          0x100252c04 device_CON::Read(unsigned char*, unsigned short*) + 340
7          0x100184a90 CALLBACK_RunRealInt(unsigned char) + 92
6          0x1000b2ecc DOSBOX_RunMachine() + 28
5          0x1000b2e90 Normal_Loop() + 264
4          0x1000b2704 increaseticks() + 196
3          0x18d8f0e44 err + 0
2          0x18d8f1ae8 abort + 180
1          0x18d9e3c28 pthread_kill + 288
0          0x18da12a24 _sigtramp + 56
2023-06-28 10:03:55.285 | Signal: SIGABRT

@kklobe kklobe requested a review from kcgen June 28, 2023 15:43
@kklobe kklobe self-assigned this Jun 28, 2023
@kklobe kklobe added enhancement New feature or enhancement of existing features build system Build system related issues and removed build system Build system related issues labels Jun 28, 2023
@kklobe kklobe marked this pull request as ready for review June 28, 2023 15:50
@kklobe kklobe force-pushed the kk/loguru-stacktraces-1 branch from 120683c to a24ed5b Compare June 28, 2023 16:48
Loguru's autodetect logic for enabling stack traces is not very robust,
so add logic to meson.build that checks for the headers included by
loguru.cpp if LOGURU_STACKTRACES=1.
@kklobe kklobe force-pushed the kk/loguru-stacktraces-1 branch from a24ed5b to 59328f5 Compare June 28, 2023 20:52
@kklobe
Copy link
Collaborator Author

kklobe commented Jun 28, 2023

@kcgen I moved this into loguru's meson.build per your suggestions, makes much more sense there.

@kcgen
Copy link
Member

kcgen commented Jun 28, 2023

@kcgen I moved this into loguru's meson.build per your suggestions, makes much more sense there.

Looks great, @kklobe 🚀

@johnnovak , very curious what this reveals in your next hour+ run w/ a debug build :)

@kcgen kcgen merged commit ae464ea into main Jun 28, 2023
@johnnovak
Copy link
Member

Thanks @kklobe, this is great! 🚀

@johnnovak , very curious what this reveals in your next hour+ run w/ a debug build :)

Yeah now those bugs have nowhere to hide! 😆 🐛 🪲 🦟

@johnnovak johnnovak deleted the kk/loguru-stacktraces-1 branch July 8, 2023 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement of existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants