Permalink
Browse files

prettyprinter: changes for enable/disable pretty printers

added global variable inet_pp_enabled:
  initially value: enabled/disabled  inet pretty printers
added InetPrinter.subprinters:
  used by "info|enable|disable pretty-printer" gdb commands
  • Loading branch information...
1 parent 4ac832c commit 9b02319235423874e3c6a0b0721ad6e7db8def46 @ZoltanBojthe ZoltanBojthe committed Jan 7, 2013
Showing with 8 additions and 2 deletions.
  1. +8 −2 misc/gdb/inet/printers.py
View
@@ -19,6 +19,8 @@
except ImportError:
_use_gdb_pp = False
+# initially enabled/disabled the inet pretty printers
+inet_pp_enabled = True
class IPv4AddressPrinter:
"Print an IPv4Address"
@@ -125,10 +127,11 @@ def to_string(self):
# "SubPrettyPrinter" protocol from gdb.printing.
class InetSubPrinter(object):
def __init__(self, name, function):
+ global inet_pp_enabled
super(InetSubPrinter, self).__init__()
self.name = name
self.function = function
- self.enabled = True
+ self.enabled = inet_pp_enabled
def invoke(self, value):
if not self.enabled:
@@ -139,13 +142,16 @@ def invoke(self, value):
# gdb.printing. It can also be used directly as an old-style printer.
class InetPrinter(object):
def __init__(self, name):
+ global inet_pp_enabled
super(InetPrinter, self).__init__()
self.name = name
+ self.subprinters = [] # used by 'gdb command: info pretty-printer'
self.lookup = {}
- self.enabled = True
+ self.enabled = inet_pp_enabled
def add(self, name, function):
printer = InetSubPrinter(name, function)
+ self.subprinters.append(printer)
self.lookup[name] = printer
@staticmethod

0 comments on commit 9b02319

Please sign in to comment.