From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15259 invoked by alias); 29 Nov 2012 17:50:01 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 15223 invoked by uid 9514); 29 Nov 2012 17:49:58 -0000 Date: Thu, 29 Nov 2012 17:50:00 -0000 Message-ID: <20121129174958.15208.qmail@sourceware.org> From: pmuldoon@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-pmuldoon-python-backtrace: Add more comments, rewrite others. Remove FrameFilter.py X-Git-Refname: refs/heads/archer-pmuldoon-python-backtrace X-Git-Reftype: branch X-Git-Oldrev: fb356a89253f12087866787ebe9fea49c56f4c24 X-Git-Newrev: a2871b2eadcd787de03d30f8b6c312aa45640f99 X-SW-Source: 2012-q4/txt/msg00020.txt.bz2 List-Id: The branch, archer-pmuldoon-python-backtrace has been updated via a2871b2eadcd787de03d30f8b6c312aa45640f99 (commit) from fb356a89253f12087866787ebe9fea49c56f4c24 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit a2871b2eadcd787de03d30f8b6c312aa45640f99 Author: Phil Muldoon Date: Thu Nov 29 17:49:30 2012 +0000 Add more comments, rewrite others. Remove FrameFilter.py ----------------------------------------------------------------------- Summary of changes: gdb/data-directory/Makefile.in | 1 - gdb/python/lib/gdb/FrameIterator.py | 33 ++++++++- gdb/python/lib/gdb/FrameWrapper.py | 106 +++++++++++++++------------ gdb/python/lib/gdb/command/frame_filters.py | 1 - 4 files changed, 88 insertions(+), 53 deletions(-) First 500 lines of diff: diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in index dbc5a25..4cc92bc 100644 --- a/gdb/data-directory/Makefile.in +++ b/gdb/data-directory/Makefile.in @@ -54,7 +54,6 @@ PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) PYTHON_FILES = \ gdb/__init__.py \ gdb/BaseFrameWrapper.py \ - gdb/FrameFilter.py \ gdb/FrameIterator.py \ gdb/FrameWrapper.py \ gdb/types.py \ diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py index 5816c57..ddc9087 100644 --- a/gdb/python/lib/gdb/FrameIterator.py +++ b/gdb/python/lib/gdb/FrameIterator.py @@ -1,13 +1,30 @@ +# Copyright (C) 2012 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 . + import gdb import itertools class FrameIterator(object): - """A frame iterator. Iterates over gdb.Frames or objects that + """A gdb.Frame iterator. Iterates over gdb.Frames or objects that conform to that interface.""" def __init__ (self, frame_obj): - """Initialize a FrameIterator. FRAME_OBJ is the starting - frame.""" + """Initialize a FrameIterator. + + Arguments: + frame_obj the starting frame.""" super(FrameIterator, self).__init__() self.frame = frame_obj @@ -16,9 +33,19 @@ class FrameIterator(object): return self def __getitem__(self,index): + """__getitem__ implementation. + + Arguments: + index: A specific index to fetch.""" + return next(itertools.islice(self.frame,index,index+1)) def next (self): + """__next__ implementation. + + Returns: + The next oldest frame.""" + result = self.frame if result is None: raise StopIteration diff --git a/gdb/python/lib/gdb/FrameWrapper.py b/gdb/python/lib/gdb/FrameWrapper.py index 0db37de..4db9a43 100644 --- a/gdb/python/lib/gdb/FrameWrapper.py +++ b/gdb/python/lib/gdb/FrameWrapper.py @@ -16,7 +16,7 @@ import gdb class FrameWrapper (object): - """Interface for a Frame Wrapper""" + """Interface for a Frame Wrapper.""" """ A frame wrapper wraps a frame and provides additional and convenience methods. """ @@ -25,23 +25,22 @@ class FrameWrapper (object): self.frame = frame def elided (self): - """ The 'elided' function groups frames together in a + """ The elided method groups frames together in a hierarchical system. An example would be an interpreter call that occurs over many frames but might be better represented as a group of frames distinct from the other frames. Arguments: None - Returns: The 'elide' function must return an iterator that - contains the frames that are being elided. Elided frames are - indented from normal frames in a backtrace, to show affinity - with the frame that elided them. Note that it is the Frame - Filter's task to filter out the elided frames from the - iterator the source frames were acquired, and also to provide - the iterator of elided frames in this function. - - If this function returns a Python None, no frames will be - elided. + Returns: The elided function must return an iterator that + contains the frames that are being elided, or None. + Elided frames are indented from normal frames in a + backtrace, to show affinity with the frame that + elided them. Note that it is the frame filter's task + to filter out the elided frames from the source + iterator, and also to provide the iterator of elided + frames in this function. If this function returns a + None, no frames will be elided. """ pass @@ -51,10 +50,9 @@ class FrameWrapper (object): Arguments: None. - Returns: A string describing the function. - - If this function returns a Python None, no data will be - displayed for this field at printing. + Returns: A string describing the function. If this function + returns None, no data will be displayed for this + field at printing. """ pass @@ -64,25 +62,22 @@ class FrameWrapper (object): Arguments: None. Returns: A numeric integer type of sufficient size to describe - the address of the frame. - - If this function returns a Python None, no data will be - displayed for this field at printing. + the address of the frame, or None. If this function + returns a None, no data will be displayed for this + field at printing. """ pass def filename (self): - """ The filename associated with the function and line number - addressed by this frame. + """ The filename associated with the function of this frame. Arguments: None. Returns: A string containing the filename, and optionally, the - path to the filename of the frame. - - If this function returns a Python None, the field output from - the function will be left blank."" + path to the filename of the frame, or None. If this + function returns a None, no data will be displayed + for this field at printing. """ pass @@ -93,10 +88,9 @@ class FrameWrapper (object): Arguments: None. - Returns: A number integer type line number - - If this function returns a Python None, the field output from - the function will be left blank."" + Returns: An integer type representing the line number, or + None. If this function returns a None, no data will + be displayed for this field at printing. """ pass @@ -106,15 +100,23 @@ class FrameWrapper (object): Arguments: None. - Returns: An iterator that returns a tuple pairing of - "argument", and "value". The "argument" element can be either - a gdb.Symbol or a string. The "value" argument must be a - gdb.Value or a Python value that can be translated into a - gdb.Value. - - - If this function returns a Python None, frame arguments will - not be printed. + Returns: An iterator that conforms to the Python iterator + protocol, or None. If this method returns a None, + instead of an iterator, then no data will be printed + for frame arguments. If this method returns an + iterator, it must contain objects that implement two + methods, described here. + + The object must implement an argument method which + takes no parameters and must return a gdb.Symbol or a + Python string. It must also implement a value method + which takes no parameters and which must return a + gdb.Value, a Python value, or None. If the value + method returns a None, and the argument method + returns a gdb.Symbol, GDB will look-up and print the + value of the gdb.Symbol automatically. If the + argument method contains a string, then the value + method must not return a None. """ pass @@ -123,15 +125,23 @@ class FrameWrapper (object): Arguments: None. - Returns: An iterator that returns a tuple pairing of - "argument", and "value". The "argument" element can be either - a gdb.Symbol or a string. The "value" argument must be a - gdb.Value or a Python value that can be translated into a - gdb.Value. - - - If this function returns a Python None, local variables will - not be printed. + Returns: An iterator that conforms to the Python iterator + protocol, or None. If this method returns a None, + instead of an iterator, then no data will be printed + for frame locals. If this method returns an + iterator, it must contain objects that implement two + methods, described here. + + The object must implement an argument method which + takes no parameters and must return a gdb.Symbol or a + Python string. It must also implement a value method + which takes no parameters and which must return a + gdb.Value, a Python value, or None. If the value + method returns a None, and the argument method + returns a gdb.Symbol, GDB will look-up and print the + value of the gdb.Symbol automatically. If the + argument method contains a string, then the value + method must not return a None. """ pass diff --git a/gdb/python/lib/gdb/command/frame_filters.py b/gdb/python/lib/gdb/command/frame_filters.py index b5a4ceb..fc115b0 100644 --- a/gdb/python/lib/gdb/command/frame_filters.py +++ b/gdb/python/lib/gdb/command/frame_filters.py @@ -18,7 +18,6 @@ import gdb import copy -import gdb.FrameFilter from gdb.FrameIterator import FrameIterator from gdb.BaseFrameWrapper import BaseFrameWrapper import itertools hooks/post-receive -- Repository for Project Archer.