2021-07-05 08:37:17

by qianfan

[permalink] [raw]
Subject: how to debug linux kernel by JLink

Hi:

I'm reading linux kernel source code and try debugging linux by using
JLink. I had developed env on my bananapi-m2u and can connected it in gdb.

I add some breakpoints in gdb and seems only code before thread ready
can hit: (next is the log)

(gdb) i b
Num     Type           Disp Enb Address    What
1       breakpoint     keep y   0xc0b00940 in start_kernel at
init/main.c:877
2       breakpoint     keep y   0xc07f7a30 in kernel_init at
init/main.c:1441
3       breakpoint     keep y   0xc0690ce4 in of_platform_populate at
drivers/of/platform.c:472
4       breakpoint     keep y   0xc0603234 in mv64xxx_i2c_probe at
drivers/i2c/busses/i2c-mv64xxx.c:935
(gdb) c
Continuing.

Breakpoint 1, start_kernel () at init/main.c:877
877     {
(gdb) c
Continuing.

Breakpoint 2, kernel_init (unused=0x0) at init/main.c:1441
1441    {
(gdb) bt
#0  kernel_init (unused=0x0) at init/main.c:1441
#1  0xc0100150 in ret_from_fork () at arch/arm/kernel/entry-common.S:158
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) c
Continuing.

breakpoints start_kernel and kernel_init hited, but of_platform_populate
and device probe functions doesn't.

Is it a good way debugging linux kernel by using hardware debug tools?

Thanks

qianfan