This section provides a brief guide of some of the common debugging operations that can be performed with GDB. It is assumed that, before starting to debug, a connection has already been set up, as discussed in How to set up remote debugging, and that the target application, symbol file, initial breakpoint etc. have been set up as described in How to configure the GDB initialisation file.
All commands are entered on the CLI command line or on the Insight Console, unless otherwise specified. Further information on the commands discussed in this section is provided in the GDB command summary.
Enter run to start the debuggee on the target device and begin debugging.
Note:
The epoc-exe-file command must have previously been called to set which file is to be started. This is normally done in gdb.ini
.
The Run
button in the Insight GUI does not work. Start the debuggee using run on the Insight command console.
This section describes the commands used to navigate through code while debugging:
Enter step to "step into" the function on the current line, tracing into other functions where necessary.
The GUI also provides a Step
button.
Enter next to execute the current function and move to the next one. Unlike step this command does not trace into the function.
The GUI also provides a Next
button.
Enter continue to execute all code until a breakpoint is reached or the debuggee exits.
The GUI also provides a Continue
button.
The GUI provides a Finish
button to allow jumping out of the current function into the function which called it.
Enter until Target to execute all code until a specified target function or line of code is reached.
until MyFunction
until Interface.cpp:407
Enter info sources to get a list of all the files that GDB knows about.
The following commands are used to set, clear and get information about breakpoints
Enter b Target to set a breakpoint at the specified target function or line number. b is the shorthand form of the break command.
b Meadebug.cpp:110
b CMeadebugAppUi::HandleCommandL
Note that breakpoints can be set from the GUI by clicking to the left of a line in the source file. This is not altogether reliable, as the GUI sometimes indicates that it is not possible to put breakpoints on perfectly valid lines. There is nothing to stop you putting them in from the CLI or GUI console.
Enter info breakpoints to get a list of the current breakpoints.
The list of breakpoints can also be accessed through the GUI's "Breakpoints" window — View | Breakpoints
in the GUI menu.
Enter delete Number to delete the specified breakpoint
delete 1
Note that breakpoints can be enabled, disabled or removed from the menu of Insight's "Breakpoints" window.
Enter clear Target to delete a breakpoint from the specified target function or line number.
clear Meadebug.cpp:110
clear CMeadebugAppUi::HandleCommandL
The following commands are used to display and set variable values:
Enter print VariableName to display the type and value of a variable.
print console
Variables can also be viewed through the GUI's "Watch Expressions" window. To get the value of Unicode descriptors see How to display Unicode descriptors.
Enter set var VariableName=Value to change the value of a specified variable.
set var console=0x1234
The backtrace command is used to perform a backtrace of the stack, showing the history of function calls:
Enter backtrace to print the history list. Enter backtrace Number to specify the number of function calls to display.
backtrace
backtrace 2
Enter list to display the section of code around the current cursor position.
list
Enter list FileName:LineNumber to display the code around the specified line in the specified file. If a file is specified, then a line number must also be specified.
list File.cpp:120
Note that this provides a limited method of displaying code being debugged. It is usually easier to the GUI for this purpose.
The following commands are used to disassemble a chunk of code, step through, and get the value of the program counter.
Enter disassemble
Function to specify a function to be disassembled. The example below disassembles code starting at E32Main
, pausing after each full screen, until q is pressed.
disassemble E32Main
Enter disassemble AddressRange to specify an address range to be disassembled.
(gdb) disassemble 0x20000000 0x2000001c
Dump of assembler code from 0x20000000 to 0x2000001c:
0x20000000 <lab>: e92d4070 stmdb sp!, {r4, r5, r6, lr}
0x20000004 <lab+4>: e3a04001 mov r4, #1
0x20000008 <lab+8>: e1a03104 mov r3, r4, lsl #2
0x2000000c <lab+12>: e1a01003 mov r1, r3
0x20000010 <lab+16>: e59f2074 ldr r2, 0x2000008c <lab+140>
0x20000014 <lab+20>: e7923003 ldr r3, [r2, r3]
0x20000018 <lab+24>: e3530000 cmp r3, #0
End of assembler dump.
Enter nexti or stepi to step through the assembler code. After each step, GDB shows the current line of source code executing.
Enter info reg pc to inspect the value of the program counter.
(gdb) info reg pc
pc 0x20000238 536871480
To close the debug session:
On the host: type "q" or "quit" on the GDB command prompt.
This shuts down GDB and closes the debuggee. Note that the GDB stub is still running, although it is moved into the background when GDB is closed.
(gdb) q
On the GDB stub: Press "q" twice.
It may be necessary to bring the GDB stub to the foreground in order to close it. Note that the method used to bring the stub forward may need to be different on different devices. See the Symbian Developer Network for device-specific information.