aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2008-07-12 17:10:59 +0000
committerVladimir Prus <vladimir@codesourcery.com>2008-07-12 17:10:59 +0000
commit77ebaa5ad37ca5888bf33444e85dd8140ffed695 (patch)
treeec53a5079de2dc4f43be7076d0333c6818dfbf87
parent1e92afda99a58f4427293937e49ef1ebe6bb3968 (diff)
downloadgdb-77ebaa5ad37ca5888bf33444e85dd8140ffed695.zip
gdb-77ebaa5ad37ca5888bf33444e85dd8140ffed695.tar.gz
gdb-77ebaa5ad37ca5888bf33444e85dd8140ffed695.tar.bz2
Implement -exec-continue/-exec-interrupt --all.
* 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.
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/infcmd.c65
-rw-r--r--gdb/inferior.h4
-rw-r--r--gdb/mi/mi-main.c26
4 files changed, 74 insertions, 32 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d8b3e0b..a5ba536 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
2008-07-12 Vladimir Prus <vladimir@codesourcery.com>
+ Implement -exec-continue/-exec-interrupt --all.
+ * 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.
+
+2008-07-12 Vladimir Prus <vladimir@codesourcery.com>
+
Implement --thread and --frame.
* gdbthread.h (find_thread_id): Declare.
* thread.c (find_thread_id): Make non-static.
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index f5fd018..0a40564 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -620,6 +620,31 @@ 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 if the current thread is running, because
+ there may be other stopped threads. */
+ struct cleanup *old_chain;
+
+ /* Backup current thread and selected frame. */
+ old_chain = make_cleanup_restore_current_thread ();
+
+ iterate_over_threads (proceed_thread_callback, NULL);
+
+ /* Restore selected ptid. */
+ do_cleanups (old_chain);
+ }
+ 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)
@@ -694,26 +719,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. */
- struct cleanup *old_chain;
-
- /* Backup current thread and selected frame. */
- old_chain = make_cleanup_restore_current_thread ();
-
- iterate_over_threads (proceed_thread_callback, NULL);
-
- /* Restore selected ptid. */
- do_cleanups (old_chain);
- }
- 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. */
@@ -2146,6 +2152,17 @@ disconnect_command (char *args, int from_tty)
deprecated_detach_hook ();
}
+void
+interrupt_target_1 (int all_threads)
+{
+ ptid_t ptid;
+ if (all_threads)
+ ptid = minus_one_ptid;
+ else
+ ptid = inferior_ptid;
+ target_stop (ptid);
+}
+
/* 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
@@ -2157,7 +2174,6 @@ interrupt_target_command (char *args, int from_tty)
{
if (target_can_async_p ())
{
- ptid_t ptid;
int all_threads = 0;
dont_repeat (); /* Not for the faint of heart */
@@ -2169,12 +2185,7 @@ interrupt_target_command (char *args, int from_tty)
if (!non_stop && all_threads)
error (_("-a is meaningless in all-stop mode."));
- if (all_threads)
- ptid = minus_one_ptid;
- else
- ptid = inferior_ptid;
-
- target_stop (ptid);
+ interrupt_target_1 (all_threads);
}
}
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 60d0352..f53af8b 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 f829a93..43f3a5f 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -163,8 +163,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
@@ -175,10 +179,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