Debugging with GDB (February 2008)

Table Of Contents
272 Debugging with GDB
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 Section 21.3.2 [gdb/mi Stream Records], page 273, for more details about the various
output records.
21.1.3 Simple examples of gdb/mi interaction
This subsection presents several simple examples of interaction using the gdb/mi inter-
face. In these examples, -> means that the following line is passed to gdb/mi as input,
while <- means the output received from gdb/mi.
Evaluate expression
Here is an example to evaluate an expression:
-> -data-evaluate-expression 2+3
<- (gdb)
<- ^done,value="5"
<- (gdb)
and later:
<- *stop,reason="stop",address="0x123",source="a.c:123"
<- (gdb)
Simple CLI command
Here is an example of a simple CLI command being passed through gdb/mi and on to
the CLI.
-> print 1+2
<- &"print 1+2\n"
<- ~"$1 = 3\n"
<- ^done
<- (gdb)
A bad command
Here is what happens if you pass a bad command:
-> -rubbish
<- ^error,msg="Undefined MI command: rubbish"
<- (gdb)