public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-tromey-python: * Makefile.in (PY_FILES): Add caller_is.py.
@ 2008-11-23 21:38 tromey
0 siblings, 0 replies; only message in thread
From: tromey @ 2008-11-23 21:38 UTC (permalink / raw)
To: archer-commits
The branch, archer-tromey-python has been updated
via 5bbc9e9236e752b546f99749a2ebc758c5fb7fcf (commit)
from 6252b3bc528df3b39ebcb186b51f298e860d78c1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 5bbc9e9236e752b546f99749a2ebc758c5fb7fcf
Author: Tom Tromey <tromey@redhat.com>
Date: Sun Nov 23 14:38:00 2008 -0700
* Makefile.in (PY_FILES): Add caller_is.py.
* python/lib/gdb/function/caller_is.py: New file.
* python/lib/gdb/command/require.py: Add "require function".
-----------------------------------------------------------------------
Summary of changes:
gdb/ChangeLog | 6 +++
gdb/Makefile.in | 5 ++-
gdb/python/lib/gdb/command/require.py | 2 +-
gdb/python/lib/gdb/function/caller_is.py | 58 ++++++++++++++++++++++++++++++
4 files changed, 68 insertions(+), 3 deletions(-)
create mode 100644 gdb/python/lib/gdb/function/caller_is.py
First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 47e01b5..2bab40d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2008-11-23 Tom Tromey <tromey@redhat.com>
+ * Makefile.in (PY_FILES): Add caller_is.py.
+ * python/lib/gdb/function/caller_is.py: New file.
+ * python/lib/gdb/command/require.py: Add "require function".
+
+2008-11-23 Tom Tromey <tromey@redhat.com>
+
* Makefile.in (PY_DIRS): Update.
(PY_FILES): List new files.
* python/lib/gdb/FrameIterator.py: New file.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 26e4aaf..6ef02bf 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1917,12 +1917,13 @@ python-value.o: $(srcdir)/python/python-value.c
# first. These are maintained by hand because that is simpler than
# writing portable sh to make the __init__.py files, and the result is
# faster.
-PY_DIRS = gdb gdb/command gdb/libstdcxx gdb/libstdcxx/v6
+PY_DIRS = gdb gdb/command gdb/function gdb/libstdcxx gdb/libstdcxx/v6
# All python library files, with the "python/lib" stripped off.
# Note that we should only install files in the "gdb" module.
PY_FILES = gdb/backtrace.py gdb/command/alias.py \
- gdb/command/backtrace.py gdb/command/require.py gdb/FrameIterator.py \
+ gdb/command/backtrace.py gdb/command/require.py \
+ gdb/function/caller_is.py gdb/FrameIterator.py \
gdb/__init__.py gdb/libstdcxx/v6/printers.py
# Install the Python library. Python library files go under
diff --git a/gdb/python/lib/gdb/command/require.py b/gdb/python/lib/gdb/command/require.py
index 2112b9a..36b63e5 100644
--- a/gdb/python/lib/gdb/command/require.py
+++ b/gdb/python/lib/gdb/command/require.py
@@ -54,4 +54,4 @@ class RequireSubcommand (gdb.Command):
RequireCommand()
RequireSubcommand("command")
-# Don't install a "require function" command until we have one.
+RequireSubcommand("function")
diff --git a/gdb/python/lib/gdb/function/caller_is.py b/gdb/python/lib/gdb/function/caller_is.py
new file mode 100644
index 0000000..8afa721
--- /dev/null
+++ b/gdb/python/lib/gdb/function/caller_is.py
@@ -0,0 +1,58 @@
+# Caller-is functions.
+
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import gdb
+import re
+
+class CallerIs (gdb.Function):
+ """Return True if the calling function's name is equal to a string.
+This function takes one or two arguments.
+The first argument is the name of a function; if the calling function's
+name is equal to this argument, this function returns True.
+The optional second argument tells this function how many stack frames
+to traverse to find the calling function. The default is 1."""
+
+ def __init__ (self):
+ super (CallerIs, self).__init__ ("caller_is")
+
+ def invoke (self, name, nframes = 1):
+ frame = gdb.get_current_frame ()
+ while nframes > 0:
+ frame = frame.get_prev ()
+ nframes = nframes - 1
+ return frame.get_name () == name.string ()
+
+class CallerMatches (gdb.Function):
+ """Return True if the calling function's name matches a string.
+This function takes one or two arguments.
+The first argument is a regular expression; if the calling function's
+name is matched by this argument, this function returns True.
+The optional second argument tells this function how many stack frames
+to traverse to find the calling function. The default is 1."""
+
+ def __init__ (self):
+ super (CallerMatches, self).__init__ ("caller_matches")
+
+ def invoke (self, name, nframes = 1):
+ frame = gdb.get_current_frame ()
+ while nframes > 0:
+ frame = frame.get_prev ()
+ nframes = nframes - 1
+ return re.match (name.string (), frame.get_name ()) is not None
+
+CallerIs()
+CallerMatches()
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-11-23 21:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-23 21:38 [SCM] archer-tromey-python: * Makefile.in (PY_FILES): Add caller_is.py tromey
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).