Search code examples
gdbgtk

Debugging Gtk-CRITICAL


When running my program, I am getting Gtk-CRITICAL error on the Terminal, which I'd like to fix.

I found this link through Google, but turns out there is no such option in gdb:

igor@IgorReinCloud ~/dbhandler/Debug/dbhandler $ gdb --g-fatal-warnings dbhandler
gdb: unrecognized option '--g-fatal-warnings'
Use `gdb --help' for a complete list of options.

I also tried to set a breakpoint on the g_log() function, but the execution didn't stop there.

What am I missing?

Thank you.


Solution

  • you can use G_DEBUG=fatal-criticals, so that the application execution breaks at the first location where a critical is emitted.

    To run inside gdb, run G_DEBUG=fatal-criticals gdb my-app, and as usual, do run inside gdb to run your application.

    You may also set the G_DEBUG environment variable with export (if in bash). Thus you could do export G_DEBUG=fatal-criticals, and then run your app as gdb my-app, which will have the same effect.

    See https://docs.gtk.org/glib/running.html for more details