Ada:Debugging
Contents
Debugging Programs with "idb"
"idb" is Intel's integrated debugging environment which can be used with either its GUI or its command line front end. We assume that the compiler environment has been prepared.
To be able to debug code developed with the Intel compilers, you should use the "-debug" flag in the compilation command line. It is best to avoid any optimization and thus you need to specify the "-O0" as well.
Simple "helloworld.c" Example
A simple Hello World application can demonstrate some of the debugger's basic features. Create a new file named 'helloworld.c' in a working directory. Add the following code to it:
#include int main( int argc, char *argv[] ) { printf("Hello World!\n"); for (; argc; argc-- ) { fprintf(stderr, "argv[%d] = %s\n", argc, argv[argc]); } return 0; }
To prepare the "helloworld.c", use the following command line
icc -debug -O0 helloworld.c -o helloworld
To start the idb debugger, enter the following command in a shell:
idb
and the debugger GUI front-end starts running.
Open Executable in the Debugger
To open the executable once inside the debugger:
- In the debugger, select File > Open Executable.
- Click the Browse button, navigate to your working directory and select the helloworld executable file.
- 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.
Display the Source File
To display the source file using the GUI:
- Select View > Source Files. The Source Files window appears, displaying a list of the project source files to be debugged.
- Double-click helloworld.c
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.
Run the Application
To run helloworld:
- Using the GUI, select Run > Run.
- Using the command line, enter 'run'.
Breakpoints
To set a breakpoint:
Enter the following command:
(idb) break main
A breakpoint is now set at function main().
- Enter run to run the application again.
The application should stop at the breakpoint you set.
To delete the breakpoint:
List the IDs of all existing breakpoint by entering the following command:
(idb) info breakpoints
The debugger displays all existing breakpoints.
- 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.
Delete the breakpoint by entering the following command:
(idb) delete breakpoint 1
You have deleted the breakpoint you set.
- 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:
- Select File > Exit.
- Enter quit.
The debugger and all output files are closed.
More Information
You can find more information once inside idb using the "help" command.