0

I'm trying to debug for the first time a gtk code and actually, I want to debug a callback function for key-press-event so I set a breakpoint with gdb and when it hits the breakpoint, the whole desktop evirement is freezing (I'm running under gnome-shell) it seems that the graphic envirement is waiting for the event to finish.

I got some idea that didn't worked :

The first attempts was to assign some gdb commands to the breakpoint :

(gdb) break on_key_press_callback
(gdb) commands
      > back trace
      > next
      > next
      > next
      > continue
      > end

but I don't know why, only the back trace command is executed, and then freeze.

The second attempt was to debug remotely using gdbserver and gdb on tty1 (no graphigs to freeze :) ) I was able to send commands like next and step after the breakpoint but there was nothing to see (can't list code, inspect the stack, ect ...)

So any good tips to be able to debug in such situations ?

Thanks

4
  • My best guess is that your system is already screwed up before the breakpoint. A desktop that freezes stinks of hardware failure or data corruption. FYI every GTK+ application has its own event loop: no way to stop them all programmatically. Commented Jul 26, 2014 at 11:35
  • @ntd I still can use the mouse (moving it) and the keyboard to switch between tty* only Commented Jul 26, 2014 at 14:15
  • So it can be a corruption occurred inside some shared code. If it is not your application, I'd point the finger to the GTK+ theme and to the graphic driver. You can try to run the application without theme (e.g. prepending GTK_THEME=Default to the command line) or enable the VESA driver in the X server. Commented Jul 26, 2014 at 14:54
  • try wiki.gnome.org/Projects/GTK+/Inspector . You can also use gdk_set_show_events(true)... but if the desktop ui freezes, the problem may be somewhere else. Commented Jul 4, 2017 at 11:31

2 Answers 2

1

It's typical to have lockups when debugging an X program running on the same server that you're using to debug. For example, if the inferior (gdb terminology for the program being debugged) does a server grab -- whoops, the gdb GUI (or terminal or emacs etc) is locked out.

Your idea of doing more programmatic debugging is a good one, but it's hard to make it all work nicely. As you found, some gdb commands (basically those related to inferior control) don't work in commands. Also, it just isn't nearly as convenient.

You can go further that direction. For example you could use SystemTap to probe the program instead.

However there are also nicer approaches.

One way is to run the inferior using a virtual X server -- a nested one, or one running in a VM. Then you can escape to the "outer" X server for debugging. This will be much nicer.

Another way is to have two computers, and run the debugger on one and the inferior on the other. In a way this is really the same answer, just using a real machine rather than a virtual one.

Sign up to request clarification or add additional context in comments.

Comments

0

The question is old, but for anyone that may be struggling with this issue, there is a way to stop the freezing behaviour from happening by disabling the X server grab.

You have to change the config in your IDE to run the program with the following system property:

-Dsun.awt.disablegrab=true

If you are using javaws (Java Web Start) to run the application use:

-J-Dsun.awt.disablegrab=true

instead.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.