GDB (API)
/home/stan/gdb/linux/gdb/data-directory/python/gdb/FrameIterator.py
Go to the documentation of this file.
00001 # Copyright (C) 2013 Free Software Foundation, Inc.
00002 
00003 # This program is free software; you can redistribute it and/or modify
00004 # it under the terms of the GNU General Public License as published by
00005 # the Free Software Foundation; either version 3 of the License, or
00006 # (at your option) any later version.
00007 #
00008 # This program is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 # GNU General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU General Public License
00014 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015 
00016 import gdb
00017 import itertools
00018 
00019 class FrameIterator(object):
00020     """A gdb.Frame iterator.  Iterates over gdb.Frames or objects that
00021     conform to that interface."""
00022 
00023     def __init__(self, frame_obj):
00024         """Initialize a FrameIterator.
00025 
00026         Arguments:
00027             frame_obj the starting frame."""
00028 
00029         super(FrameIterator, self).__init__()
00030         self.frame = frame_obj
00031 
00032     def __iter__(self):
00033         return self
00034 
00035     def next(self):
00036         """next implementation.
00037 
00038         Returns:
00039             The next oldest frame."""
00040 
00041         result = self.frame
00042         if result is None:
00043             raise StopIteration
00044         self.frame = result.older()
00045         return result
00046 
00047     # Python 3.x requires __next__(self) while Python 2.x requires
00048     # next(self).  Define next(self), and for Python 3.x create this
00049     # wrapper.
00050     def __next__(self):
00051         return self.next()
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines