在 ptrace 时如何在调试器中获取信号详细信息?
我有一个调试器,正在从 linux 移植到 *bsd。目前,我正在开发 OpenBSD 版本。
在某些情况下,我想知道所传递信号的详细信息。例如,假设发送了 SIGSEGV,我想知道错误地址是什么,如果可能的话,是读取还是写入。
另一个例子是,如果我收到陷阱,它是单步事件吗?或者可能是 INT3 操作码。
在 Linux 上,我通过调用以下命令来获取此信息:
ptrace(PTRACE_GETSIGINFO, pid, 0, &siginfo);
这非常有效,因为它让我可以访问我可能想了解的有关信号的几乎所有内容。 OpenBSD 上似乎没有类似的东西。我查看了可使用 KVM API 访问的 kinfo_proc
和 kinfo_proc2
,但我并没有真正注意到它们具有与 siginfo_t 相同类型的信息。获取此信息的正确方法是什么?
I have a debugger that I am porting over to *bsd from linux. Currently, I am working on the OpenBSD version.
Under certain conditions I would like to know the details of the signal that was delivered. For example, suppose a SIGSEGV was delivered, I'd like to know what the faulting address was, and if possible, if it was a read or write.
Another example is if I recieve a trap, was it a single step event? or maybe an INT3 opcode.
On linux I get get this information by calling:
ptrace(PTRACE_GETSIGINFO, pid, 0, &siginfo);
This works great since it lets me have access to just about everything I could possibly want to know about the signal. There does not appear to be an equivalent on OpenBSD. I took a look at kinfo_proc
and kinfo_proc2
which are accessible using the KVM API, but nothing really jumps out at me as having the same type of information as a siginfo_t does. What would be the correct way to get at this information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 KVM 至少找到了我的问题的部分答案:
这几乎是我想要的所有信息,我认为如果我可以继续挖掘相关标题,我将能够找到所有这些信息。希望其他 BSD 架构也能有一些东西;-)。
I have found at least a partial answer to my question using KVM:
This is almost all of the information that I want, I think that if I can continue to dig through the relevant headers I'll be able to find all this information. Hopefully the other BSD arches will have something too ;-).