Displaying Data Addressed by Pointers

If you want to see what a pointer is pointing to, you can use the EVAL command with the :c or :x suffix. For example, if pointer field PTR1 is pointing to 10 bytes of character data,

EVAL PTR1:c 10

will show the contents of those 10 bytes.

You can also show the contents in hexadecimal using:

EVAL PTR1:x 10

This would be especially useful when the data that the pointer addresses is not stored in printable form, such as packed or binary data.

If you have a variable FLD1 based on basing pointer PTR1 that is itself based on a pointer PTR2, you will not be able to evaluate FLD1 using a simple EVAL command in the debugger.

Instead, you must explicitly give the debugger the chain of basing pointers:

===> EVAL PTR2->PTR1->FLD1

For example, if you have the following definitions:

D pPointers       S               *                      
D pointers        DS                  based(pPointers)   
D  p1                             *                      
D  p2                             *                      
D data1           S             10A   based(p1)          
D data2           S             10A   based(p2)          

you can use these commands in the debugger to display or change the values of DATA1 and DATA2:

===> eval pPointers->p1->data1
===> eval pPointers->p2->data2 = 'new value'

To determine the expression to specify in the debugger, you start from the end of the expression with the value that you want to evaluate:

	data1

Then you move to the left and add the name that appears in the BASED keyword for the definition of data1, which is p1:

	p1->data1

Then you move to the left again and add the name that appears in the BASED keyword for the definition of p1, which is pPointers:

	pPointers->p1->data1

The expression is complete when the pointer that you have specified was not defined with the BASED keyword. In this case, pPointers is not defined as based, so the debug expression is now complete.

===> eval pPointers->p1->data1


[ Top of Page | Previous Page | Next Page | Contents | Index ]