SIGTRAP 尽管没有设置断点;隐藏硬件断点? [英] SIGTRAP despite no set breakpoints; hidden hardware breakpoint?

查看:40
本文介绍了SIGTRAP 尽管没有设置断点;隐藏硬件断点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 STM32 嵌入式系统调试这个软件.在其中一个函数中,我的程序不断遇到某种断点:

I am debugging this piece of software for an STM32 embedded system. In one of the functions my programs keeps hitting some sort of breakpoint:

SIGTRAP,跟踪/断点陷阱

SIGTRAP, Trace/breakpoint trap

但是,在 GDB 中,当我执行 info breakpoints 时,我会得到 No breakpoints or watchpoints.断点实际上对应于我很久以前在另一个版本的可执行文件中设置的断点.当我设置断点时,GDB 告诉我在只读内存上自动使用硬件断点(或类似的消息).

However, in GDB, when I do info breakpoints I get No breakpoints or watchpoints. The breakpoint actually corresponds to a breakpoint I had set quite some time ago, in another version of the executable. When I set that breakpoint, GDB told me automatically using a hardware breakpoint on read-only memory (or a similar message).

我认为硬件断点仍然在我的芯片上,尽管已经加载了新版本的软件.如果确实存在虚假断点,如何定位并移除?

I think the hardware breakpoint remains on my chip, despite having loaded a new version of the software. If there is indeed a spurious breakpoint, how can I locate and remove it?

推荐答案

好的.长答案:硬件断点通常通过写入一些特殊的 CPU 寄存器来设置.这是由 gdb 完成的.如果 gdb 死了,它可以将那些安装在 CPU 中.我猜您的(gdb)实现在连接到您的目标时不会清除或检查这些.要找到它们,您需要列出 CPU 上硬件断点寄存器的内容(不知道如何在 STM32 上执行此操作).解决方法是(有根据的猜测)是这样的:使用 gdb 设置几个硬件断点(通常只有几个,很少超过 8 个),然后将它们全部删除.这应该覆盖然后清理那些硬件寄存器.一旦您设置了这些断点(在删除它们之前),请执行继续"(以防万一,因为 gdb 仅在那时设置断点).

Ok. Long answer: Hardware breakpoints are usually set by writing to some special CPU registers. This is done by gdb. If gdb dies, it can left those installed in CPU. I guess your implementation (of gdb) does not either clear or examine those, when it connects to your target. To locate them, you would need to list the contents of hardware breakpoints registers on your CPU (don't know how to do this on STM32). Workaround would be (informed guess) be this: set few HW breakpoints (typically there are only a few, seldom more than 8) using gdb, then remove all of them. This should overwrite and then clean those hw registers. Once you do set those breakpoints (before removing them), do "continue" (just in case, as gdb sets breakpoints only at that time).

这篇关于SIGTRAP 尽管没有设置断点;隐藏硬件断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