public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-tromey-python: Add example of a Python convenience function.
@ 2008-12-16 15:31 bauermann
0 siblings, 0 replies; only message in thread
From: bauermann @ 2008-12-16 15:31 UTC (permalink / raw)
To: archer-commits
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 <bauerman@br.ibm.com>
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 <bauerman@br.ibm.com>
+ * gdb.texinfo (Commands in Python): Mention need of importing the gdb
+ Python module.
+ (Functions In Python): Add example.
+
+2008-12-16 Thiago Jung Bauermann <bauerman@br.ibm.com>
+
* 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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-12-16 15:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-16 15:31 [SCM] archer-tromey-python: Add example of a Python convenience function bauermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).