Technical Support

µVISION DEBUGGER: DETECTING NULL POINTER ASSIGNMENTS


Information in this article applies to:

  • µVision Version 1 and Later

QUESTION

How do I check my program for assignments to NULL pointers?

ANSWER

It is easy to use the µVision Debugger to check for NULL pointer assignments. The steps to take to detect NULL pointer assignments (and make them less likely to cause problems) are:

  1. Use the linker options to relocate the beginning of your data areas so they don't begin at offset 0. Since a NULL pointer accesses this memory area, starting your program's variables and data at a different address reduces the chance that a NULL pointer assignment changes anything of importance.
  2. In the debugger, set a memory access breakpoint at the beginning of the data area (at address 0x0000). When your program READS or WRITES to this location, the debugger halts execution on the line that accessed the NULL address.

The following command:

BS READWRITE BYTE(X:0x0000)

sets a READ or WRITE access breakpoint on the byte at XDATA memory location 0x0000. When anything reads from or writes to that location, the debugger halts the program.

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Saturday, July 09, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure