PR python/17364
gdb/ChangeLog: * python/lib/gdb/__init__.py (packages): Add "printer". * python/lib/gdb/command/bound_registers.py: Moved to ... * python/lib/gdb/printer/bound_registers.py: ... here. Add printer to global set of builtin printers. Rename printer from "bound" to "mpx_bound128". * python/lib/gdb/printing.py (_builtin_pretty_printers): New global, registered as global "builtin" printer. (add_builtin_pretty_printer): New function. * data-directory/Makefile.in (PYTHON_FILE_LIST): Update, and add gdb/printer/__init__.py.
This commit is contained in:
parent
35a49624e2
commit
6979730b1b
6 changed files with 54 additions and 18 deletions
|
@ -1,3 +1,18 @@
|
||||||
|
2014-10-15 Doug Evans <dje@google.com>
|
||||||
|
Walfred Tedeschi <walfred.tedeschi@intel.com>
|
||||||
|
|
||||||
|
PR python/17364
|
||||||
|
* python/lib/gdb/__init__.py (packages): Add "printer".
|
||||||
|
* python/lib/gdb/command/bound_registers.py: Moved to ...
|
||||||
|
* python/lib/gdb/printer/bound_registers.py: ... here.
|
||||||
|
Add printer to global set of builtin printers. Rename printer from
|
||||||
|
"bound" to "mpx_bound128".
|
||||||
|
* python/lib/gdb/printing.py (_builtin_pretty_printers): New global,
|
||||||
|
registered as global "builtin" printer.
|
||||||
|
(add_builtin_pretty_printer): New function.
|
||||||
|
* data-directory/Makefile.in (PYTHON_FILE_LIST): Update, and add
|
||||||
|
gdb/printer/__init__.py.
|
||||||
|
|
||||||
2014-10-15 Iain Buclaw <ibuclaw@gdcproject.org>
|
2014-10-15 Iain Buclaw <ibuclaw@gdcproject.org>
|
||||||
|
|
||||||
* Makefile.in (SFILES): Remove d-support.c.
|
* Makefile.in (SFILES): Remove d-support.c.
|
||||||
|
|
|
@ -64,7 +64,6 @@ PYTHON_FILE_LIST = \
|
||||||
gdb/printing.py \
|
gdb/printing.py \
|
||||||
gdb/prompt.py \
|
gdb/prompt.py \
|
||||||
gdb/xmethod.py \
|
gdb/xmethod.py \
|
||||||
gdb/command/bound_registers.py \
|
|
||||||
gdb/command/__init__.py \
|
gdb/command/__init__.py \
|
||||||
gdb/command/xmethods.py \
|
gdb/command/xmethods.py \
|
||||||
gdb/command/frame_filters.py \
|
gdb/command/frame_filters.py \
|
||||||
|
@ -74,7 +73,9 @@ PYTHON_FILE_LIST = \
|
||||||
gdb/command/explore.py \
|
gdb/command/explore.py \
|
||||||
gdb/function/__init__.py \
|
gdb/function/__init__.py \
|
||||||
gdb/function/caller_is.py \
|
gdb/function/caller_is.py \
|
||||||
gdb/function/strfns.py
|
gdb/function/strfns.py \
|
||||||
|
gdb/printer/__init__.py \
|
||||||
|
gdb/printer/bound_registers.py
|
||||||
|
|
||||||
@HAVE_PYTHON_TRUE@PYTHON_FILES = $(PYTHON_FILE_LIST)
|
@HAVE_PYTHON_TRUE@PYTHON_FILES = $(PYTHON_FILE_LIST)
|
||||||
@HAVE_PYTHON_FALSE@PYTHON_FILES =
|
@HAVE_PYTHON_FALSE@PYTHON_FILES =
|
||||||
|
|
|
@ -81,7 +81,8 @@ PYTHONDIR = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
|
||||||
packages = [
|
packages = [
|
||||||
'function',
|
'function',
|
||||||
'command'
|
'command',
|
||||||
|
'printer'
|
||||||
]
|
]
|
||||||
|
|
||||||
# pkgutil.iter_modules is not available prior to Python 2.6. Instead,
|
# pkgutil.iter_modules is not available prior to Python 2.6. Instead,
|
||||||
|
|
14
gdb/python/lib/gdb/printer/__init__.py
Normal file
14
gdb/python/lib/gdb/printer/__init__.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Copyright (C) 2014 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/>.
|
|
@ -1,4 +1,4 @@
|
||||||
# Pretty-printer utilities.
|
# Pretty-printers for bounds registers.
|
||||||
# Copyright (C) 2013-2014 Free Software Foundation, Inc.
|
# Copyright (C) 2013-2014 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
import gdb.printing
|
import gdb.printing
|
||||||
|
|
||||||
class BoundPrinter:
|
class MpxBound128Printer:
|
||||||
"""Adds size field to a _rawbound128 type."""
|
"""Adds size field to a mpx __gdb_builtin_type_bound128 type."""
|
||||||
|
|
||||||
def __init__ (self, val):
|
def __init__ (self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
|
@ -31,15 +31,6 @@ class BoundPrinter:
|
||||||
result = '{lbound = %s, ubound = %s} : size %s' % (lower, upper, size)
|
result = '{lbound = %s, ubound = %s} : size %s' % (lower, upper, size)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# There are two pattern matching used: first one is related to a library
|
gdb.printing.add_builtin_pretty_printer ('mpx_bound128',
|
||||||
# second is related to the type. Since we are displaying a register all
|
'^__gdb_builtin_type_bound128',
|
||||||
# libraries are accepted. Type to be processed is the same present
|
MpxBound128Printer)
|
||||||
# in the xml file.
|
|
||||||
|
|
||||||
def build_pretty_printer ():
|
|
||||||
pp = gdb.printing.RegexpCollectionPrettyPrinter (".*")
|
|
||||||
pp.add_printer ('bound', '^__gdb_builtin_type_bound128', BoundPrinter)
|
|
||||||
return pp
|
|
||||||
|
|
||||||
gdb.printing.register_pretty_printer (gdb.current_objfile (),
|
|
||||||
build_pretty_printer ())
|
|
|
@ -263,3 +263,17 @@ class FlagEnumerationPrinter(PrettyPrinter):
|
||||||
return _EnumInstance(self.enumerators, val)
|
return _EnumInstance(self.enumerators, val)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
# Builtin pretty-printers.
|
||||||
|
# The set is defined as empty, and files in printing/*.py add their printers
|
||||||
|
# to this with add_builtin_pretty_printer.
|
||||||
|
|
||||||
|
_builtin_pretty_printers = RegexpCollectionPrettyPrinter("builtin")
|
||||||
|
|
||||||
|
register_pretty_printer(None, _builtin_pretty_printers)
|
||||||
|
|
||||||
|
# Add a builtin pretty-printer.
|
||||||
|
|
||||||
|
def add_builtin_pretty_printer(name, regexp, printer):
|
||||||
|
_builtin_pretty_printers.add_printer(name, regexp, printer)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue