Using the Perl Debugger
Prev |  | Next

## Using the Perl Debugger

### Launching Perl Programs

You may launch your Perl programs from the workbench. Programs may be launched in either run or debug mode.

- In run mode, the program executes, but may not be suspended or examined.

- In debug mode, execution may be suspended and resumed, variables may be inspected, and expressions may be evaluated.

The environment a Perl program is to be executed in is defined via "Launch Configurations". A launch configuration defines

- if the program is to be executed in a CGI or normal Perl environment

- the host the program is to be executed on

- the program to execute

- execution parameters to pass

- environment variables (for CGI environment)

- configuration data for the WEB server used to provide the CGI framework

#### Launching Perl programs in run mode

1. Select Menu->Run

2. Within the dialog appearing

   select the configuration type:

   Perl(local): Run a Perl script on the local machine

   Perl-CGI(local): Run Perl programs in a CGI environment

   Perl(remote): Run Perl script on a remote machine

   and press the new button to create a new launch configuration.

3. Adjust launch configuration attributes. For details see Configuring Launch Configurations .

4. Press the "Run" Button

This executes the program. The programs console output will be shown in the console window. The console window also accepts keyboard input to be passed to the program.

If you switch to the debug view you have additional control over the execution of the program. For details see Debug View .

#### Launching Perl Programs in debug mode

Before debugging a program you may want to set break points to stop program execution at certain source code locations. For details see Debug View .

1. Select Menu->Debug

2. Within the dialog appearing

   select the configuration type:

   Perl(local): Run a Perl script on the local machine

   Perl-CGI(local): Run Perl programs in a CGI environment

   Perl(remote): Run Perl script on a remote machine

   and press the new button to create a new launch configuration.

3. Adjust launch configuration attributes. For details see .

4. Press the "Debug" Button

If you switch to the debug view you have additional control over the execution of the program. For details see Debug View .

#### Re-launching a Perl Program

The workbench keeps a history of each launched and debugged program. To relaunch a program, do one of the following:

- Select a previous launch from Run or Debug button pull-down menus.

- From the menu bar, select Run > Run History or Run > Debug History and select a previous launch from these sub-menus.

- In the Debug view, select a process that you want to relaunch, and select Relaunch from the process's pop-up menu.

To relaunch the most recent launch, do one of the following:

- Click the Run or Debug buttons (without using the button pull-down menu).

- Select Run > Run Last Launched (Ctrl+F11), or Run > Debug Last Launched (F11) from the workbench menu bar.

### Configuring Launch Configurations

#### Perl(local): Running a Perl script on the local machine

1. Enter the name for the launch configuration in they "Name" field.

2. In the "Configuration" tab

   "Project" field: select the project to debug.

   Note: Only Perl projects (projects associated with a Perl nature) will be shown. If the project you require isn't shown see Converting an existing Project for adding a Perl nature to your project.

   "File to execute" field: select the Perl file to execute.

   Note: Only files associated with the Perl editor will be shown. See Associating Files with the Perl editorfor details. "Commadline Parameters" field: Enter command line parameters to pass to the selected perl script

3. Press the "Apply" button

#### Perl-CGI(local): Run Perl programms in a CGI environment

1. Enter the name for the launch configuration in they "Name" field.

3. In the "Web Server" tab

   "HTML Root Directory" Field: Enter the base directory that contains all HTML files or use the "Browse" button to select the appropriate directory.

   "HTML Startup File" Field: Enter the file name to be shown in the browser after startup or use the "Browse" button to select this file.

   "CGI Root Directory" Field: Enter the base directory that contains all CGI files or use the "Browse" button to select the appropriate directory.

   "Extension for CGI files" Field: this is a comma separated list of file extensions (each starting with a "." ) used for CGI files in the project.

4. In the "CGI Environment" tab

   CGI-Script Environment Variables Field: Sorted list of environemt vailables to be set for CGI scripts to be excuted. Use the following syntax to specify environment variables: name=value.

5. In the "Browser" tab

   There are two possible settings:

   Select "Custom Browser": specify the path to the browser executable and add the required command line parameters. Use "%1" as a place holder for the HTML file to be opened.

   Select "Default System Browser": to use the browser defined as default browser by your OS preferences.

6. Press the "Apply" button

#### Perl(remote): Run Perl script on a remote machine

----Not yet implemented----

### Break Points

The Perl debugger supports line break points and regular expression breakpoints. Both types of breakpoints are set on an executable line of a program. If enabled they suspend thread execution before the corresponding line of code is executed. Regular expression breakpoints additionally extract the regular expression contained in the line of code they are associated with and enable you to debug the regular expression within the RegEx-Plugin.

