Commit fee7cbe5 authored by hjk's avatar hjk

Debugger: Move 'mixed native' variables extraction to DumperBase

In preparation for re-use through LLDB. Not yet functional there.

Change-Id: Ia924f1499a1bbaebf3dccbe15152f324058b1677
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent cad399f9
......@@ -1831,6 +1831,73 @@ class DumperBase:
'fileName': fileName,
'context': context }
# Contains iname, name, and value.
class LocalItem:
pass
def extractQmlVariables(self, qmlcontext):
items = []
contextType = self.lookupQtType("QV4::Heap::CallContext")
context = self.createPointerValue(self.qmlcontext, contextType)
contextItem = self.LocalItem()
contextItem.iname = "local.@context"
contextItem.name = "[context]"
contextItem.value = context.dereference()
items.append(contextItem)
argsItem = self.LocalItem()
argsItem.iname = "local.@args"
argsItem.name = "[args]"
argsItem.value = context["callData"]
items.append(argsItem)
functionObject = context["function"].dereference()
functionPtr = functionObject["function"]
if not self.isNull(functionPtr):
compilationUnit = context["compilationUnit"]
compiledFunction = functionPtr["compiledFunction"]
base = int(compiledFunction)
formalsOffset = int(compiledFunction["formalsOffset"])
formalsCount = int(compiledFunction["nFormals"])
for index in range(formalsCount):
stringIndex = self.extractInt(base + formalsOffset + 4 * index)
name = self.extractQmlRuntimeString(compilationUnit, stringIndex)
item = self.LocalItem()
item.iname = "local." + name
item.name = name
item.value = argsItem.value["args"][index]
items.append(item)
localsOffset = int(compiledFunction["localsOffset"])
localsCount = int(compiledFunction["nLocals"])
for index in range(localsCount):
stringIndex = self.extractInt(base + localsOffset + 4 * index)
name = self.extractQmlRuntimeString(compilationUnit, stringIndex)
item = self.LocalItem()
item.iname = "local." + name
item.name = name
item.value = context["locals"][index]
items.append(item)
for engine in self.qmlEngines:
engineItem = self.LocalItem()
engineItem.iname = "local.@qmlengine"
engineItem.name = "[engine]"
engineItem.value = engine
items.append(engineItem)
rootContext = self.LocalItem()
rootContext.iname = "local.@rootContext"
rootContext.name = "[rootContext]"
rootContext.value = engine["d_ptr"]
items.append(rootContext)
break
return items
# Some "Enums"
......
......@@ -207,8 +207,6 @@ class OutputSafer:
Value = gdb.Value
def stripTypedefs(typeobj):
typeobj = typeobj.unqualified()
while typeobj.code == TypedefCode:
......@@ -216,17 +214,6 @@ def stripTypedefs(typeobj):
return typeobj
#######################################################################
#
# LocalItem
#
#######################################################################
# Contains iname, name, and value.
class LocalItem:
pass
#######################################################################
#
# Edit Command
......@@ -359,69 +346,6 @@ class Dumper(DumperBase):
def listOfLocals(self):
frame = gdb.selected_frame()
if self.qmlcontext:
items = []
contextType = self.lookupQtType("QV4::Heap::CallContext")
context = self.createPointerValue(self.qmlcontext, contextType)
contextItem = LocalItem()
contextItem.iname = "local.@context"
contextItem.name = "[context]"
contextItem.value = context.dereference()
items.append(contextItem)
argsItem = LocalItem()
argsItem.iname = "local.@args"
argsItem.name = "[args]"
argsItem.value = context["callData"]
items.append(argsItem)
functionObject = context["function"].dereference()
functionPtr = functionObject["function"]
if not self.isNull(functionPtr):
compilationUnit = context["compilationUnit"]
compiledFunction = functionPtr["compiledFunction"]
base = int(compiledFunction)
formalsOffset = int(compiledFunction["formalsOffset"])
formalsCount = int(compiledFunction["nFormals"])
for index in range(formalsCount):
stringIndex = self.extractInt(base + formalsOffset + 4 * index)
name = self.extractQmlRuntimeString(compilationUnit, stringIndex)
item = LocalItem()
item.iname = "local." + name
item.name = name
item.value = argsItem.value["args"][index]
items.append(item)
localsOffset = int(compiledFunction["localsOffset"])
localsCount = int(compiledFunction["nLocals"])
for index in range(localsCount):
stringIndex = self.extractInt(base + localsOffset + 4 * index)
name = self.extractQmlRuntimeString(compilationUnit, stringIndex)
item = LocalItem()
item.iname = "local." + name
item.name = name
item.value = context["locals"][index]
items.append(item)
for engine in self.qmlEngines:
engineItem = LocalItem()
engineItem.iname = "local.@qmlengine"
engineItem.name = "[engine]"
engineItem.value = engine
items.append(engineItem)
rootContext = LocalItem()
rootContext.iname = "local.@rootContext"
rootContext.name = "[rootContext]"
rootContext.value = engine["d_ptr"]
items.append(rootContext)
break
return items
try:
block = frame.block()
#warn("BLOCK: %s " % block)
......@@ -455,7 +379,7 @@ class Dumper(DumperBase):
name1 = name
shadowed[name] = 1
#warn("SYMBOL %s (%s, %s)): " % (symbol, name, symbol.name))
item = LocalItem()
item = self.LocalItem()
item.iname = "local." + name1
item.name = name1
try:
......@@ -507,14 +431,17 @@ class Dumper(DumperBase):
# Locals
#
self.output.append('data=[')
if self.partialUpdate and len(self.varList) == 1 \
and not self.qmlcontext:
if self.qmlcontext:
locals = self.extractQmlVariables(self.qmlcontext)
elif self.partialUpdate and len(self.varList) == 1:
#warn("PARTIAL: %s" % self.varList)
parts = self.varList[0].split('.')
#warn("PARTIAL PARTS: %s" % parts)
name = parts[1]
#warn("PARTIAL VAR: %s" % name)
item = LocalItem()
item = self.LocalItem()
item.iname = parts[0] + '.' + name
item.name = name
try:
......@@ -536,7 +463,7 @@ class Dumper(DumperBase):
# Take care of the return value of the last function call.
if len(self.resultVarName) > 0:
try:
item = LocalItem()
item = self.LocalItem()
item.name = self.resultVarName
item.iname = "return." + self.resultVarName
item.value = self.parseAndEvaluate(self.resultVarName)
......
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