andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 1 | # Linux Debugging GTK |
| 2 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 3 | ## Making warnings fatal |
| 4 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 5 | See |
| 6 | [Running GLib Applications](http://developer.gnome.org/glib/stable/glib-running.html) |
| 7 | for notes on how to make GTK warnings fatal. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 8 | |
| 9 | ## Using GTK Debug packages |
| 10 | |
Tom Anderson | 287339e | 2018-08-22 21:52:02 | [diff] [blame] | 11 | sudo apt-get install libgtk-3-0-dbg |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 12 | |
| 13 | Make sure that you're building a binary that matches your architecture (e.g. |
| 14 | 64-bit on a 64-bit machine), and there you go. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 15 | |
| 16 | ### Source |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 17 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 18 | You'll likely want to get the source for gtk too so that you can step through |
| 19 | it. You can tell gdb that you've downloaded the source to your system's GTK by |
| 20 | doing: |
| 21 | |
| 22 | ```shell |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 23 | $ cd /my/dir |
Tom Anderson | 287339e | 2018-08-22 21:52:02 | [diff] [blame] | 24 | $ apt-get source libgtk-3-0 |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 25 | $ gdb ... |
| 26 | (gdb) set substitute-path /build/buildd /my/dir |
| 27 | ``` |
| 28 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 29 | NOTE: I tried debugging pango in a similar manner, but for some reason gdb |
| 30 | didn't pick up the symbols from the symbols from the `-dbg` package. I ended up |
| 31 | building from source and setting my `LD_LIBRARY_PATH`. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 32 | |
Tom Anderson | abdbd6a | 2020-01-09 16:59:27 | [diff] [blame] | 33 | See [building_debug_gtk.md](building_debug_gtk.md) for more on how |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 34 | to build your own debug version of GTK. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 35 | |
| 36 | ## Parasite |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 37 | |
| 38 | http://chipx86.github.com/gtkparasite/ is great. Go check out the site for more |
| 39 | about it. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 40 | |
| 41 | Install it with |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 42 | |
| 43 | sudo apt-get install gtkparasite |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 44 | |
| 45 | And then run Chrome with |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 46 | |
| 47 | GTK_MODULES=gtkparasite ./out/Debug/chrome |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 48 | |
nodir | a6074d4c | 2015-09-01 04:26:45 | [diff] [blame] | 49 | ## GDK_DEBUG |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 50 | |
| 51 | Use `GDK_DEBUG=nograbs` to run GTK+ without grabs. This is useful for gdb |
| 52 | sessions. |