ARM Technical Support Knowledge Articles

DETECTING NULL POINTER ASSIGNMENTS

Applies to: uVision Debugger

Answer


Information in this article applies to:


QUESTION

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

ANSWER

It is easy to use the uVision 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.

Article last edited on: 2005-07-09 11:32:59

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential