public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-pmuldoon-python-backtrace: Add frame filter management classes, and FrameFilter base class
@ 2012-06-13 14:22 pmuldoon
  0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2012-06-13 14:22 UTC (permalink / raw)
  To: archer-commits

The branch, archer-pmuldoon-python-backtrace has been updated
       via  21b52446556e641bdafebf333a95fabd015ba84f (commit)
       via  116249e4bb128d63c6ddfb57b3588e78d454f015 (commit)
      from  565c7df6b7f0146584f71bea3ee7ee57e0a6fb3a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 21b52446556e641bdafebf333a95fabd015ba84f
Author: Phil Muldoon <pmuldoon@redhat.com>
Date:   Wed Jun 13 15:21:07 2012 +0100

    Add frame filter management classes, and FrameFilter base class

commit 116249e4bb128d63c6ddfb57b3588e78d454f015
Author: Phil Muldoon <pmuldoon@redhat.com>
Date:   Wed Jun 13 15:09:51 2012 +0100

    Add Frame filter management and base class

-----------------------------------------------------------------------

Summary of changes:
 gdb/python/lib/gdb/FrameFilter.py             |   13 +
 gdb/python/lib/gdb/FrameWrapper.py            |   81 --
 gdb/python/lib/gdb/__init__.py                |   41 -
 gdb/python/lib/gdb/command/__init__.py        |   16 -
 gdb/python/lib/gdb/command/explore.py         |  755 -----------
 gdb/python/lib/gdb/command/frame_filters.py   |  282 ++++
 gdb/python/lib/gdb/command/pretty_printers.py |  372 ------
 gdb/python/lib/gdb/command/prompt.py          |   66 -
 gdb/python/lib/gdb/command/upto.py            |  128 --
 gdb/python/lib/gdb/printing.py                |  258 ----
 gdb/python/lib/gdb/prompt.py                  |  149 ---
 gdb/python/lib/gdb/types.py                   |  111 --
 gdb/python/py-auto-load.c                     |  298 -----
 gdb/python/py-block.c                         |  548 --------
 gdb/python/py-bpevent.c                       |   56 -
 gdb/python/py-breakpoint.c                    | 1022 --------------
 gdb/python/py-cmd.c                           |  699 ----------
 gdb/python/py-continueevent.c                 |   53 -
 gdb/python/py-event.c                         |  182 ---
 gdb/python/py-event.h                         |  122 --
 gdb/python/py-events.h                        |   60 -
 gdb/python/py-evtregistry.c                   |  172 ---
 gdb/python/py-evts.c                          |   74 -
 gdb/python/py-exitedevent.c                   |   79 --
 gdb/python/py-finishbreakpoint.c              |  467 -------
 gdb/python/py-frame.c                         | 1082 ---------------
 gdb/python/py-framefilter.c                   |  825 ------------
 gdb/python/py-function.c                      |  249 ----
 gdb/python/py-inferior.c                      |  870 ------------
 gdb/python/py-infthread.c                     |  342 -----
 gdb/python/py-lazy-string.c                   |  250 ----
 gdb/python/py-newobjfileevent.c               |   70 -
 gdb/python/py-objfile.c                       |  318 -----
 gdb/python/py-param.c                         |  814 -----------
 gdb/python/py-prettyprint.c                   |  836 ------------
 gdb/python/py-progspace.c                     |  306 -----
 gdb/python/py-signalevent.c                   |   53 -
 gdb/python/py-stopevent.c                     |  117 --
 gdb/python/py-stopevent.h                     |   36 -
 gdb/python/py-symbol.c                        |  595 ---------
 gdb/python/py-symtab.c                        |  603 ---------
 gdb/python/py-threadevent.c                   |   78 --
 gdb/python/py-type.c                          | 1777 -------------------------
 gdb/python/py-utils.c                         |  395 ------
 gdb/python/py-value.c                         | 1521 ---------------------
 gdb/python/python-config.py                   |   77 --
 gdb/python/python-internal.h                  |  349 -----
 gdb/python/python.c                           | 1513 ---------------------
 gdb/python/python.h                           |   57 -
 49 files changed, 295 insertions(+), 18942 deletions(-)
 create mode 100644 gdb/python/lib/gdb/FrameFilter.py
 delete mode 100644 gdb/python/lib/gdb/FrameWrapper.py
 delete mode 100644 gdb/python/lib/gdb/__init__.py
 delete mode 100644 gdb/python/lib/gdb/command/__init__.py
 delete mode 100644 gdb/python/lib/gdb/command/explore.py
 create mode 100644 gdb/python/lib/gdb/command/frame_filters.py
 delete mode 100644 gdb/python/lib/gdb/command/pretty_printers.py
 delete mode 100644 gdb/python/lib/gdb/command/prompt.py
 delete mode 100644 gdb/python/lib/gdb/command/upto.py
 delete mode 100644 gdb/python/lib/gdb/printing.py
 delete mode 100644 gdb/python/lib/gdb/prompt.py
 delete mode 100644 gdb/python/lib/gdb/types.py
 delete mode 100644 gdb/python/py-auto-load.c
 delete mode 100644 gdb/python/py-block.c
 delete mode 100644 gdb/python/py-bpevent.c
 delete mode 100644 gdb/python/py-breakpoint.c
 delete mode 100644 gdb/python/py-cmd.c
 delete mode 100644 gdb/python/py-continueevent.c
 delete mode 100644 gdb/python/py-event.c
 delete mode 100644 gdb/python/py-event.h
 delete mode 100644 gdb/python/py-events.h
 delete mode 100644 gdb/python/py-evtregistry.c
 delete mode 100644 gdb/python/py-evts.c
 delete mode 100644 gdb/python/py-exitedevent.c
 delete mode 100644 gdb/python/py-finishbreakpoint.c
 delete mode 100644 gdb/python/py-frame.c
 delete mode 100644 gdb/python/py-framefilter.c
 delete mode 100644 gdb/python/py-function.c
 delete mode 100644 gdb/python/py-inferior.c
 delete mode 100644 gdb/python/py-infthread.c
 delete mode 100644 gdb/python/py-lazy-string.c
 delete mode 100644 gdb/python/py-newobjfileevent.c
 delete mode 100644 gdb/python/py-objfile.c
 delete mode 100644 gdb/python/py-param.c
 delete mode 100644 gdb/python/py-prettyprint.c
 delete mode 100644 gdb/python/py-progspace.c
 delete mode 100644 gdb/python/py-signalevent.c
 delete mode 100644 gdb/python/py-stopevent.c
 delete mode 100644 gdb/python/py-stopevent.h
 delete mode 100644 gdb/python/py-symbol.c
 delete mode 100644 gdb/python/py-symtab.c
 delete mode 100644 gdb/python/py-threadevent.c
 delete mode 100644 gdb/python/py-type.c
 delete mode 100644 gdb/python/py-utils.c
 delete mode 100644 gdb/python/py-value.c
 delete mode 100644 gdb/python/python-config.py
 delete mode 100644 gdb/python/python-internal.h
 delete mode 100644 gdb/python/python.c
 delete mode 100644 gdb/python/python.h

