[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
GDB/MI is a line based machine oriented text interface to GDB and is activated by specifying using the `--interpreter' command line option (see section 2.1.2 Choosing Modes). It is specifically intended to support the development of systems which use the debugger as just one small component of a larger system.
This chapter is a specification of the GDB/MI interface. It is written in the form of a reference manual.
Note that GDB/MI is still under construction, so some of the features described below are incomplete and subject to change (see section GDB/MI Development and Front Ends).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter uses the following notation:
|
separates two alternatives.
[ something ]
indicates that something is optional:
it may or may not be given.
( group )*
means that group inside the parentheses
may repeat zero or more times.
( group )+
means that group inside the parentheses
may repeat one or more times.
"string"
means a literal string.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Interaction of a GDB/MI frontend with GDB involves three parts--commands sent to GDB, responses to those commands and notifications. Each command results in exactly one response, indicating either successful completion of the command, or an error. For the commands that do not resume the target, the response contains the requested information. For the commands that resume the target, the response only indicates whether the target was successfully resumed. Notifications is the mechanism for reporting changes in the state of the target, or in GDB state, that cannot conveniently be associated with a command and reported as part of that command response.
The important examples of notifications are:
There's no guarantee that whenever an MI command reports an error, GDB or the target are in any specific state, and especially, the state is not reverted to the state before the MI command was processed. Therefore, whenever an MI command results in an error, we recommend that the frontend refreshes all the information shown in the user interface.
27.1.1 Context management 27.1.2 Asynchronous command execution and non-stop mode 27.1.3 Thread groups
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In most cases when GDB accesses the target, this access is done in context of a specific thread and frame (see section 8.1 Stack Frames). Often, even when accessing global data, the target requires that a thread be specified. The CLI interface maintains the selected thread and frame, and supplies them to target on each command. This is convenient, because a command line user would not want to specify that information explicitly on each command, and because user interacts with GDB via a single terminal, so no confusion is possible as to what thread and frame are the current ones.
In the case of MI, the concept of selected thread and frame is less useful. First, a frontend can easily remember this information itself. Second, a graphical frontend can have more than one window, each one used for debugging a different thread, and the frontend might want to access additional threads for internal purposes. This increases the risk that by relying on implicitly selected thread, the frontend may be operating on a wrong one. Therefore, each MI command should explicitly specify which thread and frame to operate on. To make it possible, each MI command accepts the `--thread' and `--frame' options, the value to each is GDB identifier for thread and frame to operate on.
Usually, each top-level window in a frontend allows the user to select a thread and a frame, and remembers the user selection for further operations. However, in some cases GDB may suggest that the current thread be changed. For example, when stopping on a breakpoint it is reasonable to switch to the thread where breakpoint is hit. For another example, if the user issues the CLI `thread' command via the frontend, it is desirable to change the frontend's selected thread to the one specified by user. GDB communicates the suggestion to change current thread using the `=thread-selected' notification. No such notification is available for the selected frame at the moment.
Note that historically, MI shares the selected thread with CLI, so
frontends used the -thread-select
to execute commands in the
right context. However, getting this to work right is cumbersome. The
simplest way is for frontend to emit -thread-select
command
before every command. This doubles the number of commands that need
to be sent. The alternative approach is to suppress -thread-select
if the selected thread in GDB is supposed to be identical to the
thread the frontend wants to operate on. However, getting this
optimization right can be tricky. In particular, if the frontend
sends several commands to GDB, and one of the commands changes the
selected thread, then the behaviour of subsequent commands will
change. So, a frontend should either wait for response from such
problematic commands, or explicitly add -thread-select
for
all subsequent commands. No frontend is known to do this exactly
right, so it is suggested to just always pass the `--thread' and
`--frame' options.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
On some targets, GDB is capable of processing MI commands
even while the target is running. This is called asynchronous
command execution (see section 5.5.3 Background Execution). The frontend may
specify a preferrence for asynchronous execution using the
-gdb-set target-async 1
command, which should be emitted before
either running the executable or attaching to the target. After the
frontend has started the executable or attached to the target, it can
find if asynchronous execution is enabled using the
-list-target-features
command.
Even if GDB can accept a command while target is running, many commands that access the target do not work when the target is running. Therefore, asynchronous command execution is most useful when combined with non-stop mode (see section 5.5.2 Non-Stop Mode). Then, it is possible to examine the state of one thread, while other threads are running.
When a given thread is running, MI commands that try to access the
target in the context of that thread may not work, or may work only on
some targets. In particular, commands that try to operate on thread's
stack will not work, on any target. Commands that read memory, or
modify breakpoints, may work or not work, depending on the target. Note
that even commands that operate on global state, such as print
,
set
, and breakpoint commands, still access the target in the
context of a specific thread, so frontend should try to find a
stopped thread and perform the operation on that thread (using the
`--thread' option).
Which commands will work in the context of a running thread is
highly target dependent. However, the two commands
-exec-interrupt
, to stop a thread, and -thread-info
,
to find the state of a thread, will always work.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The key observation is that regardless of the structure of the target, MI can have a global list of threads, because most commands that accept the `--thread' option do not need to know what process that thread belongs to. Therefore, it is not necessary to introduce neither additional `--process' option, nor an notion of the current process in the MI interface. The only strictly new feature that is required is the ability to find how the threads are grouped into processes.
To allow the user to discover such grouping, and to support arbitrary
hierarchy of machines/cores/processes, MI introduces the concept of a
thread group. Thread group is a collection of threads and other
thread groups. A thread group always has a string identifier, a type,
and may have additional attributes specific to the type. A new
command, -list-thread-groups
, returns the list of top-level
thread groups, which correspond to processes that GDB is
debugging at the moment. By passing an identifier of a thread group
to the -list-thread-groups
command, it is possible to obtain
the members of specific thread group.
To allow the user to easily discover processes, and other objects, he
wishes to debug, a concept of available thread group is
introduced. Available thread group is an thread group that
GDB is not debugging, but that can be attached to, using the
-target-attach
command. The list of available top-level thread
groups can be obtained using `-list-thread-groups --available'.
In general, the content of a thread group may be only retrieved only
after attaching to that thread group.
Thread groups are related to inferiors (see section 4.9 Debugging Multiple Inferiors and Programs). Each inferior corresponds to a thread group of a special type `process', and some additional operations are permitted on such thread groups.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
27.2.1 GDB/MI Input Syntax 27.2.2 GDB/MI Output Syntax
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
command ==>
cli-command | mi-command
cli-command ==>
[ token ] cli-command nl
, where
cli-command is any existing GDB CLI command.
mi-command ==>
[ token ] "-" operation ( " " option )*
[
" --" ]
( " " parameter )* nl
token ==>
option ==>
"-" parameter [ " " parameter ]
parameter ==>
non-blank-sequence | c-string
operation ==>
non-blank-sequence ==>
c-string ==>
""" seven-bit-iso-c-string-content """
nl ==>
CR | CR-LF
Notes:
token
, when present, is passed back when the command
finishes.
Pragmatics:
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The output from GDB/MI consists of zero or more out-of-band records followed, optionally, by a single result record. This result record is for the most recent command. The sequence of output records is terminated by `(gdb)'.
If an input command was prefixed with a token
then the
corresponding output for that command will also be prefixed by that same
token.
output ==>
( out-of-band-record )* [ result-record ] "(gdb)" nl
result-record ==>
[ token ] "^" result-class ( "," result )* nl
out-of-band-record ==>
async-record | stream-record
async-record ==>
exec-async-output | status-async-output | notify-async-output
exec-async-output ==>
[ token ] "*" async-output
status-async-output ==>
[ token ] "+" async-output
notify-async-output ==>
[ token ] "=" async-output
async-output ==>
async-class ( "," result )* nl
result-class ==>
"done" | "running" | "connected" | "error" | "exit"
async-class ==>
"stopped" | others
(where others will be added
depending on the needs--this is still in development).
result ==>
variable "=" value
variable ==>
string
value ==>
const | tuple | list
const ==>
c-string
tuple ==>
"{}" | "{" result ( "," result )* "}"
list ==>
"[]" | "[" value ( "," value )* "]" | "["
result ( "," result )* "]"
stream-record ==>
console-stream-output | target-stream-output | log-stream-output
console-stream-output ==>
"~" c-string
target-stream-output ==>
"@" c-string
log-stream-output ==>
"&" c-string
nl ==>
CR | CR-LF
token ==>
Notes:
token
is from the corresponding request. Note that
for all async output, while the token is allowed by the grammar and
may be output by future versions of GDB for select async
output messages, it is generally omitted. Frontends should treat
all async output as reporting general changes in the state of the
target and there should be no need to associate async output to any
prior command.
See section GDB/MI Stream Records, for more details about the various output records.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
For the developers convenience CLI commands can be entered directly,
but there may be some unexpected behaviour. For example, commands
that query the user will behave as if the user replied yes, breakpoint
command lists are not executed and some CLI commands, such as
if
, when
and define
, prompt for further input with
`>', which is not valid MI output.
This feature may be removed at some stage in the future and it is
recommended that front ends use the -interpreter-exec
command
(see -interpreter-exec).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The application which takes the MI output and presents the state of the program being debugged to the user is called a front end.
Although GDB/MI is still incomplete, it is currently being used by a variety of front ends to GDB. This makes it difficult to introduce new functionality without breaking existing usage. This section tries to minimize the problems by describing how the protocol might change.
Some changes in MI need not break a carefully designed front end, and for these the MI version will remain unchanged. The following is a list of changes that may occur within one level, so front ends should parse MI output in a way that can handle them:
in_scope
(see -var-update) may be extended.
If the changes are likely to break front ends, the MI version level will be increased by one. This will allow the front end to parse the output according to the MI version. Apart from mi0, new versions of GDB will not support old versions of MI and it will be the responsibility of the front end to work with the new one.
The best way to avoid unexpected changes in MI that might break your front end is to make your project known to GDB developers and follow development on gdb@sourceware.org and gdb-patches@sourceware.org.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
27.5.1 GDB/MI Result Records 27.5.2 GDB/MI Stream Records 27.5.3 GDB/MI Async Records 27.5.4 GDB/MI Frame Information 27.5.5 GDB/MI Thread Information 27.5.6 GDB/MI Ada Exception Information
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In addition to a number of out-of-band notifications, the response to a GDB/MI command includes one of the following result indications:
"^done" [ "," results ]
results
are the return
values.
"^running"
"^connected"
"^error" "," c-string
c-string
contains the corresponding
error message.
"^exit"
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
GDB internally maintains a number of output streams: the console, the target, and the log. The output intended for each of these streams is funneled through the GDB/MI interface using stream records.
Each stream record begins with a unique prefix character which
identifies its stream (see section GDB/MI Output Syntax). In addition to the prefix, each stream record contains a
string-output
. This is either raw text (with an implicit new
line) or a quoted C string (which does not contain an implicit newline).
"~" string-output
"@" string-output
"&" string-output
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Async records are used to notify the GDB/MI client of additional changes that have occurred. Those changes can either be a consequence of GDB/MI commands (e.g., a breakpoint modified) or a result of target activity (e.g., target stopped).
The following is the list of possible async records:
*running,thread-id="thread"
*stopped,reason="reason",thread-id="id",stopped-threads="stopped",core="core"
breakpoint-hit
watchpoint-trigger
read-watchpoint-trigger
access-watchpoint-trigger
function-finished
location-reached
watchpoint-scope
end-stepping-range
exited-signalled
exited
exited-normally
signal-received
solib-event
stop-on-solib-events
(see section 18.1 Commands to Specify Files)
is set.
fork
catch fork
(see section 5.1.3 Setting Catchpoints) has been used.
vfork
catch vfork
(see section 5.1.3 Setting Catchpoints) has been used.
syscall-entry
catch
syscall
(see section 5.1.3 Setting Catchpoints) has been used.
syscall-entry
catch syscall
(see section 5.1.3 Setting Catchpoints) has been used.
exec
exec
. This is reported when catch exec
(see section 5.1.3 Setting Catchpoints) has been used.
The id field identifies the thread that directly caused the stop
-- for example by hitting a breakpoint. Depending on whether all-stop
mode is in effect (see section 5.5.1 All-Stop Mode), GDB may either
stop all threads, or only the thread that directly triggered the stop.
If all threads are stopped, the stopped field will have the
value of "all"
. Otherwise, the value of the stopped
field will be a list of thread identifiers. Presently, this list will
always include a single thread, but frontend should be prepared to see
several threads in the list. The core field reports the
processor core on which the stop event has happened. This field may be absent
if such information is not available.
=thread-group-added,id="id"
=thread-group-removed,id="id"
=thread-group-started,id="id",pid="pid"
=thread-group-exited,id="id"[,exit-code="code"]
=thread-created,id="id",group-id="gid"
=thread-exited,id="id",group-id="gid"
=thread-selected,id="id"
-thread-select
command but is emitted whenever an MI command that is not documented
to change the selected thread actually changes it. In particular,
invoking, directly or indirectly (via user-defined command), the CLI
thread
command, will generate this notification.
We suggest that in response to this notification, front ends highlight the selected thread and cause subsequent commands to apply to that thread.
=library-loaded,...
=library-unloaded,...
=library-loaded
notification.
The thread-group field, if present, specifies the id of the
thread group in whose context the library was unloaded. If the field is
absent, it means the library was unloaded in the context of all present
thread groups.
=breakpoint-created,bkpt={...}
=breakpoint-modified,bkpt={...}
=breakpoint-deleted,bkpt={...}
The bkpt argument is of the same form as returned by the various breakpoint commands; See section 27.8 GDB/MI Breakpoint Commands.
Note that if a breakpoint is emitted in the result record of a command, then it will not also be emitted in an async record.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Response from many MI commands includes an information about stack frame. This information is a tuple that may have the following fields:
level
func
addr
file
line
from
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Whenever GDB has to report an information about a thread, it uses a tuple with the following fields:
id
target-id
details
state
core
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Whenever a *stopped
record is emitted because the program
stopped after hitting an exception catchpoint (see section 5.1.3 Setting Catchpoints),
GDB provides the name of the exception that was raised via
the exception-name
field.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This subsection presents several simple examples of interaction using the GDB/MI interface. In these examples, `->' means that the following line is passed to GDB/MI as input, while `<-' means the output received from GDB/MI.
Note the line breaks shown in the examples are here only for readability, they don't appear in the real output.
Setting a breakpoint generates synchronous output which contains detailed information of the breakpoint.
-> -break-insert main <- ^done,bkpt={number="1",type="breakpoint",disp="keep", enabled="y",addr="0x08048564",func="main",file="myprog.c", fullname="/home/nickrob/myprog.c",line="68",times="0"} <- (gdb) |
Program execution generates asynchronous records and MI gives the reason that execution stopped.
-> -exec-run <- ^running <- (gdb) <- *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0", frame={addr="0x08048564",func="main", args=[{name="argc",value="1"},{name="argv",value="0xbfc4d4d4"}], file="myprog.c",fullname="/home/nickrob/myprog.c",line="68"} <- (gdb) -> -exec-continue <- ^running <- (gdb) <- *stopped,reason="exited-normally" <- (gdb) |
Quitting GDB just prints the result class `^exit'.
-> (gdb) <- -gdb-exit <- ^exit |
Please note that `^exit' is printed immediately, but it might take some time for GDB to actually exit. During that time, GDB performs necessary cleanups, including killing programs being debugged or disconnecting from debug hardware, so the frontend should wait till GDB exits and should only forcibly kill GDB if it fails to exit in reasonable time.
Here's what happens if you pass a non-existent command:
-> -rubbish <- ^error,msg="Undefined MI command: rubbish" <- (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The remaining sections describe blocks of commands. Each block of commands is laid out in a fashion similar to this section.
The motivation for this collection of commands.
A brief introduction to this collection of commands as a whole.
For each command in the block, the following is described:
-command args... |
The corresponding GDB CLI command(s), if any.
Example(s) formatted for readability. Some of the described commands have not been implemented yet and these are labeled N.A. (not available).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section documents GDB/MI commands for manipulating breakpoints.
-break-after
Command
-break-after number count |
The breakpoint number number is not in effect until it has been hit count times. To see how this is reflected in the output of the `-break-list' command, see the description of the `-break-list' command below.
The corresponding GDB command is `ignore'.
(gdb) -break-insert main ^done,bkpt={number="1",type="breakpoint",disp="keep", enabled="y",addr="0x000100d0",func="main",file="hello.c", fullname="/home/foo/hello.c",line="5",times="0"} (gdb) -break-after 1 3 ~ ^done (gdb) -break-list ^done,BreakpointTable={nr_rows="1",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c", line="5",times="0",ignore="3"}]} (gdb) |
-break-commands
Command
-break-commands number [ command1 ... commandN ] |
Specifies the CLI commands that should be executed when breakpoint number is hit. The parameters command1 to commandN are the commands. If no command is specified, any previously-set commands are cleared. See section 5.1.7 Breakpoint Command Lists. Typical use of this functionality is tracing a program, that is, printing of values of some variables whenever breakpoint is hit and then continuing.
The corresponding GDB command is `commands'.
(gdb) -break-insert main ^done,bkpt={number="1",type="breakpoint",disp="keep", enabled="y",addr="0x000100d0",func="main",file="hello.c", fullname="/home/foo/hello.c",line="5",times="0"} (gdb) -break-commands 1 "print v" "continue" ^done (gdb) |
-break-condition
Command
-break-condition number expr |
Breakpoint number will stop the program only if the condition in expr is true. The condition becomes part of the `-break-list' output (see the description of the `-break-list' command below).
The corresponding GDB command is `condition'.
(gdb) -break-condition 1 1 ^done (gdb) -break-list ^done,BreakpointTable={nr_rows="1",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c", line="5",cond="1",times="0",ignore="3"}]} (gdb) |
-break-delete
Command
-break-delete ( breakpoint )+ |
Delete the breakpoint(s) whose number(s) are specified in the argument list. This is obviously reflected in the breakpoint list.
The corresponding GDB command is `delete'.
(gdb) -break-delete 1 ^done (gdb) -break-list ^done,BreakpointTable={nr_rows="0",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[]} (gdb) |
-break-disable
Command
-break-disable ( breakpoint )+ |
Disable the named breakpoint(s). The field `enabled' in the break list is now set to `n' for the named breakpoint(s).
The corresponding GDB command is `disable'.
(gdb) -break-disable 2 ^done (gdb) -break-list ^done,BreakpointTable={nr_rows="1",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="n", addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c", line="5",times="0"}]} (gdb) |
-break-enable
Command
-break-enable ( breakpoint )+ |
Enable (previously disabled) breakpoint(s).
The corresponding GDB command is `enable'.
(gdb) -break-enable 2 ^done (gdb) -break-list ^done,BreakpointTable={nr_rows="1",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="y", addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c", line="5",times="0"}]} (gdb) |
-break-info
Command
-break-info breakpoint |
Get information about a single breakpoint.
The corresponding GDB command is `info break breakpoint'.
-break-insert
Command
-break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -a ] [ -c condition ] [ -i ignore-count ] [ -p thread ] [ location ] |
If specified, location, can be one of:
The possible optional parameters of this command are:
The result is in the form:
^done,bkpt={number="number",type="type",disp="del"|"keep", enabled="y"|"n",addr="hex",func="funcname",file="filename", fullname="full_filename",line="lineno",[thread="threadno,] times="times"} |
where number is the GDB number for this breakpoint, funcname is the name of the function where the breakpoint was inserted, filename is the name of the source file which contains this function, lineno is the source line number within that file and times the number of times that the breakpoint has been hit (always 0 for -break-insert but may be greater for -break-info or -break-list which use the same output).
Note: this format is open to change.
The corresponding GDB commands are `break', `tbreak', `hbreak', `thbreak', and `rbreak'.
(gdb) -break-insert main ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c", fullname="/home/foo/recursive2.c,line="4",times="0"} (gdb) -break-insert -t foo ^done,bkpt={number="2",addr="0x00010774",file="recursive2.c", fullname="/home/foo/recursive2.c,line="11",times="0"} (gdb) -break-list ^done,BreakpointTable={nr_rows="2",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x0001072c", func="main",file="recursive2.c", fullname="/home/foo/recursive2.c,"line="4",times="0"}, bkpt={number="2",type="breakpoint",disp="del",enabled="y", addr="0x00010774",func="foo",file="recursive2.c", fullname="/home/foo/recursive2.c",line="11",times="0"}]} (gdb) -break-insert -r foo.* ~int foo(int, int); ^done,bkpt={number="3",addr="0x00010774",file="recursive2.c, "fullname="/home/foo/recursive2.c",line="11",times="0"} (gdb) |
-break-list
Command
-break-list |
Displays the list of inserted breakpoints, showing the following fields:
If there are no breakpoints or watchpoints, the BreakpointTable
body
field is an empty list.
The corresponding GDB command is `info break'.
(gdb) -break-list ^done,BreakpointTable={nr_rows="2",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x000100d0",func="main",file="hello.c",line="5",times="0"}, bkpt={number="2",type="breakpoint",disp="keep",enabled="y", addr="0x00010114",func="foo",file="hello.c",fullname="/home/foo/hello.c", line="13",times="0"}]} (gdb) |
Here's an example of the result when there are no breakpoints:
(gdb) -break-list ^done,BreakpointTable={nr_rows="0",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[]} (gdb) |
-break-passcount
Command
-break-passcount tracepoint-number passcount |
Set the passcount for tracepoint tracepoint-number to passcount. If the breakpoint referred to by tracepoint-number is not a tracepoint, error is emitted. This corresponds to CLI command `passcount'.
-break-watch
Command
-break-watch [ -a | -r ] |
Create a watchpoint. With the `-a' option it will create an access watchpoint, i.e., a watchpoint that triggers either on a read from or on a write to the memory location. With the `-r' option, the watchpoint created is a read watchpoint, i.e., it will trigger only when the memory location is accessed for reading. Without either of the options, the watchpoint created is a regular watchpoint, i.e., it will trigger when the memory location is accessed for writing. See section Setting Watchpoints.
Note that `-break-list' will report a single list of watchpoints and breakpoints inserted.
The corresponding GDB commands are `watch', `awatch', and `rwatch'.
Setting a watchpoint on a variable in the main
function:
(gdb) -break-watch x ^done,wpt={number="2",exp="x"} (gdb) -exec-continue ^running (gdb) *stopped,reason="watchpoint-trigger",wpt={number="2",exp="x"}, value={old="-268439212",new="55"}, frame={func="main",args=[],file="recursive2.c", fullname="/home/foo/bar/recursive2.c",line="5"} (gdb) |
Setting a watchpoint on a variable local to a function. GDB will stop the program execution twice: first for the variable changing value, then for the watchpoint going out of scope.
(gdb) -break-watch C ^done,wpt={number="5",exp="C"} (gdb) -exec-continue ^running (gdb) *stopped,reason="watchpoint-trigger", wpt={number="5",exp="C"},value={old="-276895068",new="3"}, frame={func="callee4",args=[], file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"} (gdb) -exec-continue ^running (gdb) *stopped,reason="watchpoint-scope",wpnum="5", frame={func="callee3",args=[{name="strarg", value="0x11940 \"A string argument.\""}], file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"} (gdb) |
Listing breakpoints and watchpoints, at different points in the program execution. Note that once the watchpoint goes out of scope, it is deleted.
(gdb) -break-watch C ^done,wpt={number="2",exp="C"} (gdb) -break-list ^done,BreakpointTable={nr_rows="2",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x00010734",func="callee4", file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c"line="8",times="1"}, bkpt={number="2",type="watchpoint",disp="keep", enabled="y",addr="",what="C",times="0"}]} (gdb) -exec-continue ^running (gdb) *stopped,reason="watchpoint-trigger",wpt={number="2",exp="C"}, value={old="-276895068",new="3"}, frame={func="callee4",args=[], file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"} (gdb) -break-list ^done,BreakpointTable={nr_rows="2",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x00010734",func="callee4", file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"}, bkpt={number="2",type="watchpoint",disp="keep", enabled="y",addr="",what="C",times="-5"}]} (gdb) -exec-continue ^running ^done,reason="watchpoint-scope",wpnum="2", frame={func="callee3",args=[{name="strarg", value="0x11940 \"A string argument.\""}], file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"} (gdb) -break-list ^done,BreakpointTable={nr_rows="1",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x00010734",func="callee4", file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8", times="1"}]} (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-exec-arguments
Command
-exec-arguments args |
Set the inferior program arguments, to be used in the next `-exec-run'.
The corresponding GDB command is `set args'.
(gdb) -exec-arguments -v word ^done (gdb) |
-environment-cd
Command
-environment-cd pathdir |
Set GDB's working directory.
The corresponding GDB command is `cd'.
(gdb) -environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb ^done (gdb) |
-environment-directory
Command
-environment-directory [ -r ] [ pathdir ]+ |
Add directories pathdir to beginning of search path for source files. If the `-r' option is used, the search path is reset to the default search path. If directories pathdir are supplied in addition to the `-r' option, the search path is first reset and then addition occurs as normal. Multiple directories may be specified, separated by blanks. Specifying multiple directories in a single command results in the directories added to the beginning of the search path in the same order they were presented in the command. If blanks are needed as part of a directory name, double-quotes should be used around the name. In the command output, the path will show up separated by the system directory-separator character. The directory-separator character must not be used in any directory name. If no directories are specified, the current search path is displayed.
The corresponding GDB command is `dir'.
(gdb) -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd" (gdb) -environment-directory "" ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd" (gdb) -environment-directory -r /home/jjohnstn/src/gdb /usr/src ^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd" (gdb) -environment-directory -r ^done,source-path="$cdir:$cwd" (gdb) |
-environment-path
Command
-environment-path [ -r ] [ pathdir ]+ |
Add directories pathdir to beginning of search path for object files. If the `-r' option is used, the search path is reset to the original search path that existed at gdb start-up. If directories pathdir are supplied in addition to the `-r' option, the search path is first reset and then addition occurs as normal. Multiple directories may be specified, separated by blanks. Specifying multiple directories in a single command results in the directories added to the beginning of the search path in the same order they were presented in the command. If blanks are needed as part of a directory name, double-quotes should be used around the name. In the command output, the path will show up separated by the system directory-separator character. The directory-separator character must not be used in any directory name. If no directories are specified, the current path is displayed.
The corresponding GDB command is `path'.
(gdb) -environment-path ^done,path="/usr/bin" (gdb) -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin ^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin" (gdb) -environment-path -r /usr/local/bin ^done,path="/usr/local/bin:/usr/bin" (gdb) |
-environment-pwd
Command
-environment-pwd |
Show the current working directory.
The corresponding GDB command is `pwd'.
(gdb) -environment-pwd ^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb" (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-thread-info
Command
-thread-info [ thread-id ] |
Reports information about either a specific thread, if the thread-id parameter is present, or about all threads. When printing information about all threads, also reports the current thread.
The `info thread' command prints the same information about all threads.
The result is a list of threads. The following attributes are defined for a given thread:
thread name
command, then this name is given. Otherwise, if
GDB can extract the thread name from the target, then that
name is given. If GDB cannot find the thread name, then this
field is omitted.
stopped
running
-thread-info ^done,threads=[ {id="2",target-id="Thread 0xb7e14b90 (LWP 21257)", frame={level="0",addr="0xffffe410",func="__kernel_vsyscall", args=[]},state="running"}, {id="1",target-id="Thread 0xb7e156b0 (LWP 21254)", frame={level="0",addr="0x0804891f",func="foo", args=[{name="i",value="10"}], file="/tmp/a.c",fullname="/tmp/a.c",line="158"}, state="running"}], current-thread-id="1" (gdb) |
-thread-list-ids
Command
-thread-list-ids |
Produces a list of the currently known GDB thread ids. At the end of the list it also prints the total number of such threads.
This command is retained for historical reasons, the
-thread-info
command should be used instead.
Part of `info threads' supplies the same information.
(gdb) -thread-list-ids ^done,thread-ids={thread-id="3",thread-id="2",thread-id="1"}, current-thread-id="1",number-of-threads="3" (gdb) |
-thread-select
Command
-thread-select threadnum |
Make threadnum the current thread. It prints the number of the new current thread, and the topmost frame for that thread.
This command is deprecated in favor of explicitly using the `--thread' option to each command.
The corresponding GDB command is `thread'.
(gdb) -exec-next ^running (gdb) *stopped,reason="end-stepping-range",thread-id="2",line="187", file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c" (gdb) -thread-list-ids ^done, thread-ids={thread-id="3",thread-id="2",thread-id="1"}, number-of-threads="3" (gdb) -thread-select 3 ^done,new-thread-id="3", frame={level="0",func="vprintf", args=[{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""}, {name="arg",value="0x2"}],file="vprintf.c",line="31"} (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-ada-task-info
Command
-ada-task-info [ task-id ] |
Reports information about either a specific Ada task, if the task-id parameter is present, or about all Ada tasks.
The `info tasks' command prints the same information about all Ada tasks (see section 15.4.8.6 Extensions for Ada Tasks).
The result is a table of Ada tasks. The following columns are defined for each Ada task:
This field should always exist, as Ada tasks are always implemented on top of a thread. But if GDB cannot find this corresponding thread for any reason, the field is omitted.
-ada-task-info ^done,tasks={nr_rows="3",nr_cols="8", hdr=[{width="1",alignment="-1",col_name="current",colhdr=""}, {width="3",alignment="1",col_name="id",colhdr="ID"}, {width="9",alignment="1",col_name="task-id",colhdr="TID"}, {width="4",alignment="1",col_name="thread-id",colhdr=""}, {width="4",alignment="1",col_name="parent-id",colhdr="P-ID"}, {width="3",alignment="1",col_name="priority",colhdr="Pri"}, {width="22",alignment="-1",col_name="state",colhdr="State"}, {width="1",alignment="2",col_name="name",colhdr="Name"}], body=[{current="*",id="1",task-id=" 644010",thread-id="1",priority="48", state="Child Termination Wait",name="main_task"}]} (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These are the asynchronous commands which generate the out-of-band record `*stopped'. Currently GDB only really executes asynchronously with remote targets and this interaction is mimicked in other cases.
-exec-continue
Command
-exec-continue [--reverse] [--all|--thread-group N] |
Resumes the execution of the inferior program, which will continue to execute until it reaches a debugger stop event. If the `--reverse' option is specified, execution resumes in reverse until it reaches a stop event. Stop events may include
The corresponding GDB corresponding is `continue'.
-exec-continue ^running (gdb) @Hello world *stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame={ func="foo",args=[],file="hello.c",fullname="/home/foo/bar/hello.c", line="13"} (gdb) |
-exec-finish
Command
-exec-finish [--reverse] |
Resumes the execution of the inferior program until the current function is exited. Displays the results returned by the function. If the `--reverse' option is specified, resumes the reverse execution of the inferior program until the point where current function was called.
The corresponding GDB command is `finish'.
Function returning void
.
-exec-finish ^running (gdb) @hello from foo *stopped,reason="function-finished",frame={func="main",args=[], file="hello.c",fullname="/home/foo/bar/hello.c",line="7"} (gdb) |
Function returning other than void
. The name of the internal
GDB variable storing the result is printed, together with the
value itself.
-exec-finish ^running (gdb) *stopped,reason="function-finished",frame={addr="0x000107b0",func="foo", args=[{name="a",value="1"],{name="b",value="9"}}, file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, gdb-result-var="$1",return-value="0" (gdb) |
-exec-interrupt
Command
-exec-interrupt [--all|--thread-group N] |
Interrupts the background execution of the target. Note how the token associated with the stop message is the one for the execution command that has been interrupted. The token for the interrupt itself only appears in the `^done' output. If the user is trying to interrupt a non-running program, an error message will be printed.
Note that when asynchronous execution is enabled, this command is asynchronous just like other execution commands. That is, first the `^done' response will be printed, and the target stop will be reported after that using the `*stopped' notification.
In non-stop mode, only the context thread is interrupted by default. All threads (in all inferiors) will be interrupted if the `--all' option is specified. If the `--thread-group' option is specified, all threads in that group will be interrupted.
The corresponding GDB command is `interrupt'.
(gdb) 111-exec-continue 111^running (gdb) 222-exec-interrupt 222^done (gdb) 111*stopped,signal-name="SIGINT",signal-meaning="Interrupt", frame={addr="0x00010140",func="foo",args=[],file="try.c", fullname="/home/foo/bar/try.c",line="13"} (gdb) (gdb) -exec-interrupt ^error,msg="mi_cmd_exec_interrupt: Inferior not executing." (gdb) |
-exec-jump
Command
-exec-jump location |
Resumes execution of the inferior program at the location specified by parameter. See section 9.2 Specifying a Location, for a description of the different forms of location.
The corresponding GDB command is `jump'.
-exec-jump foo.c:10 *running,thread-id="all" ^running |
-exec-next
Command
-exec-next [--reverse] |
Resumes execution of the inferior program, stopping when the beginning of the next source line is reached.
If the `--reverse' option is specified, resumes reverse execution of the inferior program, stopping at the beginning of the previous source line. If you issue this command on the first line of a function, it will take you back to the caller of that function, to the source line where the function was called.
The corresponding GDB command is `next'.
-exec-next ^running (gdb) *stopped,reason="end-stepping-range",line="8",file="hello.c" (gdb) |
-exec-next-instruction
Command
-exec-next-instruction [--reverse] |
Executes one machine instruction. If the instruction is a function call, continues until the function returns. If the program stops at an instruction in the middle of a source line, the address will be printed as well.
If the `--reverse' option is specified, resumes reverse execution of the inferior program, stopping at the previous instruction. If the previously executed instruction was a return from another function, it will continue to execute in reverse until the call to that function (from the current stack frame) is reached.
The corresponding GDB command is `nexti'.
(gdb) -exec-next-instruction ^running (gdb) *stopped,reason="end-stepping-range", addr="0x000100d4",line="5",file="hello.c" (gdb) |
-exec-return
Command
-exec-return |
Makes current function return immediately. Doesn't execute the inferior. Displays the new current frame.
The corresponding GDB command is `return'.
(gdb) 200-break-insert callee4 200^done,bkpt={number="1",addr="0x00010734", file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"} (gdb) 000-exec-run 000^running (gdb) 000*stopped,reason="breakpoint-hit",disp="keep",bkptno="1", frame={func="callee4",args=[], file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"} (gdb) 205-break-delete 205^done (gdb) 111-exec-return 111^done,frame={level="0",func="callee3", args=[{name="strarg", value="0x11940 \"A string argument.\""}], file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"} (gdb) |
-exec-run
Command
-exec-run [--all | --thread-group N] |
Starts execution of the inferior from the beginning. The inferior executes until either a breakpoint is encountered or the program exits. In the latter case the output will include an exit code, if the program has exited exceptionally.
When no option is specified, the current inferior is started. If the `--thread-group' option is specified, it should refer to a thread group of type `process', and that thread group will be started. If the `--all' option is specified, then all inferiors will be started.
The corresponding GDB command is `run'.
(gdb) -break-insert main ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",line="4"} (gdb) -exec-run ^running (gdb) *stopped,reason="breakpoint-hit",disp="keep",bkptno="1", frame={func="main",args=[],file="recursive2.c", fullname="/home/foo/bar/recursive2.c",line="4"} (gdb) |
Program exited normally:
(gdb) -exec-run ^running (gdb) x = 55 *stopped,reason="exited-normally" (gdb) |
Program exited exceptionally:
(gdb) -exec-run ^running (gdb) x = 55 *stopped,reason="exited",exit-code="01" (gdb) |
Another way the program can terminate is if it receives a signal such as
SIGINT
. In this case, GDB/MI displays this:
(gdb) *stopped,reason="exited-signalled",signal-name="SIGINT", signal-meaning="Interrupt" |
-exec-step
Command
-exec-step [--reverse] |
Resumes execution of the inferior program, stopping when the beginning of the next source line is reached, if the next source line is not a function call. If it is, stop at the first instruction of the called function. If the `--reverse' option is specified, resumes reverse execution of the inferior program, stopping at the beginning of the previously executed source line.
The corresponding GDB command is `step'.
Stepping into a function:
-exec-step ^running (gdb) *stopped,reason="end-stepping-range", frame={func="foo",args=[{name="a",value="10"}, {name="b",value="0"}],file="recursive2.c", fullname="/home/foo/bar/recursive2.c",line="11"} (gdb) |
Regular stepping:
-exec-step ^running (gdb) *stopped,reason="end-stepping-range",line="14",file="recursive2.c" (gdb) |
-exec-step-instruction
Command
-exec-step-instruction [--reverse] |
Resumes the inferior which executes one machine instruction. If the `--reverse' option is specified, resumes reverse execution of the inferior program, stopping at the previously executed instruction. The output, once GDB has stopped, will vary depending on whether we have stopped in the middle of a source line or not. In the former case, the address at which the program stopped will be printed as well.
The corresponding GDB command is `stepi'.
(gdb) -exec-step-instruction ^running (gdb) *stopped,reason="end-stepping-range", frame={func="foo",args=[],file="try.c", fullname="/home/foo/bar/try.c",line="10"} (gdb) -exec-step-instruction ^running (gdb) *stopped,reason="end-stepping-range", frame={addr="0x000100f4",func="foo",args=[],file="try.c", fullname="/home/foo/bar/try.c",line="10"} (gdb) |
-exec-until
Command
-exec-until [ location ] |
Executes the inferior until the location specified in the argument is reached. If there is no argument, the inferior executes until a source line greater than the current one is reached. The reason for stopping in this case will be `location-reached'.
The corresponding GDB command is `until'.
(gdb) -exec-until recursive2.c:6 ^running (gdb) x = 55 *stopped,reason="location-reached",frame={func="main",args=[], file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="6"} (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-stack-info-frame
Command
-stack-info-frame |
Get info on the selected frame.
The corresponding GDB command is `info frame' or `frame' (without arguments).
(gdb) -stack-info-frame ^done,frame={level="1",addr="0x0001076c",func="callee3", file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"} (gdb) |
-stack-info-depth
Command
-stack-info-depth [ max-depth ] |
Return the depth of the stack. If the integer argument max-depth is specified, do not count beyond max-depth frames.
There's no equivalent GDB command.
For a stack with frame levels 0 through 11:
(gdb) -stack-info-depth ^done,depth="12" (gdb) -stack-info-depth 4 ^done,depth="4" (gdb) -stack-info-depth 12 ^done,depth="12" (gdb) -stack-info-depth 11 ^done,depth="11" (gdb) -stack-info-depth 13 ^done,depth="12" (gdb) |
-stack-list-arguments
Command
-stack-list-arguments print-values [ low-frame high-frame ] |
Display a list of the arguments for the frames between low-frame and high-frame (inclusive). If low-frame and high-frame are not provided, list the arguments for the whole call stack. If the two arguments are equal, show the single frame at the corresponding level. It is an error if low-frame is larger than the actual number of frames. On the other hand, high-frame may be larger than the actual number of frames, in which case only existing frames will be returned.
If print-values is 0 or --no-values
, print only the names of
the variables; if it is 1 or --all-values
, print also their
values; and if it is 2 or --simple-values
, print the name,
type and value for simple data types, and the name and type for arrays,
structures and unions.
Use of this command to obtain arguments in a single frame is deprecated in favor of the `-stack-list-variables' command.
GDB does not have an equivalent command. gdbtk
has a
`gdb_get_args' command which partially overlaps with the
functionality of `-stack-list-arguments'.
(gdb) -stack-list-frames ^done, stack=[ frame={level="0",addr="0x00010734",func="callee4", file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"}, frame={level="1",addr="0x0001076c",func="callee3", file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"}, frame={level="2",addr="0x0001078c",func="callee2", file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="22"}, frame={level="3",addr="0x000107b4",func="callee1", file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="27"}, frame={level="4",addr="0x000107e0",func="main", file="../../../devo/gdb/testsuite/gdb.mi/basics.c", fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="32"}] (gdb) -stack-list-arguments 0 ^done, stack-args=[ frame={level="0",args=[]}, frame={level="1",args=[name="strarg"]}, frame={level="2",args=[name="intarg",name="strarg"]}, frame={level="3",args=[name="intarg",name="strarg",name="fltarg"]}, frame={level="4",args=[]}] (gdb) -stack-list-arguments 1 ^done, stack-args=[ frame={level="0",args=[]}, frame={level="1", args=[{name="strarg",value="0x11940 \"A string argument.\""}]}, frame={level="2",args=[ {name="intarg",value="2"}, {name="strarg",value="0x11940 \"A string argument.\""}]}, {frame={level="3",args=[ {name="intarg",value="2"}, {name="strarg",value="0x11940 \"A string argument.\""}, {name="fltarg",value="3.5"}]}, frame={level="4",args=[]}] (gdb) -stack-list-arguments 0 2 2 ^done,stack-args=[frame={level="2",args=[name="intarg",name="strarg"]}] (gdb) -stack-list-arguments 1 2 2 ^done,stack-args=[frame={level="2", args=[{name="intarg",value="2"}, {name="strarg",value="0x11940 \"A string argument.\""}]}] (gdb) |
-stack-list-frames
Command
-stack-list-frames [ low-frame high-frame ] |
List the frames currently on the stack. For each frame it displays the following info:
$pc
value for that frame.
$pc
.
If invoked without arguments, this command prints a backtrace for the whole stack. If given two integer arguments, it shows the frames whose levels are between the two arguments (inclusive). If the two arguments are equal, it shows the single frame at the corresponding level. It is an error if low-frame is larger than the actual number of frames. On the other hand, high-frame may be larger than the actual number of frames, in which case only existing frames will be returned.
The corresponding GDB commands are `backtrace' and `where'.
Full stack backtrace:
(gdb) -stack-list-frames ^done,stack= [frame={level="0",addr="0x0001076c",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="11"}, frame={level="1",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="2",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="3",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="4",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="5",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="6",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="7",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="8",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="9",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="10",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="11",addr="0x00010738",func="main", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="4"}] (gdb) |
Show frames between low_frame and high_frame:
(gdb) -stack-list-frames 3 5 ^done,stack= [frame={level="3",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="4",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, frame={level="5",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}] (gdb) |
Show a single frame:
(gdb) -stack-list-frames 3 3 ^done,stack= [frame={level="3",addr="0x000107a4",func="foo", file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}] (gdb) |
-stack-list-locals
Command
-stack-list-locals print-values |
Display the local variable names for the selected frame. If
print-values is 0 or --no-values
, print only the names of
the variables; if it is 1 or --all-values
, print also their
values; and if it is 2 or --simple-values
, print the name,
type and value for simple data types, and the name and type for arrays,
structures and unions. In this last case, a frontend can immediately
display the value of simple data types and create variable objects for
other data types when the user wishes to explore their values in
more detail.
This command is deprecated in favor of the `-stack-list-variables' command.
`info locals' in GDB, `gdb_get_locals' in gdbtk
.
(gdb) -stack-list-locals 0 ^done,locals=[name="A",name="B",name="C"] (gdb) -stack-list-locals --all-values ^done,locals=[{name="A",value="1"},{name="B",value="2"}, {name="C",value="{1, 2, 3}"}] -stack-list-locals --simple-values ^done,locals=[{name="A",type="int",value="1"}, {name="B",type="int",value="2"},{name="C",type="int [3]"}] (gdb) |
-stack-list-variables
Command
-stack-list-variables print-values |
Display the names of local variables and function arguments for the selected frame. If
print-values is 0 or --no-values
, print only the names of
the variables; if it is 1 or --all-values
, print also their
values; and if it is 2 or --simple-values
, print the name,
type and value for simple data types, and the name and type for arrays,
structures and unions.
(gdb) -stack-list-variables --thread 1 --frame 0 --all-values ^done,variables=[{name="x",value="11"},{name="s",value="{a = 1, b = 2}"}] (gdb) |
-stack-select-frame
Command
-stack-select-frame framenum |
Change the selected frame. Select a different frame framenum on the stack.
This command in deprecated in favor of passing the `--frame' option to every command.
The corresponding GDB commands are `frame', `up', `down', `select-frame', `up-silent', and `down-silent'.
(gdb) -stack-select-frame 2 ^done (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Variable objects are "object-oriented" MI interface for examining and changing values of expressions. Unlike some other MI interfaces that work with expressions, variable objects are specifically designed for simple and efficient presentation in the frontend. A variable object is identified by string name. When a variable object is created, the frontend specifies the expression for that variable object. The expression can be a simple variable, or it can be an arbitrary complex expression, and can even involve CPU registers. After creating a variable object, the frontend can invoke other variable object operations--for example to obtain or change the value of a variable object, or to change display format.
Variable objects have hierarchical tree structure. Any variable object that corresponds to a composite type, such as structure in C, has a number of child variable objects, for example corresponding to each element of a structure. A child variable object can itself have children, recursively. Recursion ends when we reach leaf variable objects, which always have built-in types. Child variable objects are created only by explicit request, so if a frontend is not interested in the children of a particular variable object, no child will be created.
For a leaf variable object it is possible to obtain its value as a string, or set the value from a string. String value can be also obtained for a non-leaf variable object, but it's generally a string that only indicates the type of the object, and does not list its contents. Assignment to a non-leaf variable object is not allowed. A frontend does not need to read the values of all variable objects each time the program stops. Instead, MI provides an update command that lists all variable objects whose values has changed since the last update operation. This considerably reduces the amount of data that must be transferred to the frontend. As noted above, children variable objects are created on demand, and only leaf variable objects have a real value. As result, gdb will read target memory only for leaf variables that frontend has created.
The automatic update is not always desirable. For example, a frontend might want to keep a value of some expression for future reference, and never update it. For another example, fetching memory is relatively slow for embedded targets, so a frontend might want to disable automatic update for the variables that are either not visible on the screen, or "closed". This is possible using so called "frozen variable objects". Such variable objects are never implicitly updated.
Variable objects can be either fixed or floating. For the fixed variable object, the expression is parsed when the variable object is created, including associating identifiers to specific variables. The meaning of expression never changes. For a floating variable object the values of variables whose names appear in the expressions are re-evaluated every time in the context of the current frame. Consider this example:
void do_work(...) { struct work_state state; if (...) do_work(...); } |
If a fixed variable object for the state
variable is created in
this function, and we enter the recursive call, the variable
object will report the value of state
in the top-level
do_work
invocation. On the other hand, a floating variable
object will report the value of state
in the current frame.
If an expression specified when creating a fixed variable object refers to a local variable, the variable object becomes bound to the thread and frame in which the variable object is created. When such variable object is updated, GDB makes sure that the thread/frame combination the variable object is bound to still exists, and re-evaluates the variable object in context of that thread/frame.
The following is the complete set of GDB/MI operations defined to access this functionality:
Operation | Description |
-enable-pretty-printing |
enable Python-based pretty-printing |
-var-create |
create a variable object |
-var-delete |
delete the variable object and/or its children |
-var-set-format |
set the display format of this variable |
-var-show-format |
show the display format of this variable |
-var-info-num-children |
tells how many children this object has |
-var-list-children |
return a list of the object's children |
-var-info-type |
show the type of this variable object |
-var-info-expression |
print parent-relative expression that this variable object represents |
-var-info-path-expression |
print full expression that this variable object represents |
-var-show-attributes |
is this variable editable? does it exist here? |
-var-evaluate-expression |
get the value of this variable |
-var-assign |
set the value of this variable |
-var-update |
update the variable and its children |
-var-set-frozen |
set frozeness attribute |
-var-set-update-range |
set range of children to display on update |
In the next subsection we describe each operation in detail and suggest how it can be used.
-enable-pretty-printing
Command
-enable-pretty-printing |
GDB allows Python-based visualizers to affect the output of the MI variable object commands. However, because there was no way to implement this in a fully backward-compatible way, a front end must request that this functionality be enabled.
Once enabled, this feature cannot be disabled.
Note that if Python support has not been compiled into GDB, this command will still succeed (and do nothing).
This feature is currently (as of GDB 7.0) experimental, and may work differently in future versions of GDB.
-var-create
Command
-var-create {name | "-"} {frame-addr | "*" | "@"} expression |
This operation creates a variable object, which allows the monitoring of a variable, the result of an expression, a memory cell or a CPU register.
The name parameter is the string by which the object can be referenced. It must be unique. If `-' is specified, the varobj system will generate a string "varNNNNNN" automatically. It will be unique provided that one does not specify name of that format. The command fails if a duplicate name is found.
The frame under which the expression should be evaluated can be specified by frame-addr. A `*' indicates that the current frame should be used. A `@' indicates that a floating variable object must be created.
expression is any expression valid on the current language set (must not begin with a `*'), or one of the following:
A varobj's contents may be provided by a Python-based pretty-printer. In this
case the varobj is known as a dynamic varobj. Dynamic varobjs
have slightly different semantics in some cases. If the
-enable-pretty-printing
command is not sent, then GDB
will never create a dynamic varobj. This ensures backward
compatibility for existing clients.
This operation returns attributes of the newly-created varobj. These are:
struct
), or for a dynamic varobj, this value
will not be interesting.
display_hint
method. See section 23.2.2.5 Pretty Printing API.
Typical output will look like this:
name="name",numchild="N",type="type",thread-id="M", has_more="has_more" |
-var-delete
Command
-var-delete [ -c ] name |
Deletes a previously created variable object and all of its children. With the `-c' option, just deletes the children.
Returns an error if the object name is not found.
-var-set-format
Command
-var-set-format name format-spec |
Sets the output format for the value of the object name to be format-spec.
The syntax for the format-spec is as follows:
format-spec ==> {binary | decimal | hexadecimal | octal | natural} |
The natural format is the default format choosen automatically
based on the variable type (like decimal for an int
, hex
for pointers, etc.).
For a variable with children, the format is set only on the variable itself, and the children are not affected.
-var-show-format
Command
-var-show-format name |
Returns the format used to display the value of the object name.
format ==> format-spec |
-var-info-num-children
Command
-var-info-num-children name |
Returns the number of children of a variable object name:
numchild=n |
Note that this number is not completely reliable for a dynamic varobj. It will return the current number of children, but more children may be available.
-var-list-children
Command
-var-list-children [print-values] name [from to] |
Return a list of the children of the specified variable object and
create variable objects for them, if they do not already exist. With
a single argument or if print-values has a value of 0 or
--no-values
, print only the names of the variables; if
print-values is 1 or --all-values
, also print their
values; and if it is 2 or --simple-values
print the name and
value for simple data types and just the name for arrays, structures
and unions.
from and to, if specified, indicate the range of children to report. If from or to is less than zero, the range is reset and all children will be reported. Otherwise, children starting at from (zero-based) and up to and excluding to will be reported.
If a child range is requested, it will only affect the current call to
-var-list-children
, but not future calls to -var-update
.
For this, you must instead use -var-set-update-range
. The
intent of this approach is to enable a front end to implement any
update approach it likes; for example, scrolling a view may cause the
front end to request more children with -var-list-children
, and
then the front end could call -var-set-update-range
with a
different range to ensure that future updates are restricted to just
the visible items.
For each child the following results are returned:
For a dynamic varobj, this value cannot be used to form an expression. There is no way to do this at all with a dynamic varobj.
For C/C++ structures there are several pseudo children returned to designate access qualifiers. For these pseudo children exp is `public', `private', or `protected'. In this case the type and value are not present.
A dynamic varobj will not report the access qualifying pseudo-children, regardless of the language. This information is not available at all with a dynamic varobj.
The result may have its own attributes:
display_hint
method. See section 23.2.2.5 Pretty Printing API.
(gdb) -var-list-children n ^done,numchild=n,children=[child={name=name,exp=exp, numchild=n,type=type},(repeats N times)] (gdb) -var-list-children --all-values n ^done,numchild=n,children=[child={name=name,exp=exp, numchild=n,value=value,type=type},(repeats N times)] |
-var-info-type
Command
-var-info-type name |
Returns the type of the specified variable name. The type is returned as a string in the same format as it is output by the GDB CLI:
type=typename |
-var-info-expression
Command
-var-info-expression name |
Returns a string that is suitable for presenting this variable object in user interface. The string is generally not valid expression in the current language, and cannot be evaluated.
For example, if a
is an array, and variable object
A
was created for a
, then we'll get this output:
(gdb) -var-info-expression A.1 ^done,lang="C",exp="1" |
Here, the values of lang
can be {"C" | "C++" | "Java"}
.
Note that the output of the -var-list-children
command also
includes those expressions, so the -var-info-expression
command
is of limited use.
-var-info-path-expression
Command
-var-info-path-expression name |
Returns an expression that can be evaluated in the current
context and will yield the same value that a variable object has.
Compare this with the -var-info-expression
command, which
result can be used only for UI presentation. Typical use of
the -var-info-path-expression
command is creating a
watchpoint from a variable object.
This command is currently not valid for children of a dynamic varobj, and will give an error when invoked on one.
For example, suppose C
is a C++ class, derived from class
Base
, and that the Base
class has a member called
m_size
. Assume a variable c
is has the type of
C
and a variable object C
was created for variable
c
. Then, we'll get this output:
(gdb) -var-info-path-expression C.Base.public.m_size ^done,path_expr=((Base)c).m_size) |
-var-show-attributes
Command
-var-show-attributes name |
List attributes of the specified variable object name:
status=attr [ ( ,attr )* ] |
where attr is { { editable | noneditable } | TBD }
.
-var-evaluate-expression
Command
-var-evaluate-expression [-f format-spec] name |
Evaluates the expression that is represented by the specified variable
object and returns its value as a string. The format of the string
can be specified with the `-f' option. The possible values of
this option are the same as for -var-set-format
(see -var-set-format). If the `-f' option is not specified,
the current display format will be used. The current display format
can be changed using the -var-set-format
command.
value=value |
Note that one must invoke -var-list-children
for a variable
before the value of a child variable can be evaluated.
-var-assign
Command
-var-assign name expression |
Assigns the value of expression to the variable object specified
by name. The object must be `editable'. If the variable's
value is altered by the assign, the variable will show up in any
subsequent -var-update
list.
(gdb) -var-assign var1 3 ^done,value="3" (gdb) -var-update * ^done,changelist=[{name="var1",in_scope="true",type_changed="false"}] (gdb) |
-var-update
Command
-var-update [print-values] {name | "*"} |
Reevaluate the expressions corresponding to the variable object
name and all its direct and indirect children, and return the
list of variable objects whose values have changed; name must
be a root variable object. Here, "changed" means that the result of
-var-evaluate-expression
before and after the
-var-update
is different. If `*' is used as the variable
object names, all existing variable objects are updated, except
for frozen ones (see -var-set-frozen). The option
print-values determines whether both names and values, or just
names are printed. The possible values of this option are the same
as for -var-list-children
(see -var-list-children). It is
recommended to use the `--all-values' option, to reduce the
number of MI commands needed on each program stop.
With the `*' parameter, if a variable object is bound to a currently running thread, it will not be updated, without any diagnostic.
If -var-set-update-range
was previously used on a varobj, then
only the selected range of children will be reported.
-var-update
reports all the changed varobjs in a tuple named
`changelist'.
Each item in the change list is itself a tuple holding:
"true"
"false"
"invalid"
file
command. The front end should normally choose to delete these variable
objects.
In the future new values may be added to this list so the front should be prepared for this possibility. See section GDB/MI Development and Front Ends.
The `numchild' field in other varobj responses is generally not valid for a dynamic varobj -- it will show the number of children that GDB knows about, but because dynamic varobjs lazily instantiate their children, this will not reflect the number of children which may be available.
The `new_num_children' attribute only reports changes to the number of children known by GDB. This is the only way to detect whether an update has removed children (which necessarily can only happen at the end of the update range).
-var-set-update-range
), then they will
be listed in this attribute.
(gdb) -var-assign var1 3 ^done,value="3" (gdb) -var-update --all-values var1 ^done,changelist=[{name="var1",value="3",in_scope="true", type_changed="false"}] (gdb) |
-var-set-frozen
Command
-var-set-frozen name flag |
Set the frozenness flag on the variable object name. The
flag parameter should be either `1' to make the variable
frozen or `0' to make it unfrozen. If a variable object is
frozen, then neither itself, nor any of its children, are
implicitly updated by -var-update
of
a parent variable or by -var-update *
. Only
-var-update
of the variable itself will update its value and
values of its children. After a variable object is unfrozen, it is
implicitly updated by all subsequent -var-update
operations.
Unfreezing a variable does not update it, only subsequent
-var-update
does.
(gdb) -var-set-frozen V 1 ^done (gdb) |
-var-set-update-range
command
-var-set-update-range name from to |
Set the range of children to be returned by future invocations of
-var-update
.
from and to indicate the range of children to report. If from or to is less than zero, the range is reset and all children will be reported. Otherwise, children starting at from (zero-based) and up to and excluding to will be reported.
(gdb) -var-set-update-range V 1 2 ^done |
-var-set-visualizer
command
-var-set-visualizer name visualizer |
Set a visualizer for the variable object name.
visualizer is the visualizer to use. The special value `None' means to disable any visualizer in use.
If not `None', visualizer must be a Python expression. This expression must evaluate to a callable object which accepts a single argument. GDB will call this object with the value of the varobj name as an argument (this is done so that the same Python pretty-printing code can be used for both the CLI and MI). When called, this object must return an object which conforms to the pretty-printing interface (see section 23.2.2.5 Pretty Printing API).
The pre-defined function gdb.default_visualizer
may be used to
select a visualizer by following the built-in process
(see section 23.2.2.6 Selecting Pretty-Printers). This is done automatically when
a varobj is created, and so ordinarily is not needed.
This feature is only available if Python support is enabled. The MI
command -list-features
(see section 27.21 Miscellaneous GDB/MI Commands)
can be used to check this.
Resetting the visualizer:
(gdb) -var-set-visualizer V None ^done |
Reselecting the default (type-based) visualizer:
(gdb) -var-set-visualizer V gdb.default_visualizer ^done |
Suppose SomeClass
is a visualizer class. A lambda expression
can be used to instantiate this class for a varobj:
(gdb) -var-set-visualizer V "lambda val: SomeClass()" ^done |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes the GDB/MI commands that manipulate data: examine memory and registers, evaluate expressions, etc.
-data-disassemble
Command
-data-disassemble [ -s start-addr -e end-addr ] | [ -f filename -l linenum [ -n lines ] ] -- mode |
Where:
$pc
)
The output for each instruction is composed of four fields:
Note that whatever included in the instruction field, is not manipulated directly by GDB/MI, i.e., it is not possible to adjust its format.
There's no direct mapping from this command to the CLI.
Disassemble from the current value of $pc
to $pc + 20
:
(gdb) -data-disassemble -s $pc -e "$pc + 20" -- 0 ^done, asm_insns=[ {address="0x000107c0",func-name="main",offset="4", inst="mov 2, %o0"}, {address="0x000107c4",func-name="main",offset="8", inst="sethi %hi(0x11800), %o2"}, {address="0x000107c8",func-name="main",offset="12", inst="or %o2, 0x140, %o1\t! 0x11940 <_lib_version+8>"}, {address="0x000107cc",func-name="main",offset="16", inst="sethi %hi(0x11800), %o2"}, {address="0x000107d0",func-name="main",offset="20", inst="or %o2, 0x168, %o4\t! 0x11968 <_lib_version+48>"}] (gdb) |
Disassemble the whole main
function. Line 32 is part of
main
.
-data-disassemble -f basics.c -l 32 -- 0 ^done,asm_insns=[ {address="0x000107bc",func-name="main",offset="0", inst="save %sp, -112, %sp"}, {address="0x000107c0",func-name="main",offset="4", inst="mov 2, %o0"}, {address="0x000107c4",func-name="main",offset="8", inst="sethi %hi(0x11800), %o2"}, [...] {address="0x0001081c",func-name="main",offset="96",inst="ret "}, {address="0x00010820",func-name="main",offset="100",inst="restore "}] (gdb) |
Disassemble 3 instructions from the start of main
:
(gdb) -data-disassemble -f basics.c -l 32 -n 3 -- 0 ^done,asm_insns=[ {address="0x000107bc",func-name="main",offset="0", inst="save %sp, -112, %sp"}, {address="0x000107c0",func-name="main",offset="4", inst="mov 2, %o0"}, {address="0x000107c4",func-name="main",offset="8", inst="sethi %hi(0x11800), %o2"}] (gdb) |
Disassemble 3 instructions from the start of main
in mixed mode:
(gdb) -data-disassemble -f basics.c -l 32 -n 3 -- 1 ^done,asm_insns=[ src_and_asm_line={line="31", file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \ testsuite/gdb.mi/basics.c",line_asm_insn=[ {address="0x000107bc",func-name="main",offset="0", inst="save %sp, -112, %sp"}]}, src_and_asm_line={line="32", file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \ testsuite/gdb.mi/basics.c",line_asm_insn=[ {address="0x000107c0",func-name="main",offset="4", inst="mov 2, %o0"}, {address="0x000107c4",func-name="main",offset="8", inst="sethi %hi(0x11800), %o2"}]}] (gdb) |
-data-evaluate-expression
Command
-data-evaluate-expression expr |
Evaluate expr as an expression. The expression could contain an inferior function call. The function call will execute synchronously. If the expression contains spaces, it must be enclosed in double quotes.
The corresponding GDB commands are `print', `output', and
`call'. In gdbtk
only, there's a corresponding
`gdb_eval' command.
In the following example, the numbers that precede the commands are the tokens described in GDB/MI Command Syntax. Notice how GDB/MI returns the same tokens in its output.
211-data-evaluate-expression A 211^done,value="1" (gdb) 311-data-evaluate-expression &A 311^done,value="0xefffeb7c" (gdb) 411-data-evaluate-expression A+3 411^done,value="4" (gdb) 511-data-evaluate-expression "A + 3" 511^done,value="4" (gdb) |
-data-list-changed-registers
Command
-data-list-changed-registers |
Display a list of the registers that have changed.
GDB doesn't have a direct analog for this command; gdbtk
has the corresponding command `gdb_changed_register_list'.
On a PPC MBX board:
(gdb) -exec-continue ^running (gdb) *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={ func="main",args=[],file="try.c",fullname="/home/foo/bar/try.c", line="5"} (gdb) -data-list-changed-registers ^done,changed-registers=["0","1","2","4","5","6","7","8","9", "10","11","13","14","15","16","17","18","19","20","21","22","23", "24","25","26","27","28","30","31","64","65","66","67","69"] (gdb) |
-data-list-register-names
Command
-data-list-register-names [ ( regno )+ ] |
Show a list of register names for the current target. If no arguments are given, it shows a list of the names of all the registers. If integer numbers are given as arguments, it will print a list of the names of the registers corresponding to the arguments. To ensure consistency between a register name and its number, the output list may include empty register names.
GDB does not have a command which corresponds to
`-data-list-register-names'. In gdbtk
there is a
corresponding command `gdb_regnames'.
For the PPC MBX board:
(gdb) -data-list-register-names ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7", "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18", "r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29", "r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9", "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20", "f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31", "", "pc","ps","cr","lr","ctr","xer"] (gdb) -data-list-register-names 1 2 3 ^done,register-names=["r1","r2","r3"] (gdb) |
-data-list-register-values
Command
-data-list-register-values fmt [ ( regno )*] |
Display the registers' contents. fmt is the format according to which the registers' contents are to be returned, followed by an optional list of numbers specifying the registers to display. A missing list of numbers indicates that the contents of all the registers must be returned.
Allowed formats for fmt are:
x
o
t
d
r
N
The corresponding GDB commands are `info reg', `info
all-reg', and (in gdbtk
) `gdb_fetch_registers'.
For a PPC MBX board (note: line breaks are for readability only, they don't appear in the actual output):
(gdb) -data-list-register-values r 64 65 ^done,register-values=[{number="64",value="0xfe00a300"}, {number="65",value="0x00029002"}] (gdb) -data-list-register-values x ^done,register-values=[{number="0",value="0xfe0043c8"}, {number="1",value="0x3fff88"},{number="2",value="0xfffffffe"}, {number="3",value="0x0"},{number="4",value="0xa"}, {number="5",value="0x3fff68"},{number="6",value="0x3fff58"}, {number="7",value="0xfe011e98"},{number="8",value="0x2"}, {number="9",value="0xfa202820"},{number="10",value="0xfa202808"}, {number="11",value="0x1"},{number="12",value="0x0"}, {number="13",value="0x4544"},{number="14",value="0xffdfffff"}, {number="15",value="0xffffffff"},{number="16",value="0xfffffeff"}, {number="17",value="0xefffffed"},{number="18",value="0xfffffffe"}, {number="19",value="0xffffffff"},{number="20",value="0xffffffff"}, {number="21",value="0xffffffff"},{number="22",value="0xfffffff7"}, {number="23",value="0xffffffff"},{number="24",value="0xffffffff"}, {number="25",value="0xffffffff"},{number="26",value="0xfffffffb"}, {number="27",value="0xffffffff"},{number="28",value="0xf7bfffff"}, {number="29",value="0x0"},{number="30",value="0xfe010000"}, {number="31",value="0x0"},{number="32",value="0x0"}, {number="33",value="0x0"},{number="34",value="0x0"}, {number="35",value="0x0"},{number="36",value="0x0"}, {number="37",value="0x0"},{number="38",value="0x0"}, {number="39",value="0x0"},{number="40",value="0x0"}, {number="41",value="0x0"},{number="42",value="0x0"}, {number="43",value="0x0"},{number="44",value="0x0"}, {number="45",value="0x0"},{number="46",value="0x0"}, {number="47",value="0x0"},{number="48",value="0x0"}, {number="49",value="0x0"},{number="50",value="0x0"}, {number="51",value="0x0"},{number="52",value="0x0"}, {number="53",value="0x0"},{number="54",value="0x0"}, {number="55",value="0x0"},{number="56",value="0x0"}, {number="57",value="0x0"},{number="58",value="0x0"}, {number="59",value="0x0"},{number="60",value="0x0"}, {number="61",value="0x0"},{number="62",value="0x0"}, {number="63",value="0x0"},{number="64",value="0xfe00a300"}, {number="65",value="0x29002"},{number="66",value="0x202f04b5"}, {number="67",value="0xfe0043b0"},{number="68",value="0xfe00b3e4"}, {number="69",value="0x20002b03"}] (gdb) |
-data-read-memory
Command
This command is deprecated, use -data-read-memory-bytes
instead.
-data-read-memory [ -o byte-offset ] address word-format word-size nr-rows nr-cols [ aschar ] |
where:
print
command (see section Output Formats).
This command displays memory contents as a table of nr-rows by
nr-cols words, each word being word-size bytes. In total,
nr-rows * nr-cols * word-size
bytes are read
(returned as `total-bytes'). Should less than the requested number
of bytes be returned by the target, the missing words are identified
using `N/A'. The number of bytes read from the target is returned
in `nr-bytes' and the starting address used to read memory in
`addr'.
The address of the next/previous row or page is available in `next-row' and `prev-row', `next-page' and `prev-page'.
The corresponding GDB command is `x'. gdbtk
has
`gdb_get_mem' memory read command.
Read six bytes of memory starting at bytes+6
but then offset by
-6
bytes. Format as three rows of two columns. One byte per
word. Display each word in hex.
(gdb) 9-data-read-memory -o -6 -- bytes+6 x 1 3 2 9^done,addr="0x00001390",nr-bytes="6",total-bytes="6", next-row="0x00001396",prev-row="0x0000138e",next-page="0x00001396", prev-page="0x0000138a",memory=[ {addr="0x00001390",data=["0x00","0x01"]}, {addr="0x00001392",data=["0x02","0x03"]}, {addr="0x00001394",data=["0x04","0x05"]}] (gdb) |
Read two bytes of memory starting at address shorts + 64
and
display as a single word formatted in decimal.
(gdb) 5-data-read-memory shorts+64 d 2 1 1 5^done,addr="0x00001510",nr-bytes="2",total-bytes="2", next-row="0x00001512",prev-row="0x0000150e", next-page="0x00001512",prev-page="0x0000150e",memory=[ {addr="0x00001510",data=["128"]}] (gdb) |
Read thirty two bytes of memory starting at bytes+16
and format
as eight rows of four columns. Include a string encoding with `x'
used as the non-printable character.
(gdb) 4-data-read-memory bytes+16 x 1 8 4 x 4^done,addr="0x000013a0",nr-bytes="32",total-bytes="32", next-row="0x000013c0",prev-row="0x0000139c", next-page="0x000013c0",prev-page="0x00001380",memory=[ {addr="0x000013a0",data=["0x10","0x11","0x12","0x13"],ascii="xxxx"}, {addr="0x000013a4",data=["0x14","0x15","0x16","0x17"],ascii="xxxx"}, {addr="0x000013a8",data=["0x18","0x19","0x1a","0x1b"],ascii="xxxx"}, {addr="0x000013ac",data=["0x1c","0x1d","0x1e","0x1f"],ascii="xxxx"}, {addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"}, {addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&'"}, {addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"}, {addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"}] (gdb) |
-data-read-memory-bytes
Command
-data-read-memory-bytes [ -o byte-offset ] address count |
where:
This command attempts to read all accessible memory regions in the specified range. First, all regions marked as unreadable in the memory map (if one is defined) will be skipped. See section 10.16 Memory Region Attributes. Second, GDB will attempt to read the remaining regions. For each one, if reading full region results in an errors, GDB will try to read a subset of the region.
In general, every single byte in the region may be readable or not, and the only way to read every readable byte is to try a read at every address, which is not practical. Therefore, GDB will attempt to read all accessible bytes at either beginning or the end of the region, using a binary division scheme. This heuristic works well for reading accross a memory map boundary. Note that if a region has a readable range that is neither at the beginning or the end, GDB will not read it.
The result record (see section 27.5.1 GDB/MI Result Records) that is output of the command includes a field named `memory' whose content is a list of tuples. Each tuple represent a successfully read memory block and has the following fields:
begin
end
offset
-data-read-memory-bytes
.
contents
The corresponding GDB command is `x'.
(gdb) -data-read-memory-bytes &a 10 ^done,memory=[{begin="0xbffff154",offset="0x00000000", end="0xbffff15e", contents="01000000020000000300"}] (gdb) |
-data-write-memory-bytes
Command
-data-write-memory-bytes address contents |
where:
There's no corresponding GDB command.
(gdb) -data-write-memory-bytes &a "aabbccdd" ^done (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The commands defined in this section implement MI support for tracepoints. For detailed introduction, see 13. Tracepoints.
-trace-find
Command
-trace-find mode [parameters...] |
Find a trace frame using criteria defined by mode and
parameters. The following table lists permissible
modes and their parameters. For details of operation, see 13.2.1 tfind n
.
If `none' was passed as mode, the response does not have fields. Otherwise, the response may have the following fields:
The corresponding GDB command is `tfind'.
-trace-define-variable name [ value ] |
Create trace variable name if it does not exist. If value is specified, sets the initial value of the specified trace variable to that value. Note that the name should start with the `$' character.
The corresponding GDB command is `tvariable'.
-trace-list-variables |
Return a table of all defined trace variables. Each element of the table has the following fields:
The corresponding GDB command is `tvariables'.
(gdb) -trace-list-variables ^done,trace-variables={nr_rows="1",nr_cols="3", hdr=[{width="15",alignment="-1",col_name="name",colhdr="Name"}, {width="11",alignment="-1",col_name="initial",colhdr="Initial"}, {width="11",alignment="-1",col_name="current",colhdr="Current"}], body=[variable={name="$trace_timestamp",initial="0"} variable={name="$foo",initial="10",current="15"}]} (gdb) |
-trace-save [-r ] filename |
Saves the collected trace data to filename. Without the `-r' option, the data is downloaded from the target and saved in a local file. With the `-r' option the target is asked to perform the save.
The corresponding GDB command is `tsave'.
-trace-start |
Starts a tracing experiments. The result of this command does not have any fields.
The corresponding GDB command is `tstart'.
-trace-status |
Obtains the status of a tracing experiment. The result may include the following fields:
-trace-stop
command. The value of `overflow' means
the tracing buffer is full. The value of `disconnection' means
tracing was automatically stopped when GDB has disconnected.
The value of `passcount' means tracing was stopped when a
tracepoint was passed a maximal number of times for that tracepoint.
This field is present if `supported' field is not `0'.
1
means that the
trace buffer is circular and old trace frames will be discarded if
necessary to make room, 0
means that the trace buffer is linear
and may fill up.
1
means that
tracing will continue after GDB disconnects, 0
means
that the trace run will stop.
The corresponding GDB command is `tstatus'.
-trace-stop |
Stops a tracing experiment. The result of this command has the same
fields as -trace-status
, except that the `supported' and
`running' fields are not output.
The corresponding GDB command is `tstop'.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-symbol-list-lines
Command
-symbol-list-lines filename |
Print the list of lines that contain code and their associated program addresses for the given source filename. The entries are sorted in ascending PC order.
There is no corresponding GDB command.
(gdb) -symbol-list-lines basics.c ^done,lines=[{pc="0x08048554",line="7"},{pc="0x0804855a",line="8"}] (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes the GDB/MI commands to specify executable file names and to read in and obtain symbol table information.
-file-exec-and-symbols
Command
-file-exec-and-symbols file |
Specify the executable file to be debugged. This file is the one from which the symbol table is also read. If no file is specified, the command clears the executable and symbol information. If breakpoints are set when using this command with no arguments, GDB will produce error messages. Otherwise, no output is produced, except a completion notification.
The corresponding GDB command is `file'.
(gdb) -file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx ^done (gdb) |
-file-exec-file
Command
-file-exec-file file |
Specify the executable file to be debugged. Unlike `-file-exec-and-symbols', the symbol table is not read from this file. If used without argument, GDB clears the information about the executable file. No output is produced, except a completion notification.
The corresponding GDB command is `exec-file'.
(gdb) -file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx ^done (gdb) |
-file-list-exec-source-file
Command
-file-list-exec-source-file |
List the line number, the current source file, and the absolute path to the current source file for the current executable. The macro information field has a value of `1' or `0' depending on whether or not the file includes preprocessor macro information.
The GDB equivalent is `info source'
(gdb) 123-file-list-exec-source-file 123^done,line="1",file="foo.c",fullname="/home/bar/foo.c,macro-info="1" (gdb) |
-file-list-exec-source-files
Command
-file-list-exec-source-files |
List the source files for the current executable.
It will always output the filename, but only when GDB can find the absolute file name of a source file, will it output the fullname.
The GDB equivalent is `info sources'.
gdbtk
has an analogous command `gdb_listfiles'.
(gdb) -file-list-exec-source-files ^done,files=[ {file=foo.c,fullname=/home/foo.c}, {file=/home/bar.c,fullname=/home/bar.c}, {file=gdb_could_not_find_fullpath.c}] (gdb) |
-file-symbol-file
Command
-file-symbol-file file |
Read symbol table info from the specified file argument. When used without arguments, clears GDB's symbol table info. No output is produced, except for a completion notification.
The corresponding GDB command is `symbol-file'.
(gdb) -file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx ^done (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-target-attach
Command
-target-attach pid | gid | file |
Attach to a process pid or a file file outside of GDB, or a thread group gid. If attaching to a thread group, the id previously returned by `-list-thread-groups --available' must be used.
The corresponding GDB command is `attach'.
(gdb) -target-attach 34 =thread-created,id="1" *stopped,thread-id="1",frame={addr="0xb7f7e410",func="bar",args=[]} ^done (gdb) |
-target-detach
Command
-target-detach [ pid | gid ] |
Detach from the remote target which normally resumes its execution. If either pid or gid is specified, detaches from either the specified process, or specified thread group. There's no output.
The corresponding GDB command is `detach'.
(gdb) -target-detach ^done (gdb) |
-target-disconnect
Command
-target-disconnect |
Disconnect from the remote target. There's no output and the target is generally not resumed.
The corresponding GDB command is `disconnect'.
(gdb) -target-disconnect ^done (gdb) |
-target-download
Command
-target-download |
Loads the executable onto the remote target. It prints out an update message every half second, which includes the fields:
Each message is sent as status record (see section GDB/MI Output Syntax).
In addition, it prints the name and size of the sections, as they are downloaded. These messages include the following fields:
At the end, a summary is printed.
The corresponding GDB command is `load'.
Note: each status message appears on a single line. Here the messages have been broken down so that they can fit onto a page.
(gdb) -target-download +download,{section=".text",section-size="6668",total-size="9880"} +download,{section=".text",section-sent="512",section-size="6668", total-sent="512",total-size="9880"} +download,{section=".text",section-sent="1024",section-size="6668", total-sent="1024",total-size="9880"} +download,{section=".text",section-sent="1536",section-size="6668", total-sent="1536",total-size="9880"} +download,{section=".text",section-sent="2048",section-size="6668", total-sent="2048",total-size="9880"} +download,{section=".text",section-sent="2560",section-size="6668", total-sent="2560",total-size="9880"} +download,{section=".text",section-sent="3072",section-size="6668", total-sent="3072",total-size="9880"} +download,{section=".text",section-sent="3584",section-size="6668", total-sent="3584",total-size="9880"} +download,{section=".text",section-sent="4096",section-size="6668", total-sent="4096",total-size="9880"} +download,{section=".text",section-sent="4608",section-size="6668", total-sent="4608",total-size="9880"} +download,{section=".text",section-sent="5120",section-size="6668", total-sent="5120",total-size="9880"} +download,{section=".text",section-sent="5632",section-size="6668", total-sent="5632",total-size="9880"} +download,{section=".text",section-sent="6144",section-size="6668", total-sent="6144",total-size="9880"} +download,{section=".text",section-sent="6656",section-size="6668", total-sent="6656",total-size="9880"} +download,{section=".init",section-size="28",total-size="9880"} +download,{section=".fini",section-size="28",total-size="9880"} +download,{section=".data",section-size="3156",total-size="9880"} +download,{section=".data",section-sent="512",section-size="3156", total-sent="7236",total-size="9880"} +download,{section=".data",section-sent="1024",section-size="3156", total-sent="7748",total-size="9880"} +download,{section=".data",section-sent="1536",section-size="3156", total-sent="8260",total-size="9880"} +download,{section=".data",section-sent="2048",section-size="3156", total-sent="8772",total-size="9880"} +download,{section=".data",section-sent="2560",section-size="3156", total-sent="9284",total-size="9880"} +download,{section=".data",section-sent="3072",section-size="3156", total-sent="9796",total-size="9880"} ^done,address="0x10004",load-size="9880",transfer-rate="6586", write-rate="429" (gdb) |
No equivalent.
-target-select
Command
-target-select type parameters ... |
Connect GDB to the remote target. This command takes two args:
The output is a connection notification, followed by the address at which the target program is, in the following form:
^connected,addr="address",func="function name", args=[arg list] |
The corresponding GDB command is `target'.
(gdb) -target-select remote /dev/ttya ^connected,addr="0xfe00a300",func="??",args=[] (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-target-file-put
Command
-target-file-put hostfile targetfile |
Copy file hostfile from the host system (the machine running GDB) to targetfile on the target system.
The corresponding GDB command is `remote put'.
(gdb) -target-file-put localfile remotefile ^done (gdb) |
-target-file-get
Command
-target-file-get targetfile hostfile |
Copy file targetfile from the target system to hostfile on the host system.
The corresponding GDB command is `remote get'.
(gdb) -target-file-get remotefile localfile ^done (gdb) |
-target-file-delete
Command
-target-file-delete targetfile |
Delete targetfile from the target system.
The corresponding GDB command is `remote delete'.
(gdb) -target-file-delete remotefile ^done (gdb) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
-gdb-exit
Command
-gdb-exit |
Exit GDB immediately.
Approximately corresponds to `quit'.
(gdb) -gdb-exit ^exit |
-gdb-set
Command
-gdb-set |
Set an internal GDB variable.
The corresponding GDB command is `set'.
(gdb) -gdb-set $foo=3 ^done (gdb) |
-gdb-show
Command
-gdb-show |
Show the current value of a GDB variable.
The corresponding GDB command is `show'.
(gdb) -gdb-show annotate ^done,value="0" (gdb) |
-gdb-version
Command
-gdb-version |
Show version information for GDB. Used mostly in testing.
The GDB equivalent is `show version'. GDB by default shows this information when you start an interactive session.
(gdb) -gdb-version ~GNU gdb 5.2.1 ~Copyright 2000 Free Software Foundation, Inc. ~GDB is free software, covered by the GNU General Public License, and ~you are welcome to change it and/or distribute copies of it under ~ certain conditions. ~Type "show copying" to see the conditions. ~There is absolutely no warranty for GDB. Type "show warranty" for ~ details. ~This GDB was configured as "--host=sparc-sun-solaris2.5.1 --target=ppc-eabi". ^done (gdb) |
-list-features
Command Returns a list of particular features of the MI protocol that this version of gdb implements. A feature can be a command, or a new field in an output of some command, or even an important bugfix. While a frontend can sometimes detect presence of a feature at runtime, it is easier to perform detection at debugger startup.
The command returns a list of strings, with each string naming an available feature. Each returned string is just a name, it does not have any internal structure. The list of possible feature names is given below.
Example output:
(gdb) -list-features ^done,result=["feature1","feature2"] |
The current list of features is:
-var-set-frozen
command, as well
as possible presense of the frozen
field in the output
of -varobj-create
.
-break-insert
command.
-var-list-children
-thread-info
command.
-data-read-memory-bytes
and the
-data-write-memory-bytes
commands.
-ada-task-info
command.
-list-target-features
Command
Returns a list of particular features that are supported by the
target. Those features affect the permitted MI commands, but
unlike the features reported by the -list-features
command, the
features depend on which target GDB is using at the moment. Whenever
a target can change, due to commands such as -target-select
,
-target-attach
or -exec-run
, the list of target features
may change, and the frontend should obtain it again.
Example output:
(gdb) -list-features ^done,result=["async"] |
The current list of features is:
-list-thread-groups
Command
-list-thread-groups [ --available ] [ --recurse 1 ] [ group ... ] |
Lists thread groups (see section 27.1.3 Thread groups). When a single thread group is passed as the argument, lists the children of that group. When several thread group are passed, lists information about those thread groups. Without any parameters, lists information about all top-level thread groups.
Normally, thread groups that are being debugged are reported. With the `--available' option, GDB reports thread groups available on the target.
The output of this command may have either a `threads' result or a `groups' result. The `thread' result has a list of tuples as value, with each tuple describing a thread (see section 27.5.5 GDB/MI Thread Information). The `groups' result has a list of tuples as value, each tuple describing a thread group. If top-level groups are requested (that is, no parameter is passed), or when several groups are passed, the output always has a `groups' result. The format of the `group' result is described below.
To reduce the number of roundtrips it's possible to list thread groups together with their children, by passing the `--recurse' option and the recursion depth. Presently, only recursion depth of 1 is permitted. If this option is present, then every reported thread group will also include its children, either as `group' or `threads' field.
In general, any combination of option and parameters is permitted, with the following caveats:
The `groups' result is a list of tuples, where each tuple may have the following fields:
id
type
pid
num_children
threads
cores
executable
gdb -list-thread-groups ^done,groups=[{id="17",type="process",pid="yyy",num_children="2"}] -list-thread-groups 17 ^done,threads=[{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)", frame={level="0",addr="0xffffe410",func="__kernel_vsyscall",args=[]},state="running"}, {id="1",target-id="Thread 0xb7e156b0 (LWP 21254)", frame={level="0",addr="0x0804891f",func="foo",args=[{name="i",value="10"}], file="/tmp/a.c",fullname="/tmp/a.c",line="158"},state="running"}]] -list-thread-groups --available ^done,groups=[{id="17",type="process",pid="yyy",num_children="2",cores=[1,2]}] -list-thread-groups --available --recurse 1 ^done,groups=[{id="17", types="process",pid="yyy",num_children="2",cores=[1,2], threads=[{id="1",target-id="Thread 0xb7e14b90",cores=[1]}, {id="2",target-id="Thread 0xb7e14b90",cores=[2]}]},..] -list-thread-groups --available --recurse 1 17 18 ^done,groups=[{id="17", types="process",pid="yyy",num_children="2",cores=[1,2], threads=[{id="1",target-id="Thread 0xb7e14b90",cores=[1]}, {id="2",target-id="Thread 0xb7e14b90",cores=[2]}]},...] |
-add-inferior
Command
-add-inferior |
Creates a new inferior (see section 4.9 Debugging Multiple Inferiors and Programs). The created inferior is not associated with any executable. Such association may be established with the `-file-exec-and-symbols' command (see section 27.18 GDB/MI File Commands). The command response has a single field, `thread-group', whose value is the identifier of the thread group corresponding to the new inferior.
gdb -add-inferior ^done,thread-group="i3" |
-interpreter-exec
Command
-interpreter-exec interpreter command |
Execute the specified command in the given interpreter.
The corresponding GDB command is `interpreter-exec'.
(gdb) -interpreter-exec console "break main" &"During symbol reading, couldn't parse type; debugger out of date?.\n" &"During symbol reading, bad structure-type format.\n" ~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n" ^done (gdb) |
-inferior-tty-set
Command
-inferior-tty-set /dev/pts/1 |
Set terminal for future runs of the program being debugged.
The corresponding GDB command is `set inferior-tty' /dev/pts/1.
(gdb) -inferior-tty-set /dev/pts/1 ^done (gdb) |
-inferior-tty-show
Command
-inferior-tty-show |
Show terminal for future runs of program being debugged.
The corresponding GDB command is `show inferior-tty'.
(gdb) -inferior-tty-set /dev/pts/1 ^done (gdb) -inferior-tty-show ^done,inferior_tty_terminal="/dev/pts/1" (gdb) |
-enable-timings
Command
-enable-timings [yes | no] |
Toggle the printing of the wallclock, user and system times for an MI command as a field in its output. This command is to help frontend developers optimize the performance of their code. No argument is equivalent to `yes'.
No equivalent.
(gdb) -enable-timings ^done (gdb) -break-insert main ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x080484ed",func="main",file="myprog.c", fullname="/home/nickrob/myprog.c",line="73",times="0"}, time={wallclock="0.05185",user="0.00800",system="0.00000"} (gdb) -enable-timings no ^done (gdb) -exec-run ^running (gdb) *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0", frame={addr="0x080484ed",func="main",args=[{name="argc",value="1"}, {name="argv",value="0xbfb60364"}],file="myprog.c", fullname="/home/nickrob/myprog.c",line="73"} (gdb) |
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |