Sun Studio 12 Update 1: Debugging a Program With dbx

attach Command

The attach command attaches dbx to a running process, stopping execution and putting the program under debugging control. It has identical syntax and identical functionality in native mode and Java mode.

Syntax

attach process_id

Begin debugging the program with process ID process_id. dbx finds the program using /proc.

attach -p process_id program_name

Begin debugging program_name with process ID process_id.

attach program_name process_id

Begin debugging program_name with process ID process_id. program_name can be ‐ dbx finds it using /proc.

attach -r ...

The -r option causes dbx to retain all watch commands, display commands, when commands, andstop commands. With no -r option, an implicit delete all command andundisplay 0 command are performed.

where:

process_id is the process ID of a running process.

program_name is the path name of the running program.

ProcedureTo Attach to a Running Java Process

  1. Ensure that the JVMTM software can find libdbx_agent.so by adding libdbx_agent.so to your LD_LIBRARY_PATH. libdbx_agent.so:

    • If you are using the 32-bit version of the JVM software on a system running the Solaris OS, add /installation_directory/libdbx_agent.so to LD_LIBRARY_PATH.

    • If you are using the 64-bit version of the JVM software on a SPARC based system running the Solaris OS, add /installation_directory/lib/v9/libdbx_agent.so to LD_LIBRARY_PATH.

    • If you are using the 64-bit version of the JVM software on an x64 based system running the Solaris OS or the Linux OS, add /installation_directory/lib/amd64/libdbx_agent.so to LD_LIBRARY_PATH.

    The installation_directory is the location where the Sun Studio software is installed.

  2. Start your Java application by typing:

    java -Djava.compiler=NONE -Xdebug -Xnoagent -Xrundbx_agent myclass.class

  3. Then you can attach to the process by starting dbx with the process id:

    dbx -process_id