Basic Information on Starting the Debugger

Before you start the debugger, make sure that you have correctly set the size information for your terminal; otherwise, the debugger's command line editing support may act unpredictably. For example, if your terminal is 25x80, you may need to set the following:

% stty rows 25 ; setenv LINES 25

% stty cols 80 ; setenv COLS 80

There are four basic alternatives for running the debugger on a process (see examples below):

  1. Have the debugger create the process using the shell command line to identify the executable to run
  2. Have the debugger create the process using the debugger commands to identify the executable to run
  3. Have the debugger attach to a running process using the shell command line to identify the process and the executable file that process is running
  4. Have the debugger attach to a running process using the debugger commands to identify the process and the executable file that process is running

Below are examples for GDB and DBX modes

GDB Mode

From the command line, the debugger starts operating in GDB mode by default. When you use the debugger from the GUI, it operates in DBX mode by default.

1. Creating the process using the shell command line.

% idb a.out

Intel(R) Debugger for ..., Version ..., Build ...

------------------

object file name: a.out

Reading symbols from a.out...done

(idb) break main

Breakpoint 1 at 0x80484f6: file qwerty.c, line 9.

(idb) run

2. Creating the process using the debugger commands.

% idb

Intel(R) Debugger for ..., Version ..., Build ...

-------------------

(idb) file a.out

Reading symbols from a.out...done.

(idb) break main

Breakpoint 1 at 0x80484f6: file qwerty.c, line 9.

(idb) run

3. Attaching to a running process using the shell command line.

% ./a.out &

[1] 27859

% jobs

[1]+  Running                 ./a.out &

% idb a.out -pid 27859

Intel(R) Debugger for ..., Version ..., Build ...

------------------

object file name: a.out

Reading symbols from a.out...done.

Attached to process id 27859  ....

Press Ctrl+C to interrupt the process.

4. Attaching to the process using the debugger commands.

% ./a.out &

[1] 27859

% jobs

[1]+  Running                 ./a.out &

% idb

Intel(R) Debugger for ..., Version ..., Build ...

(idb) file a.out

Reading symbols from a.out...done.

(idb) attach 27859

Attached to process id 27859  ....

DBX Mode

When you use the debugger from the command line, it operates in GDB mode by default. When you use the debugger from the GUI, it operates in DBX mode by default.

1. Creating the process using the shell command line.

 % idb -dbx a.out

Intel(R) Debugger for ..., Version ..., Build ...

------------------

object file name: a.out

Reading symbolic information ...done

(idb) stop in main

[#1: stop in int main(void) ]

(idb) run

2. Creating the process using the debugger commands.

% idb -dbx

Intel(R) Debugger for ..., Version ..., Build ...

------------------

(idb) load a.out

Reading symbolic information ...done

(idb) stop in main

[#1: stop in int main(void) ]

(idb) run

3. Attaching to a running process using the shell command line.

% ./a.out &

[1] 27859

% jobs

[1]+  Running                 ./a.out &

% idb -dbx a.out -pid 27859

Intel(R) Debugger for ..., Version ..., Build ...

------------------

Reading symbolic information ...done

Attached to process id 27859  ....

Press Ctrl+C to interrupt the process.

4. Attaching to the process using the debugger commands.

% ./a.out &

[1] 27859

% jobs

[1]+  Running                 ./a.out &

% idb -dbx

Intel(R) Debugger for ..., Version ..., Build ...

------------------

(idb) attach 27859 a.out

Reading symbolic information ...done

Attached to process id 27859  ....

Press Ctrl+C to interrupt the process.

Note:

In the case of Fortran, routine main at which your program stops is not your main program unit. Rather, it is a main routine supplied by the Fortran system that performs some initialization and then calls your code. Just step forward using the step command a couple of times (probably twice) and you will soon step into your code.

Note:

If you want full compatibility with GDB output, you need to set the debugger variable $gdb_compatible_output to 1. Otherwise, IDB will produce the extended GDB output in some cases.

See Attaching to a Running Program for the information about how to obtain the PID of a program.

See also:

Starting the Debugger