Commit b8ae9fd4 authored by hjk's avatar hjk Committed by Christian Stenger

Debugger: Adjust native mixed debugging after upstream changes

Change-Id: I4d137fadd0de2aa346f2f49932faac4ee9ed41e7
Reviewed-by: default avatarUlf Hermann <ulf.hermann@theqtcompany.com>
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent be1e0f7e
This diff is collapsed.
...@@ -1603,7 +1603,7 @@ class Dumper(DumperBase): ...@@ -1603,7 +1603,7 @@ class Dumper(DumperBase):
objfile = fromNativePath(symtab.objfile.filename) objfile = fromNativePath(symtab.objfile.filename)
fileName = fromNativePath(symtab.fullname()) fileName = fromNativePath(symtab.fullname())
if self.nativeMixed and functionName == "qt_qmlDebugEventFromService": if self.nativeMixed and functionName == "qt_qmlDebugMessageAvailable":
interpreterStack = self.extractInterpreterStack() interpreterStack = self.extractInterpreterStack()
#print("EXTRACTED INTEPRETER STACK: %s" % interpreterStack) #print("EXTRACTED INTEPRETER STACK: %s" % interpreterStack)
for interpreterFrame in interpreterStack.get('frames', []): for interpreterFrame in interpreterStack.get('frames', []):
...@@ -1641,13 +1641,11 @@ class Dumper(DumperBase): ...@@ -1641,13 +1641,11 @@ class Dumper(DumperBase):
self.dumper = dumper self.dumper = dumper
self.args = args self.args = args
spec = "qt_qmlDebugConnectorOpen" spec = "qt_qmlDebugConnectorOpen"
print("Preparing hook to resolve pending QML breakpoint at %s" % args)
super(Resolver, self).\ super(Resolver, self).\
__init__(spec, gdb.BP_BREAKPOINT, internal=True, temporary=False) __init__(spec, gdb.BP_BREAKPOINT, internal=True, temporary=False)
def stop(self): def stop(self):
bp = self.dumper.doInsertInterpreterBreakpoint(args, True) self.dumper.resolvePendingInterpreterBreakpoint(args)
print("Resolving QML breakpoint %s -> %s" % (args, bp))
self.enabled = False self.enabled = False
return False return False
...@@ -1800,14 +1798,14 @@ registerCommand("threadnames", threadnames) ...@@ -1800,14 +1798,14 @@ registerCommand("threadnames", threadnames)
# #
####################################################################### #######################################################################
class QmlEngineEventBreakpoint(gdb.Breakpoint): class InterpreterMessageBreakpoint(gdb.Breakpoint):
def __init__(self): def __init__(self):
spec = "qt_qmlDebugEventFromService" spec = "qt_qmlDebugMessageAvailable"
super(QmlEngineEventBreakpoint, self).\ super(InterpreterMessageBreakpoint, self).\
__init__(spec, gdb.BP_BREAKPOINT, internal=True) __init__(spec, gdb.BP_BREAKPOINT, internal=True)
def stop(self): def stop(self):
print("Interpreter event received.") print("Interpreter event received.")
return theDumper.handleInterpreterEvent() return theDumper.handleInterpreterMessage()
QmlEngineEventBreakpoint() InterpreterMessageBreakpoint()
...@@ -693,7 +693,7 @@ class Dumper(DumperBase): ...@@ -693,7 +693,7 @@ class Dumper(DumperBase):
if self.nativeMixed: if self.nativeMixed:
self.interpreterEventBreakpoint = \ self.interpreterEventBreakpoint = \
self.target.BreakpointCreateByName("qt_qmlDebugEventFromService") 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)
...@@ -871,7 +871,7 @@ class Dumper(DumperBase): ...@@ -871,7 +871,7 @@ class Dumper(DumperBase):
functionName = frame.GetFunctionName() functionName = frame.GetFunctionName()
if isNativeMixed and functionName == "::qt_qmlDebugEventFromService()": if isNativeMixed and functionName == "::qt_qmlDebugMessageAvailable()":
interpreterStack = self.extractInterpreterStack() interpreterStack = self.extractInterpreterStack()
for interpreterFrame in interpreterStack.get('frames', []): for interpreterFrame in interpreterStack.get('frames', []):
function = interpreterFrame.get('function', '') function = interpreterFrame.get('function', '')
...@@ -1341,9 +1341,9 @@ class Dumper(DumperBase): ...@@ -1341,9 +1341,9 @@ class Dumper(DumperBase):
self.reportState("inferiorstopok") self.reportState("inferiorstopok")
self.process.Continue(); self.process.Continue();
return return
if functionName == "::qt_qmlDebugEventFromService()": if functionName == "::qt_qmlDebugMessageAvailable()":
self.report("EVENT FROM SERVICE") self.report("ASYNC MESSAGE FROM SERVICE")
res = self.handleInterpreterEvent() res = self.handleInterpreterMessage()
if not res: if not res:
self.report("EVENT NEEDS NO STOP") self.report("EVENT NEEDS NO STOP")
self.reportState("stopped") self.reportState("stopped")
...@@ -1427,7 +1427,7 @@ class Dumper(DumperBase): ...@@ -1427,7 +1427,7 @@ class Dumper(DumperBase):
if bpType == BreakpointByFileAndLine: if bpType == BreakpointByFileAndLine:
fileName = args["file"] fileName = args["file"]
if fileName.endswith(".js") or fileName.endswith(".qml"): if fileName.endswith(".js") or fileName.endswith(".qml"):
self.doInsertInterpreterBreakpoint(args, False) self.insertInterpreterBreakpoint(args)
return return
extra = '' extra = ''
...@@ -1742,7 +1742,7 @@ class Dumper(DumperBase): ...@@ -1742,7 +1742,7 @@ class Dumper(DumperBase):
bp = self.target.BreakpointCreateByName("qt_qmlDebugConnectorOpen") bp = self.target.BreakpointCreateByName("qt_qmlDebugConnectorOpen")
bp.SetOneShot(True) bp.SetOneShot(True)
self.interpreterBreakpointResolvers.append( self.interpreterBreakpointResolvers.append(
lambda: self.doInsertInterpreterBreakpoint(args, True)) lambda: self.resolvePendingInterpreterBreakpoint(args))
# Used in dumper auto test. # Used in dumper auto test.
......
...@@ -2308,7 +2308,7 @@ def qdump__QV4__String(d, value): ...@@ -2308,7 +2308,7 @@ def qdump__QV4__String(d, value):
d.putStringValue(d.addressOf(value) + 2 * d.ptrSize()) d.putStringValue(d.addressOf(value) + 2 * d.ptrSize())
def qdump__QV4__Value(d, value): def qdump__QV4__Value(d, value):
v = toInteger(str(value["val"])) v = toInteger(str(value["_val"]))
NaNEncodeMask = 0xffff800000000000 NaNEncodeMask = 0xffff800000000000
IsInt32Mask = 0x0002000000000000 IsInt32Mask = 0x0002000000000000
IsDoubleMask = 0xfffc000000000000 IsDoubleMask = 0xfffc000000000000
...@@ -2319,7 +2319,10 @@ def qdump__QV4__Value(d, value): ...@@ -2319,7 +2319,10 @@ def qdump__QV4__Value(d, value):
ns = d.qtNamespace() ns = d.qtNamespace()
if v & IsInt32Mask: if v & IsInt32Mask:
d.putBetterType("%sQV4::Value (int32)" % ns) d.putBetterType("%sQV4::Value (int32)" % ns)
d.putValue(value["int_32"]) vv = v & 0xffffffff
vv = vv if vv < 0x80000000 else -(0x100000000 - vv)
d.putBetterType("%sQV4::Value (int32)" % ns)
d.putValue("%d" % vv)
elif v & IsDoubleMask: elif v & IsDoubleMask:
d.putBetterType("%sQV4::Value (double)" % ns) d.putBetterType("%sQV4::Value (double)" % ns)
d.putValue("%x" % (v ^ 0xffff800000000000), Hex2EncodedFloat8) d.putValue("%x" % (v ^ 0xffff800000000000), Hex2EncodedFloat8)
...@@ -2332,6 +2335,7 @@ def qdump__QV4__Value(d, value): ...@@ -2332,6 +2335,7 @@ def qdump__QV4__Value(d, value):
elif v & IsNullOrBooleanMask: elif v & IsNullOrBooleanMask:
d.putBetterType("%sQV4::Value (null/bool)" % ns) d.putBetterType("%sQV4::Value (null/bool)" % ns)
d.putValue("(null/bool)") d.putValue("(null/bool)")
d.putValue(v & 1)
else: else:
vtable = value["m"]["vtable"] vtable = value["m"]["vtable"]
if toInteger(vtable["isString"]): if toInteger(vtable["isString"]):
......
...@@ -1470,6 +1470,8 @@ QString BreakpointItem::toToolTip() const ...@@ -1470,6 +1470,8 @@ QString BreakpointItem::toToolTip() const
<< "</td><td>" << QDir::toNativeSeparators(markerFileName()) << "</td></tr>" << "</td><td>" << QDir::toNativeSeparators(markerFileName()) << "</td></tr>"
<< "<tr><td>" << tr("Marker Line:") << "<tr><td>" << tr("Marker Line:")
<< "</td><td>" << markerLineNumber() << "</td></tr>" << "</td><td>" << markerLineNumber() << "</td></tr>"
<< "<tr><td>" << tr("Hit Count:")
<< "</td><td>" << m_response.hitCount << "</td></tr>"
<< "</table><br><hr><table>" << "</table><br><hr><table>"
<< "<tr><th>" << tr("Property") << "<tr><th>" << tr("Property")
<< "</th><th>" << tr("Requested") << "</th><th>" << tr("Requested")
......
...@@ -877,6 +877,8 @@ DebuggerEncoding debuggerEncoding(const QByteArray &data) ...@@ -877,6 +877,8 @@ DebuggerEncoding debuggerEncoding(const QByteArray &data)
return SpecialNullValue; return SpecialNullValue;
if (data == "itemcount") if (data == "itemcount")
return SpecialItemCountValue; return SpecialItemCountValue;
if (data == "notaccessible")
return SpecialNotAccessibleValue;
return DebuggerEncoding(data.toInt()); return DebuggerEncoding(data.toInt());
} }
......
This diff is collapsed.
...@@ -211,6 +211,7 @@ private: ...@@ -211,6 +211,7 @@ private:
private: ////////// Gdb Output, State & Capability Handling ////////// private: ////////// Gdb Output, State & Capability Handling //////////
protected: protected:
Q_SLOT void handleResponse(const QByteArray &buff); Q_SLOT void handleResponse(const QByteArray &buff);
void handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &result);
void handleStopResponse(const GdbMi &data); void handleStopResponse(const GdbMi &data);
void handleResultRecord(DebuggerResponse *response); void handleResultRecord(DebuggerResponse *response);
void handleStop1(const GdbMi &data); void handleStop1(const GdbMi &data);
...@@ -282,6 +283,8 @@ private: ////////// View & Data Stuff ////////// ...@@ -282,6 +283,8 @@ private: ////////// View & Data Stuff //////////
void handleBreakCondition(const DebuggerResponse &response, Breakpoint bp); void handleBreakCondition(const DebuggerResponse &response, Breakpoint bp);
void handleBreakThreadSpec(const DebuggerResponse &response, Breakpoint bp); void handleBreakThreadSpec(const DebuggerResponse &response, Breakpoint bp);
void handleBreakLineNumber(const DebuggerResponse &response, Breakpoint bp); void handleBreakLineNumber(const DebuggerResponse &response, Breakpoint bp);
void handleInsertInterpreterBreakpoint(const DebuggerResponse &response, Breakpoint bp);
void handleInterpreterBreakpointModified(const GdbMi &data);
void handleWatchInsert(const DebuggerResponse &response, Breakpoint bp); void handleWatchInsert(const DebuggerResponse &response, Breakpoint bp);
void handleCatchInsert(const DebuggerResponse &response, Breakpoint bp); void handleCatchInsert(const DebuggerResponse &response, Breakpoint bp);
void handleBkpt(const GdbMi &bkpt, Breakpoint bp); void handleBkpt(const GdbMi &bkpt, Breakpoint bp);
......
...@@ -954,7 +954,7 @@ void LldbEngine::handleLocationNotification(const GdbMi &reportedLocation) ...@@ -954,7 +954,7 @@ void LldbEngine::handleLocationNotification(const GdbMi &reportedLocation)
// Quickly set the location marker. // Quickly set the location marker.
if (lineNumber > 0 if (lineNumber > 0
&& QFileInfo::exists(fileName) && QFileInfo::exists(fileName)
&& function != "::qt_qmlDebugEventFromService()") && function != "::qt_qmlDebugMessageAvailable()")
gotoLocation(Location(fileName, lineNumber)); gotoLocation(Location(fileName, lineNumber));
} }
......
...@@ -167,6 +167,21 @@ QString StackFrame::toToolTip() const ...@@ -167,6 +167,21 @@ QString StackFrame::toToolTip() const
return res; return res;
} }
static QString findFile(const QString &baseDir, const QString &relativeFile)
{
QDir dir(baseDir);
while (true) {
const QString path = dir.absoluteFilePath(relativeFile);
const QFileInfo fi(path);
if (fi.isFile())
return path;
if (dir.isRoot())
break;
dir.cdUp();
}
return QString();
}
// Try to resolve files coming from resource files. // Try to resolve files coming from resource files.
void StackFrame::fixQrcFrame(const DebuggerRunParameters &rp) void StackFrame::fixQrcFrame(const DebuggerRunParameters &rp)
{ {
...@@ -179,21 +194,19 @@ void StackFrame::fixQrcFrame(const DebuggerRunParameters &rp) ...@@ -179,21 +194,19 @@ void StackFrame::fixQrcFrame(const DebuggerRunParameters &rp)
} }
if (!file.startsWith(QLatin1String("qrc:/"))) if (!file.startsWith(QLatin1String("qrc:/")))
return; return;
const QString relativeFile = file.right(file.size() - 5);
if (rp.projectSourceDirectory.isEmpty()) QString relativeFile = file.right(file.size() - 5);
return; while (relativeFile.startsWith(QLatin1Char('/')))
const QFileInfo pFi(rp.projectSourceDirectory + QLatin1Char('/') + relativeFile); relativeFile = relativeFile.mid(1);
if (pFi.isFile()) {
file = pFi.absoluteFilePath(); QString absFile = findFile(rp.projectSourceDirectory, relativeFile);
usable = true; if (absFile.isEmpty())
return; absFile = findFile(QDir::currentPath(), relativeFile);
}
const QFileInfo cFi(QDir::currentPath() + QLatin1Char('/') + relativeFile); if (absFile.isEmpty())
if (cFi.isFile()) {
file = cFi.absoluteFilePath();
usable = true;
return; return;
} file = absFile;
usable = true;
} }
QDebug operator<<(QDebug d, const StackFrame &f) QDebug operator<<(QDebug d, const StackFrame &f)
......
...@@ -391,8 +391,8 @@ QByteArray WatchData::hexAddress() const ...@@ -391,8 +391,8 @@ QByteArray WatchData::hexAddress() const
void WatchData::updateValue(const GdbMi &item) void WatchData::updateValue(const GdbMi &item)
{ {
GdbMi value = item["value"]; GdbMi value = item["value"];
if (value.isValid()) { DebuggerEncoding encoding = debuggerEncoding(item["valueencoded"].data());
DebuggerEncoding encoding = debuggerEncoding(item["valueencoded"].data()); if (value.isValid() || encoding != Unencoded8Bit) {
setValue(decodeData(value.data(), encoding)); setValue(decodeData(value.data(), encoding));
} else { } else {
setValueNeeded(); setValueNeeded();
...@@ -576,7 +576,8 @@ void parseChildrenData(const WatchData &data0, const GdbMi &item, ...@@ -576,7 +576,8 @@ void parseChildrenData(const WatchData &data0, const GdbMi &item,
setWatchDataValueEnabled(data, item["valueenabled"]); setWatchDataValueEnabled(data, item["valueenabled"]);
setWatchDataValueEditable(data, item["valueeditable"]); setWatchDataValueEditable(data, item["valueeditable"]);
data.updateChildCount(item["numchild"]); data.updateChildCount(item["numchild"]); // GDB/MI
data.updateChildCount(item["haschild"]); // native-mixed
itemHandler(data); itemHandler(data);
bool ok = false; bool ok = false;
......
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