Sun Studio 12: Debugging a Program With dbx

Starting dbx and Loading Your Program

To start dbx, type the dbx command at a shell prompt:


$ dbx

To start dbx and load the program to be debugged:


$ dbx program_name

To start dbx and load a program that is a mixture of Java code and C JNI code or C++ JNI code:


$ dbx program_name{.class | .jar}

You can use the dbx command to start dbx and attach it to a running process by specifying the process ID.


$ dbx - process_id

If you don’t know the process ID of the process, include the pgrep command in the dbx command to find and attach to the process. For example:


$ dbx - ”pgrep Freeway”
Reading -
Reading ld.so.1
Reading libXm.so.4
Reading libgen.so.1
Reading libXt.so.4
Reading libX11.so.4
Reading libce.so.0
Reading libsocket.so.1
Reading libm.so.1
Reading libw.so.1
Reading libc.so.1
Reading libSM.so.6
Reading libICE.so.6
Reading libXext.so.0
Reading libnsl.so.1
Reading libdl.so.1
Reading libmp.so.2
Reading libc_psr.so.1
Attached to process 1855
stopped in _libc_poll at 0xfef9437c
0xfef9437c: _libc_poll+0x0004:   ta     0x8
Current function is main
   48   XtAppMainLoop(app_context);
(dbx)

For more information on the dbx command and start-up options, see dbx Command and the dbx(1) man page, or type dbx -h.

If you are already running dbx, you can load the program to be debugged, or switch from the program you are debugging to another program, with the debug command:


(dbx) debug program_name

To load or switch to a program that includes Java code and C JNI code or C++ JNI code:


(dbx> debug program_name{.class | .jar}

If you are already running dbx, you can also use the debug command to attach dbx to a running process:


(dbx) debug program_name process_id

To attach dbx to a running process that includes Java code and C JNI (Java Native Interface) code or C++ JNI code:


(dbx) debug program_name{.class | .jar} process_id

For more information on the debug command, see debug Command.