summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--development/debugging.mdwn86
-rw-r--r--index.mdwn1
2 files changed, 87 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
+
diff --git a/index.mdwn b/index.mdwn
index 097a096..409f252 100644
--- a/index.mdwn
+++ b/index.mdwn
@@ -26,3 +26,4 @@ In case you find any of these projects useful, you can <a href="https://flattr.c
* [[development/GTK+_development_with_VIM]]
* [[development/Sigxcpu.org_GIT_repositories]]
* [[development/Debian packages in Git]]
+* [[development/Debugging]]