I am using GDBs machine interface (mi) to write some simple tracers/loggers.
Now I ran into the problem of telling apart GDB output from text the target-program itself wrote to stdout.
If I look into the documentation here: https://ftp.gnu.org/old-gnu/Manuals/gdb/html_chapter/gdb_22.html
it says
target-stream-output is the output produced by the target program. All the target output is prefixed by `@'.
This is not what I observe, however. Consider this example session of running ls like so:
gdb -i mi ls
start
which gives this output:
...
...
~"[Thread debugging using libthread_db enabled]\n"
file1.jpg file2.jpg file3.jpg dir1 dir2 <---(!!!)
~"[Inferior 1 (process 22233) exited normally]\n"
=thread-exited,id="1",group-id="i1"
=thread-group-exited,id="i1",exit-code="0"
*stopped,reason="exited-normally"
(gdb)
As you can see, the output of the ls command was just randomly dumped into the console. Great.
How can I parse this?
Thanks!
gdb version is 8.1