The following symbols are used to indicate breakpoints :

Status | Line Break Point | Regular Expression Break Point
Enabled |  |
Disabled |  |
Registered with debugger |  |

Note: Regular Expressions Break Points are still in an experimental state and will at the moment only work for expressions of the type: Expr1 =~ <delim>regexp<delim>modifier; Modifiers are ignored.

#### Setting Break Points

1. In the editor area, open the file where you want to add the breakpoint with the Perl editor.

2. Directly to the left of the line where you want to add the breakpoint, open the marker bar (vertical ruler) pop-up menu and select Add Breakpoint or Add RegExp Breakpoint.

While the breakpoint is enabled, thread execution suspends before that line of code is executed.

#### Enabling or Disabling Break Points

Open the debug view, open the breakpoint view and use the check box in front of the break point to enable or disable the break point.

#### Removing Break Points

There are two possible ways for removing a breakpoint:

1. Right click on the breakpoint symbol in marker the bar (vertical ruler) of the editor pop-up menu and select Remove Breakpoint.

2. Open the debug view, open the breakpoint window (if this window is not visible see Adding and Removing views ), right-click the breakpoint you want to remove and select Remove.

### Views in the Debug Perspective

#### Debug View

This view allows you to manage the debugging or running of programs in the workbench. It displays the stack frame for the suspended threads for each target you are debugging. Each thread in your program appears as a node in the tree. It also displays the process for each target you are running. If the thread is suspended, its stack frames are shown as child elements.

#### Variable View

When a stack frame is selected, you can see the visible variables in that stack frame in the Variables view.

The Variables view shows the value of primitive types. Complex variables can be examined by expanding them to show their members.

Global variables (including Perl internal variables) are marked with an

icon, local variables with an
icon.

If the value of a variable has changed since the last execution step it is displayed in red.

If changes in inner levels of complex variables have occurred the path to the changed variables is indicated via delta symbols:

This makes it possible to see these kind of changes even if variables are collapsed.

#### Customizing the Variables View

You can customize the presentation with the configuration menu.

##### Show detail pane

To show the detail pane select "Vertical View Orientation" or "Horizontal View Orientation" . Select "Variables View Only" to disable it.

The details pane shows the value of primitive variables (especially useful for string variables).

##### Select Variables to display

The variables view allows to select the following types of variables for displaying by checking the corresponding menu entry:

- Perl internal Variables

  these are variables provided by the Perl interpreter like $_, %INC etc. .

- Global Variables

  Variables visible from every where in your program.

- Local variables

  more correctly called "lexical" variables in Perl. Variables declared with my .

  To show lexical variables you need to install the Perl PadWalker module. The PadWalkers module has some problems which influence viewing of local variables.

#### Breakpoint View

The breakpoint views shows all breakpoints, their state (see Break Points) and location.

By selecting one ore more break points and invoking the context menu you can enable, disable or remove these break points.

#### Perl Expression View

The Perl Expression View allows you to execute any valid Perl code within the current context of the program executed in debug mode.

1. Open the Perl Debug View (Window->Open View->Other->Epic->Perl Expression View)

2. Enter the code to execute

3. Press the

   symbol

### Stepping through the execution of a Perl program

When a thread is suspended, the step controls can be used to step through the execution of the program line-by-line. If a breakpoint is encountered while performing a step operation, the execution will suspend at the breakpoint and the step operation is ended.

#### Step over

1. Select a stack frame in the Debug view. The current line of execution in that stack frame is highlighted in the editor in the Debug perspective.

2. Click the Step Over button (

   ) in the Debug view toolbar, or press the F6 key. The currently-selected line is executed and suspends on the next executable line.

#### Step into

1. Select a stack frame in the Debug view. The current line of execution in the selected frame is highlighted in the editor in the Debug perspective.

2. Click the Step Into (

   ) button in the Debug view toolbar, or press the F5 key. The next expression on the currently-selected line to be executed is invoked, and execution suspends at the next executable line in the method that is invoked.

#### Run to return

1. Select a stack frame in the Debug view. The current line of execution in the selected frame is highlighted in the editor in the Debug perspective.

2. Click the Run to Return button (

   ) in the Debug view toolbar or press the F7 key. Execution resumes until the next return statement in the current method is executed, and execution suspends on the next executable line.

Prev | Up | Next
Working with the Perl Editor | Home | RegExp Plugin