如何使用GDB远程串行协议查询线程栈帧和局部变量?

How to query thread stack frame and local variables using GDB remote serial protocol?

我正在尝试实施 GDB remote serial protocol。到目前为止,我只是在阅读文档,但找不到如何获取线程的堆栈框架和局部变量信息。我怎样才能得到这些信息?

I am implementing UI. I think it's GDB (local) part.

听起来你的问题是:

鉴于我已经在某处停止了一个进程(由 gdbserver 控制),我如何找出它停止的位置(在哪个函数中)(即当前堆栈帧是什么),那个地方有哪些局部变量点(它们在内存中的什么位置)?

坏消息:要回答上述问题,您必须重新实现 30-50% 的 GDB。你可以开始 here ("Finding variables" section in particular), but should probably read the entire series.