Keil Logo

Check Illegal Memory Access

Check illegal memory access with access breakpoints using the system variable _break_.

The example stops program execution when the array save_record is accessed outside of the function clear_records. This example is written for the Measure project located in the folder \toolchain\Examples\Measure.

Expression:

// expression to check
\measure\save_record

Command:

// stop execution when save_record has been accessed outside of clear_records()
// 0x24 - size of clear_records  (the size depends on the toolchain selected and needs adaptation)
// $ - PC

_break_ = ($ < \\measure\\clear_records || $ >= \\measure\\clear_records + 0x24)

Illegal Memory Access Check

Add the following test instruction to main().

save_record[1].time.hour = 0xff;

The program stops:

  • While initializing the array save_record.
  • Right after the test instruction has been executed.
  • Whenever the array is accessed outside of clear_records.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.