binutils-gdb/gdb/testsuite/gdb.mi
Pedro Alves 49940788ab Always switch fork child to the main UI
The following scenario:

 - gdb started in normal CLI mode.

 - separate MI channel created with new-ui

 - inferior output redirected with the "set inferior-tty" command.

 - use -exec-run in the MI channel to run the inferior

is presently mishandled.

When we create the inferior, in fork-child.c, right after vfork, we'll
close all the file descriptors in the vfork child, and then dup the
tty to file descriptors 0/1/2, create a session, etc.  Note that when
we close all descriptors, we close the file descriptors behind
gdb_stdin/gdb_stdout/gdb_stderr of all secondary UIs...  So if
anything goes wrong in the child and it calls warning/error, it'll end
up writting to the current UI's stdout/stderr streams, which are
backed by file descriptors that have since been closed.  Because this
happens in a vfork region, the corresponding stdin/stdout/stderr in
the parent/gdb end up corrupted.

The fix is to switch to the main UI right after the vfork, so that
gdb_stdin/gdb_stdout/gdb_stderr are correctly mapped to
stdin/stdout/stderr (and thus to file descriptors 0/1/2), so this code
works as it has always worked.

(Technically, we're doing a lot of stuff we shouldn't be doing after a
vfork, while we should only be calling async-signal-safe functions.)

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

	* fork-child.c (fork_inferior): Switch the child to the main UI
	right after vfork.  Save/restore the current UI in the parent.
	Flush outputs of the main UI instead of the current UI.

gdb/testsuite/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

	* gdb.mi/mi-exec-run.exp: New file.
2016-06-21 01:11:57 +01:00
..
ChangeLog-1999-2003
array.f GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
basics.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
dw2-ref-missing-frame-func.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
dw2-ref-missing-frame-main.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
dw2-ref-missing-frame.S GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
dw2-ref-missing-frame.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
gdb669.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
gdb680.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
gdb701.c
gdb701.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
gdb792.cc
gdb792.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
gdb2549.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-async-run.c Fix -exec-run not running asynchronously with mi-async on (PR gdb/18077) 2016-05-17 16:46:18 -04:00
mi-async-run.exp Fix -exec-run not running asynchronously with mi-async on (PR gdb/18077) 2016-05-17 16:46:18 -04:00
mi-async.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-basics.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-break.exp Make mi-break.exp always expect breakpoint commands output on the main UI 2016-06-21 01:11:56 +01:00
mi-breakpoint-changed.exp Fix gdb.mi/mi-breakpoint-changed.exp for remote targets 2016-04-04 10:31:30 -04:00
mi-catch-load-so.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-catch-load.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-catch-load.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-cli.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-cmd-param-changed.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-condbreak-call-thr-state-mt.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-condbreak-call-thr-state-st.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-condbreak-call-thr-state.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-condbreak-call-thr-state.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-console.c GDB testsuite: Fix warnings with -std=gnu11 2014-11-13 10:20:44 +01:00
mi-console.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-detach.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-disassemble.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-dprintf-pending.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-dprintf-pending.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-dprintf-pendshr.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-dprintf.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-dprintf.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-editing.exp Make command line editing (use of readline) be per UI 2016-06-21 01:11:48 +01:00
mi-eval.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-exec-run.exp Always switch fork child to the main UI 2016-06-21 01:11:57 +01:00
mi-exit-code.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-exit-code.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-file-transfer.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-file.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-fill-memory.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-fullname-deleted.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-hack-cli.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-i-cmd.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-info-os.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-inheritance-syntax-error.cc
mi-inheritance-syntax-error.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-language.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-linespec-err-cp.cc PR 18303, Tolerate malformed input for lookup_symbol-called functions 2016-03-15 15:25:15 -07:00
mi-linespec-err-cp.exp PR 18303, Tolerate malformed input for lookup_symbol-called functions 2016-03-15 15:25:15 -07:00
mi-logging.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-memory-changed.exp mi-memory-changed.exp: Fix filename passed to untested 2016-06-02 10:08:28 -04:00
mi-nonstop-exit.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-nonstop.exp Reapply: List inferiors/threads/pspaces in ascending order 2016-01-12 01:12:38 +00:00
mi-ns-stale-regcache.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-nsintrall.exp Reapply: List inferiors/threads/pspaces in ascending order 2016-01-12 01:12:38 +00:00
mi-nsmoribund.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-nsthrexec.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-pending.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-pending.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-pendshr.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-pendshr2.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-pthreads.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-read-memory.c
mi-read-memory.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-record-changed.exp Add method/format information to =record-started 2016-06-06 17:10:18 -04:00
mi-reg-undefined.S GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-reg-undefined.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-reg-undefined.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-regs.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-return.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-reverse.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-simplerun.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-solib.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-stack.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-stack.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-start.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-start.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-stepi.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-stepn.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-stepn.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-syn-frame.c GDB testsuite: Fix warnings with -std=gnu11 2014-11-13 10:20:44 +01:00
mi-syn-frame.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-threads-interrupt.c Add mi-threads-interrupt.exp test (PR 20039) 2016-05-18 10:13:16 -04:00
mi-threads-interrupt.exp Add mi-threads-interrupt.exp test (PR 20039) 2016-05-18 10:13:16 -04:00
mi-undefined-cmd.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-until.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-block.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-child-f.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-child.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-child.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-cmd.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-cp.cc GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-cp.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-create-rtti.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-create-rtti.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-display.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-invalidate.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-list-children-invalid-grandchild.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-list-children-invalid-grandchild.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-rtti.cc GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-var-rtti.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-vla-c99.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-vla-fortran.exp gdb: Guard against undefined behaviour in mi-vla-fortran.exp 2016-02-01 18:05:35 +00:00
mi-watch-nonstop.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi-watch.exp Send deleted watchpoint-scope output to all UIs 2016-06-21 01:11:56 +01:00
mi2-amd64-entry-value.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi2-amd64-entry-value.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi2-amd64-entry-value.s GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi2-prompt.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mi2-var-child.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
non-stop-exit.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
non-stop.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
ns-stale-regcache.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
nsintrall.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
nsmoribund.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
nsthrexec.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
pending.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
pendshr1.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
pendshr2.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
pr11022.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
pr11022.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
pthreads.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
solib-lib.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
solib-main.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
testcmds
until.c Eliminate literal line numbers in mi-until.exp 2014-11-17 10:26:30 +01:00
var-cmd.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
vla.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
vla.f90 testsuite: Nullify pointers before first usage. 2016-03-02 16:36:37 +01:00
watch-nonstop.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00