Target output printed raw on MI channel

Jan Vrany
Tue Jan 22 15:51:00 GMT 2019


the GDB/MI interface describes "target-stream-output" MI record and
says [1]:

  * target-stream-output is the output produced by the target program. 
    All the target output is prefixed by ‘@’. 

My understanding is that if I run GDB with MI2 interpreter, all debugee 
output written to stdout / stderr shall be sent to MI client as 
target-stream-output. However, it is not: 

./gdb -i=mi2 -ex "set startup-with-shell on" -ex r -ex quit --args /bin/ls -al /etc/passwd


      <...truncated for clarity...>
      =library-loaded,id="/lib/x86_64-linux-gnu/",target-name="/lib/x8<...truncated for clarity...>
      =library-loaded,id="/lib/x86_64-linux-gnu/",target-name="/lib/x8<...truncated for clarity...>
-->   -rw-r--r-- 1 root root 2386 Nov 14 14:21 /etc/passwd
      ~"[Inferior 1 (process 27339) exited normally]\n"
      *stopped,"Starting program",execfile="/bin/ls",infargs="-al /etc/passwd",reason="exited-normally"

Note, that the output is raw, not something like

     @"-rw-r--r-- 1 root root 2386 Nov 14 14:21 /etc/passwd\n"
as I'd expect. This is produced with current GDB master b1afaa3566. 
Using "set startup-with-shell off" produces the same. As you can imagine, this can 
confuse (my) MI parser quite a lot. 

Is it a bug or do I misunderstand the documentation and/or purpose of 
"target-stream-output" MI record? 

Thanks, Jan


More information about the Gdb mailing list