From 37f022e58ccf4f10720dddc52232dd127fd612cd Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 6 Feb 2020 15:40:11 +0100 Subject: [PATCH] Dev Docs: Update debugging instructions --- doc/21-development.md | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/doc/21-development.md b/doc/21-development.md index ff24971a3..e4540a961 100644 --- a/doc/21-development.md +++ b/doc/21-development.md @@ -71,9 +71,23 @@ SLES/openSUSE | `zypper install gdb` #### GDB Run -Since v2.11 we would attach to the umbrella process spawned with `/usr/lib/icinga2/sbin/icinga2`, -therefore rather attach to a running process. +Run the icinga2 binary `/usr/lib{,64}/icinga2/sbin/icinga2` with gdb, `/usr/bin/icinga2` is a shell wrapper. +``` +gdb --args /usr/lib/icinga2/sbin/icinga2 daemon + +(gdb) set follow-fork-mode child +``` + +When gdb halts on SIGUSR2, press `c` to continue. This signal originates from the umbrella +process and can safely be ignored. + + +> **Note** +> +> Since v2.11 we would attach to the umbrella process spawned with `/usr/lib/icinga2/sbin/icinga2`, +> therefore rather attach to a running process. +> ``` # Typically the order of PIDs is: 1) umbrella 2) spawn helper 3) main process pidof icinga2 @@ -366,6 +380,24 @@ pidof icinga2 lldb -p $(pidof icinga2 | cut -d ' ' -f3) ``` +In case you'll need to attach to the main process immediately, you can delay +the forked child process and attach to the printed PID. + +``` +$ icinga2 daemon -DInternal.DebugWorkerDelay=120 +Closed FD 6 which we inherited from our parent process. +[2020-01-29 12:22:33 +0100] information/cli: Icinga application loader (version: v2.11.0-477-gfe8701d77; debug) +[2020-01-29 12:22:33 +0100] information/RunWorker: DEBUG: Current PID: 85253. Sleeping for 120 seconds to allow lldb/gdb -p attachment. +``` + +``` +lldb -p 85253 +``` + +When lldb halts on SIGUSR2, press `c` to continue. This signal originates from the umbrella +process and can safely be ignored. + + Breakpoint: ```