From: "Jakob Engblom" <jakob@virtutech.com>
To: "'Michael Snyder'" <msnyder@vmware.com>
Cc: "'Vladimir Prus'" <vladimir@codesourcery.com>,
<gdb-patches@sourceware.org>, "'Hui Zhu'" <teawater@gmail.com>
Subject: RE: GDB MI Reverse Commands added [1 of 3]
Date: Wed, 13 Jan 2010 13:16:00 -0000 [thread overview]
Message-ID: <00e501ca9452$9b47e610$d1d7b230$@com> (raw)
In-Reply-To: <4B310DBD.5000700@vmware.com>
I am now on parental leave, really, but I just gave it a try to try to get the
MI reverse commands fixed. In particular, making them compatible with gdb7. We
have an internal version at VT that does that, but that also contains the
offending piece of code that is duplicated from reverse.c.
In our code, and in the submitted patches, in mi-main.c, we have:
----
static void
exec_continue (char **argv, int argc)
{
if (argc == 0)
continue_1 (0);
else if (argc == 1 && strcmp (argv[0], "--all") == 0)
continue_1 (1);
else if (argc == 2 && strcmp (argv[0], "--thread-group") == 0)
{
struct cleanup *old_chain;
int pid;
if (argv[1] == NULL || argv[1] == '\0')
error ("Thread group id not specified");
pid = atoi (argv[1]);
if (!in_inferior_list (pid))
error ("Invalid thread group id '%s'", argv[1]);
old_chain = make_cleanup_restore_current_thread ();
iterate_over_threads (proceed_thread_callback, &pid);
do_cleanups (old_chain);
}
else
error ("Usage: -exec-continue [--reverse] [--all|--thread-group id]");
}
/* continue in reverse direction:
XXX: code duplicated from reverse.c */
static void
exec_direction_default (void *notused)
{
/* Return execution direction to default state. */
execution_direction = EXEC_FORWARD;
}
static void
exec_reverse_continue (char **argv, int argc)
{
enum exec_direction_kind dir = execution_direction;
struct cleanup *old_chain;
if (dir == EXEC_ERROR)
error (_("Target %s does not support this command."), target_shortname);
if (dir == EXEC_REVERSE)
error (_("Already in reverse mode."));
if (!target_can_execute_reverse)
error (_("Target %s does not support this command."), target_shortname);
old_chain = make_cleanup (exec_direction_default, NULL);
execution_direction = EXEC_REVERSE;
exec_continue (argv, argc);
do_cleanups (old_chain);
}
void
mi_cmd_exec_continue (char *command, char **argv, int argc)
{
if (argc > 0 && strcmp(argv[0], "--reverse") == 0)
exec_reverse_continue (argv + 1, argc - 1);
else
exec_continue (argv, argc);
}
----
This code is much more complex than for the other MI reverse commands, where the
logic is very simple:
----
void
mi_cmd_exec_step (char *command, char **argv, int argc)
{
/* FIXME: Should call a libgdb function, not a cli wrapper. */
if (argc > 0 && strcmp(argv[0], "--reverse") == 0)
mi_execute_async_cli_command ("reverse-step", argv + 1, argc - 1);
else
mi_execute_async_cli_command ("step", argv, argc);
}
----
To me, it is not clear why MI has to do such a special thing with the "continue"
command at all. I assume there is a good reason for having the management of
-all and -thread-group inside the MI code?
Note that the standard gdb7 non-reversible MI does this for the continue
command:
----
void
mi_cmd_exec_continue (char *command, char **argv, int argc)
{
if (argc == 0)
continue_1 (0);
else if (argc == 1 && strcmp (argv[0], "--all") == 0)
continue_1 (1);
else if (argc == 2 && strcmp (argv[0], "--thread-group") == 0)
{
struct cleanup *old_chain;
int pid;
if (argv[1] == NULL || argv[1] == '\0')
error ("Thread group id not specified");
pid = atoi (argv[1]);
if (!in_inferior_list (pid))
error ("Invalid thread group id '%s'", argv[1]);
old_chain = make_cleanup_restore_current_thread ();
iterate_over_threads (proceed_thread_callback, &pid);
do_cleanups (old_chain);
}
else
error ("Usage: -exec-continue [--reverse] [--all|--thread-group id]");
}
----
Given this, the safest thing to do appears to be to maintain the current special
handling for reverse continue. This works as a wrapper around the core code
from mi_cmd_exec_continue, with an additional setting of direction before
calling it.
/jakob
next prev parent reply other threads:[~2010-01-13 13:16 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-26 14:38 Jakob Engblom
2009-08-27 1:13 ` Michael Snyder
2009-08-31 13:26 ` Jakob Engblom
2009-08-31 19:56 ` Michael Snyder
2009-09-01 6:37 ` Jakob Engblom
2009-09-01 19:08 ` Michael Snyder
2009-08-27 2:06 ` Michael Snyder
2009-08-31 13:15 ` Jakob Engblom
2009-08-31 20:29 ` Tom Tromey
2009-09-02 8:16 ` Vladimir Prus
2009-09-10 21:09 ` Michael Snyder
2009-09-10 21:10 ` Michael Snyder
2010-01-13 20:32 ` Jakob Engblom
2010-01-13 20:36 ` Vladimir Prus
2010-01-13 20:44 ` Michael Snyder
2009-12-15 19:39 ` Michael Snyder
2009-12-16 7:54 ` Vladimir Prus
2009-12-16 7:57 ` Vladimir Prus
2009-12-17 14:40 ` Jakob Engblom
2009-12-21 10:06 ` Vladimir Prus
2009-12-22 11:34 ` Jakob Engblom
2009-12-22 11:48 ` Vladimir Prus
2010-01-13 13:15 ` Jakob Engblom
2009-12-22 18:22 ` Michael Snyder
2010-01-13 13:16 ` Jakob Engblom [this message]
2010-02-12 21:33 ` Michael Snyder
2009-08-27 3:11 ` Hui Zhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='00e501ca9452$9b47e610$d1d7b230$@com' \
--to=jakob@virtutech.com \
--cc=gdb-patches@sourceware.org \
--cc=msnyder@vmware.com \
--cc=teawater@gmail.com \
--cc=vladimir@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox