Getting Started with the Intel® Debugger

Document number: 319697-005US

The Intel® Debugger supports debugging applications written in C, C++, Fortran and Assembly languages.

About This Document

This document helps you get started using the debugger by taking you through building a simple application and executing all the necessary steps to begin debugging, as well as several basic debugging tasks.

NOTE

The information here is applicable to both the GUI-based version of the debugger, and the command-line version. The GUI-based version is available on systems based on based on IA-32 or Intel® 64 architecture running Linux* OS.

All technical requirements must be satisfied. All program examples are created with the Intel® C++ Compiler or the Intel® Fortran Compiler.

Technical Requirements

The Intel® Debugger graphical environment is a Java* application and requires a Java Runtime Environment (JRE) to execute. See the Release Notes for the exact requirements.

For other technical requirements, see the installation guide and Release Notes for the Intel® Debugger.

Building the Sample Code

A simple Hello World application can demonstrate some of the debugger's basic features.

To prepare helloworld in C:

Create a new file named helloworld.c in a working directory. Add the following code to helloworld.c:

#include <stdio.h>

int main()

{

    printf("Hello World!\n");

    return 0;

}

To compile helloworld.c:

Before compiling you must set the environment variables as described in the compiler User Guide.

  1. Open a shell and change to the working directory.
  2. Compile the application:
    • On Linux* OS, compile the application using the following command:
    • icc -debug -O0 helloworld.c -o helloworld

    • On Mac OS* X, the debugger reads debug information from object files. As a result, the executables don't contain any debug information. To be able to debug, you must retain the object files.
    • First, create an object file with debug information using the following command:

      icc -debug -O0 -c helloworld.c -o helloworld.o

      Then compile the application using the following command:

      icc -debug -O0 helloworld.o -o helloworld

Following successful compilation, the compiler creates an executable named helloworld in the working directory.

To prepare helloworld in Fortran:

Create a new file named helloworld.f90 in a working directory. Add the following code to helloworld.f90:

program main

    print *,"Hello World!"

end program main

To compile helloworld.c:

  1. Open a shell and change to the working directory.
  2. Compile the application:
    • On Linux* OS, compile the application using the following command:
    • ifort -debug -O0 helloworld.f90 -o helloworld

    • On Mac OS* X, the debugger reads debug information from object files. As a result, the executables don't contain any debug information. To be able to debug, you must retain the object files.
    • First, create an object file with debug information using the following command:

      ifort -debug -O0 -c helloworld.f90 -o helloworld.o

      Then compile the application using the following command:

      ifort -debug -O0 helloworld.o -o helloworld

Following successful compilation, the compiler creates an executable named helloworld in the working directory.

Starting the Debugger

On systems based on IA-32 or Intel® 64 architecture running Linux* OS, the debugger runs in GUI mode by default. You can also start the debugger in command line mode on these systems by specifying idbc instead of idb in the command line.

On all other systems, the debugger only runs in command line mode.

NOTE

The idb command is enabled when you run the script that sets up the compiler environment as described in the Getting Started document for the compiler.

To start the debugger:

Enter the following command in a shell:

idb

The debugger starts running.

Opening the helloworld Executable

To open the executable file using the GUI:

  1. In the debugger, select File > Open Executable.
  2. Click the Browse button, navigate to your working directory and select the helloworld executable file.
  3. Click OK.

The debugger opens helloworld.

To open the executable file using the command line:

Enter the following command:

(idb) file helloworld

The debugger opens helloworld.

Displaying the Source File

To display the source file using the GUI:

  1. Select View > Source Files.
  2. The Source Files window appears, displaying a list of the project source files to be debugged.

  3. Double-click helloworld.c or helloworld.f90.

The Source window displays the source code and sets the scope appropriately.

To display the source file using the command line:

Enter the following command:

(idb) list main

The debugger displays the source code of the main function in helloworld.

Running the Application

To run helloworld:

The application runs, and displays Hello World! in the shell that spawned the debugger, and the program exits.

In a case such as this, in which the application doesn't contain any code to stop program execution, you must use breakpoints to stop the application.

Setting and Deleting a Breakpoint

In this section, you set and then delete a breakpoint at the main function.

Setting and Deleting a Breakpoint-GUI

