HPlogo HP WDB-GUI Reference Manual: HP-UX 11i v2 > Chapter 3 Debugging with WDB GUI

Loading a Program and Changing Program Settings

» 

Technical documentation

Complete book in PDF

 » Table of Contents

You can set the following options for your debug sessions:

  • Run options

  • Environment variables

  • Standard input/output redirection

NOTE: When you click OK in the Load Program dialog box, any settings that you have specified in the Command view will be overridden.

If you change any debug settings or click OK in the Load Program dialog box, WDB reloads your executable and unloads the running executable.

The Load Program dialog box with the Run tab selected

Setting Run Options

In the Load Program dialog box, use the Run tab to set options that specify the executable name, program arguments, core file name, and existing process to be used for the current debug session.

To specify an executable:

  1. On the File menu, click Load Program, then click the Run tab.

  2. In the Executable Name box, type the path and name of the executable. To browse for the file, click the Browse button.

    1. If you browse for the file, the Executable Name dialog box displays

    2. In the Executable Name dialog box, double-click to select the appropriate directory from the Directories list and select the appropriate file from the Files list.

    3. When the proper path and file appear in the Selection box, click OK.

  3. In the Load Program dialog box, verify that the proper path and file appear in the Executable Name box.

  4. In the Arguments box, type the command line arguments that you want to pass to the executable when it runs.

  5. Click OK.

To load a core file for debugging

  1. On the File menu, click Load Program, then click the Run tab.

  2. Select the Core File option, then type the path and name of the core file. To browse for the file, click the Browse button.

  3. Click OK.

To attach to an existing process for debugging

  1. On the File menu, click Load Program, then click the Run tab.

  2. Select the Attach Process ID option, then type the process ID number (PID).

  3. Click OK.

The process execution pauses and the program loads into the WDB GUI. You can now set breakpoints, view variables, and perform other debugging tasks.

Set desired breakpoints at this stage because once you continue executing the process, you will not have control of execution until a breakpoint has been reached.

NOTE:
  • You can debug executables that are stored on NFS-mounted file systems, but you cannot attach to an existing process if the executable that you run resides on an NFS-mounted file system rather than on your local machine’s file system. To fix this problem, copy the executable onto your local machine’s file system, restart the process on your local machine, run the debugger, and attach to the process.

  • If you want to attach to a running process that contains shared libraries, before you run your program, run the command /usr/bin/pxdb -s enable executable_file where executable_file is the name of your program executable.

To detach process

Click Stop Debugging on the Debug menu to detach a process.

After the process is detached, the process continues running independently of the WDB GUI, and the WDB GUI no longer has any control of the process.

Setting Environment Variables

You can set environment variables that will be in effect for the current debug session.

To view current environment variables

  1. On the File menu, click Load Program, then click the Environment tab.

  2. Check the Debug Environment Variables list box for a list of current environment variables.

  3. Click OK.

NOTE:
  • The Load Program dialog box does not display the environment variables that you specify using the Command view.

  • The Load Program dialog box does not display the environment variables that were inherited from the shell from which the WDB GUI was launched.

  • To see a list of all the environment variables that are currently set, use the show env command in the Command view.

To set new environment variables

  1. On the File menu, click Load Program, then click the Environment tab.

  2. In the Variable box on the Add/Modify Environment Variable section, type the name of the variable you want to set.

  3. In the Value box, type the value that you want to assign to the specified variable. For example, to assign the variable, “DISPLAY,” a value of “test:0,” type DISPLAY in the Variable box and type test:0 in the Value box.

  4. Click Set.

  5. Click OK.

To delete environment variables

  1. On the File menu, click Load Program.

  2. Click the Environment tab.

  3. In the Debug Environment Variables list box, select the variable that you want to delete.

  4. Click Delete and click OK.

  5. In the Command view, enter the command, unset env Varname where VarName is the name of the environment variable you want to remove.

  6. Use the show env command in the Command view to verify that the environment variable has been removed.

Setting Program Input/Output Redirection

You can specify where you want to accept standard input and send output information for the current debug session. When these fields are blank, the Program Console is used for standard input and output.

NOTE: Files you redirect using the Command view do not appear in the Load Program dialog box.

To redirect standard input and output information

  1. On the File menu, click Load Program.

  2. Click the Input/Output tab.

  3. In the Stdin box, type the name of the file or browse to the file that you want to specify for standard input.

  4. In the Stdout box, type or browse to the file that you want to specify for standard output. Click the Append button if you want to append information to the standard output file rather than overwrite existing information in the file.

  5. When you have the correct file name in each box, click OK.

NOTE: You cannot redirect standard error from the WDB GUI. It will display in the Program Console. If you want to redirect standard error output, start your program in a terminal window outside the WDB GUI and then attach to the process. This allows you to control standard error output.
Tips:

To save the program settings that you set in the Load Program dialog box, click Save Session on the File menu and make sure that the Program Settings (Load Program) check box is checked.

© 2004-2005 Hewlett-Packard Development Company, L.P.