diff options
author | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:57 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:57 +0100 |
commit | 49940788ab38b9d58c663cf38855f29c0ebb1b55 (patch) | |
tree | ef322e16fd2feb6219aacba550aac37b9b38772f /gdb/testsuite/ChangeLog | |
parent | ef274d26b57336b3baa5bb0ae93b49178bc45631 (diff) | |
download | gdb-49940788ab38b9d58c663cf38855f29c0ebb1b55.zip gdb-49940788ab38b9d58c663cf38855f29c0ebb1b55.tar.gz gdb-49940788ab38b9d58c663cf38855f29c0ebb1b55.tar.bz2 |
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.
Diffstat (limited to 'gdb/testsuite/ChangeLog')
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index ee27566..6790c45 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2016-06-21 Pedro Alves <palves@redhat.com> + * gdb.mi/mi-exec-run.exp: New file. + +2016-06-21 Pedro Alves <palves@redhat.com> + * gdb.mi/mi-break.exp (test_breakpoint_commands): Always expect breakpoint command's output on the main UI. (test_break): New procedure, factored out from calls in the top |