我想通过串口ttyS0从我的64位suse机器调试MIPS linux驱动程序.使用的gdb通过LAN调试应用程序而不是kgdb over serial.我使用这个page以及其他一些来开始调试但没有最终结果.
我的内核使用以下设置编译:
CONFIG_MAGIC_SYSRQ=y
CONFIG_HAVE_ARCH_KGDB=y
CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y
# CONFIG_KGDB_TESTS is not set
CONFIG_CMDLINE="kgdboc=ttyS0,115200"
如果我运行gdb:
gdb vmlinux
(gdb) set remotebaud 115200
(gdb) set debug remote 1
(gdb) target remote /dev/ttyS0
我可以观察以下输出:
输出(GDB_TERMINAL):
(gdb) target remote /dev/ttyS0
Remote debugging using /dev/ttyS0
Sending packet: $qSupported:qRelocInsn+#9a...Ack
Timeout in mid-packet,retrying
Timed out.
Timed out.
Ignoring packet error,continuing...
Packet qSupported (supported-packets) is supported
warning: unrecognized item "qSupported:qRelocIns" in "qSupported" response
Sending packet: $Hg0#df...Nak
Sending packet: $Hg0#df...Ack
Packet received: Hg0
Sending packet: $?#3f...Packet instead of Ack,ignoring it
Ack
Timed out.
Timed out.
Timed out.
Ignoring packet error,continuing...
Sending packet: $Hc-1#09...Nak
Sending packet: $Hc-1#09...Ack
Reply contains invalid hex digit 36
输出(REMOTE_TARGET):
+$?#3f09n+#9a$Hg0#df+09
没有更多的事情发生!
我也测试了sysrq但是提到的sysrq-option’g’似乎不适合!
echo b > /proc/sysrq-trigger
#successfully reboot
echo g > /proc/sysrq-trigger
#prints only the help message (SysRq : HELP : loglevel(0-9) reBoot Crash termin .....)
sysrq是否正常运行?
有没有我错过的东西?
有没有办法测试我的远程设备上运行的kgdb?
1)不要与屏幕或minicom同时使用gdb.
在tty上连接了minicom,GDB挂起然后崩溃:
(gdb) target remote /dev/ttyUSB0
Ignoring packet error,continuing...
Ignoring packet error,continuing...
/build/gdb-cXfXJ3/gdb-7.11.1/gdb/thread.c:89: internal-error: inferior_thread: Assertion `tp' Failed.
A problem internal to GDB has been detected,further debugging may prove unreliable.```
当屏幕连接时,GDB无法连接:
(gdb) tar rem /dev/ttyUSB0
/dev/ttyUSB0: Device or resource busy.
2)损坏的数据包和超时
Invalid packet,Bad checksum,Saw new packet start in middle of old one,Timed out
使用支持目标体系结构的GDB. x86上的默认GDB(至少在Ubuntu上)不支持arm目标.请使用gdb-multiarch或与交叉编译工具集相对应的GDB,即arm-linux-gnueabihf-gdb.列出可用的(gdb)set architecture命令的architecutres.在我的情况下,自动架构正确地检测到手臂目标.
3)在连接之前必须在目标上触发KGDB
Remote replied unexpectedly to ‘vMustReplyEmpty’: vMustReplyEmpty
Malformed response to offset query,qOffsets
GDB尝试连接,但目标未处于调试模式.必须在连接GDB之前触发debug sysrq.键盘快捷键对我不起作用.运行命令echo g> / proc / sysrq-通过SSH作为root工作.
4)配置波特率
warning: Invalid baud rate 115200. Maximum value is 38400.
/dev/ttyUSB0: Invalid argument.
配置的波特率必须在kgdboc内核参数和GDB之间匹配.就我而言,不支持波特率115200.建议将波特率设置为38400是必要的.使用内核cmdline重新启动目标:kgdboc = ttyAMA0,38400然后:
(gdb) set remotebaud 38400
(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
0x800b4730 in kgdb_breakpoint ()
解决这些问题后,内核调试按预期工作.