[bootlin/training-materials updates] master: labs: debugging: remove crash from the debugging lab (a257a4b7)

Clément Léger clement.leger at bootlin.com
Fri Feb 3 18:12:29 CET 2023

Repository : https://github.com/bootlin/training-materials
On branch  : master
Link       : https://github.com/bootlin/training-materials/commit/a257a4b76602a04dfeab0fb55920e1fd80f09073


commit a257a4b76602a04dfeab0fb55920e1fd80f09073
Author: Clément Léger <clement.leger at bootlin.com>
Date:   Fri Feb 3 18:12:29 2023 +0100

    labs: debugging: remove crash from the debugging lab
    Closes #168
    Signed-off-by: Clément Léger <clement.leger at bootlin.com>


 lab-data/debugging/nfsroot/root/kgdb/kgdb_test.c   |  5 ++-
 .../debugging-kernel-debugging.tex                 | 47 +++++++++++-----------
 2 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/lab-data/debugging/nfsroot/root/kgdb/kgdb_test.c b/lab-data/debugging/nfsroot/root/kgdb/kgdb_test.c
index 9355f5b7..8dc6cf60 100644
--- a/lab-data/debugging/nfsroot/root/kgdb/kgdb_test.c
+++ b/lab-data/debugging/nfsroot/root/kgdb/kgdb_test.c
@@ -8,10 +8,13 @@ static struct task_struct *kthread;
 static int kgdb_test_thread_routine(void *data)
+	unsigned long i = 0;
 	while(1) {
+		i++;
 		usleep_range(1000, 2000);
-		pr_debug("I'm awake !\n");
+		pr_debug("I'm awake for (%ld) !\n", i);
 		if (kthread_should_stop())
diff --git a/labs/debugging-kernel-debugging/debugging-kernel-debugging.tex b/labs/debugging-kernel-debugging/debugging-kernel-debugging.tex
index cb86160d..126735d2 100644
--- a/labs/debugging-kernel-debugging/debugging-kernel-debugging.tex
+++ b/labs/debugging-kernel-debugging/debugging-kernel-debugging.tex
@@ -267,17 +267,33 @@ automatically and the symbols will be loaded:
 # loading @0xbf000000: /home/<user>/debugging-labs/nfsroot/root/kgdb_test/kgdb_test.ko
-If you attach KGDB after module loading, then you will need to execute the \code{lx-symbols}
-command in GDB:
+If not, you need to enter KGDB mode using the magic SySrq:
+# echo g > /proc/sysrq_trigger
+Then you will need to execute the \code{lx-symbols} command in GDB to reload the
+symbols from the module. You'll also need to pass a list of path that may
+contain the external modules:
-(gdb) lx-symbols
+(gdb) lx-symbols /home/<user>/debugging-labs/nfsroot/root/kgdb_test/
 loading vmlinux
 # scanning for modules in /home/<user>/debugging-labs/nfsroot/root
 # loading @0xbf000000: /home/<user>/debugging-labs/nfsroot/root/kgdb_test/kgdb_test.ko
 Finally, add a breakpoint right after the \code{pr_debug()} call and continue
-the execution to trigger it.
+the execution to trigger it:
+(gdb) tbreak kgdb_test.c:16
+(gdb) continue
+At some point, the breakpoint will be triggered. Try to display the variable
+\code{i} to display the current loop value.
 Note: Due to a GDB bug, the execution after the breakpoint will crash. You can
 use a temporary breakpoint using \code{tbreak} command to workaround this
@@ -370,26 +386,9 @@ $ scp root at .
 Finally, we will be able to debug that kernel coredump using crash.
+Using gdb, you can load the \code{vmcore} file using \code{gdb-multiarch}:
-\subsection{Compiling crash}
-\code{crash} utility that is available on your computer does not support ARM
-so we will need to recompile it for the ARM target. This can be done using the
-following commands:
-$ sudo apt install gcc-multilib g++-multilib lib32z1-dev lib32ncurses5-dev texinfo bison
-$ cd /home/$USER/debugging-labs/
-$ git clone https://github.com/crash-utility/crash.git
-$ cd crash
-$ make target=ARM
-Once done, you can open the vmcore file with crash using
-$ ./crash /home/$USER/debugging-labs/buildroot/output/build/linux-5.13/vmlinux 
-  /home/$USER/debugging-labs/vmcore
+$ gdb-multiarch /home/$USER/debugging-labs/buildroot/output/build/linux-5.13/vmlinux \
+  vmcore
\ No newline at end of file
-Take some times to analyze the content of the dump using the commands that are
-offered by \code{crash}.
\ No newline at end of file

More information about the training-materials-updates mailing list