2

OK folks. I set a Data Breakpoint in Atmel studio (With ICEmk2-JTag Debugger) and it won't get hit although the value at the address is changed. (I checked it with following breakpoints) Why is this?

The whole purpose of Data breakpoints is to detect a change of the value at the address, or am I misunderstanding something?

To be more specific: I have a Pointer A that points to a value. But the pointer A is changed (not the value it points to!) by a bug I'm trying to hunt down. So, I created a pointer B that points to the address where pointer A is stored and set a Data Breakpoint on Pointer B. Here is the initialization:

#define lastCMDRingBufferSIZE 255

volatile uint8_t lastCMDRingbuffer[lastCMDRingBufferSIZE]; //
volatile uint8_t*lastCMDRingstartPtr = lastCMDRingbuffer; // This is PtrA
volatile uint32_t*ptrToPtr = &lastCMDRingstartPtr; // PtrB

Or another way to put it; Is a databreakpoint triggered if:

  1. the content of the address is written by a array overflow?
  2. the content of the address is interpreted as part of a larger data structure that is somehow written by a rogue pointer? (expl: a 64 bit pointer is dereferenced and written to, as a result a 32bit integer gets overwritten)

Your suspections and advice are highly appreciated :)

4

2 回答 2

2

您没有以正确的方式解决(双关语不是有意的)这个问题。如果指针A被破坏,需要&A直接设置数据断点;除非您可以设置条件断点,否则创建辅助指针不会有任何用处A != B

在以下情况下是否触发数据断点:

  1. 地址的内容是由数组溢出写入的?地址的内容被解释为更大数据结构的一部分
  2. 以某种方式由流氓指针编写?(解释:一个 64 位指针被取消引用并被写入,结果一个 32 位整数被覆盖)

当断点地址的值发生变化时触发它——就这么简单;片上调试硬件没有语言结构的概念;因此,您需要查看的地址&A不是Aor B

在你的实际代码的上下文中如果lastCMDRingstartPtr被修改,ptrToPtr也不会改变。只需输入&lastCMDRingstartPtr地址;那么当值lastCMDRingstartPtr改变时你会得到一个休息。

于 2017-04-12T14:13:36.167 回答
1

我使用的支持数据访问中断的调试硬件并没有像我认为大多数人期望的那样实现。硬件不监视地址处的内存并在它发生变化时发出断点,它监视 CPU 的读/写总线,如果在给定地址(或地址范围)和正确宽度的访问发生时中断.

最终结果是您可以让一些活动不被硬件捕获。访问内存的 DMA 是一个您根本无法捕获的大问题(除非您的 SRAM/DRAM 接口能够发出这样的故障)。此外,如果您在未配置调试硬件的模式下访问地址(即,在您寻找字写入时进行字节写入 - 如果您有一个非常幼稚的 memset/memcpy ,这可能是可能的是否进行字节访问)

我的猜测是您正在对指针之前声明的数组进行一些字节访问,并通过溢出数组来踩踏指针。即使您在指针上设置了单词访问硬件断点,它也不会被捕获,因为您正在执行字节访问。

于 2017-04-17T19:23:27.293 回答