summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2019-02-28 15:51:50 +0106
committerJohn Ogness <john.ogness@linutronix.de>2019-02-28 15:51:50 +0106
commit1c70d0ddc0dbe5e4b15f2308b3cba4e944af79cf (patch)
treede61a14020e6ac467c4293255f6cd63f6768cd82
parent63e2c59580653b05a3e8c41e02e1449564a5882d (diff)
kernel-debugging: lots of minor fixups discovered during training
- update dynamic printk format - update addr2line for kernels by using script - update qemu lines for vexpress - add note about kaslr with qemu gdbserver - use uart0 for console and uart1 for kgdb - use 127.0.0.1 instead of localhost (otherwise qemu and gdb get confused about IPv4 or IPv6) Signed-off-by: John Ogness <john.ogness@linutronix.de>
-rw-r--r--kernel-devel/kernel-debugging/pres_kernel-debugging_en.tex48
1 files changed, 26 insertions, 22 deletions
diff --git a/kernel-devel/kernel-debugging/pres_kernel-debugging_en.tex b/kernel-devel/kernel-debugging/pres_kernel-debugging_en.tex
index 2a015a7..a0d52ac 100644
--- a/kernel-devel/kernel-debugging/pres_kernel-debugging_en.tex
+++ b/kernel-devel/kernel-debugging/pres_kernel-debugging_en.tex
@@ -149,17 +149,17 @@ can be used to define the printed prefix.
\frametitle{dynamic printk}
controlled by debugfs: dynamic\_debug/control
-format: filename:lineno [module]function flags format
+example: file core.c line 1075 +p
\begin{description}
-\item[filename] source file of the debug statement
-\item[lineno] line number of the debug statement
-\item[module] module that contains the debug statement
-\item[function] function that contains the debug statement
-\item[flags] '=p' means the line is turned 'on' for printing
+\item[file] source file of the debug statement
+\item[line] line number of the debug statement
+\item[func] function that contains the debug statement(s)
+\item[module] module that contains the debug statement(s)
\item[format] the format used for the debug statement
+\item[flags] '+p' means turn on printing
\end{description}
-see also: Documentation/dynamic-debug-howto.txt
+see also: Documentation/admin-guide/dynamic-debug-howto.rst
\end{frame}
\section{Logging messages}
@@ -240,8 +240,8 @@ If you compiled your kernel with debug info, you can use addr2line to decode
the address:
\small
\begin{verbatim}
-$ arm-none-linux-gnueabi-addr2line -e vmlinux c0009378
-linux-2.6.37/init/do_mounts.c:488
+$ echo prepare_namespace+0x0/0x1d4 | ./scripts/decode_stacktrace.sh vmlinux .
+prepare_namespace (/home/devel/linux/init/do_mounts.c:549)
\end{verbatim}
\end{frame}
@@ -325,13 +325,14 @@ kworker/-14 0..... 12004us : 14:120:S ==> [000] 15:120:R kswapd0
\begin{frame}[fragile]
\frametitle{Kerneldebugging with Qemu}
\begin{verbatim}
-$ qemu-system-arm -M versatilepb -m 128 \
--S -s -kernel zImage
+$ qemu-system-arm -M vexpress-a9 -nographic \
+ -S -s \
+ -kernel zImage -dtb vexpress-v2p-ca9.dtb
\end{verbatim}
\begin{verbatim}
$ arm-none-linux-gnueabi-gdb vmlinux
-(gdb) target remote localhost:1234
-Remote debugging using localhost:1234
+(gdb) target remote 127.0.0.1:1234
+Remote debugging using 127.0.0.1:1234
0x00000000 in ?? ()
(gdb) break start_kernel
(gdb) c
@@ -341,6 +342,7 @@ Breakpoint 1, start_kernel ()
at linux-2.6.37-rc4/init/main.c:539
539 smp_setup_processor_id();
\end{verbatim}
+Boot with "nokaslr" to disable base randomization.
\end{frame}
\section{KGDB}
@@ -370,7 +372,7 @@ Kernel hacking --->
\end{verbatim}
Kernel Commandline:
\begin{verbatim}
-kgdboc=ttyAMA0 kgdbwait
+kgdboc=ttyAMA1 kgdbwait
\end{verbatim}
\end{frame}
@@ -378,16 +380,18 @@ kgdboc=ttyAMA0 kgdbwait
\frametitle{KGDB}
1)\\
\begin{verbatim}
-qemu-system-arm -M versatilepb -m 128 \
- -serial tcp:localhost:2345,server \
- -kernel zImage -append "kgdboc=ttyAMA0 kgdbwait"
+qemu-system-arm -M vexpress-a9 -nographic \
+ -serial mon:stdio \
+ -serial tcp:127.0.0.1:2345,server \
+ -kernel zImage -dtb vexpress-v2p-ca9.dtb \
+ -append "console=ttyAMA0 kgdboc=ttyAMA1 kgdbwait"
\end{verbatim}
2)\\
-telnet localhost 2345\\
\begin{verbatim}
-kgdb: Wait for connection from remote gdb...
+QEMU: waiting for connection on: disconnected:tcp:127.0.0.1:2345,server
\end{verbatim}
-CTRL-]
+telnet 127.0.0.1 2345\\
+CTRL-]\\
quit
\end{frame}
@@ -396,8 +400,8 @@ quit
3)\\
\begin{verbatim}
arm-none-linux-gnueabi-gdb vmlinux
-(gdb) target remote localhost:2345
-Remote debugging using localhost:2345
+(gdb) target remote 127.0.0.1:2345
+Remote debugging using 127.0.0.1:2345
kgdb_breakpoint ()
at linux-2.6.37-rc4/kernel/debug/debug_core.c:959