From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32353 invoked by alias); 20 May 2013 19:46:22 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 32329 invoked by uid 306); 20 May 2013 19:46:21 -0000 Date: Mon, 20 May 2013 19:46:00 -0000 Message-ID: <20130520194621.32300.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/python: remove dead "require" code X-Git-Refname: refs/heads/tromey/python X-Git-Reftype: branch X-Git-Oldrev: f2d682f1693239824f88eb87d50056df18125ea1 X-Git-Newrev: 2b5a5335d5c9ae7d9a546c542bedcd41811de385 X-SW-Source: 2013-q2/txt/msg00081.txt.bz2 List-Id: The branch, tromey/python has been updated via 2b5a5335d5c9ae7d9a546c542bedcd41811de385 (commit) via e273b85865b63c768f340a564855c0e4ee838ba7 (commit) from f2d682f1693239824f88eb87d50056df18125ea1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 2b5a5335d5c9ae7d9a546c542bedcd41811de385 Author: Tom Tromey Date: Mon May 20 13:44:11 2013 -0600 remove dead "require" code The old "require" command hasn't been needed in quite a long time. This patch deletes it. commit e273b85865b63c768f340a564855c0e4ee838ba7 Author: Tom Tromey Date: Mon May 20 13:40:46 2013 -0600 remove old frame wrapping code The old frame wrapping code and "new-backtrace" implementation are obsolete now that frame filters have gone in upstream. This patch removes the dead code. Unfortunately this necessitated removing "upto" and friends. There's no evidence that these were ever used, though. If needed they can be updated and resurrected. ----------------------------------------------------------------------- Summary of changes: gdb/data-directory/Makefile.in | 6 -- gdb/python/lib/gdb/FrameIterator.py | 33 -------- gdb/python/lib/gdb/FrameWrapper.py | 112 --------------------------- gdb/python/lib/gdb/backtrace.py | 42 ---------- gdb/python/lib/gdb/command/backtrace.py | 106 ------------------------- gdb/python/lib/gdb/command/require.py | 57 -------------- gdb/python/lib/gdb/command/upto.py | 129 ------------------------------- 7 files changed, 0 insertions(+), 485 deletions(-) delete mode 100644 gdb/python/lib/gdb/FrameIterator.py delete mode 100644 gdb/python/lib/gdb/FrameWrapper.py delete mode 100644 gdb/python/lib/gdb/backtrace.py delete mode 100644 gdb/python/lib/gdb/command/backtrace.py delete mode 100644 gdb/python/lib/gdb/command/require.py delete mode 100644 gdb/python/lib/gdb/command/upto.py First 500 lines of diff: diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in index e248399..f6a4b99 100644 --- a/gdb/data-directory/Makefile.in +++ b/gdb/data-directory/Makefile.in @@ -52,12 +52,8 @@ SYSCALLS_FILES = \ PYTHON_DIR = python PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) PYTHON_FILES = \ - gdb/FrameIterator.py \ - gdb/FrameWrapper.py \ gdb/__init__.py \ - gdb/backtrace.py \ gdb/command/__init__.py \ - gdb/command/backtrace.py \ gdb/command/ignore_errors.py \ gdb/command/pahole.py \ gdb/command/type_printers.py \ @@ -66,8 +62,6 @@ PYTHON_FILES = \ gdb/command/explore.py \ gdb/function/__init__.py \ gdb/function/strfns.py \ - gdb/command/require.py \ - gdb/command/upto.py \ gdb/function/__init__.py \ gdb/function/caller_is.py \ gdb/function/in_scope.py \ diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py deleted file mode 100644 index 5654546..0000000 --- a/gdb/python/lib/gdb/FrameIterator.py +++ /dev/null @@ -1,33 +0,0 @@ -# Iterator over frames. - -# Copyright (C) 2008, 2009 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 . - -class FrameIterator: - """An iterator that iterates over frames.""" - - def __init__ (self, frame): - "Initialize a FrameIterator. FRAME is the starting frame." - self.frame = frame - - def __iter__ (self): - return self - - def next (self): - result = self.frame - if result is None: - raise StopIteration - self.frame = result.older () - return result diff --git a/gdb/python/lib/gdb/FrameWrapper.py b/gdb/python/lib/gdb/FrameWrapper.py deleted file mode 100644 index b790a54..0000000 --- a/gdb/python/lib/gdb/FrameWrapper.py +++ /dev/null @@ -1,112 +0,0 @@ -# Wrapper API for frames. - -# Copyright (C) 2008, 2009 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 - -# FIXME: arguably all this should be on Frame somehow. -class FrameWrapper: - def __init__ (self, frame): - self.frame = frame; - - def write_symbol (self, stream, sym, block): - if len (sym.linkage_name): - nsym, is_field_of_this = gdb.lookup_symbol (sym.linkage_name, block) - if nsym.addr_class != gdb.SYMBOL_LOC_REGISTER: - sym = nsym - - stream.write (sym.print_name + "=") - try: - val = self.read_var (sym) - if val != None: - val = str (val) - # FIXME: would be nice to have a more precise exception here. - except RuntimeError, text: - val = text - if val == None: - stream.write ("???") - else: - stream.write (str (val)) - - def print_frame_locals (self, stream, func): - if not func: - return - - first = True - block = func.value - - for sym in block: - if sym.is_argument: - continue; - - self.write_symbol (stream, sym, block) - stream.write ('\n') - - def print_frame_args (self, stream, func): - if not func: - return - - first = True - block = func.value - - for sym in block: - if not sym.is_argument: - continue; - - if not first: - stream.write (", ") - - self.write_symbol (stream, sym, block) - first = False - - # FIXME: this should probably just be a method on gdb.Frame. - # But then we need stream wrappers. - def describe (self, stream, full): - if self.type () == gdb.DUMMY_FRAME: - stream.write (" \n") - elif self.type () == gdb.SIGTRAMP_FRAME: - stream.write (" \n") - else: - sal = self.find_sal () - pc = self.pc () - name = self.name () - if not name: - name = "??" - if pc != sal.pc or not sal.symtab: - stream.write (" 0x%08x in" % pc) - stream.write (" " + name + " (") - - func = self.function () - self.print_frame_args (stream, func) - - stream.write (")") - - if sal.symtab and sal.symtab.filename: - stream.write (" at " + sal.symtab.filename) - stream.write (":" + str (sal.line)) - - if not self.name () or (not sal.symtab or not sal.symtab.filename): - lib = gdb.solib_address (pc) - if lib: - stream.write (" from " + lib) - - stream.write ("\n") - - if full: - self.print_frame_locals (stream, func) - - def __getattr__ (self, name): - return getattr (self.frame, name) diff --git a/gdb/python/lib/gdb/backtrace.py b/gdb/python/lib/gdb/backtrace.py deleted file mode 100644 index 6bb4fb1..0000000 --- a/gdb/python/lib/gdb/backtrace.py +++ /dev/null @@ -1,42 +0,0 @@ -# Filtering backtrace. - -# Copyright (C) 2008, 2011 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 - -# Our only exports. -__all__ = ['push_frame_filter', 'create_frame_filter'] - -frame_filter = None - -def push_frame_filter (constructor): - """Register a new backtrace filter class with the 'backtrace' command. -The filter will be passed an iterator as an argument. The iterator -will return gdb.Frame-like objects. The filter should in turn act as -an iterator returning such objects.""" - global frame_filter - if frame_filter == None: - frame_filter = constructor - else: - frame_filter = lambda iterator, filter = frame_filter: constructor (filter (iterator)) - -def create_frame_filter (iter): - global frame_filter - if frame_filter is None: - return iter - return frame_filter (iter) - diff --git a/gdb/python/lib/gdb/command/backtrace.py b/gdb/python/lib/gdb/command/backtrace.py deleted file mode 100644 index eeea909..0000000 --- a/gdb/python/lib/gdb/command/backtrace.py +++ /dev/null @@ -1,106 +0,0 @@ -# New backtrace command. - -# Copyright (C) 2008, 2009, 2011 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 gdb.backtrace -import itertools -from gdb.FrameIterator import FrameIterator -from gdb.FrameWrapper import FrameWrapper -import sys - -class ReverseBacktraceParameter (gdb.Parameter): - """The new-backtrace command can show backtraces in 'reverse' order. -This means that the innermost frame will be printed last. -Note that reverse backtraces are more expensive to compute.""" - - set_doc = "Enable or disable reverse backtraces." - show_doc = "Show whether backtraces will be printed in reverse order." - - def __init__(self): - gdb.Parameter.__init__ (self, "reverse-backtrace", - gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN) - # Default to compatibility with gdb. - self.value = False - -class FilteringBacktrace (gdb.Command): - """Print backtrace of all stack frames, or innermost COUNT frames. -With a negative argument, print outermost -COUNT frames. -Use of the 'full' qualifier also prints the values of the local variables. -Use of the 'raw' qualifier avoids any filtering by loadable modules. -""" - - def __init__ (self): - # FIXME: this is not working quite well enough to replace - # "backtrace" yet. - gdb.Command.__init__ (self, "new-backtrace", gdb.COMMAND_STACK) - self.reverse = ReverseBacktraceParameter() - - def reverse_iter (self, iter): - result = [] - for item in iter: - result.append (item) - result.reverse() - return result - - def final_n (self, iter, x): - result = [] - for item in iter: - result.append (item) - return result[x:] - - def invoke (self, arg, from_tty): - i = 0 - count = 0 - filter = True - full = False - - for word in arg.split (" "): - if word == '': - continue - elif word == 'raw': - filter = False - elif word == 'full': - full = True - else: - count = int (word) - - # FIXME: provide option to start at selected frame - # However, should still number as if starting from newest - newest_frame = gdb.newest_frame() - iter = itertools.imap (FrameWrapper, - FrameIterator (newest_frame)) - if filter: - iter = gdb.backtrace.create_frame_filter (iter) - - # Now wrap in an iterator that numbers the frames. - iter = itertools.izip (itertools.count (0), iter) - - # Reverse if the user wanted that. - if self.reverse.value: - iter = self.reverse_iter (iter) - - # Extract sub-range user wants. - if count < 0: - iter = self.final_n (iter, count) - elif count > 0: - iter = itertools.islice (iter, 0, count) - - for pair in iter: - sys.stdout.write ("#%-2d" % pair[0]) - pair[1].describe (sys.stdout, full) - -FilteringBacktrace() diff --git a/gdb/python/lib/gdb/command/require.py b/gdb/python/lib/gdb/command/require.py deleted file mode 100644 index 1fbc1e8..0000000 --- a/gdb/python/lib/gdb/command/require.py +++ /dev/null @@ -1,57 +0,0 @@ -# Demand-loading commands. - -# Copyright (C) 2008, 2009 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 os - -class RequireCommand (gdb.Command): - """Prefix command for requiring features.""" - - def __init__ (self): - super (RequireCommand, self).__init__ ("require", - gdb.COMMAND_SUPPORT, - gdb.COMPLETE_NONE, - True) - -class RequireSubcommand (gdb.Command): - """Demand-load a command by name.""" - - def __init__ (self, name): - self.__doc__ = "Demand-load a %s by name." % name - super (RequireSubcommand, self).__init__ ("require %s" % name, - gdb.COMMAND_SUPPORT) - self.name = name - - def invoke (self, arg, from_tty): - for cmd in arg.split(): - exec ('import gdb.' + self.name + '.' + cmd, globals ()) - - def complete (self, text, word): - dir = gdb.pythondir + '/gdb/' + self.name - result = [] - for file in os.listdir(dir): - if not file.startswith (word) or not file.endswith ('.py'): - continue - feature = file[0:-3] - if feature == 'require' or feature == '__init__': - continue - result.append (feature) - return result - -RequireCommand() -RequireSubcommand("command") -RequireSubcommand("function") diff --git a/gdb/python/lib/gdb/command/upto.py b/gdb/python/lib/gdb/command/upto.py deleted file mode 100644 index faf54ed..0000000 --- a/gdb/python/lib/gdb/command/upto.py +++ /dev/null @@ -1,129 +0,0 @@ -# upto command. - -# Copyright (C) 2009 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 re -from gdb.FrameIterator import FrameIterator -from gdb.FrameWrapper import FrameWrapper - -class UptoPrefix (gdb.Command): - def __init__ (self): - super (UptoPrefix, self).__init__ ("upto", gdb.COMMAND_STACK, - prefix = True) - -class UptoImplementation (gdb.Command): - def __init__ (self, subcommand): - super (UptoImplementation, self).__init__ ("upto " + subcommand, - gdb.COMMAND_STACK) - - def search (self): - saved = gdb.selected_frame () - iter = FrameIterator (saved) - found = False - try: - for frame in iter: - frame.select () - try: - if self.filter (frame): - wrapper = FrameWrapper (frame) - wrapper.describe (sys.stdout, False) - return - except: - pass - except: - pass - saved.select () - raise RuntimeError, 'Could not find a matching frame' - - def invoke (self, arg, from_tty): - self.rx = re.compile (arg) - self.search () - -class UptoSymbolCommand (UptoImplementation): - """Select and print some calling stack frame, based on symbol. -The argument is a regular expression. This command moves up the -stack, stopping at the first frame whose symbol matches the regular -expression.""" - - def __init__ (self): - super (UptoSymbolCommand, self).__init__ ("symbol") - - def filter (self, frame): - name = frame.name () - if name is not None: - if self.rx.search (name) is not None: - return True - return False - -class UptoSourceCommand (UptoImplementation): - """Select and print some calling stack frame, based on source file. -The argument is a regular expression. This command moves up the -stack, stopping at the first frame whose source file name matches the -regular expression.""" - - def __init__ (self): - super (UptoSourceCommand, self).__init__ ("source") - - def filter (self, frame): - name = frame.find_sal ().symtab.filename - if name is not None: - if self.rx.search (name) is not None: - return True - return False - -class UptoObjectCommand (UptoImplementation): hooks/post-receive -- Repository for Project Archer.