From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65183 invoked by alias); 3 Mar 2015 21:45:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 65174 invoked by uid 89); 3 Mar 2015 21:45:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 03 Mar 2015 21:45:55 +0000 Received: from EUSAAHC002.ericsson.se (Unknown_Domain [147.117.188.78]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id 77.D8.19660.CBAC5F45; Tue, 3 Mar 2015 15:52:44 +0100 (CET) Received: from elxcz23q12-y4.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.78) with Microsoft SMTP Server (TLS) id 14.3.210.2; Tue, 3 Mar 2015 16:45:52 -0500 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH] mi_async_p: Use the default run target (PR gdb/18077) Date: Tue, 03 Mar 2015 21:45:00 -0000 Message-ID: <1425419133-7843-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00110.txt.bz2 When using -exec-run in mi-async mode on a fresh gdb launch, we can see that it is not actually done asynchronously. The problem is that when we issue -exec-run, the linux native target is not pushed yet. So when the code in mi_cmd_exec-run checks if we support async (by calling mi_async_p), tdefault_can_async_p from the dummy target answers 0. I am not certain of the conceptual correctness of this solution, but it seems to work. It changes mi_async_p so that it uses find_run_target() instead of using the current_target. When -exec-run is used before the native target is pushed, mi_async_p will now report that the target that will eventually be used for running supports async, instead of saying that the current target (dummy) does not. I added a small testcase that I copied from mi-async.exp. Please indicate if you think it should be integrated to an existing test rather than in a new test. I have two questions regarding the test: - Why do we have mi_expect_stop and mi_expect_interrupt? It seems like the functionality of _interrupt could be integrated in _stop. - The signal reported when interrupting a thread changes when in non-stop vs all-stop: non-stop: *stopped,reason="signal-received",signal-name="0",signal-meaning="Signal 0",.. all-stop: *stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",... As a consequence, mi_expect_interrupt only works with non-stop. gdb/ChangeLog: * mi/mi-main.c (mi_async_p): Use find_run_target to check for async support. gdb/testsuite/ChangeLog: * gdb.mi/mi-async-run.c: New file. * gdb.mi/mi-async-run.exp: New file. --- gdb/mi/mi-main.c | 9 +++++- gdb/testsuite/gdb.mi/mi-async-run.c | 30 ++++++++++++++++++ gdb/testsuite/gdb.mi/mi-async-run.exp | 60 +++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.mi/mi-async-run.c create mode 100644 gdb/testsuite/gdb.mi/mi-async-run.exp diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 7412f7d..c296bf3 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -140,7 +140,14 @@ show_mi_async_command (struct ui_file *file, int from_tty, int mi_async_p (void) { - return mi_async && target_can_async_p (); + struct target_ops *ops; + + if (!mi_async) + return 0; + + ops = find_run_target (); + gdb_assert (ops != NULL); + return ops->to_can_async_p (ops); } /* Command implementations. FIXME: Is this libgdb? No. This is the MI diff --git a/gdb/testsuite/gdb.mi/mi-async-run.c b/gdb/testsuite/gdb.mi/mi-async-run.c new file mode 100644 index 0000000..760e7e6 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-async-run.c @@ -0,0 +1,30 @@ +/* Copyright 2015 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +int main () +{ + int i; + + for (i = 0; i < 30; i++) + { + sleep (1); + } + + return 0; +} diff --git a/gdb/testsuite/gdb.mi/mi-async-run.exp b/gdb/testsuite/gdb.mi/mi-async-run.exp new file mode 100644 index 0000000..c1bbbcc --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-async-run.exp @@ -0,0 +1,60 @@ +# Copyright 2015 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# The purpose of this test if to verify that -exec-run with mi-async on +# results in asynchronous execution (PR 18077). + +# The plan is for async mode to become the default but toggle for now. +set saved_gdbflags $GDBFLAGS +set GDBFLAGS [concat $GDBFLAGS " -ex \"set mi-async on\""] + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +standard_testfile + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested mi-async.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +# Necessary for mi_expect_interrupt to work, as the reported signal is not the +# same in all-stop. +mi_gdb_test "-gdb-set non-stop 1" ".*" + +proc linux_async_run_test {} { + global mi_gdb_prompt + global hex + + mi_run_cmd + mi_gdb_test "123-exec-interrupt --all" "123\\^done" "send interrupt command" + mi_expect_interrupt "expect interrupt" +} + +linux_async_run_test + +mi_gdb_exit + +set GDBFLAGS $saved_gdbflags + +return 0 -- 2.1.4