Commit 6b2665a1 authored by hjk's avatar hjk
Browse files

Debugger: Consolidate dumper state setting



Move all the currentFoo initialization to DumperBase

Change-Id: I0a59715fe1550f466e78cbf678622dd8dfe1783c
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
Reviewed-by: default avatarhjk <hjk@qt.io>
parent 9d7b562f
...@@ -35,29 +35,8 @@ from dumper import * ...@@ -35,29 +35,8 @@ from dumper import *
class Dumper(DumperBase): class Dumper(DumperBase):
def __init__(self): def __init__(self):
DumperBase.__init__(self) DumperBase.__init__(self)
self.outputLock = threading.Lock() self.outputLock = threading.Lock()
self.isCdb = True self.isCdb = True
self.expandedINames = {}
self.passExceptions = False
self.showQObjectNames = False
self.autoDerefPointers = True
self.useDynamicType = True
self.useFancy = True
self.formats = {}
self.typeformats = {}
self.currentContextValue = None
self.currentIName = None
self.currentValue = ReportItem()
self.currentType = ReportItem()
self.currentNumChild = None
self.currentMaxNumChild = None
self.currentPrintsAddress = True
self.currentChildType = None
self.currentChildNumChild = -1
self.currentWatchers = {}
def fromNativeValue(self, nativeValue): def fromNativeValue(self, nativeValue):
val = self.Value(self) val = self.Value(self)
...@@ -183,19 +162,9 @@ class Dumper(DumperBase): ...@@ -183,19 +162,9 @@ class Dumper(DumperBase):
self.reportResult(res, args) self.reportResult(res, args)
return return
self.expandedINames = set(args.get('expanded', [])) self.setVariableFetchingOptions(args)
self.autoDerefPointers = int(args.get('autoderef', '0'))
self.useDynamicType = int(args.get('dyntype', '0'))
self.useFancy = int(args.get('fancy', '0'))
self.passExceptions = int(args.get('passexceptions', '0'))
self.showQObjectNames = int(args.get('qobjectnames', '0'))
self.currentWatchers = args.get('watchers', {})
self.typeformats = args.get('typeformats', {})
self.formats = args.get('formats', {})
self.output = '' self.output = ''
partialVariable = args.get('partialvar', "")
isPartial = len(partialVariable) > 0
self.currentIName = 'local' self.currentIName = 'local'
self.put('data=[') self.put('data=[')
...@@ -212,7 +181,7 @@ class Dumper(DumperBase): ...@@ -212,7 +181,7 @@ class Dumper(DumperBase):
self.handleLocals(variables) self.handleLocals(variables)
self.handleWatches(args) self.handleWatches(args)
self.put('],partial="%d"' % isPartial) self.put('],partial="%d"' % (len(self.partialVariable) > 0))
self.reportResult(self.output, args) self.reportResult(self.output, args)
def report(self, stuff): def report(self, stuff):
......
...@@ -302,6 +302,44 @@ class DumperBase: ...@@ -302,6 +302,44 @@ class DumperBase:
"personaltypes", "personaltypes",
] ]
# These values are never used, but the variables need to have
# some value base for the swapping logic in Children.__enter__()
# and Children.__exit__().
self.currentIName = None
self.currentValue = None
self.currentType = None
self.currentNumChild = None
self.currentMaxNumChild = None
self.currentPrintsAddress = True
self.currentChildType = None
self.currentChildNumChild = None
def setVariableFetchingOptions(self, args):
self.resultVarName = args.get('resultvarname', '')
self.expandedINames = set(args.get('expanded', []))
self.stringCutOff = int(args.get('stringcutoff', 10000))
self.displayStringLimit = int(args.get('displaystringlimit', 100))
self.typeformats = args.get('typeformats', {})
self.formats = args.get('formats', {})
self.watchers = args.get('watchers', {})
self.useDynamicType = int(args.get('dyntype', '0'))
self.useFancy = int(args.get('fancy', '0'))
self.forceQtNamespace = int(args.get('forcens', '0'))
self.passExceptions = int(args.get('passexceptions', '0'))
self.showQObjectNames = int(args.get('qobjectnames', '0'))
self.nativeMixed = int(args.get('nativemixed', '0'))
self.autoDerefPointers = int(args.get('autoderef', '0'))
self.partialVariable = args.get('partialvar', '')
self.partialUpdate = int(args.get('partial', '0'))
self.fallbackQtVersion = 0x50200
#warn('NAMESPACE: "%s"' % self.qtNamespace())
#warn('EXPANDED INAMES: %s' % self.expandedINames)
#warn('WATCHERS: %s' % self.watchers)
# The guess does not need to be updated during a fetchVariables()
# as the result is fixed during that time (ignoring "active"
# dumpers causing loading of shared objects etc).
self.currentQtNamespaceGuess = None
def resetCaches(self): def resetCaches(self):
# This is a cache mapping from 'type name' to 'display alternatives'. # This is a cache mapping from 'type name' to 'display alternatives'.
......
...@@ -203,41 +203,7 @@ class Dumper(DumperBase): ...@@ -203,41 +203,7 @@ class Dumper(DumperBase):
def prepare(self, args): def prepare(self, args):
self.output = [] self.output = []
self.currentIName = "" self.setVariableFetchingOptions(args)
self.currentPrintsAddress = True
self.currentChildType = ""
self.currentChildNumChild = -1
self.currentMaxNumChild = -1
self.currentNumChild = -1
self.currentValue = ReportItem()
self.currentType = ReportItem()
self.currentAddress = None
self.resultVarName = args.get("resultvarname", "")
self.expandedINames = set(args.get("expanded", []))
self.stringCutOff = int(args.get("stringcutoff", 10000))
self.displayStringLimit = int(args.get("displaystringlimit", 100))
self.typeformats = args.get("typeformats", {})
self.formats = args.get("formats", {})
self.watchers = args.get("watchers", {})
self.useDynamicType = int(args.get("dyntype", "0"))
self.useFancy = int(args.get("fancy", "0"))
self.forceQtNamespace = int(args.get("forcens", "0"))
self.passExceptions = int(args.get("passexceptions", "0"))
self.showQObjectNames = int(args.get("qobjectnames", "0"))
self.nativeMixed = int(args.get("nativemixed", "0"))
self.autoDerefPointers = int(args.get("autoderef", "0"))
self.partialUpdate = int(args.get("partial", "0"))
self.fallbackQtVersion = 0x50200
#warn("NAMESPACE: '%s'" % self.qtNamespace())
#warn("EXPANDED INAMES: %s" % self.expandedINames)
#warn("WATCHERS: %s" % self.watchers)
# The guess does not need to be updated during a fetchVariables()
# as the result is fixed during that time (ignoring "active"
# dumpers causing loading of shared objects etc).
self.currentQtNamespaceGuess = None
def fromNativeDowncastableValue(self, nativeValue): def fromNativeDowncastableValue(self, nativeValue):
if self.useDynamicType: if self.useDynamicType:
......
...@@ -61,7 +61,7 @@ class Dumper(DumperBase): ...@@ -61,7 +61,7 @@ class Dumper(DumperBase):
def __init__(self): def __init__(self):
DumperBase.__init__(self) DumperBase.__init__(self)
lldb.theDumper = self lldb.theDumper = self
self.isLldb = True
self.outputLock = threading.Lock() self.outputLock = threading.Lock()
self.debugger = lldb.SBDebugger.Create() self.debugger = lldb.SBDebugger.Create()
#self.debugger.SetLoggingCallback(loggingCallback) #self.debugger.SetLoggingCallback(loggingCallback)
...@@ -91,30 +91,9 @@ class Dumper(DumperBase): ...@@ -91,30 +91,9 @@ class Dumper(DumperBase):
#for i in range(self.debugger.GetNumCategories()): #for i in range(self.debugger.GetNumCategories()):
# self.debugger.GetCategoryAtIndex(i).SetEnabled(False) # self.debugger.GetCategoryAtIndex(i).SetEnabled(False)
self.isLldb = True
self.process = None self.process = None
self.target = None self.target = None
self.eventState = lldb.eStateInvalid self.eventState = lldb.eStateInvalid
self.expandedINames = {}
self.passExceptions = False
self.showQObjectNames = False
self.useLldbDumpers = False
self.autoDerefPointers = True
self.useDynamicType = True
self.useFancy = True
self.formats = {}
self.typeformats = {}
self.currentContextValue = None
self.currentIName = None
self.currentValue = ReportItem()
self.currentType = ReportItem()
self.currentNumChild = None
self.currentMaxNumChild = None
self.currentPrintsAddress = True
self.currentChildType = None
self.currentChildNumChild = -1
self.currentWatchers = {}
self.executable_ = None self.executable_ = None
self.startMode_ = None self.startMode_ = None
...@@ -629,7 +608,8 @@ class Dumper(DumperBase): ...@@ -629,7 +608,8 @@ class Dumper(DumperBase):
self.target.BreakpointCreateByName("qt_qmlDebugMessageAvailable") self.target.BreakpointCreateByName("qt_qmlDebugMessageAvailable")
state = 1 if self.target.IsValid() else 0 state = 1 if self.target.IsValid() else 0
self.reportResult('success="%s",msg="%s",exe="%s"' % (state, error, self.executable_), args) self.reportResult('success="%s",msg="%s",exe="%s"'
% (state, error, self.executable_), args)
def runEngine(self, args): def runEngine(self, args):
self.prepare(args) self.prepare(args)
...@@ -876,15 +856,7 @@ class Dumper(DumperBase): ...@@ -876,15 +856,7 @@ class Dumper(DumperBase):
self.reportResult(res, args) self.reportResult(res, args)
return return
self.expandedINames = set(args.get('expanded', [])) self.setVariableFetchingOptions(args)
self.autoDerefPointers = int(args.get('autoderef', '0'))
self.useDynamicType = int(args.get('dyntype', '0'))
self.useFancy = int(args.get('fancy', '0'))
self.passExceptions = int(args.get('passexceptions', '0'))
self.showQObjectNames = int(args.get('qobjectnames', '0'))
self.currentWatchers = args.get('watchers', {})
self.typeformats = args.get('typeformats', {})
self.formats = args.get('formats', {})
frame = self.currentFrame() frame = self.currentFrame()
if frame is None: if frame is None:
...@@ -892,9 +864,7 @@ class Dumper(DumperBase): ...@@ -892,9 +864,7 @@ class Dumper(DumperBase):
return return
self.output = '' self.output = ''
self.currentAddress = None isPartial = len(self.partialVariable) > 0
partialVariable = args.get('partialvar', "")
isPartial = len(partialVariable) > 0
self.currentIName = 'local' self.currentIName = 'local'
self.put('data=[') self.put('data=[')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment