forked from qt-creator/qt-creator
Debugger: Allow use of regular expressions for dumpers
The pattern is given as (unused) default value of a third parameter of the dump__* functions. Change-Id: Ia9092427c240f2198acd00267cd136a3becc71b6 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import base64
|
||||
import re
|
||||
import time
|
||||
import json
|
||||
import inspect
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
xrange = range
|
||||
@@ -372,7 +373,8 @@ class DumperBase:
|
||||
self.qqFormats = { "QVariant (QVariantMap)" : mapForms() }
|
||||
|
||||
# This is a cache of all known dumpers.
|
||||
self.qqDumpers = {}
|
||||
self.qqDumpers = {} # Direct type match
|
||||
self.qqDumpersEx = {} # Using regexp
|
||||
|
||||
# This is a cache of all dumpers that support writing.
|
||||
self.qqEditable = {}
|
||||
@@ -1025,6 +1027,12 @@ class DumperBase:
|
||||
dumper(self, value)
|
||||
return True
|
||||
|
||||
for pattern in self.qqDumpersEx.keys():
|
||||
dumper = self.qqDumpersEx[pattern]
|
||||
if re.match(pattern, nsStrippedType):
|
||||
dumper(self, value)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def putSimpleCharArray(self, base, size = None):
|
||||
@@ -1731,11 +1739,13 @@ class DumperBase:
|
||||
|
||||
def registerDumper(self, funcname, function):
|
||||
try:
|
||||
#warn("FUNCTION: %s " % funcname)
|
||||
#funcname = function.func_name
|
||||
if funcname.startswith("qdump__"):
|
||||
typename = funcname[7:]
|
||||
self.qqDumpers[typename] = function
|
||||
spec = inspect.getargspec(function)
|
||||
if len(spec.args) == 2:
|
||||
self.qqDumpers[typename] = function
|
||||
elif len(spec.args) == 3 and len(spec.defaults) == 1:
|
||||
self.qqDumpersEx[spec.defaults[0]] = function
|
||||
self.qqFormats[typename] = self.qqFormats.get(typename, [])
|
||||
elif funcname.startswith("qform__"):
|
||||
typename = funcname[7:]
|
||||
|
Reference in New Issue
Block a user