aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2008-03-14 18:57:44 +0000
committerVladimir Prus <vladimir@codesourcery.com>2008-03-14 18:57:44 +0000
commit32c1e744c108afe9bebd41766ab3025279878f85 (patch)
treeb2753a1c815eb9b5c2cca33ec36afe7ebcebf560 /gdb/top.c
parentc04ea773f9e9764a17382e6c1e0cf5a8d24df67a (diff)
downloadgdb-32c1e744c108afe9bebd41766ab3025279878f85.zip
gdb-32c1e744c108afe9bebd41766ab3025279878f85.tar.gz
gdb-32c1e744c108afe9bebd41766ab3025279878f85.tar.bz2
Async mode fixes.
* Makefile.in (infcmd.o, inf-loop.o): Update dependencies. * breakpoint.c (bpstat_do_actions): In async mode, don't jump to top expecting stop_bpstat to be already updated. * event-loop.c (start_event_loop): Call async_enable_stdin on exception. * event-top.c (async_enable_stdin): Do nothing if sync_execution is not set. (command_handler): Do not setup continuation here. (command_line_handler_continuation): Move to... * top.c (command_line_handler_continuation): ... here. (execute_command): In async mode, register continuation. Don't check frame's language in running in async mode. * exceptions.c (throw_exception): Don't do exec_error_cleanups. * inf-loop.c (complete_execution): Inline into... (inferior_event_handler): ... here. Clear target_executing before doing any cleanups. Don't try to show prompt if the target was resumed. * infcmd.c (signal_command): Add support for async mode. (finish_command): Only add continuation if the target was successfully resumed. * remote.c (init_async_opts): Register to_get_thread_local_address handler. * mi/mi-interp.c (mi_cmd_interpreter_exec): Don't mess with sync_execution. * tui/tui-interp.c (tui_command_loop): Call async_enable_stdin on exception.
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c77
1 files changed, 76 insertions, 1 deletions
diff --git a/gdb/top.c b/gdb/top.c
index c205ec3..3b9aaab 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -364,6 +364,42 @@ do_chdir_cleanup (void *old_dir)
}
#endif
+/* Do any commands attached to breakpoint we stopped at. Only if we
+ are always running synchronously. Or if we have just executed a
+ command that doesn't start the target. */
+static void
+command_line_handler_continuation (struct continuation_arg *arg)
+{
+ extern int display_time;
+ extern int display_space;
+
+ long time_at_cmd_start = arg->data.longint;
+ long space_at_cmd_start = arg->next->data.longint;
+
+ bpstat_do_actions (&stop_bpstat);
+
+ if (display_time)
+ {
+ long cmd_time = get_run_time () - time_at_cmd_start;
+
+ printf_unfiltered (_("Command execution time: %ld.%06ld\n"),
+ cmd_time / 1000000, cmd_time % 1000000);
+ }
+ if (display_space)
+ {
+#ifdef HAVE_SBRK
+ char *lim = (char *) sbrk (0);
+ long space_now = lim - lim_at_start;
+ long space_diff = space_now - space_at_cmd_start;
+
+ printf_unfiltered (_("Space used: %ld (%c%ld for this command)\n"),
+ space_now,
+ (space_diff >= 0 ? '+' : '-'),
+ space_diff);
+#endif
+ }
+}
+
/* Execute the line P as a command.
Pass FROM_TTY as second argument to the defining function. */
@@ -374,6 +410,27 @@ execute_command (char *p, int from_tty)
enum language flang;
static int warned = 0;
char *line;
+ struct continuation_arg *arg1;
+ struct continuation_arg *arg2;
+ long time_at_cmd_start;
+#ifdef HAVE_SBRK
+ long space_at_cmd_start = 0;
+#endif
+ extern int display_time;
+ extern int display_space;
+
+ if (target_can_async_p ())
+ {
+ time_at_cmd_start = get_run_time ();
+
+ if (display_space)
+ {
+#ifdef HAVE_SBRK
+ char *lim = (char *) sbrk (0);
+ space_at_cmd_start = lim - lim_at_start;
+#endif
+ }
+ }
free_all_values ();
@@ -470,7 +527,7 @@ execute_command (char *p, int from_tty)
/* FIXME: This should be cacheing the frame and only running when
the frame changes. */
- if (target_has_stack)
+ if (!target_executing && target_has_stack)
{
flang = get_frame_language ();
if (!warned
@@ -481,6 +538,24 @@ execute_command (char *p, int from_tty)
warned = 1;
}
}
+
+ /* Set things up for this function to be compete later, once the
+ execution has completed, if we are doing an execution command,
+ otherwise, just go ahead and finish. */
+ if (target_can_async_p () && target_executing)
+ {
+ arg1 =
+ (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
+ arg2 =
+ (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
+ arg1->next = arg2;
+ arg2->next = NULL;
+ arg1->data.longint = time_at_cmd_start;
+#ifdef HAVE_SBRK
+ arg2->data.longint = space_at_cmd_start;
+#endif
+ add_continuation (command_line_handler_continuation, arg1);
+ }
}
/* Read commands from `instream' and execute them