Debugging with GDB: GDB/MI Output Syntax

Previous: GDB/MI Input Syntax, Up: GDB/MI Command Syntax   [Contents][Index]


27.2.2 GDB/MI Output Syntax

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 nl

status-async-output →

[ token ] "+" async-output nl

notify-async-output →

[ token ] "=" async-output nl

async-output →

async-class ( "," result )*

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 nl

target-stream-output →

"@" c-string nl

log-stream-output →

"&" c-string nl

nl →

CR | CR-LF

token →

any sequence of digits.

Notes:

  • All output sequences end in a single line containing a period.
  • The 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.
  • status-async-output contains on-going status information about the progress of a slow operation. It can be discarded. All status output is prefixed by ‘+’.
  • exec-async-output contains asynchronous state change on the target (stopped, started, disappeared). All async output is prefixed by ‘*’.
  • notify-async-output contains supplementary information that the client should handle (e.g., a new breakpoint information). All notify output is prefixed by ‘=’.
  • console-stream-output is output that should be displayed as is in the console. It is the textual response to a CLI command. All the console output is prefixed by ‘~’.
  • target-stream-output is the output produced by the target program. All the target output is prefixed by ‘@’.
  • log-stream-output is output text coming from GDB’s internals, for instance messages that should be displayed as part of an error log. All the log output is prefixed by ‘&’.
  • New GDB/MI commands should only output lists containing values.

See GDB/MI Stream Records, for more details about the various output records.


Previous: GDB/MI Input Syntax, Up: GDB/MI Command Syntax   [Contents][Index]