Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Attributes
libpython.Frame Class Reference
Inheritance diagram for libpython.Frame:
Inheritance graph
[legend]
Collaboration diagram for libpython.Frame:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def older
def newer
def select
def get_index
def is_evalframeex
def get_pyop
def get_selected_frame
def get_selected_python_frame
def print_summary
def print_traceback

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Attributes

 _gdbframe

Detailed Description

Wrapper for gdb.Frame, adding various methods

Definition at line 1343 of file libpython.py.


Constructor & Destructor Documentation

def libpython.Frame.__init__ (   self,
  gdbframe 
)

Definition at line 1347 of file libpython.py.

01347 
01348     def __init__(self, gdbframe):
01349         self._gdbframe = gdbframe

Here is the caller graph for this function:


Member Function Documentation

def libpython.Frame.get_index (   self)
Calculate index of frame, starting at 0 for the newest frame within
this thread

Definition at line 1376 of file libpython.py.

01376 
01377     def get_index(self):
01378         '''Calculate index of frame, starting at 0 for the newest frame within
01379         this thread'''
01380         index = 0
01381         # Go down until you reach the newest frame:
01382         iter_frame = self
01383         while iter_frame.newer():
01384             index += 1
01385             iter_frame = iter_frame.newer()
01386         return index

Here is the caller graph for this function:

def libpython.Frame.get_pyop (   self)

Definition at line 1403 of file libpython.py.

01403 
01404     def get_pyop(self):
01405         try:
01406             f = self._gdbframe.read_var('f')
01407             return PyFrameObjectPtr.from_pyobject_ptr(f)
01408         except ValueError:
01409             return None

Here is the caller graph for this function:

Definition at line 1411 of file libpython.py.

01411 
01412     def get_selected_frame(cls):
01413         _gdbframe = gdb.selected_frame()
01414         if _gdbframe:
01415             return Frame(_gdbframe)
01416         return None

Try to obtain the Frame for the python code in the selected frame,
or None

Definition at line 1418 of file libpython.py.

01418 
01419     def get_selected_python_frame(cls):
01420         '''Try to obtain the Frame for the python code in the selected frame,
01421         or None'''
01422         frame = cls.get_selected_frame()
01423 
01424         while frame:
01425             if frame.is_evalframeex():
01426                 return frame
01427             frame = frame.older()
01428 
01429         # Not found:
01430         return None

Is this a PyEval_EvalFrameEx frame?

Definition at line 1387 of file libpython.py.

01387 
01388     def is_evalframeex(self):
01389         '''Is this a PyEval_EvalFrameEx frame?'''
01390         if self._gdbframe.name() == 'PyEval_EvalFrameEx':
01391             '''
01392             I believe we also need to filter on the inline
01393             struct frame_id.inline_depth, only regarding frames with
01394             an inline depth of 0 as actually being this function
01395 
01396             So we reject those with type gdb.INLINE_FRAME
01397             '''
01398             if self._gdbframe.type() == gdb.NORMAL_FRAME:
01399                 # We have a PyEval_EvalFrameEx frame:
01400                 return True
01401 
01402         return False

Here is the caller graph for this function:

def libpython.Frame.newer (   self)

Definition at line 1357 of file libpython.py.

01357 
01358     def newer(self):
01359         newer = self._gdbframe.newer()
01360         if newer:
01361             return Frame(newer)
01362         else:
01363             return None

def libpython.Frame.older (   self)

Definition at line 1350 of file libpython.py.

01350 
01351     def older(self):
01352         older = self._gdbframe.older()
01353         if older:
01354             return Frame(older)
01355         else:
01356             return None

Definition at line 1431 of file libpython.py.

01431 
01432     def print_summary(self):
01433         if self.is_evalframeex():
01434             pyop = self.get_pyop()
01435             if pyop:
01436                 line = pyop.get_truncated_repr(MAX_OUTPUT_LEN)
01437                 write_unicode(sys.stdout, '#%i %s\n' % (self.get_index(), line))
01438                 line = pyop.current_line()
01439                 if line is not None:
01440                     sys.stdout.write(line)
01441             else:
01442                 sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index())
01443         else:
01444             sys.stdout.write('#%i\n' % self.get_index())

Here is the call graph for this function:

Definition at line 1445 of file libpython.py.

01445 
01446     def print_traceback(self):
01447         if self.is_evalframeex():
01448             pyop = self.get_pyop()
01449             if pyop:
01450                 pyop.print_traceback()
01451                 line = pyop.current_line()
01452                 if line is not None:
01453                     sys.stdout.write('    %s\n' % line.strip())
01454             else:
01455                 sys.stdout.write('  (unable to read python frame information)\n')
01456         else:
01457             sys.stdout.write('  (not a python frame)\n')

Here is the call graph for this function:

def libpython.Frame.select (   self)
If supported, select this frame and return True; return False if unsupported

Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12
onwards, but absent on Ubuntu buildbot

Definition at line 1364 of file libpython.py.

01364 
01365     def select(self):
01366         '''If supported, select this frame and return True; return False if unsupported
01367 
01368         Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12
01369         onwards, but absent on Ubuntu buildbot'''
01370         if not hasattr(self._gdbframe, 'select'):
01371             print ('Unable to select frame: '
01372                    'this build of gdb does not expose a gdb.Frame.select method')
01373             return False
01374         self._gdbframe.select()
01375         return True


Member Data Documentation

Definition at line 1348 of file libpython.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


The documentation for this class was generated from the following file: