This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Include token in ^running notification for CLI commands.
- From: Vladimir Prus <vladimir at codesourcery dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 12 Mar 2009 23:17:07 +0300
- Subject: Include token in ^running notification for CLI commands.
At present, it is possible to specify a token when sending CLI command
to MI, e.g.:
20 continue
but the ^running response does not include this token. The ^running is
synchronous response, sent when we've managed to ask the target to
resume, and is essentially a different spelling of ^done, so should
include token. This patch makes it so. Checked in.
[This patch includes a debug print, which I have accidentally checked in.
This is already fixed by a follow-up patch].
- Volodya
gdb/
* mi/mi-main.c (mi_execute_command): Set current_token here.
(mi_cmd_execute): Do not set current_token here.
gdb/testsuite/
* gdb.mi/mi-cli.exp: Verify that CLI commands that run inferior
include the token in ^running and frame info in *stopped.
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.143
diff -u -p -r1.143 mi-main.c
--- gdb/mi/mi-main.c 12 Mar 2009 19:54:54 -0000 1.143
+++ gdb/mi/mi-main.c 12 Mar 2009 20:07:13 -0000
@@ -1137,11 +1137,15 @@ mi_cmd_list_target_features (char *comma
static void
captured_mi_execute_command (struct ui_out *uiout, void *data)
{
+ struct cleanup *cleanup;
struct mi_parse *context = (struct mi_parse *) data;
if (do_timings)
current_command_ts = context->cmd_start;
+ current_token = xstrdup (context->token);
+ cleanup = make_cleanup (free_current_contents, ¤t_token);
+
running_result_record_printed = 0;
switch (context->op)
{
@@ -1216,6 +1220,8 @@ captured_mi_execute_command (struct ui_o
}
+ do_cleanups (cleanup);
+
return;
}
@@ -1310,10 +1316,9 @@ mi_cmd_execute (struct mi_parse *parse)
{
struct cleanup *cleanup;
int i;
- free_all_values ();
- current_token = xstrdup (parse->token);
- cleanup = make_cleanup (free_current_contents, ¤t_token);
+ free_all_values ();
+ cleanup = make_cleanup (null_cleanup, NULL);
if (parse->frame != -1 && parse->thread == -1)
error (_("Cannot specify --frame without --thread"));
Index: gdb/testsuite/gdb.mi/mi-cli.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-cli.exp,v
retrieving revision 1.16
diff -u -p -r1.16 mi-cli.exp
--- gdb/testsuite/gdb.mi/mi-cli.exp 14 Feb 2009 15:24:43 -0000 1.16
+++ gdb/testsuite/gdb.mi/mi-cli.exp 12 Mar 2009 20:07:15 -0000
@@ -155,8 +155,24 @@ mi_execute_to "exec-continue" "breakpoin
$line_main_hello { "" "disp=\"del\"" } \
"-exec-continue to line $line_main_hello"
-mi_execute_to "exec-next" "end-stepping-range" "main" "" ".*basics.c"
$line_main_return "" \
- "-exec-next to line $line_main_return"
+# Test that the token is output even for CLI commands
+# Also test that *stopped includes frame information.
+mi_gdb_test "34 next" \
+ ".*34\\\^running.*\\*running,thread-id=\"all\"" \
+ "34 next: run"
+
+gdb_expect {
+ -re "~\[^\r\n\]+\r\n" {
+ verbose -log "Hi there"
+ }
+}
+
+# Note that the output does not include stop reason. This is fine.
+# The purpose of *stopped notification for CLI command is to make
+# sure that frontend knows that inferior is stopped, and knows where.
+# Supplementary information is not necessary.
+mi_expect_stop "" "main" "" ".*basics.c" $line_main_return "" \
+ "34 next: stop"
mi_gdb_test "-interpreter-exec console \"list\"" \
"\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \