From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10122 invoked by alias); 6 May 2008 15:50:07 -0000 Received: (qmail 9939 invoked by uid 22791); 6 May 2008 15:50:05 -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; Tue, 06 May 2008 15:49:48 +0000 Received: (qmail 28475 invoked from network); 6 May 2008 15:49:46 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 6 May 2008 15:49:46 -0000 From: Pedro Alves Subject: [RFC] 09/10 Add "continue --all" Date: Tue, 06 May 2008 18:12:00 -0000 User-Agent: KMail/1.9.9 MIME-Version: 1.0 To: gdb-patches@sourceware.org Content-Type: Multipart/Mixed; boundary="Boundary-00=_e4HII9DAco8lzF9" Message-Id: <200805061649.50105.pedro@codesourcery.com> X-IsSubscribed: yes 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-05/txt/msg00241.txt.bz2 --Boundary-00=_e4HII9DAco8lzF9 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 492 In non-stop mode, exec commands apply only to the current thread. We can add a mechanism to resume all threads. In a frontend perpective, I'm not clear if we should implement -exec-continue --all, -exec-continue --thread="all", or just require the frontend to do the: for each thread in stopped threads resume thread done In CLI, "thread apply all continue&" works too, but it feels to longuish to type? Opinions? Import mi-getopt into common code and use it in CLI? -- Pedro Alves --Boundary-00=_e4HII9DAco8lzF9 Content-Type: text/x-diff; charset="utf-8"; name="009-continue_all.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="009-continue_all.diff" Content-length: 4245 2008-05-06 Pedro Alves * infcmd.c (proceed_thread_callback, do_context_switch_to): New. (continue_command): In non-stop mode, if user passes "--all", resume all running threads. * inferior.h (proceed_ptid): Declare. * infrun.c (proceed_ptid): New. --- gdb/infcmd.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++-------- gdb/inferior.h | 2 + gdb/infrun.c | 9 ++++++++ 3 files changed, 62 insertions(+), 8 deletions(-) Index: src/gdb/infcmd.c =================================================================== --- src.orig/gdb/infcmd.c 2008-05-06 12:15:51.000000000 +0100 +++ src/gdb/infcmd.c 2008-05-06 12:17:35.000000000 +0100 @@ -607,16 +607,37 @@ start_command (char *args, int from_tty) run_command_1 (args, from_tty, 1); } +static int +proceed_thread_callback (struct thread_info *thread, void *arg) +{ + if (is_running (thread->ptid)) + return 0; + if (thread == arg) + return 0; + + proceed_ptid (thread->ptid); + return 0; +} + +static void +do_context_switch_to (void *arg) +{ + ptid_t *ptid = arg; + context_switch_to (*ptid); +} + +/* continue [--all] [proceed count] [&] */ void -continue_command (char *proc_count_exp, int from_tty) +continue_command (char *args, int from_tty) { int async_exec = 0; + int all_threads = 0; ERROR_NO_INFERIOR; ensure_not_running (); /* Find out whether we must run in the background. */ - if (proc_count_exp != NULL) - async_exec = strip_bg_char (&proc_count_exp); + if (args != NULL) + async_exec = strip_bg_char (&args); /* If we must run in the background, but the target can't do it, error out. */ @@ -631,9 +652,20 @@ continue_command (char *proc_count_exp, async_disable_stdin (); } + if (args != NULL) + { + if (strncmp (args, "--all", 5) == 0) + { + all_threads = 1; + args += sizeof ("--all") - 1; + if (*args == '\0') + args = NULL; + } + } + /* If have argument (besides '&'), set proceed count of breakpoint we stopped at. */ - if (proc_count_exp != NULL) + if (args != NULL) { bpstat bs = stop_bpstat; int num, stat; @@ -643,7 +675,7 @@ continue_command (char *proc_count_exp, if (stat > 0) { set_ignore_count (num, - parse_and_eval_long (proc_count_exp) - 1, + parse_and_eval_long (args) - 1, from_tty); /* set_ignore_count prints a message ending with a period. So print two spaces before "Continuing.". */ @@ -662,9 +694,20 @@ continue_command (char *proc_count_exp, if (from_tty) printf_filtered (_("Continuing.\n")); - clear_proceed_status (); - - proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); + if (non_stop && all_threads) + { + ptid_t current_ptid = inferior_ptid; + struct cleanup *old_chain + = make_cleanup (do_context_switch_to, ¤t_ptid); + iterate_over_threads (proceed_thread_callback, NULL); + /* Restore selected ptid. */ + do_cleanups (old_chain); + } + else + { + clear_proceed_status (); + proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); + } } /* Step until outside of current statement. */ Index: src/gdb/inferior.h =================================================================== --- src.orig/gdb/inferior.h 2008-05-06 12:15:51.000000000 +0100 +++ src/gdb/inferior.h 2008-05-06 12:15:55.000000000 +0100 @@ -132,6 +132,8 @@ extern void clear_proceed_status (void); extern void proceed (CORE_ADDR, enum target_signal, int); +extern void proceed_ptid (ptid_t); + extern ptid_t context_switch_to (ptid_t ptid); /* When set, stop the 'step' command if we enter a function which has Index: src/gdb/infrun.c =================================================================== --- src.orig/gdb/infrun.c 2008-05-06 12:15:51.000000000 +0100 +++ src/gdb/infrun.c 2008-05-06 12:15:55.000000000 +0100 @@ -1317,6 +1317,15 @@ proceed (CORE_ADDR addr, enum target_sig normal_stop (); } } + +/* Proceed thread PTID. */ +void +proceed_ptid (ptid_t ptid) +{ + context_switch_to (ptid); + clear_proceed_status (); + proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0); +} /* Start remote-debugging of a machine over a serial link. */ --Boundary-00=_e4HII9DAco8lzF9--