Skip to content

Instantly share code, notes, and snippets.

@janjongboom
Created June 3, 2017 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janjongboom/0ad27f2c98e9cd2c146ad937c1e9a0f2 to your computer and use it in GitHub Desktop.
Save janjongboom/0ad27f2c98e9cd2c146ad937c1e9a0f2 to your computer and use it in GitHub Desktop.
Memory breakpoint testing mbed OS 5
#include "mbed.h"
DigitalOut led1(LED1);
// main() runs in its own thread in the OS
int main() {
Serial pc(USBTX, USBRX);
pc.baud(115200);
char test[200];
for (size_t ix = 0; ix < sizeof(test); ix++) {
test[ix] = rand() % 255;
}
wait(osWaitForever);
}
@janjongboom
Copy link
Author

How to use:

  1. Break on line 12.

  2. Inspect address of test in the watch window via (&test).

  3. Add a memory watch using the Debug console via:

    -exec watch *0x20001950
    

    (where 0x20001950 is the address of test offset by 68 (but less than 200 :-)) bytes)

  4. Hit the 'Play' button.

  5. The trap should fire. Inspect the value of ix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment