Example: monitoring and modifying registers and storage in C
The examples below use the following C program to demonstrate how
to monitor and modify registers and storage.
int dbl(int j) /* line 1 */
{ /* line 2 */
return 2*j; /* line 3 */
} /* line 4 */
int main(void)
{
int i;
i = 10;
return dbl(i);
}
If you compile the program above using the compiler options
TEST(ALL),LIST
,
then your pseudo assembly listing will be similar to the listing shown
below.
* int dbl(int j)
ST r1,152(,r13)
* {
EX r0,HOOK..PGM-ENTRY
* return 2*j;
EX r0,HOOK..STMT
L r15,152(,r13)
L r15,0(,r15)
SLL r15,1
B @5L2
DC A@5L2-ep)
NOPR
@5L1 DS 0D
* }
@5L2 DS 0D
EX r0,HOOK..PGM-EXIT
To display a continuously updated view of the registers in the
Monitor window, enter the following command:
MONITOR LIST REGISTERS
After a few steps, z/OS® Debugger halts on line 1 (the program entry hook,
shown in the listing above). Another STEP
takes you to
line 3, and halts on the statement hook. The next STEP
takes
you to line 4, and halts on the program exit hook. As indicated by
the pseudo assembly listing, only register 15 has changed during this STEP
,
and it contains the return value of the function. In the Monitor
window, register 15 now has the value 0x00000014
(decimal
20), as expected.
You can change the value from 20 to 8 just before returning from
dbl()
by
issuing the command:
%GPR15 = 8 ;