From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22660 invoked by alias); 31 Aug 2010 18:33:26 -0000 Received: (qmail 22651 invoked by uid 22791); 31 Aug 2010 18:33:25 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD 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; Tue, 31 Aug 2010 18:33:20 +0000 Received: from mailhost4.vmware.com (mailhost4.vmware.com [10.16.67.124]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id AE2085800B; Tue, 31 Aug 2010 11:33:17 -0700 (PDT) Received: from msnyder-server.eng.vmware.com (promd-2s-dhcp138.eng.vmware.com [10.20.124.138]) by mailhost4.vmware.com (Postfix) with ESMTP id A41B4C9B8B; Tue, 31 Aug 2010 11:33:17 -0700 (PDT) Message-ID: <4C7D4AED.1090000@vmware.com> Date: Tue, 31 Aug 2010 18:33:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.24 (X11/20100702) MIME-Version: 1.0 To: Pedro Alves CC: "gdb@sourceware.org" , Marc Khouzam Subject: Re: Different output from -gdb-show than show References: <201008311629.12479.pedro@codesourcery.com> In-Reply-To: <201008311629.12479.pedro@codesourcery.com> Content-Type: multipart/mixed; boundary="------------040206030504060600040402" X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-08/txt/msg00175.txt.bz2 This is a multi-part message in MIME format. --------------040206030504060600040402 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2769 Pedro Alves wrote: > On Tuesday 31 August 2010 16:02:39, Marc Khouzam wrote: >> Hi, >> >> while looking for a way know if a target supports reverse execution >> I noticed this: >> >>> gdb.7.2 -i mi testing/a.out >> (gdb) start >> (gdb) -gdb-set exec-direction reverse >> ^done >> (gdb) -gdb-show exec-direction >> ^done,value="reverse" >> (gdb) show exec-direction >> &"show exec-direction\n" >> ~"Forward.\n" >> ^done >> >> For some reason, -gdb-show is giving a different result than CLI show. >> For my "does target support reverse" case, I will be forced to use 'show'. >> >> Bug? > > Yes. Here in infrun.c: > >> /* User interface for reverse debugging: >> Set exec-direction / show exec-direction commands >> (returns error unless target implements to_set_exec_direction method). */ >> >> enum exec_direction_kind execution_direction = EXEC_FORWARD; >> static const char exec_forward[] = "forward"; >> static const char exec_reverse[] = "reverse"; >> static const char *exec_direction = exec_forward; >> static const char *exec_direction_names[] = { >> exec_forward, >> exec_reverse, >> NULL >> }; >> >> >> static void >> set_exec_direction_func (char *args, int from_tty, >> struct cmd_list_element *cmd) >> { >> if (target_can_execute_reverse) >> { >> if (!strcmp (exec_direction, exec_forward)) >> execution_direction = EXEC_FORWARD; >> else if (!strcmp (exec_direction, exec_reverse)) >> execution_direction = EXEC_REVERSE; >> } >> } >> > > The above does not complain if target_can_execute_reverse is false, contrary > to what the comment above says. > Leaves exec_direction and execution_direction out of sync in that case. > (your case, because you haven't started the process yet, you're debugging > the executable, which can't do reverse debugging) > >> static void >> show_exec_direction_func (struct ui_file *out, int from_tty, >> struct cmd_list_element *cmd, const char *value) >> { >> switch (execution_direction) { >> case EXEC_FORWARD: >> fprintf_filtered (out, _("Forward.\n")); >> break; >> case EXEC_REVERSE: >> fprintf_filtered (out, _("Reverse.\n")); >> break; >> case EXEC_ERROR: >> default: >> fprintf_filtered (out, >> _("Forward (target `%s' does not support exec-direction).\n"), >> target_shortname); >> break; >> } >> } > > "show exec-direction" prints based on execution_direction, while > "-gdb-show exec-direction" prints the raw exec_drection string: > >> add_setshow_enum_cmd ("exec-direction", class_run, exec_direction_names, >> &exec_direction, _("Set direction of execution.\n\ > ^^^^^^^^^^^^^^^ > This is what is used by -gdb-show. --^ > > My bad. Would this be suitable? --------------040206030504060600040402 Content-Type: text/plain; name="infrun.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="infrun.txt" Content-length: 676 2010-08-31 Michael Snyder * infrun.c (set_exec_direction_func): Error out if target does not support reverse execution. Index: infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.445 diff -u -p -r1.445 infrun.c --- infrun.c 1 Jul 2010 15:36:15 -0000 1.445 +++ infrun.c 31 Aug 2010 18:32:36 -0000 @@ -6436,6 +6436,8 @@ set_exec_direction_func (char *args, int else if (!strcmp (exec_direction, exec_reverse)) execution_direction = EXEC_REVERSE; } + else + error (_("Target does not support this operation.")); } static void --------------040206030504060600040402--