kgdboc小记

使用gdb来单步跟踪kernel,基本都是buildin,所以忽略模块。

host上编译kernel,配置如下:

CONFIG_HAVE_ARCH_KGDB=y
CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y
CONFIG_EARLY_PRINTK_USB=y
CONFIG_X86_VERBOSE_BOOTUP=y
CONFIG_EARLY_PRINTK=y
CONFIG_EARLY_PRINTK_DBGP=y
CONFIG_EARLY_PRINTK_EFI=y
CONFIG_EARLY_PRINTK_USB_XDBC=y

拷贝kernel和模块到target机器后,配置target启动参数.

target启动参数

console=ttyS0,115200n8 kgdboc=ttyS0,115200n8 kgdbwait

host上配置gdb

$ cat ~/.gdbinit

define kgdb
     show serial baud
     set serial baud 115200
     target remote /dev/ttyS0
     set detach-on-fork on
end

启动target机器后,在host上运行gdb并键入kgdb;设置断点后c;

Thread 72 hit Breakpoint 5, skl_compute_wm (state=0xffff88835e32f000) at drivers/gpu/drm/i915/intel_pm.c:5533
5533    {
(gdb) bt
#0  skl_compute_wm (state=0xffff88835e32f000) at drivers/gpu/drm/i915/intel_pm.c:5533
#1  0xffffffff816c928c in calc_watermark_data (state=<optimized out>) at drivers/gpu/drm/i915/intel_display.c:12352
#2  intel_atomic_check (dev=<optimized out>, state=0xffff88835e32f000) at drivers/gpu/drm/i915/intel_display.c:12433
#3  0xffffffff8160bbc5 in drm_atomic_check_only (state=0xffff88835e32f000) at drivers/gpu/drm/drm_atomic.c:1982
#4  0xffffffff8160be38 in drm_atomic_commit (state=0xffff88835e32f000) at drivers/gpu/drm/drm_atomic.c:2024
#5  0xffffffff815f2348 in restore_fbdev_mode_atomic (fb_helper=0xffff88835f43ca00, active=<optimized out>) at drivers/gpu/drm/drm_fb_helper.c:451
#6  0xffffffff815f2596 in restore_fbdev_mode (fb_helper=0xffff88835f43ca00) at drivers/gpu/drm/drm_fb_helper.c:517
#7  0xffffffff815f399e in drm_fb_helper_restore_fbdev_mode_unlocked (fb_helper=0xffff88835f43ca00) at drivers/gpu/drm/drm_fb_helper.c:545
#8  0xffffffff815f3a1d in drm_fb_helper_set_par (info=<optimized out>) at drivers/gpu/drm/drm_fb_helper.c:1767
#9  0xffffffff816e8eca in intel_fbdev_set_par (info=<optimized out>) at drivers/gpu/drm/i915/intel_fbdev.c:64
#10 0xffffffff814fa82f in fbcon_init (vc=0xffff88835fd41c00, init=<optimized out>) at drivers/video/fbdev/core/fbcon.c:1151
#11 0xffffffff8159017c in visual_init (vc=0xffff88835fd41c00, num=<optimized out>, init=0) at drivers/tty/vt/vt.c:1051
#12 0xffffffff815917d8 in do_bind_con_driver (csw=<optimized out>, first=<optimized out>, last=<optimized out>, deflt=<optimized out>) at drivers/tty/vt/vt.c:3500
#13 0xffffffff81591c9d in do_take_over_console (csw=0xffff88835e32f000, first=254, last=1596604608, deflt=<optimized out>) at drivers/tty/vt/vt.c:4061
#14 0xffffffff814f8c6c in do_fbcon_takeover (show_logo=<optimized out>) at drivers/video/fbdev/core/fbcon.c:556
#15 0xffffffff814fd74c in fbcon_fb_registered (info=<optimized out>) at drivers/video/fbdev/core/fbcon.c:3228
#16 fbcon_event_notify (self=<optimized out>, action=<optimized out>, data=<optimized out>) at drivers/video/fbdev/core/fbcon.c:3358
#17 0xffffffff810c846e in notifier_call_chain (nl=<optimized out>, val=<optimized out>, v=<optimized out>, nr_to_call=-1, nr_calls=0x0 <irq_stack_union>) at kernel/notifier.c:93
#18 0xffffffff810c8bb3 in __blocking_notifier_call_chain (nr_calls=<optimized out>, nr_to_call=<optimized out>, v=<optimized out>, val=<optimized out>, nh=<optimized out>)
    at kernel/notifier.c:317
#19 blocking_notifier_call_chain (nh=0xffffffff82aca4e0 <fb_notifier_list>, val=5, v=0xffff88835dc5bd30) at kernel/notifier.c:328
#20 0xffffffff814efc8b in fb_notifier_call_chain (val=<optimized out>, v=<optimized out>) at drivers/video/fbdev/core/fb_notify.c:45
#21 0xffffffff814f1677 in do_register_framebuffer (fb_info=<optimized out>) at drivers/video/fbdev/core/fbmem.c:1705
#22 register_framebuffer (fb_info=0xffff88835e385c00) at drivers/video/fbdev/core/fbmem.c:1828
#23 0xffffffff815f35e5 in __drm_fb_helper_initial_config_and_unlock (fb_helper=0xffff88835f43ca00, bpp_sel=<optimized out>) at drivers/gpu/drm/drm_fb_helper.c:2690
#24 0xffffffff815f3855 in drm_fb_helper_initial_config (fb_helper=0xffff88835f43ca00, bpp_sel=32) at drivers/gpu/drm/drm_fb_helper.c:2757
#25 0xffffffff816e9fc8 in intel_fbdev_initial_config (data=0xffff88835f43ca00, cookie=<optimized out>) at drivers/gpu/drm/i915/intel_fbdev.c:714
#26 0xffffffff810ca6fe in async_run_entry_fn (work=0xffff88835e32f000) at kernel/async.c:127
#27 0xffffffff810c069f in process_one_work (worker=0xffff88835e32f000, work=0xffff88835e39f820) at kernel/workqueue.c:2153
#28 0xffffffff810c091f in worker_thread (__worker=0xffff88835e2faa80) at kernel/workqueue.c:2296
#29 0xffffffff810c774c in kthread (_create=0xffff88835e17b540) at kernel/kthread.c:246
#30 0xffffffff81e001da in ret_from_fork () at arch/x86/entry/entry_64.S:413
#31 0x0000000000000000 in ?? ()

参考:
1. https://www.cnblogs.com/Ph-one/p/6432717.html

发表评论

邮箱地址不会被公开。 必填项已用*标注