Debugger: Make gdbbridge fetchVariable output similar to lldbbridge's

Change-Id: I11fc7d163dbd6b7deb5e88cac65dc61df3352411
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2016-12-16 09:28:40 +01:00
parent 9861a58400
commit fb57391767
4 changed files with 17 additions and 40 deletions

View File

@@ -887,6 +887,9 @@ class DumperBase:
self.putField('sortgroup', sortorder) self.putField('sortgroup', sortorder)
self.putPlainChildren(value) self.putPlainChildren(value)
def put(self, stuff):
self.output += stuff
def check(self, exp): def check(self, exp):
if not exp: if not exp:
error('Check failed: %s' % exp) error('Check failed: %s' % exp)

View File

@@ -172,14 +172,14 @@ class OutputSafer:
def __enter__(self): def __enter__(self):
self.savedOutput = self.d.output self.savedOutput = self.d.output
self.d.output = [] self.d.output = ''
def __exit__(self, exType, exValue, exTraceBack): def __exit__(self, exType, exValue, exTraceBack):
if self.d.passExceptions and not exType is None: if self.d.passExceptions and not exType is None:
showException('OUTPUTSAFER', exType, exValue, exTraceBack) showException('OUTPUTSAFER', exType, exValue, exTraceBack)
self.d.output = self.savedOutput self.d.output = self.savedOutput
else: else:
self.savedOutput.extend(self.d.output) self.savedOutput += self.d.output
self.d.output = self.savedOutput self.d.output = self.savedOutput
return False return False
@@ -203,7 +203,7 @@ class Dumper(DumperBase):
self.interpreterBreakpointResolvers = [] self.interpreterBreakpointResolvers = []
def prepare(self, args): def prepare(self, args):
self.output = [] self.output = ''
self.setVariableFetchingOptions(args) self.setVariableFetchingOptions(args)
def fromFrameValue(self, nativeValue): def fromFrameValue(self, nativeValue):
@@ -688,7 +688,7 @@ class Dumper(DumperBase):
safePrint(res) safePrint(res)
return return
self.output.append('data=[') self.output += 'data=['
partialVar = args.get('partialvar', '') partialVar = args.get('partialvar', '')
isPartial = len(partialVar) > 0 isPartial = len(partialVar) > 0
@@ -711,30 +711,27 @@ class Dumper(DumperBase):
self.handleLocals(variables) self.handleLocals(variables)
self.handleWatches(args) self.handleWatches(args)
self.output.append('],typeinfo=[') self.output += '],typeinfo=['
for name in self.typesToReport.keys(): for name in self.typesToReport.keys():
typeobj = self.typesToReport[name] typeobj = self.typesToReport[name]
# Happens e.g. for '(anonymous namespace)::InsertDefOperation' # Happens e.g. for '(anonymous namespace)::InsertDefOperation'
#if not typeobj is None: #if not typeobj is None:
# self.output.append('{name="%s",size="%s"}' # self.output.append('{name="%s",size="%s"}'
# % (self.hexencode(name), typeobj.sizeof)) # % (self.hexencode(name), typeobj.sizeof))
self.output.append(']') self.output += ']'
self.typesToReport = {} self.typesToReport = {}
if self.forceQtNamespace: if self.forceQtNamespace:
self.qtNamepaceToReport = self.qtNamespace() self.qtNamepaceToReport = self.qtNamespace()
if self.qtNamespaceToReport: if self.qtNamespaceToReport:
self.output.append(',qtnamespace="%s"' % self.qtNamespaceToReport) self.output += ',qtnamespace="%s"' % self.qtNamespaceToReport
self.qtNamespaceToReport = None self.qtNamespaceToReport = None
self.output.append(',partial="%d"' % isPartial) self.output += ',partial="%d"' % isPartial
self.output.append(',counts=%s' % self.counts) self.output += ',counts=%s' % self.counts
self.output.append(',timimgs=%s' % self.timings) self.output += ',timimgs=%s' % self.timings
self.reportResult(self.output)
tt = time.time()
safePrint(''.join(self.output))
print(',time="%d"' % int(1000 * (tt - time.time())))
def parseAndEvaluate(self, exp): def parseAndEvaluate(self, exp):
#warn('EVALUATE "%s"' % exp) #warn('EVALUATE "%s"' % exp)
@@ -855,9 +852,6 @@ class Dumper(DumperBase):
address = gdb.parse_and_eval("&'%s'" % symbolName) address = gdb.parse_and_eval("&'%s'" % symbolName)
return toInteger(address) return toInteger(address)
def put(self, value):
self.output.append(value)
def isArmArchitecture(self): def isArmArchitecture(self):
return 'arm' in gdb.TARGET_CONFIG.lower() return 'arm' in gdb.TARGET_CONFIG.lower()
@@ -1252,7 +1246,7 @@ class Dumper(DumperBase):
limit = 10000 limit = 10000
self.prepare(args) self.prepare(args)
self.output = [] self.output = ''
i = 0 i = 0
if extraQml: if extraQml:
@@ -1342,7 +1336,7 @@ class Dumper(DumperBase):
frame = frame.older() frame = frame.older()
i += 1 i += 1
self.reportResult('stack={frames=[' + ','.join(self.output) + '].report}') self.reportResult('stack={frames=[' + self.output + '].report}')
def createResolvePendingBreakpointsHookBreakpoint(self, args): def createResolvePendingBreakpointsHookBreakpoint(self, args):
class Resolver(gdb.Breakpoint): class Resolver(gdb.Breakpoint):

View File

@@ -708,9 +708,6 @@ class Dumper(DumperBase):
else: else:
self.report('error="%s"' % result.GetError()) self.report('error="%s"' % result.GetError())
def put(self, stuff):
self.output += stuff
def canonicalTypeName(self, name): def canonicalTypeName(self, name):
return re.sub('\\bconst\\b', '', name).replace(' ', '') return re.sub('\\bconst\\b', '', name).replace(' ', '')

View File

@@ -4504,24 +4504,7 @@ void GdbEngine::doUpdateLocals(const UpdateParameters &params)
void GdbEngine::handleFetchVariables(const DebuggerResponse &response) void GdbEngine::handleFetchVariables(const DebuggerResponse &response)
{ {
m_inUpdateLocals = false; m_inUpdateLocals = false;
updateLocalsView(response.data);
if (response.resultClass == ResultDone) {
QString out = response.consoleStreamOutput;
while (out.endsWith(' ') || out.endsWith('\n'))
out.chop(1);
int pos = out.indexOf("data=");
if (pos != 0) {
showMessage("DISCARDING JUNK AT BEGIN OF RESPONSE: " + out.left(pos));
out = out.mid(pos);
}
GdbMi all;
all.fromStringMultiple(out);
updateLocalsView(all);
} else {
showMessage("DUMPER FAILED: " + response.toString());
}
watchHandler()->notifyUpdateFinished(); watchHandler()->notifyUpdateFinished();
} }