KGDB example: mkdir syscall
From the ADB Shell, trigger KGDB
$ adb shell
# cd /data
# mkdir kgdb-test
# cd kgdb-test
# ls
# echo -n g>/proc/sysrq-trigger
Connect to KGDB from the host, and set a break point at "sys_mkdir"
$ arm-eabi-gdb ./vmlinux
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-elf-linux"...
(gdb) target remote /dev/ttyACM0
Remote debugging using /dev/ttyACM0
warning: shared library handler failed to enable breakpoint
0x800a1380 in kgdb_breakpoint () at /.../kernel/arch/arm/include/asm/atomic.h:37
37 __asm__ __volatile__("@ atomic_set\n"
(gdb) l
32 */
33 static inline void atomic_set(atomic_t *v, int i)
34 {
35 unsigned long tmp;
36
37 __asm__ __volatile__("@ atomic_set\n"
38 "1: ldrex %0, [%1]\n"
39 " strex %0, %2, [%1]\n"
40 " teq %0, #0\n"
41 " bne 1b"
(gdb) info br
No breakpoints or watchpoints.
(gdb) br sys_mkdir
Breakpoint 1 at 0x800e033c: file /.../kernel/fs/namei.c, line 2085.
(gdb) c
Continuing.
[New Thread 1092]
[Switching to Thread 1092]
Create a directory from the ADB shell
# mkdir test-dirr
The kernel hits the break point:
Breakpoint 1, sys_mkdir (pathname=0x7eefce46 "test-dirr", mode=511)
at /.../kernel/fs/namei.c:2085
2085 {
(gdb) l
2080 out_err:
2081 return error;
2082 }
2083
2084 SYSCALL_DEFINE2(mkdir, const char __user *, pathname, int, mode)
2085 {
2086 return sys_mkdirat(AT_FDCWD, pathname, mode);
2087 }
2088
2089 /*
(gdb) p mode
$1 = 511
(gdb) p/o mode
$2 = 0777
(gdb) set mode=0700
(gdb) p pathname
$3 = 0x7eefce46 "test-dirr"
(gdb) set *(pathname + 8)=0
(gdb) p pathname
$4 = 0x7eefce46 "test-dir"
(gdb) c
Continuing.
KGDB can display and modify local variables as well as global symbols.
See if the result is expected in ADB shell:
# ls -l
drwx------ root root 1980-01-06 01:36 test-dir
#
page revision: 0, last edited: 20 Jul 2010 19:35