1

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.

Igor
  • 5,620
  • 11
  • 51
  • 103

2 Answers2

4

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

Mohammed Sadiq
  • 741
  • 3
  • 3
1

What am I missing?

Looks like that after reading the link, you were confused that gdb should have --g-fatal-warnings option for debugging Gtk applications. This is not the case because gdb is not Gtk application, but your program is. So you should run your program with --g-fatal-warnings option inside gdb like this:

gdb --args dbhandler --g-fatal-warnings

See also related question How do I run a program with commandline args using gdb within a bash script?.

ks1322
  • 33,961
  • 14
  • 109
  • 164