summaryrefslogtreecommitdiff
path: root/development
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2010-11-22 18:00:40 +0100
committerGuido Günther <agx@sigxcpu.org>2010-11-22 18:08:54 +0100
commite8d123b76c216ca8dd40fd2a892f15a338247f73 (patch)
tree0c76c20b598f5e2103d6877f2fb758b5f78700fb /development
parentab28decea5ae78a14681aac2920213275dd57ba8 (diff)
Add some debugging notes
Diffstat (limited to 'development')
-rw-r--r--development/debugging.mdwn86
1 files changed, 86 insertions, 0 deletions
diff --git a/development/debugging.mdwn b/development/debugging.mdwn
new file mode 100644
index 0000000..1b7f531
--- /dev/null
+++ b/development/debugging.mdwn
@@ -0,0 +1,86 @@
+# Debugging with GDB
+
+## Loading the program
+To load a program for debugging simply pass it to gdb
+
+ gdb <executable>
+
+### Debugging programs using libtool
+To execute gdb for a program using libtool from it's build directory you can
+use:
+
+ libtool --mode=execute gdb <executable>
+
+this makes sure *LD_LIBRARY_PATH* etc. is setup correctly.
+
+## Breaking
+Once the program is loaded we can start to examin it. To stop program execution
+at a certain position we can use a breakpoint. Once the program hits the
+breakpoint you can step through the code. First set a breakpoint
+
+ break <file>:<function>
+ break <file>:<linenumerber>
+
+## Stepping
+Once you broke out of program execution you can step through the code. To show
+the source code around the current execution point:
+
+ list
+
+Step to the next statement in the current function:
+
+ next
+
+Step to the next statement following function calls:
+
+ step
+
+Other useful commands:
+
+ finish: run until the function exits and print it's return value
+
+## Backtrace
+The current stacktrace can be inspected using *bt*. *bt full* additionally
+includes the values of local variables. In threaded programs use *thread apply
+all bt* to see all threads.
+
+## Calling functions
+To call functions use:
+
+ call g_hash_table_lookup (priv->sockets_by_msg, msg)
+
+## Configuration
+Add this to *~/.gdbinit*
+
+ # save history
+ set history save on
+
+# Miscelanous
+
+## Generating a core file
+
+On some systems the limit for core files size is 0, change that to unlimited to
+make the system generate core files on e.g. SEGV:
+
+ ulimit -c unlimited
+
+## Aborting on GTK+ warning
+
+To abort on the first encountered glib/GTK+ warning use:
+
+ <program> --g-fatal-warnings
+
+# Other tools
+* valgrind
+* strace, ltrace
+
+## Packages
+
+Debugging things in a vm is useful, this needs the following packages in the guest:
+
+ aptitude install vim-nox gdb gdb-doc build-essential exuberant-ctags libc6-dbg git git-buildpackage ccache strace valgrind
+
+And when debugging GTK+ related problems:
+
+ aptitude install libglib2.0-0-dbg libgnutls26-dbg libgtk2.0-0-dbg libpcre3-dbg vim-syntax-gtk gtkparasite
+