After successful compilation with the appropriate target you can launch
the simulation and automatically attach a GDB instance to it. To launch an interactive
GDB session run the command with the switch --gdb
as
follows.
x86simulator --gdb
By default, when running the x86 simulator with the --gdb
command line switch it breaks immediately before entering main()
in graph.cpp.
This pauses execution before any AI Engine kernels
have started because the graph has not been run. To exit GDB type quit
or help
for more
commands.
Setting a breakpoint can be done in multiple ways. One method uses the following syntax:
break <kernel_function_name>
By typing continue
(shorthand c
) the debugger runs until the breakpoint in <kernel function name>
is reached. When the
breakpoint is reached it is possible to examine local stack variables and function
arguments. The following table shows some commonly used GDB instructions to allow
examination of these variables.
Command | Description |
---|---|
info stack
|
Reports the function call stack at the current breakpoint. |
info
locals
|
Shows the current status of local variables within the scope of the function call shown in the call stack. |
print
<local_variable_name>
|
Prints the current value of a single variable. |
finish
|
Exits the current function call but keeps the simulation paused. |
continue
|
Causes the debugger to run to completion. |
GDB is a very powerful debugger with many features. Complete documentation of GDB is beyond the scope of this document. For GDB documentation, see https://sourceware.org/gdb/current/onlinedocs/gdb.pdf and https://sourceware.org/gdb/current/onlinedocs/refcard.pdf.