manpagez: man pages & more
info gdb
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

24.5 Simple Examples of GDB/MI Interaction

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

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

Program execution generates asynchronous records and MI gives the reason that execution stopped.

 
-> -exec-run
<- ^running
<- (gdb)
<- *stopped,reason="breakpoint-hit",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 No value for GDBN

Quitting No value for GDBN just prints the result class ‘^exit’.

 
-> (gdb)
<- -gdb-exit
<- ^exit

A Bad Command

Here's what happens if you pass a non-existent command:

 
-> -rubbish
<- ^error,msg="Undefined MI command: rubbish"
<- (gdb)

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.