From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2142 invoked by alias); 16 Aug 2011 11:22:23 -0000 Received: (qmail 2129 invoked by uid 22791); 16 Aug 2011 11:22:21 -0000 X-SWARE-Spam-Status: No, hits=-6.9 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, 16 Aug 2011 11:22:07 +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.14.4/8.14.4) with ESMTP id p7GBIJAi018803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 16 Aug 2011 07:18:24 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7GBIH4W016295; Tue, 16 Aug 2011 07:18:18 -0400 From: Phil Muldoon To: Eli Zaretskii Cc: tromey@redhat.com, gdb-patches@sourceware.org Subject: Re: [python] [patch] set/show extended-prompt References: <834o1ivcge.fsf@gnu.org> Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Tue, 16 Aug 2011 11:22:00 -0000 In-Reply-To: <834o1ivcge.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 15 Aug 2011 19:58:25 +0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2011-08/txt/msg00325.txt.bz2 Eli Zaretskii writes: >> +@item \[ >> +Begin a sequence of non-printing characters. >> +@item \] >> +End a sequence of non-printing characters. > > It would be useful to tell something regarding the display of the > non-printing characters themselves, and how to specify them in the > string. > > Thanks. Updated (doc-only) patch. What do you think? Cheers, Phil -- diff --git a/gdb/NEWS b/gdb/NEWS index 089e6ce..255a22e 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -23,6 +23,14 @@ ** A prompt subsitution hook (prompt_hook) is now available to the Python API. + ** A new command set/show extended-prompt has been added. + + ** A new Python module, gdb.prompt has been added to the GDB Python + modules library. This module provides functionality for + escape sequentions in prompts (used by set/show + extended-prompt). These escape sequences are replaced by their + corresponding value. + ** Python commands and convenience-functions located in 'data-directory'/python/gdb/command and 'data-directory'/python/gdb/function are now automatically loaded diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index b477cf3..bdaea3d 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -19620,6 +19620,35 @@ Directs @value{GDBN} to use @var{newprompt} as its prompt string henceforth. Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}} @end table +Versions of @value{GDBN} that ship with Python scripting enabled have +prompt extensions. The commands for interacting with these extensions +are: + +@table @code +@kindex set extended-prompt +@item set extended-prompt @var{prompt} +Set an extended prompt that allows for substitutions. +@xref{gdb.prompt}, for a list of escape sequences that can be used for +substitution. Any escape sequences specified as part of the prompt +string are replaced with the corresponding strings each time the prompt +is displayed. + +For example: + +@smallexample +set extended-prompt Current working directory: \w (gdb) +@end smallexample + +Note that when an extended-prompt is set, it takes control of the +@var{prompt_hook} hook. @xref{prompt_hook}, for further information. + +@kindex show extended-prompt +@item show extended-prompt +Prints the extended prompt. Any escape sequences specified as part of +the prompt string with @code{set extended-prompt}, are replaced with the +corresponding strings each time the prompt is displayed. +@end table + @node Editing @section Command Editing @cindex readline @@ -21176,6 +21205,8 @@ provided, it is decoded the way that @value{GDBN}'s inbuilt @end defun @defop Operation {@value{GDBN}} prompt_hook current_prompt +@anchor{prompt_hook} + If @var{prompt_hook} is callable, @value{GDBN} will call the method assigned to this operation before a prompt is displayed by @value{GDBN}. @@ -23887,11 +23918,12 @@ top of the source tree to the source search path. @subsection Python modules @cindex python modules -@value{GDBN} comes with a module to assist writing Python code. +@value{GDBN} comes with several modules to assist writing Python code. @menu * gdb.printing:: Building and registering pretty-printers. * gdb.types:: Utilities for working with types. +* gdb.prompt:: Utilities for prompt value substitution. @end menu @node gdb.printing @@ -23959,6 +23991,62 @@ Return @code{True} if @var{type}, assumed to be a type with fields Return a Python @code{dictionary} type produced from @var{enum_type}. @end table +@node gdb.prompt +@subsubsection gdb.prompt +@cindex gdb.prompt + +This module provides a method for prompt value-substitution. + +@table @code +@item substitute_prompt (@var{string}) +Return @var{string} with escape sequences substituted by values. Some +escape sequences take arguments. You can specify arguments inside +``@{@}'' immediately following the escape sequence. + +The escape sequences you can pass to this function are: + +@table @code +@item \\ +Substitute a backslash. +@item \e +Substitute an ESC character. +@item \f +Substitute the selected frame; an argument names a frame parameter. +@item \n +Substitute a newline. +@item \p +Substitute a parameter's value; the argument names the parameter. +@item \r +Substitute a carriage return. +@item \t +Substitute the selected thread; an argument names a thread parameter. +@item \v +Substitute the version of GDB. +@item \w +Substitute the current working directory. +@item \[ +Begin a sequence of non-printing characters. These sequences are +typically used with the ESC character, and are not counted in the string +length. Example,: ``\[\e[0;34m\](gdb)\[\e[0m\]'' will return a +blue-colored ``(gdb)'' prompt where the length is three. +@item \] +End a sequence of non-printing characters. +@end table + +For example: + +@smallexample +substitute_prompt (``frame: \f, + print arguments: \p@{print frame-arguments@}'') +@end smallexample + +@exdent will return the string: + +@smallexample +"frame: main, print arguments: scalars" +@end smallexample +@end table + @node Interpreters @chapter Command Interpreters @cindex command interpreters