From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21156 invoked by alias); 28 Jun 2008 16:46:01 -0000 Received: (qmail 21143 invoked by uid 22791); 28 Jun 2008 16:46:00 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 28 Jun 2008 16:45:42 +0000 Received: (qmail 10150 invoked from network); 28 Jun 2008 16:45:41 -0000 Received: from unknown (HELO 172.16.unknown.plus.ru) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 28 Jun 2008 16:45:41 -0000 From: Vladimir Prus Date: Sat, 28 Jun 2008 16:56:00 -0000 Subject: [MI non-stop 05/11, RFA] -exec-continue/-exec-interrupt --all To: gdb-patches@sources.redhat.com X-TUID: 17cfe3aefec44b2a X-Length: 5087 X-UID: 264 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200806282045.39438.vladimir@codesourcery.com> 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 X-SW-Source: 2008-06/txt/msg00544.txt.bz2 Per MI non-stop spec, continue and interrupt need --all option to resume every thread. Implemented thusly. OK? - Volodya * infcmd.c (continue_1): New, extracted from (continue_command): ...here. (interrupt_target_1): New, extracted from (interrupt_target_command): ...here. * inferior.h (continue_1, interrupt_target_1): New. * mi/mi-main.c (mi_cmd_exec_continue) (mi_cmd_exec_interrupt): Handle --all. --- gdb/infcmd.c | 58 ++++++++++++++++++++++++++++++++--------------------- gdb/inferior.h | 4 +++ gdb/mi/mi-main.c | 26 +++++++++++++++++++---- 3 files changed, 60 insertions(+), 28 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index ae3668f..6ec458c 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -625,6 +625,21 @@ proceed_thread_callback (struct thread_info *thread, void *arg) return 0; } +void +continue_1 (int all_threads) +{ + if (non_stop && all_threads) + /* Don't error out current thread is running, because there may + be other stopped threads. */ + iterate_over_threads (proceed_thread_callback, NULL); + else + { + ensure_not_running (); + clear_proceed_status (); + proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); + } +} + /* continue [-a] [proceed-count] [&] */ void continue_command (char *args, int from_tty) @@ -699,16 +714,7 @@ Can't resume all threads and specify proceed count simultaneously.")); if (from_tty) printf_filtered (_("Continuing.\n")); - if (non_stop && all_threads) - /* Don't error out if the current thread is running, because - there may be other stopped threads. */ - iterate_over_threads (proceed_thread_callback, NULL); - else - { - ensure_not_running (); - clear_proceed_status (); - proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); - } + continue_1 (all_threads); } /* Step until outside of current statement. */ @@ -2148,6 +2154,24 @@ disconnect_command (char *args, int from_tty) deprecated_detach_hook (); } +void +interrupt_target_1 (int all_threads) +{ + if (non_stop) + { + ptid_t ptid; + + if (all_threads) + ptid = minus_one_ptid; + else + ptid = inferior_ptid; + + target_stop_ptid (ptid); + } + else + target_stop (); +} + /* Stop the execution of the target while running in async mode, in the backgound. In all-stop, stop the whole process. In non-stop mode, stop the current thread only by default, or stop all threads @@ -2170,19 +2194,7 @@ interrupt_target_command (char *args, int from_tty) if (!non_stop && all_threads) error (_("-a is meaningless in all-stop mode.")); - if (non_stop) - { - ptid_t ptid; - - if (all_threads) - ptid = minus_one_ptid; - else - ptid = inferior_ptid; - - target_stop_ptid (ptid); - } - else - target_stop (); + interrupt_target_1 (all_threads); } } diff --git a/gdb/inferior.h b/gdb/inferior.h index f4c6b83..d0067ce 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -271,10 +271,14 @@ extern void nexti_command (char *, int); extern void stepi_command (char *, int); +extern void continue_1 (int all_threads); + extern void continue_command (char *, int); extern void interrupt_target_command (char *args, int from_tty); +extern void interrupt_target_1 (int all_threads); + /* Last signal that the inferior received (why it stopped). */ extern enum target_signal stop_signal; diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 61ef5a4..87c3257 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -177,8 +177,12 @@ mi_cmd_exec_return (char *command, char **argv, int argc) void mi_cmd_exec_continue (char *command, char **argv, int argc) { - /* FIXME: Should call a libgdb function, not a cli wrapper. */ - return mi_execute_async_cli_command ("continue", argv, argc); + if (argc == 0) + continue_1 (0); + else if (argc == 1 && strcmp (argv[0], "--all") == 0) + continue_1 (1); + else + error ("Usage: -exec-continue [--all]"); } /* Interrupt the execution of the target. Note how we must play around @@ -189,10 +193,22 @@ mi_cmd_exec_continue (char *command, char **argv, int argc) void mi_cmd_exec_interrupt (char *command, char **argv, int argc) { - if (!is_running (inferior_ptid)) - error ("mi_cmd_exec_interrupt: Inferior not running."); + if (argc == 0) + { + if (!is_running (inferior_ptid)) + error ("Current thread is not running."); - interrupt_target_command (NULL, 0); + interrupt_target_1 (0); + } + else if (argc == 1 && strcmp (argv[0], "--all") == 0) + { + if (!any_running ()) + error ("Inferior not running."); + + interrupt_target_1 (1); + } + else + error ("Usage: -exec-interrupt [--all]"); } void -- 1.5.3.5