From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Add mi-threads-interrupt.exp test (PR 20039)
Date: Tue, 03 May 2016 21:57:00 -0000 [thread overview]
Message-ID: <5983d4d2-016a-8020-c109-cb7ea2cfd179@redhat.com> (raw)
In-Reply-To: <1462305612-16493-1-git-send-email-simon.marchi@ericsson.com>
On 05/03/2016 09:00 PM, Simon Marchi wrote:
> Add a new test for PR 20039. The test spawns new threads, then tries to
> interrupt, continue, and interrupt again. This use case was fixed by
> commit 5fe966540d6b748f825774868463003700f0c878 in master, but gdb 7.11
> is affected (so if you try it on the gdb-7.11-branch right now, the test
> will fail).
Thanks for the test!
I debugged this a little, and I see that the bug is that -exec-continue ends
up with thread 3 selected, which generates a =thread-selected event.
-exec-continue
^running
*running,thread-id="all"
(gdb)
=thread-selected,id="3"
And then the code that emits that =thread-selected calls target_terminal_ours,
and doesn't restore the terminal with target_terminal_inferior:
if (report_change)
{
struct thread_info *ti = inferior_thread ();
target_terminal_ours ();
fprintf_unfiltered (mi->event_channel,
"thread-selected,id=\"%d\"",
ti->global_num);
gdb_flush (mi->event_channel);
}
We'll end up calling target_terminal_inferior when we next
re-resume the inferior after some internal event, but if no
such event ever happens, the target will remain running
free with target_terminal_ours in effect...
So two bugs: calling target_terminal_ours instead of
target_terminal_ours_for_output, and not restoring the target terminal,
both addressed in 5fe966540d6b (Use target_terminal_ours_for_output in MI):
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2171,12 +2171,17 @@ mi_execute_command (const char *cmd, int from_tty)
if (report_change)
{
struct thread_info *ti = inferior_thread ();
+ struct cleanup *old_chain;
+
+ old_chain = make_cleanup_restore_target_terminal ();
+ target_terminal_ours_for_output ();
- target_terminal_ours ();
fprintf_unfiltered (mi->event_channel,
"thread-selected,id=\"%d\"",
ti->global_num);
gdb_flush (mi->event_channel);
+
+ do_cleanups (old_chain);
}
> + # Load the binary in gdb and run it.
> + mi_gdb_load $binfile
> + mi_runto "all_threads_created"
I think we could add a comment saying:
# Note this test relies on mi_runto deleting the breakpoint.
# A step-over here would mask the bug.
> +
> + # Consistency check.
> + mi_check_thread_states {"stopped" "stopped" "stopped"} "check thread states"
> +
> + # Continue.
> + mi_gdb_test "565-exec-continue" "565\\^running\r\n\\*running,thread-id=\"all\"" "continue #1"
> +
> + # Send ctrl-C
> + send_gdb "\003"
I guess you didn't add a match for =thread-selected because that
detail may change in future. I agree with that.
However, I think it'll good to wait a second or some such before
sending the ctrl-C, to make sure all such events were indeed
output. Otherwise, if the machine is fast enough, we may
end up sending the ctrl-C before the =thread-selected event
is reached.
> + mi_expect_interrupt "interrupt #1"
> +
> + # Continue.
> + mi_gdb_test "565-exec-continue" "565\\^running\r\n\\*running,thread-id=\"all\"" "continue #2"
> +
> + # Send ctrl-C again.
> + send_gdb "\003"
Ditto.
> + mi_expect_interrupt "interrupt #2"
> +}
AFAICS, the test relies on "set mi-async off". Could you make sure that
if you run it against a board file that forces that on, the test either
passes (probably with -exec-interrupt in async mode) or is skipped?
See mi_detect_async and the async global.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2016-05-03 21:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-03 20:00 Simon Marchi
2016-05-03 21:57 ` Pedro Alves [this message]
2016-05-03 21:59 ` Pedro Alves
2016-05-03 22:04 ` Pedro Alves
2016-05-04 9:20 ` Pedro Alves
2016-05-04 18:04 ` Simon Marchi
2016-05-04 19:27 ` Pedro Alves
2016-05-04 14:34 ` Simon Marchi
2016-05-04 15:07 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5983d4d2-016a-8020-c109-cb7ea2cfd179@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@ericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox