可以在 ISR 中使用断点吗?
断点可以用在中断服务程序(ISR)中吗?
Can breakpoints be used in interrupt service routines (ISRs)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
断点可以用在中断服务程序(ISR)中吗?
Can breakpoints be used in interrupt service routines (ISRs)?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
是的 - 在模拟器中。
否则,不行。 这很难实现,而且无论如何都是一个坏主意。 ISR(通常)应该与硬件一起工作,当您在每条指令之间留出半秒的间隙时,硬件很容易表现出截然不同的行为。
相反,设置某种日志系统。
ISR 还会不礼貌地从其他进程中“窃取”CPU,因此许多操作系统建议让 ISR 保持极短,并且仅执行严格必要的操作(例如处理任何紧急硬件的东西,并安排一个将正确处理事件的任务)。 因此理论上,ISR 应该非常简单,不需要调试。
如果问题出在硬件行为上,请按照我的建议使用某种日志记录。 如果硬件并不介意指令之间的较长时间间隔,那么您可以在用户空间中编写大部分驱动程序 - 并且您可以对此使用调试器!
Yes - in an emulator.
Otherwise, no. It's difficult to pull off, and a bad idea in any case. ISRs are (usually) supposed to work with the hardware, and hardware can easily behave very differently when you leave a gap of half a second between each instruction.
Set up some sort of logging system instead.
ISRs also ungracefully "steal" the CPU from other processes, so many operating systems recommend keeping your ISRs extremely short and doing only what is strictly necessary (such as dealing with any urgent hardware stuff, and scheduling a task that will deal with the event properly). So in theory, ISRs should be so simple that they don't need to be debugged.
If it's hardware behaviour that's the problem, use some sort of logging instead, as I've suggested. If the hardware doesn't really mind long gaps of time between instructions, then you could just write most of the driver in user space - and you can use a debugger on that!
根据您的平台,您可以通过访问处理器的调试端口(通常使用 JTAG 接口)来完成此操作。 请记住,您正在彻底改变与该方法的计时有关的所有内容,因此您的调试会话可能毫无用处。 但话又说回来,很多错误都可以通过这种方式捕获。 还要注意基于 MMU 的内存映射,因为 JTAG 调试器通常不会考虑它们。
Depending on your platform, you can do this by accessing the debug port of your processor, typically using the JTAG interface. Keep in mind that you're drastically changing everything that has to do with timing with that method, so your debug session may be useless. But then again, many bugs can be caught this way. Also mind MMU based memory mappings, as JTAG debuggers often don't take them into account.
在 Windows 中,附加了内核调试器,您确实可以放置断点在中断处理程序中。
In Windows, with a kernel debugger attached, you can indeed place breakpoints in interrupt handlers.