First 500 lines of diff:
diff --git a/gdb/python/lib/gdb/FrameFilter.py b/gdb/python/lib/gdb/FrameFilter.py
new file mode 100644
index 0000000..2ce909f
--- /dev/null
+++ b/gdb/python/lib/gdb/FrameFilter.py
@@ -0,0 +1,13 @@
+import gdb
+
+class FrameFilter():
+    
+    name = "Default"
+    priority = 100
+    enabled = True
+
+    def __init__(self, next_filter):
+        self.next_filter = next_filter
+        
+    def filter(iter):
+        return iter
diff --git a/gdb/python/lib/gdb/FrameWrapper.py b/gdb/python/lib/gdb/FrameWrapper.py
deleted file mode 100644
index 11f69ed..0000000
--- a/gdb/python/lib/gdb/FrameWrapper.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# 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 <http://www.gnu.org/licenses/>.
-
-import gdb
-
-class FrameWrapper:
-    "Base Frame Wrapper"
-
-    def __init__ (self, frame):
-        self.frame = frame
-
-    def __new__ (self):
-        return self
-
-    def omit (self):
-        return False
-
-    def elide (self):
-        return False
-
-    def function (self):
-        fname = str (self.frame.function())
-        if (fname == ""):
-            return "<unknown function>"
-        else:
-            return fname
-
-    def level (self, level):
-        return level
-
-    def address (self):
-        return self.frame.pc()
-
-    def filename (self):
-        sal = self.frame.find_sal()
-        if (sal):
-            return sal.symtab.filename
-        else:
-            return "<unknown filename>"
-
-    def frame_args (self):
-        args = self.frame.arguments()
-        args_list = []
-        if args != None:
-            for arg in args:
-                value = arg.value(self.frame)
-                args_list.append((arg, value))
-
-        return args_list
-
-    def frame_locals (self):
-        frame_locals = self.frame.locals()
-        frame_locals_list = []
-        if frame_locals != None:
-            for frame_local in frame_locals:
-                value = frame_local.value(self.frame)
-                frame_locals_list.append((frame_local, value))
-
-        return frame_locals_list
-
-    def line (self):
-        sal = self.frame.find_sal()
-        if (sal):
-            return sal.line        
-        else:
-            return "<unknown line>"
-
-    def inferior_frame (self):
-        return self.frame
diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
deleted file mode 100644
index a82e495..0000000
--- a/gdb/python/lib/gdb/__init__.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (C) 2010-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 <http://www.gnu.org/licenses/>.
-
-import traceback
-
-# Auto-load all functions/commands.
-
-# Modules to auto-load, and the paths where those modules exist.
-
-module_dict = {
-  'gdb.function': os.path.join(gdb.PYTHONDIR, 'gdb', 'function'),
-  'gdb.command': os.path.join(gdb.PYTHONDIR, 'gdb', 'command')
-}
-
-# Iterate the dictionary, collating the Python files in each module
-# path.  Construct the module name, and import.
-
-for module, location in module_dict.iteritems():
-  if os.path.exists(location):
-     py_files = filter(lambda x: x.endswith('.py') and x != '__init__.py',
-                       os.listdir(location))
-
-     for py_file in py_files:
-       # Construct from foo.py, gdb.module.foo
-       py_file = module + '.' + py_file[:-3]
-       try:
-         exec('import ' + py_file)
-       except:
-         print >> sys.stderr, traceback.format_exc()
diff --git a/gdb/python/lib/gdb/command/__init__.py b/gdb/python/lib/gdb/command/__init__.py
deleted file mode 100644
index 0eb19f2..0000000
--- a/gdb/python/lib/gdb/command/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2010-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 <http://www.gnu.org/licenses/>.
-
-
diff --git a/gdb/python/lib/gdb/command/explore.py b/gdb/python/lib/gdb/command/explore.py
deleted file mode 100644
index aad3671..0000000
--- a/gdb/python/lib/gdb/command/explore.py
+++ /dev/null
@@ -1,755 +0,0 @@
-# GDB 'explore' command.
-# 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 <http://www.gnu.org/licenses/>.
-
-"""Implementation of the GDB 'explore' command using the GDB Python API."""
-
-import gdb
-
-class Explorer(object):
-    """Internal class which invokes other explorers."""
-
-    # This map is filled by the Explorer.init_env() function
-    type_code_to_explorer_map = { }
-
-    _SCALAR_TYPE_LIST = (
-        gdb.TYPE_CODE_CHAR,
-        gdb.TYPE_CODE_INT,
-        gdb.TYPE_CODE_BOOL,
-        gdb.TYPE_CODE_FLT,
-        gdb.TYPE_CODE_VOID,
-        gdb.TYPE_CODE_ENUM,
-    )
-
-    @staticmethod
-    def guard_expr(expr):
-        length = len(expr)
-        guard = False
-
-        if expr[0] == '(' and expr[length-1] == ')':
-            pass
-        else:
-            i = 0
-            while i < length:
-                c = expr[i]
-                if (c == '_' or ('a' <= c and c <= 'z') or
-                    ('A' <= c and c <= 'Z') or ('0' <= c and c <= '9')):
-                    pass
-                else:
-                    guard = True
-                    break
-                i += 1
-
-        if guard:
-            return "(" + expr + ")"
-        else:
-            return expr
-
-    @staticmethod
-    def explore_expr(expr, value, is_child):
-        """Main function to explore an expression value.
-
-        Arguments:
-            expr: The expression string that is being explored.
-            value: The gdb.Value value of the expression.
-            is_child: Boolean value to indicate if the expression is a child.
-                      An expression is a child if it is derived from the main
-                      expression entered by the user.  For example, if the user
-                      entered an expression which evaluates to a struct, then
-                      when exploring the fields of the struct, is_child is set
-                      to True internally.
-
-        Returns:
-            No return value.
-        """
-        type_code = value.type.code
-        if type_code in Explorer.type_code_to_explorer_map:
-            explorer_class = Explorer.type_code_to_explorer_map[type_code]
-            while explorer_class.explore_expr(expr, value, is_child):
-                pass
-        else:
-            print ("Explorer for type '%s' not yet available.\n" %
-                   str(value.type))
-
-    @staticmethod
-    def explore_type(name, datatype, is_child):
-        """Main function to explore a data type.
-
-        Arguments:
-            name: The string representing the path to the data type being
-                  explored.
-            datatype: The gdb.Type value of the data type being explored.
-            is_child: Boolean value to indicate if the name is a child.
-                      A name is a child if it is derived from the main name
-                      entered by the user.  For example, if the user entered
-                      the name of struct type, then when exploring the fields
-                      of the struct, is_child is set to True internally.
-
-        Returns:
-            No return value.
-        """
-        type_code = datatype.code
-        if type_code in Explorer.type_code_to_explorer_map:
-            explorer_class = Explorer.type_code_to_explorer_map[type_code]
-            while explorer_class.explore_type(name, datatype, is_child):
-                pass
-        else:
-            print ("Explorer for type '%s' not yet available.\n" %
-                   str(datatype))
-
-    @staticmethod
-    def init_env():
-        """Initializes the Explorer environment.
-        This function should be invoked before starting any exploration.  If
-        invoked before an exploration, it need not be invoked for subsequent
-        explorations.
-        """
-        Explorer.type_code_to_explorer_map = {
-            gdb.TYPE_CODE_CHAR : ScalarExplorer,
-            gdb.TYPE_CODE_INT : ScalarExplorer,
-            gdb.TYPE_CODE_BOOL : ScalarExplorer,
-            gdb.TYPE_CODE_FLT : ScalarExplorer,
-            gdb.TYPE_CODE_VOID : ScalarExplorer,
-            gdb.TYPE_CODE_ENUM : ScalarExplorer,
-            gdb.TYPE_CODE_STRUCT : CompoundExplorer,
-            gdb.TYPE_CODE_UNION : CompoundExplorer,
-            gdb.TYPE_CODE_PTR : PointerExplorer,
-            gdb.TYPE_CODE_REF : ReferenceExplorer,
-            gdb.TYPE_CODE_TYPEDEF : TypedefExplorer,
-            gdb.TYPE_CODE_ARRAY : ArrayExplorer
-        }
-
-    @staticmethod
-    def is_scalar_type(type):
-        """Checks whether a type is a scalar type.
-        A type is a scalar type of its type is
-            gdb.TYPE_CODE_CHAR or
-            gdb.TYPE_CODE_INT or
-            gdb.TYPE_CODE_BOOL or
-            gdb.TYPE_CODE_FLT or
-            gdb.TYPE_CODE_VOID or
-            gdb.TYPE_CODE_ENUM.
-
-        Arguments:
-            type: The type to be checked.
-
-        Returns:
-            'True' if 'type' is a scalar type. 'False' otherwise.
-        """
-        return type.code in Explorer._SCALAR_TYPE_LIST
-
-    @staticmethod
-    def return_to_parent_value():
-        """A utility function which prints that the current exploration session
-        is returning to the parent value. Useful when exploring values.
-        """
-        print "\nReturning to parent value...\n"
-        
-    @staticmethod
-    def return_to_parent_value_prompt():
-        """A utility function which prompts the user to press the 'enter' key
-        so that the exploration session can shift back to the parent value.
-        Useful when exploring values.
-        """
-        raw_input("\nPress enter to return to parent value: ")
-        
-    @staticmethod
-    def return_to_enclosing_type():
-        """A utility function which prints that the current exploration session
-        is returning to the enclosing type.  Useful when exploring types.
-        """
-        print "\nReturning to enclosing type...\n"
-        
-    @staticmethod
-    def return_to_enclosing_type_prompt():
-        """A utility function which prompts the user to press the 'enter' key
-        so that the exploration session can shift back to the enclosing type.
-        Useful when exploring types.
-        """
-        raw_input("\nPress enter to return to enclosing type: ")
-
-
-class ScalarExplorer(object):
-    """Internal class used to explore scalar values."""
-
-    @staticmethod
-    def explore_expr(expr, value, is_child):
-        """Function to explore scalar values.
-        See Explorer.explore_expr and Explorer.is_scalar_type for more
-        information.
-        """
-        print ("'%s' is a scalar value of type '%s'." %
-               (expr, value.type))
-        print "%s = %s" % (expr, str(value))
-
-        if is_child:
-            Explorer.return_to_parent_value_prompt()
-            Explorer.return_to_parent_value()
-
-        return False
-
-    @staticmethod
-    def explore_type(name, datatype, is_child):
-        """Function to explore scalar types.
-        See Explorer.explore_type and Explorer.is_scalar_type for more
-        information.
-        """
-        if datatype.code == gdb.TYPE_CODE_ENUM:
-            if is_child:
-                print ("%s is of an enumerated type '%s'." %
-                       (name, str(datatype)))
-            else:
-                print "'%s' is an enumerated type." % name
-        else:
-            if is_child:
-                print ("%s is of a scalar type '%s'." %
-                       (name, str(datatype)))
-            else:
-                print "'%s' is a scalar type." % name
-
-        if is_child:
-            Explorer.return_to_enclosing_type_prompt()
-            Explorer.return_to_enclosing_type()
-
-        return False
-
-
-class PointerExplorer(object):
-    """Internal class used to explore pointer values."""
-
-    @staticmethod
-    def explore_expr(expr, value, is_child):
-        """Function to explore pointer values.
-        See Explorer.explore_expr for more information.
-        """
-        print ("'%s' is a pointer to a value of type '%s'" %
-               (expr, str(value.type.target())))
-        option  = raw_input("Continue exploring it as a pointer to a single "
-                            "value [y/n]: ")
-        if option == "y":
-            deref_value = None
-            try:
-                deref_value = value.dereference()
-                str(deref_value)
-            except gdb.MemoryError:
-                print ("'%s' a pointer pointing to an invalid memory "
-                       "location." % expr)
-                if is_child:
-                    Explorer.return_to_parent_value_prompt()
-                return False
-            Explorer.explore_expr("*%s" % Explorer.guard_expr(expr),
-                                  deref_value, is_child)
-            return False
-        
-        option  = raw_input("Continue exploring it as a pointer to an "
-                            "array [y/n]: ")
-        if option == "y":
-            while True:
-                index = 0
-                try:
-                    index = int(raw_input("Enter the index of the element you "
-                                          "want to explore in '%s': " % expr))
-                except ValueError:
-                    break
-                element_expr = "%s[%d]" % (Explorer.guard_expr(expr), index)
-                element = value[index]
-                try:
-                    str(element)
-                except gdb.MemoryError:
-                    print "Cannot read value at index %d." % index
-                    continue
-                Explorer.explore_expr(element_expr, element, True)
-            return False
-
-        if is_child:
-            Explorer.return_to_parent_value()
-        return False
-
-    @staticmethod
-    def explore_type(name, datatype, is_child):
-        """Function to explore pointer types.
-        See Explorer.explore_type for more information.
-        """
-        target_type = datatype.target()
-        print ("\n%s is a pointer to a value of type '%s'." %
-               (name, str(target_type)))
-
-        Explorer.explore_type("the pointee type of %s" % name,
-                              target_type,
-                              is_child)
-        return False
-
-
-class ReferenceExplorer(object):
-    """Internal class used to explore reference (TYPE_CODE_REF) values."""
-
-    @staticmethod
-    def explore_expr(expr, value, is_child):
-        """Function to explore array values.
-        See Explorer.explore_expr for more information.
-        """
-        referenced_value = value.referenced_value()
-        Explorer.explore_expr(expr, referenced_value, is_child)
-        return False
-
-    @staticmethod
-    def explore_type(name, datatype, is_child):
-        """Function to explore pointer types.
-        See Explorer.explore_type for more information.
-        """
-        target_type = datatype.target()
-        Explorer.explore_type(name, target_type, is_child)
-        return False
-
-
-class ArrayExplorer(object):
-    """Internal class used to explore arrays."""
-


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-06-13 14:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-13 14:22 [SCM] archer-pmuldoon-python-backtrace: Add frame filter management classes, and FrameFilter base class pmuldoon

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).