From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 313 invoked by alias); 19 Jul 2011 20:55:18 -0000 Received: (qmail 305 invoked by uid 22791); 19 Jul 2011 20:55:18 -0000 X-SWARE-Spam-Status: No, hits=-7.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS 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; Tue, 19 Jul 2011 20:55:03 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6JKt3bD026258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Jul 2011 16:55:03 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6JKt2gj015104; Tue, 19 Jul 2011 16:55:02 -0400 Received: from barimba (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 p6JKt1kK011482; Tue, 19 Jul 2011 16:55:01 -0400 From: Tom Tromey To: pmuldoon@redhat.com Cc: gdb-patches@sourceware.org Subject: Re: [patch] [python] Prompt substitution References: Date: Tue, 19 Jul 2011 22:58:00 -0000 In-Reply-To: (Phil Muldoon's message of "Mon, 18 Jul 2011 16:45:51 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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-07/txt/msg00499.txt.bz2 >>>>> "Phil" == Phil Muldoon writes: Phil> +@findex gdb.get_current_prompt Phil> +@defun get_current_prompt Phil> +Return the current @value{GDBN} prompt as a string. Phil> +@end defun Is this different from gdb.parameter('prompt')? Phil> +@findex gdb.set_current_prompt Phil> +@defun set_current_prompt @r{[}new_prompt@r{]} Phil> +Sets the @value{GDBN} prompt to @var{new_prompt}. @var{new_prompt} Phil> +must be a string. This method has no return value. Phil> +@end defun I'm on the fence about this. It would probably be better to have a general facility for setting parameters. Phil> +@defop Operation {@value{GDBN}} prompt_hook [current_prompt] Phil> +If @var{prompt_hook} exists, and is not set to @code{None}, ... really if it is callable. Phil> +The parameter @code{current_prompt} contains the current @value{GDBN} Phil> +prompt. If the parameter is not optional, then it should not be surrounded in [] in the @defop. Phil> + observer_notify_before_prompt (pre_gdb_prompt); Phil> + post_gdb_prompt = get_prompt (); Phil> + Phil> + /* If the observer changed the prompt, use that prompt overriding Phil> + any new_prompt that was passed to this function. */ Phil> + if (strcmp (pre_gdb_prompt, post_gdb_prompt) != 0) Suppose an observer sets the prompt. Won't this free the memory pointed to by pre_gdb_prompt? Thus making this strcmp access invalid memory? Phil> + if (current_gdb_prompt == NULL) Phil> + { When can this happen? Phil> + current_prompt = PyString_FromString (current_gdb_prompt); Extra space after the '='. Phil> + if ((result != Py_None) && (! PyString_Check (result))) Too many parens. Phil> + const char *prompt = get_prompt (); Phil> + if (prompt) Phil> + return PyString_FromString (prompt); Likewise about whether this can happen. Phil> + { "flush", (PyCFunction)gdbpy_flush, METH_VARARGS | METH_KEYWORDS, Phil> + "Flush gdb's filtered stdout stream." }, This is already in the code and shouldn't be in this patch. Phil> + PROMPT (0) = xstrdup (s); Extra space. Tom