Debugger: Mimic parts of lldbbridge in gdbbridge

Make code more similar for later sharing.

Change-Id: I260e10ba1b613dfcebc45bb1a268b6fcebbde353
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2016-12-15 18:28:58 +01:00
parent a61b6dfc57
commit 5c2a7b57e4
2 changed files with 17 additions and 12 deletions

View File

@@ -665,6 +665,9 @@ class Dumper(DumperBase):
return items return items
def reportToken(self, args):
pass
# Hack to avoid QDate* dumper timeouts with GDB 7.4 on 32 bit # Hack to avoid QDate* dumper timeouts with GDB 7.4 on 32 bit
# due to misaligned %ebx in SSE calls (qstring.cpp:findChar) # due to misaligned %ebx in SSE calls (qstring.cpp:findChar)
# This seems to be fixed in 7.9 (or earlier) # This seems to be fixed in 7.9 (or earlier)
@@ -1086,6 +1089,7 @@ class Dumper(DumperBase):
gdb.execute(cmd) gdb.execute(cmd)
def watchPoint(self, args): def watchPoint(self, args):
self.reportToken(args)
ns = self.qtNamespace() ns = self.qtNamespace()
lenns = len(ns) lenns = len(ns)
strns = ('%d%s' % (lenns - 2, ns[:lenns - 2])) if lenns else '' strns = ('%d%s' % (lenns - 2, ns[:lenns - 2])) if lenns else ''
@@ -1094,7 +1098,7 @@ class Dumper(DumperBase):
res = self.parseAndEvaluate(expr) res = self.parseAndEvaluate(expr)
p = 0 if res is None else res.pointer() p = 0 if res is None else res.pointer()
n = ("'%sQWidget'" % ns) if lenns else 'QWidget' n = ("'%sQWidget'" % ns) if lenns else 'QWidget'
safePrint('{selected="0x%x",expr="(%s*)0x%x"}' % (p, n, p)) self.reportResult('selected="0x%x",expr="(%s*)0x%x"' % (p, n, p), args)
def nativeDynamicTypeName(self, address, baseType): def nativeDynamicTypeName(self, address, baseType):
# Needed for Gdb13393 test. # Needed for Gdb13393 test.
@@ -1338,7 +1342,7 @@ class Dumper(DumperBase):
frame = frame.older() frame = frame.older()
i += 1 i += 1
safePrint('frames=[' + ','.join(self.output) + ']') self.reportResult('stack={frames=[' + ','.join(self.output) + '].report}')
def createResolvePendingBreakpointsHookBreakpoint(self, args): def createResolvePendingBreakpointsHookBreakpoint(self, args):
class Resolver(gdb.Breakpoint): class Resolver(gdb.Breakpoint):
@@ -1359,8 +1363,8 @@ class Dumper(DumperBase):
def exitGdb(self, _): def exitGdb(self, _):
gdb.execute('quit') gdb.execute('quit')
def reportResult(self, msg, args): def reportResult(self, result, args = {}):
print(msg) print('result={token="%s",%s}' % (args.get("token", 0), result))
def profile1(self, args): def profile1(self, args):
'''Internal profiling''' '''Internal profiling'''

View File

@@ -574,6 +574,9 @@ void GdbEngine::handleResponse(const QString &buff)
m_pendingLogStreamOutput.clear(); m_pendingLogStreamOutput.clear();
m_pendingConsoleStreamOutput.clear(); m_pendingConsoleStreamOutput.clear();
if (response.data.data().isEmpty())
response.data.fromString(response.consoleStreamOutput);
handleResultRecord(&response); handleResultRecord(&response);
break; break;
} }
@@ -1706,8 +1709,7 @@ void GdbEngine::handlePythonSetup(const DebuggerResponse &response)
{ {
CHECK_STATE(EngineSetupRequested); CHECK_STATE(EngineSetupRequested);
if (response.resultClass == ResultDone) { if (response.resultClass == ResultDone) {
GdbMi data; GdbMi data = response.data;
data.fromStringMultiple(response.consoleStreamOutput);
watchHandler()->addDumpers(data["dumpers"]); watchHandler()->addDumpers(data["dumpers"]);
m_pythonVersion = data["python"].toInt(); m_pythonVersion = data["python"].toInt();
if (m_pythonVersion < 20700) { if (m_pythonVersion < 20700) {
@@ -3243,12 +3245,11 @@ void GdbEngine::handleStackListFrames(const DebuggerResponse &response, bool isF
return; return;
} }
GdbMi frames = response.data["stack"]; // C++ GdbMi stack = response.data["stack"]; // C++
if (!frames.isValid() || frames.childCount() == 0) { // Mixed. //if (!frames.isValid() || frames.childCount() == 0) // Mixed.
GdbMi mixed; GdbMi frames = stack["frames"];
mixed.fromStringMultiple(response.consoleStreamOutput); if (!frames.isValid())
frames = mixed["frames"]; isFull = true;
}
stackHandler()->setFramesAndCurrentIndex(frames, isFull); stackHandler()->setFramesAndCurrentIndex(frames, isFull);
activateFrame(stackHandler()->currentIndex()); activateFrame(stackHandler()->currentIndex());