From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2754 invoked by alias); 16 Dec 2008 15:31:21 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 2729 invoked by uid 9723); 16 Dec 2008 15:31:19 -0000 Date: Tue, 16 Dec 2008 15:31:00 -0000 Message-ID: <20081216153119.2713.qmail@sourceware.org> From: bauermann@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-tromey-python: Add example of a Python convenience function. X-Git-Refname: refs/heads/archer-tromey-python X-Git-Reftype: branch X-Git-Oldrev: 158aa0cd9d6e48686959e9c626d0ef0f936479d9 X-Git-Newrev: 384d4b3a8cc4a2080deeb5299f75b7b45d7a55a0 X-SW-Source: 2008-q4/txt/msg00218.txt.bz2 List-Id: The branch, archer-tromey-python has been updated via 384d4b3a8cc4a2080deeb5299f75b7b45d7a55a0 (commit) from 158aa0cd9d6e48686959e9c626d0ef0f936479d9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 384d4b3a8cc4a2080deeb5299f75b7b45d7a55a0 Author: Thiago Jung Bauermann Date: Tue Dec 16 13:29:37 2008 -0200 Add example of a Python convenience function. * python/lib/gdb/function/in_scope.py: Fix use of gdb.Symbol attributes. Change to receive variable number of arguments. ----------------------------------------------------------------------- Summary of changes: gdb/doc/ChangeLog | 6 ++++++ gdb/doc/gdb.texinfo | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletions(-) First 500 lines of diff: diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index ba0b2dc..4fb6e94 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,5 +1,11 @@ 2008-12-16 Thiago Jung Bauermann + * gdb.texinfo (Commands in Python): Mention need of importing the gdb + Python module. + (Functions In Python): Add example. + +2008-12-16 Thiago Jung Bauermann + * gdb.texinfo (GDB/MI Variable Objects): Fix references to renamed `gdb.default_visualizer' Python function. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index d1f3c5e..060b67f 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -18956,7 +18956,10 @@ HelloWorld () @end smallexample The last line instantiates the class, and is necessary to trigger the -registration of the command with @value{GDBN}. +registration of the command with @value{GDBN}. Depending on how the +Python code is read into @value{GDBN}, you may need to import the +@code{gdb} module explicitly. + @node Parameters In Python @subsubsection Parameters In Python @@ -19124,6 +19127,28 @@ expression. If an ordinary Python value is returned, it is converted to a @code{gdb.Value} following the usual rules. @end defmethod +The following code snippet shows how a trivial convenience function can +be implemented in Python: + +@smallexample +class Greet (gdb.Function): + """Return string to greet someone. +Takes a name as argument.""" + + def __init__ (self): + super (Greet, self).__init__ ("greet") + + def invoke (self, name): + return "Hello, %s!" % name.string () + +Greet () +@end smallexample + +The last line instantiates the class, and is necessary to trigger the +registration of the function with @value{GDBN}. Depending on how the +Python code is read into @value{GDBN}, you may need to import the +@code{gdb} module explicitly. + @node Objfiles in Python @subsubsection Objfiles in Python hooks/post-receive -- Repository for Project Archer.