From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4654 invoked by alias); 28 Jan 2011 17:11:52 -0000 Received: (qmail 4634 invoked by uid 22791); 28 Jan 2011 17:11:51 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 Jan 2011 17:11:45 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0SHBhkK011809 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 Jan 2011 12:11:44 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0SHBhUi005833; Fri, 28 Jan 2011 12:11:43 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p0SHBgaM026709; Fri, 28 Jan 2011 12:11:43 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 87DAB3784E2; Fri, 28 Jan 2011 10:11:42 -0700 (MST) From: Tom Tromey To: gdb-patches@sourceware.org Subject: FYI: fix PR python/12216 Date: Fri, 28 Jan 2011 17:48:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2011-01/txt/msg00556.txt.bz2 I plan to check this in. This fixes PR 12216. The bug is that invoking a non-repeatable command via gdb.execute will cause the current command to act as if dont_repeat was called directly. This is undesirable; a command should control its own repeatability. Since global state is already involved, I took the straightforward approach of more global state. Built and regtested on x86-64 (compile farm). Tom 2011-01-25 Tom Tromey PR python/12216: * python/python.c (execute_gdb_command): Call prevent_dont_repeat. * top.c (suppress_dont_repeat): New global. (dont_repeat): Use it. (prevent_dont_repeat): New function. * command.h (prevent_dont_repeat): Declare. diff --git a/gdb/command.h b/gdb/command.h index f53cc80..d2f5ca5 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -355,6 +355,8 @@ extern void error_no_arg (char *) ATTRIBUTE_NORETURN; extern void dont_repeat (void); +extern struct cleanup *prevent_dont_repeat (void); + /* Used to mark commands that don't do anything. If we just leave the function field NULL, the command is interpreted as a help topic, or as a class of commands. */ diff --git a/gdb/python/python.c b/gdb/python/python.c index 134e730..b2ee8f9 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -375,6 +375,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) char *copy = xstrdup (arg); struct cleanup *cleanup = make_cleanup (xfree, copy); + prevent_dont_repeat (); if (to_string) result = execute_command_to_string (copy, from_tty); else diff --git a/gdb/top.c b/gdb/top.c index bba1a2d..9ca855d 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -546,12 +546,17 @@ command_loop (void) } } +/* When nonzero, cause dont_repeat to do nothing. This should only be + set via prevent_dont_repeat. */ + +static int suppress_dont_repeat = 0; + /* Commands call this if they do not want to be repeated by null lines. */ void dont_repeat (void) { - if (server_command) + if (suppress_dont_repeat || server_command) return; /* If we aren't reading from standard input, we are saving the last @@ -560,6 +565,19 @@ dont_repeat (void) if (instream == stdin) *line = 0; } + +/* Prevent dont_repeat from working, and return a cleanup that + restores the previous state. */ + +struct cleanup * +prevent_dont_repeat (void) +{ + struct cleanup *result = make_cleanup_restore_integer (&suppress_dont_repeat); + + suppress_dont_repeat = 1; + return result; +} + /* Read a line from the stream "instream" without command line editing.