Commit e1ff6226 authored by Peter Waller's avatar Peter Waller Committed by Simon Marchi
Browse files

Preserve gdb_std{out, err, log, targ, targerr} across interpreter_exec_cmd



Calls through interpreter_exec_cmd can cause the output state to be modified in
a way which doesn't get back after the execution.

It looks like the intent is that interp::resume should put things back how they
should be, however, mi_interp::resume modifies gdb_stdout and nothing currently
restores it to the previous state.

To see the broken behaviour:

  gdb -ex starti -ex bt -ex 'interpreter-exec mi echo' -ex bt -ex q echo <<<''

Prior to this patch, on a terminal environment, the first backtrace is
coloured, and the second backtrace is not. The reason is that
stdio_file::can_emit_style_escape becomes false, because the gdb_stdout gets
overwritten in mi_interp::resume and not replaced.

gdb/ChangeLog:

	* interps.c (interpreter_exec_cmd): Restore streams pointers.

gdb/testsuite/ChangeLog:

	* gdb.base/style-interp-exec-mi.exp: New.
	* gdb.base/style-interp-exec-mi.c: New.

Signed-off-by: default avatarPeter Waller <p@pwaller.net>
Change-Id: Id87423b262d058857ea9dca5866ca6471741e512
parent ca01f1bf
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment