how to interrupt kgdb after press continue

本文详细介绍了如何配置和使用kgdb进行内核调试的方法,包括启动参数设置、停止内核执行、连接gdb和常见问题解决策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ctrl+C obviously unusable!

true way:

echo g > /proc/sysrq-trigger


from :

https://www.kernel.org/doc/htmldocs/kgdb/EnableKGDB.html


total record:

In order to use kgdb you must activate it by passing configuration information to one of the kgdb I/O drivers. If you do not pass any configuration information kgdb will not do anything at all. Kgdb will only actively hook up to the kernel trap hooks if a kgdb I/O driver is loaded and configured. If you unconfigure a kgdb I/O driver, kgdb will unregister all the kernel hook points.

All kgdb I/O drivers can be reconfigured at run time, if CONFIG_SYSFS and CONFIG_MODULES are enabled, by echo'ing a new config string to /sys/module/<driver>/parameter/<option>. The driver can be unconfigured by passing an empty string. You cannot change the configuration while the debugger is attached. Make sure to detach the debugger with the detach command prior to trying to unconfigure a kgdb I/O driver.

Connecting with gdb to a serial port

  1. Configure kgdboc

    Boot kernel with arguments:

    • kgdboc=ttyS0,115200

    OR

    Configure kgdboc after the kernel booted:

    • echo ttyS0 > /sys/module/kgdboc/parameters/kgdboc

  2. Stop kernel execution (break into the debugger)

    In order to connect to gdb via kgdboc, the kernel must first be stopped. There are several ways to stop the kernel which include using kgdbwait as a boot argument, via a sysrq-g, or running the kernel until it takes an exception where it waits for the debugger to attach.

    • When logged in as root or with a super user session you can run:

      echo g > /proc/sysrq-trigger

    • Example using minicom 2.2

      Press: Control-a

      Press: f

      Press: g

    • When you have telneted to a terminal server that supports sending a remote break

      Press: Control-]

      Type in:send break

      Press: Enter

      Press: g

  3. Connect from from gdb

    Example (using a directly connected port):

        % gdb ./vmlinux
        (gdb) set remotebaud 115200
        (gdb) target remote /dev/ttyS0
        

    Example (kgdb to a terminal server on TCP port 2012):

        % gdb ./vmlinux
        (gdb) target remote 192.168.2.2:2012
        

    Once connected, you can debug a kernel the way you would debug an application program.

    If you are having problems connecting or something is going seriously wrong while debugging, it will most often be the case that you want to enable gdb to be verbose about its target communications. You do this prior to issuing the target remote command by typing in: set debug remote 1

Remember if you continue in gdb, and need to "break in" again, you need to issue an other sysrq-g. It is easy to create a simple entry point by putting a breakpoint at sys_sync and then you can run "sync" from a shell or script to break into the debugger.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值