int main(void) {
int *p1 = 0;
*p1 = 42;
return 0;
}
that is the object from a compile using the c89
-g option, enter: c89 -g -o samp samp.c
dbx -r samp
FDBX6421: Loaded debug data from "./samp.dbg"
FDBX0163: Entering debugger…
FDBX0089: dbx for z/OS.
FDBX0399: Compiled: Dec 8 2003 at 13:58:54
FDBX0400: OS level: 15.00 03; LE level: 4.1.5; (Local)
FDBX6499: CDA levels: ELF=P040106.z1r6, DWARF=P040106.zosv1r6,
DDPI=P040106.zosv1r6
FDBX0100: Type 'help' for help.
FDBX0048: Set an event like 'st in main' then use 'c' to start debugging.
FDBX0150: Debug target is 31-bit
segmentation violation (invalid key access) in main at line 6 in file
"/mylog/appl/execut/samp/samp.c" ($t1)
6 return 0;
(dbx31) quit
#include <stdio.h>
int main(void)
{
int i, x[64];
for (i = 0; i < 10;) {
printf("%d\n", x[i]);
sleep(1);
}
return 0;
}
c89 -g -o looper looper.c
Then run the program
from the command line: looper &
dbx -a $!
or perform the following steps:
ps -u userid -o pid,tty,time,comm
where userid is
your TSO/E user ID that is running looper. All active processes
that belong to that user ID are displayed: PID TT TIME COMMAND
655362 ? 00:00:10
458755 ttyp0000 00:00:00 /bin/sh
524292 ttyp0000 00:00:02 looper
6 ttyp0000 00:00:00 /bin/ps
The process ID associated with looper is 524292.
dbx -a 524292
dbx attaches
to the process running the program, displays the last instruction
processed, and prompts you for a debugging subcommand: FDBX0089: dbx for z/OS.
FDBX0399: Compiled: Dec 8 2003 at 13:58:54
FDBX0400: OS level: 15.00 03; LE level: 4.1.5; (Local)
FDBX6499: CDA levels: ELF=P040106.zosv1r6, DWARF=P040106.zosv1r6,
DDPI=P040106.zosv1r6
FDBX0100: Type 'help' for help.
FDBX0048: Set an event like 'st in main' then use 'c' to start debugging.
FDBX0278: Waiting to attach to process 33619980 …
FDBX6421: Loaded debug data from "./looper.dbg"
attached in . at 0x0d9d8d1c ($t1)
sleep() at 0xd9d8ca8, PPA1 at 0xd9dded0, stack at 0x2001f3c0
main.$b2, line 9 in "/tmp/looper.c"
main(), line 9 in "/tmp/looper.c"
EDCZMINV() at 0xdaa6416, PPA1 at 0xdaa6416, stack at 0x2001f0f8
CEEBBEXT() at 0xce89130, PPA1 at 0xce89418, stack at 0x2001f030
0x0d9d8d1c () 58f0d0a0 l $r15,X'A0'(,$r13)
FDBX0150: Debug target is 31-bit
(dbx31) quit
You can now query and debug the process as if it had been originally started with dbx. When you are finished debugging the process and have ended dbx, enter the shell exit command to end the second shell session and return to your initial session.