Tuesday, January 22, 2008

Debugging Pointers:

In the debugger, you can see the data that a pointer is pointing to even if you don't have a variable that is based on the pointer.

When debugging an RPG or COBOL program, if you display a pointer variable using :c or :x, the debugger will display the data that the pointer is pointing to rather than displaying the 16 bytes of the pointer variable itself.

D p S *
D packedVal S 5P 0 INZ(12345)
D charVal S 5A INZ('abcde')
/free
p = %addr(charVal);
p = %addr(packedVal);
return;

In the debugger, after the first assignment to p:

> EVAL p
P = SPP:DE60CDB47B069738
> EVAL p:c 5
P:C 5 = 'abcde'
> EVAL p:x 5
00000 81828384 85......

After the second assignment to p:

> EVAL p
P = SPP:DE60CDB47B06973D
> EVAL p:c 3
P:C 3 = ' ¬'
> EVAL p:x 3
00000 12345F..

No comments: