RV-LINK:输出非预期响应向 GDB 报告错误

通过返回非预期的响应,GDB 将会检测到非预期响应,并报告响应的内容,可以利用这个特性,向 GDB 报告错误。

zoomdy at 163 dot com

对 target 不匹配的报告

RV-LINK 因为程序空间的限制,一个固件只支持一个系列的 MCU,在 GDB 建立连接时,RV-LINK 会检测 target 是不是当前固件支持的 MCU 系列,如果不是,那么要给调试人员给出反馈信息,要求更换 RV-LINK 的固件。

这可以通过对 ​​vMustReplyEmpty​​​ 命令给出非预期响应来实现。​​vMustReplyEmpty​​​ 的预期响应是​​空​​​或 ​​OK​​,当检测到 target 不匹配时,返回提示字符串,在 GDB 上会显示如下:

Remote replied unexpectedly to 'vMustReplyEmpty': 
RV-LINK ERROR: target is not match!
this firmware only support GD32VF103, please change the firmware!

(gdb)

GDB 首先会报告说 ​​Remote replied unexpectedly​​ 接收到了非预期的响应,接着会打印出响应的内容。奇巧淫技!