From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16984 invoked by alias); 12 Feb 2010 21:33:57 -0000 Received: (qmail 16965 invoked by uid 22791); 12 Feb 2010 21:33:56 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Feb 2010 21:33:52 +0000 Received: from jupiter.vmware.com (mailhost5.vmware.com [10.16.68.131]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 6242D23006; Fri, 12 Feb 2010 13:33:50 -0800 (PST) Received: from [10.20.124.101] (promd-2s-dhcp101.eng.vmware.com [10.20.124.101]) by jupiter.vmware.com (Postfix) with ESMTP id 9E6C9DC4F7; Fri, 12 Feb 2010 13:33:47 -0800 (PST) Message-ID: <4B75C938.1000806@vmware.com> Date: Fri, 12 Feb 2010 21:33:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.22 (X11/20090609) MIME-Version: 1.0 To: Michael Snyder CC: Jakob Engblom , 'Vladimir Prus' , "gdb-patches@sourceware.org" , 'Hui Zhu' Subject: Re: GDB MI Reverse Commands added [1 of 3] References: <00ce01ca265a$ccb66ca0$662345e0$@com> <200912161056.58856.vladimir@codesourcery.com> <008f01ca7f26$d9e97140$8dbc53c0$@com> <200912211305.55412.vladimir@codesourcery.com> <00af01ca82fa$a8b74b60$fa25e220$@com> <4B310DBD.5000700@vmware.com> In-Reply-To: <4B310DBD.5000700@vmware.com> Content-Type: multipart/mixed; boundary="------------030403030308020505030305" 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: 2010-02/txt/msg00327.txt.bz2 This is a multi-part message in MIME format. --------------030403030308020505030305 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 58 per private email from Volodya, checked in as follows: --------------030403030308020505030305 Content-Type: text/plain; name="main.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="main.txt" Content-length: 4150 2010-02-12 Tomas Holmberg * mi/mi-main.c: Added the --reverse flag to the following MI commands: exec-continue, exec-finish, exec-next, exec-step, exec-next-instruction, exec-step-instruction. This is to support reverse execution over the MI interface to gdb. Index: mi/mi-main.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-main.c,v retrieving revision 1.164 retrieving revision 1.165 diff -u -p -r1.164 -r1.165 --- mi/mi-main.c 4 Feb 2010 07:37:36 -0000 1.164 +++ mi/mi-main.c 12 Feb 2010 21:28:25 -0000 1.165 @@ -121,35 +121,50 @@ void mi_cmd_exec_next (char *command, char **argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ - mi_execute_async_cli_command ("next", argv, argc); + if (argc > 0 && strcmp(argv[0], "--reverse") == 0) + mi_execute_async_cli_command ("reverse-next", argv + 1, argc - 1); + else + mi_execute_async_cli_command ("next", argv, argc); } void mi_cmd_exec_next_instruction (char *command, char **argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ - mi_execute_async_cli_command ("nexti", argv, argc); + if (argc > 0 && strcmp(argv[0], "--reverse") == 0) + mi_execute_async_cli_command ("reverse-nexti", argv + 1, argc - 1); + else + mi_execute_async_cli_command ("nexti", argv, argc); } void mi_cmd_exec_step (char *command, char **argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ - mi_execute_async_cli_command ("step", argv, argc); + 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); } void mi_cmd_exec_step_instruction (char *command, char **argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ - mi_execute_async_cli_command ("stepi", argv, argc); + if (argc > 0 && strcmp(argv[0], "--reverse") == 0) + mi_execute_async_cli_command ("reverse-stepi", argv + 1, argc - 1); + else + mi_execute_async_cli_command ("stepi", argv, argc); } void mi_cmd_exec_finish (char *command, char **argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ - mi_execute_async_cli_command ("finish", argv, argc); + if (argc > 0 && strcmp(argv[0], "--reverse") == 0) + mi_execute_async_cli_command ("reverse-finish", argv + 1, argc - 1); + else + mi_execute_async_cli_command ("finish", argv, argc); } void @@ -195,8 +210,8 @@ proceed_thread_callback (struct thread_i return 0; } -void -mi_cmd_exec_continue (char *command, char **argv, int argc) +static void +exec_continue (char **argv, int argc) { if (argc == 0) continue_1 (0); @@ -217,7 +232,47 @@ mi_cmd_exec_continue (char *command, cha do_cleanups (old_chain); } else - error ("Usage: -exec-continue [--all|--thread-group id]"); + 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); } static int --------------030403030308020505030305--