gdb - 是否可以指示 GDB 从目标异步获取变量值?
问题描述
我printf()
通过分配“打印变量值然后继续”代码来放置断点来实现该功能:
break main.c:18
commands
print myVar
cont
end
到目前为止,这工作得很好。但是,AFAIU,它需要与目标(在我的例子中是一个微控制器)进行多次通信:
- 当断点被击中时,微控制器发送信号
- GDB 立即要求
myVar
- MCU发送
myVar
值 - GDB 指示 MCU 继续
这些步骤会导致明显的抖动,因此 MCU 上的应用程序表现得非常奇怪。
有没有机会告诉 GDB 一次性完成上述步骤,例如:“告诉我myVar
值,然后继续而不等待任何进一步的指示。”?
解决方案
AFAIU,它需要与目标进行多次沟通
实际上在 GDB 和目标之间交换的数据包要多得多(GDB 远程协议非常健谈)。您可以使用set debug remote on
.
您正在寻找的是追踪:
> For each tracepoint, you can specify, in advance, some arbitrary set
> of data that you want the target to collect in the trace buffer when
> it hits that tracepoint. The collected data can include registers,
> local variables, or global data. Later, you can use GDB commands to
> examine the values these data had at the time the tracepoint was hit.
更新:
当我发布
tstart
时,GDB 给出error: Target does not support this command.
显然您使用的是 MCU 以外gdbserver
的东西(您没有告诉我们 GDB 的远程端有什么),并且您的远程端不支持跟踪。
这可能是一个gdbserver
太旧的实例,或者可能是远程调试存根没有实现这部分协议。
如果是前者,您可以将其更新gdbserver
到较新的版本。如果是后者,则您无能为力(除了自己实现跟踪支持)。
推荐阅读
- flutter - Flutter Camera startImageStream 返回 null 的图像
- c++ - 确定给出错误结果的向量之间的长度
- optimization - 是否有通过声明已知和未知变量来解决优化问题的包装库?
- r - Debuggin 函数翻译
- python - 使用分类器进行面部识别的迁移学习
- vb.net - 当我通过按下按钮开始循环时,它会循环一次然后冻结
- python - 隐藏到json pandas python时删除obejct列中的\
- javascript - _.memoize 不会提高性能
- python-3.x - 如何在python中获取堆对象(树)?
- rocksdb - 在 Java 中创建 RocksDB SST 文件以进行批量加载