summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2010-02-04 13:54:45 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2010-02-04 13:54:45 -0500
commit9c02ed624ab7e794ccc36a8d1d7fcfe2cff1a854 (patch)
tree4051846a236b523aa42a72073c2bac1ea3133734
parente83edc5519ed716142f4695ba792332eb19df861 (diff)
downloadlibpython-9c02ed624ab7e794ccc36a8d1d7fcfe2cff1a854.tar.gz
libpython-9c02ed624ab7e794ccc36a8d1d7fcfe2cff1a854.tar.xz
libpython-9c02ed624ab7e794ccc36a8d1d7fcfe2cff1a854.zip
Clean up the work-in-progress stuff at the end of the file
-rw-r--r--libpython.py80
1 files changed, 44 insertions, 36 deletions
diff --git a/libpython.py b/libpython.py
index 8e3e0f5..dc93177 100644
--- a/libpython.py
+++ b/libpython.py
@@ -396,39 +396,6 @@ class FrameInfo:
', '.join(['%s=%s' % (k, stringify(v)) for k, v in self.locals]))
)
-
-def pyframe():
- fval = PyFrameObjectPtr.from_pyobject_ptr(gdb.selected_frame().read_var('f')) #.dereference()
- fi = FrameInfo(fval)
- print fi
-
-def mybt():
- def print_EvalFrameEx(gdbframe):
- try:
- f = gdbframe.read_var('f')
- except ValueError:
- print '(unable to print python frame, could not access "f")',
- return
-
- try:
- fval = PyFrameObjectPtr.from_pyobject_ptr(f) #.dereference()
- fi = FrameInfo(fval)
- print fi,
- except RuntimeError:
- print '(unable to print python frame; corrupt data?)',
-
-
- for i, gdbframe in enumerate(gdb.selected_thread().frames()):
- #print dir(gdbframe), gdbframe.name()
- print '#%i' % i,
- if 'PyEval_EvalFrameEx' == gdbframe.name():
- print_EvalFrameEx(gdbframe)
- print ' 0x%x in %s' % (gdbframe.pc(), gdbframe.name())
-
-#pyframe()
-#if gdb.selected_thread():
-# mybt()
-
class PyObjectPtrPrinter:
"Prints a (PyObject*)"
@@ -458,9 +425,12 @@ def pretty_printer_lookup(gdbval):
return PyFrameObjectPtrPrinter(gdbval)
+# Wire up the pretty-printer
+# FIXME: is there a better way to do this than to simply do it on import?
gdb.pretty_printers.append(pretty_printer_lookup)
"""
+Here's how I've been invoking this code:
(gdb) python
import sys
@@ -471,6 +441,44 @@ reload(libpython)
end
"""
-# TODO:
-# - write actual backtrace
-# - integrate into backtrace hook
+
+# Remainder of the file is work-in-progress; don't use:
+def pyframe():
+ '''
+ Work towards a reimplementation of "pyframe" from the gdbinit file
+ '''
+ fval = PyFrameObjectPtr.from_pyobject_ptr(gdb.selected_frame().read_var('f')) #.dereference()
+ fi = FrameInfo(fval)
+ print fi
+
+def mybt():
+ '''
+ Attempt at writing a replacement backtrace hook
+ Ought to be integrated into pluggable gdb backtrace hook
+ '''
+ def print_EvalFrameEx(gdbframe):
+ try:
+ f = gdbframe.read_var('f')
+ except ValueError:
+ print '(unable to print python frame, could not access "f")',
+ return
+
+ try:
+ fval = PyFrameObjectPtr.from_pyobject_ptr(f) #.dereference()
+ fi = FrameInfo(fval)
+ print fi,
+ except RuntimeError:
+ print '(unable to print python frame; corrupt data?)',
+
+
+ for i, gdbframe in enumerate(gdb.selected_thread().frames()):
+ #print dir(gdbframe), gdbframe.name()
+ print '#%i' % i,
+ if 'PyEval_EvalFrameEx' == gdbframe.name():
+ print_EvalFrameEx(gdbframe)
+ print ' 0x%x in %s' % (gdbframe.pc(), gdbframe.name())
+
+#pyframe()
+#if gdb.selected_thread():
+# mybt()
+