0

我正在尝试使用运行 gdb 的远程计算机调试一个设备驱动程序,该驱动程序正在使 Mac 上的内核崩溃(尝试按照此处的说明进行操作)。两台机器通过以太网连接到同一个网络(甚至同一个路由器,都可以访问网络)。我也设置nvram boot-args="debug=0x144"了目标并重新启动。

然后我像往常一样在目标上加载内核扩展。在主机上,我像这样启动 gdb:

$ gdb -arch i386 /Volumes/KernelDebugKit/mach_kernel

进入 gdb 后,我加载内核宏并设置远程连接

(gdb) source /Volumes/KernelDebugKit/kgmacros
(gdb) target remote-kdp
(gdb) kdp-reattach 11.22.33.44

但是,最后一个命令没有建立连接,我得到了一个无穷无尽的线轴

kdp_reply_wait: error from kdp_receive: receive timeout exceeded
kdp_transaction (remote_connect): transaction timed out
kdp_transaction (remote_connect): re-sending transaction

将 gdb 连接到目标机器的正确方法是什么?

4

2 回答 2

1

有多种方法可以突破目标,包括:

  • 内核恐慌,如您在上面的回答中所述。
  • 不可屏蔽中断,由 cmd-option-ctrl-shift-esc 组合键触发。
  • 使用在 pexpert/pexpert.h 中声明的 PE_enter_debugger() 在内核扩展中编写中断代码
  • 通过在 NVRAM 引导参数值中设置 DB_HALT (0x01) 来停止引导。

此外,您可能需要设置一个持久的 ARP 表条目,因为目标在调试器中停止时无法响应 ARP 请求。我在调试器启动 shell 脚本中使用以下内容来设置 ARP 条目(如果它尚不存在):

if !(arp -a -n -i en0 | grep '10\.211\.55\.10[)] at 0:1c:42:d7:29:47 on en0 permanent' > /dev/null) ; then
    echo "Adding arp entry"
    sudo arp -s 10.211.55.10 00:1c:42:d7:29:47
fi

更专业的人可能会改进我的 shell 脚本。

以上所有内容都记录在 http://developer.apple.com/library/mac/documentation/Darwin/Conceptual/KernelProgramming/KernelProgramming.pdf中。

于 2012-09-05T17:09:02.770 回答
1

答案只是在您尝试从主机附加 gdb之前确保目标有内核崩溃。

于 2012-09-05T15:55:22.450 回答