In the Source window, the debugger indicates lines of code on which you can set breakpoints with a blue dot at the start of the line.

To set a breakpoint in the Source window:

  1. Right-click a line of code that contains a blue dot or a selected expression.
  2. The line pointer is set to this line, and the pop-up menu of the window appears.

  3. Select Set Breakpoint.
  4. Alternatively, you can set a breakpoint by double-clicking the blue dot.

    A breakpoint is now set at main, indicated by a red stop-sign.

  5. Run the application again.

The application should stop at the breakpoint you set.

To delete the breakpoint:

  1. Right-click a line of code that contains a stop sign.
  2. The line pointer is set to this line, and the pop-up menu of the window appears.

  3. Select Delete Breakpoint.
  4. Alternatively, you can delete a breakpoint by double-clicking the stop sign.

    You have deleted the breakpoint you set. The blue dot has replaced the stop-sign.

  5. Run the application again.

The application runs, and displays Hello World! in the shell that spawned the debugger, and the program exits.

Setting and Deleting a Breakpoint-Command-line

To set a breakpoint:

  1. Enter the following command:
  2. (idb) break main

    A breakpoint is now set at main.

  3. Enter run to run the application again.

The application should stop at the breakpoint you set.

To delete the breakpoint:

  1. List the IDs of all existing breakpoint by entering the following command:
  2. (idb) info breakpoints

    The debugger displays all existing breakpoints.

  3. Identify the ID of the breakpoint you want to delete. If you have not set any other breakpoints since starting the debugger, there is only one breakpoint, and its ID is 1.
  4. Delete the breakpoint by entering the following command:
  5. (idb) delete breakpoint 1

    You have deleted the breakpoint you set.

  6. Run the application again.

The application runs, and displays Hello World! in the shell that spawned the debugger, and the program exits.

Exiting the Debugger

To exit the debugger:

The debugger and all output files are closed.

Further Information

See the Intel® Debugger Online Help for more detailed descriptions of commands.

You can also use the help command by entering the following at the debugger command prompt:

(idb) help

Disclaimer and Legal Information

INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL® PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.

UNLESS OTHERWISE AGREED IN WRITING BY INTEL, THE INTEL PRODUCTS ARE NOT DESIGNED NOR INTENDED FOR ANY APPLICATION IN WHICH THE FAILURE OF THE INTEL PRODUCT COULD CREATE A SITUATION WHERE PERSONAL INJURY OR DEATH MAY OCCUR.

Intel may make changes to specifications and product descriptions at any time, without notice. Designers must not rely on the absence or characteristics of any features or instructions marked reserved or undefined. Intel reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them. The information here is subject to change without notice. Do not finalize a design with this information.

The products described in this document may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request.

Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.

Copies of documents which have an order number and are referenced in this document, or other Intel literature, may be obtained by calling 1-800-548-4725, or by visiting Intel's Web Site.

Intel processor numbers are not a measure of performance. Processor numbers differentiate features within each processor family, not across different processor families. See http://www.intel.com/products/processor_number for details.

BunnyPeople, Celeron, Celeron Inside, Centrino, Centrino Atom, Centrino Atom Inside, Centrino Inside, Centrino logo, Core Inside, FlashFile, i960, InstantIP, Intel, Intel logo, Intel386, Intel486, IntelDX2, IntelDX4, IntelSX2, Intel Atom, Intel Atom Inside, Intel Core, Intel Inside, Intel Inside logo, Intel. Leap ahead., Intel. Leap ahead. logo, Intel NetBurst, Intel NetMerge, Intel NetStructure, Intel SingleDriver, Intel SpeedStep, Intel StrataFlash, Intel Viiv, Intel vPro, Intel XScale, Itanium, Itanium Inside, MCS, MMX, Oplus, OverDrive, PDCharm, Pentium, Pentium Inside, skoool, Sound Mark, The Journey Inside, Viiv Inside, vPro Inside, VTune, Xeon, and Xeon Inside are trademarks of Intel Corporation in the U.S. and other countries.

* Other names and brands may be claimed as the property of others.

Copyright © 2001-2009, Intel Corporation. All rights reserved.

Portions Copyright © 2001, Hewlett-Packard Development Company, L.P.