Bug 17507

Summary: GDB-MI interpreter should use "console-stream" records for monitor command results
Product: gdb Reporter: Teodor Madan <teodor.madan>
Component: miAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: enhancement CC: tromey
Priority: P2    
Version: 7.6   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Teodor Madan 2014-10-23 15:52:21 UTC
When executing "monitor help", reply from gdbserver is reported as "target-stream" thus it will be routed to console/tty associated with debugged application. It is expected to be printed to console-stream being a result of CLI command.
A gdb/mi frontend (e.g. eclipse) will route stream records to different console views depending on the record type. 

The undesirable effect in this situation: user will enter a gdb command in gdb shell console and will see result in a totally different console. 

In low-level GDB jtag debugging user has to interact often with "monitor" commands due to a lot of very specialized extensions. 

---------------steps to reproduce -------------
1. start "gdbserver  -multi :2345"
2. start gdb with mi interpretter: "gdb --interpretter=mi"

(gdb)
target extended-remote :2345
&"target extended-remote :2345\n"
~"Remote debugging using :2345\n"
=tsv-created,name="trace_timestamp",initial="0"\n
^done
(gdb)
mon set debug-hw-points 1
&"mon set debug-hw-points 1\n"
@"H/W point debugging output enabled.\n"
^done
(gdb)

Inspect result of the command. It does start with "@" as a sign of a stdout activity of debugged application, not "~" that would mean that it is a string dedicated to be displayed to whoever sent that command.

-------------

According to chapter "27.5.2 gdb/mi Output Syntax",

"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 ‘@’."

An optional gdb set subcommand would work as well. e.g. "set remoteshell 1"