forked from qt-creator/qt-creator
debugger: extract qt namespace before running the inferior.
This commit is contained in:
@@ -94,9 +94,24 @@ void AbstractPlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &respon
|
||||
void AbstractPlainGdbAdapter::runEngine()
|
||||
{
|
||||
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
||||
m_engine->postCommand("print QString", CB(handleNamespaceExtraction));
|
||||
m_engine->postCommand("-exec-run", GdbEngine::RunRequest, CB(handleExecRun));
|
||||
}
|
||||
|
||||
void AbstractPlainGdbAdapter::handleNamespaceExtraction(const GdbResponse &response)
|
||||
{
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
// $1 = {void (myns::QString * const, const char *)} 0x8058e2c <QString>"}
|
||||
const QByteArray ba = response.data.findChild("consolestreamoutput").data();
|
||||
const int posQString = ba.indexOf("QString");
|
||||
const int posNs = ba.lastIndexOf('(', posQString) + 1;
|
||||
const QByteArray ns = ba.mid(posNs, posQString - posNs);
|
||||
//qDebug() << "BA: " << response.toString() << ba << posQString << posNs << ns;
|
||||
if (!ns.isEmpty())
|
||||
m_engine->setQtNamespace(ns);
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractPlainGdbAdapter::handleExecRun(const GdbResponse &response)
|
||||
{
|
||||
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
|
||||
protected:
|
||||
void handleInfoTarget(const GdbResponse &response);
|
||||
void handleNamespaceExtraction(const GdbResponse &response);
|
||||
|
||||
private:
|
||||
virtual QByteArray execFilePath() const = 0;
|
||||
@@ -60,7 +61,6 @@ private:
|
||||
virtual QString fromLocalEncoding(const QByteArray &b) const = 0;
|
||||
void handleExecRun(const GdbResponse &response);
|
||||
void handleFileExecAndSymbols(const GdbResponse &response);
|
||||
|
||||
};
|
||||
|
||||
} // namespace Debugger
|
||||
|
||||
@@ -3719,30 +3719,32 @@ void GdbEngine::watchPoint(const QPoint &pnt)
|
||||
{
|
||||
QByteArray x = QByteArray::number(pnt.x());
|
||||
QByteArray y = QByteArray::number(pnt.y());
|
||||
postCommand("print 'QApplication::widgetAt'(" + x + ',' + y + ')',
|
||||
postCommand("print '" + qtNamespace() + "QApplication::widgetAt'("
|
||||
+ x + ',' + y + ')',
|
||||
NeedsStop, CB(handleWatchPoint));
|
||||
}
|
||||
|
||||
void GdbEngine::handleWatchPoint(const GdbResponse &response)
|
||||
{
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
GdbMi contents = response.data.findChild("consolestreamoutput");
|
||||
const GdbMi contents = response.data.findChild("consolestreamoutput");
|
||||
// "$5 = (void *) 0xbfa7ebfc\n"
|
||||
QByteArray ba = parsePlainConsoleStream(response);
|
||||
const QByteArray ba = parsePlainConsoleStream(response);
|
||||
//qDebug() << "BA: " << ba;
|
||||
const int posWidget = ba.indexOf("QWidget");
|
||||
if (posWidget == -1)
|
||||
return;
|
||||
const int posNs = ba.lastIndexOf(' ', posWidget) + 1;
|
||||
if (posNs == 0)
|
||||
return;
|
||||
const int pos0x = ba.indexOf("0x", posWidget + 7);
|
||||
if (pos0x == -1)
|
||||
return;
|
||||
const QByteArray addr = ba.mid(pos0x);
|
||||
const QByteArray ns = ba.mid(posNs, posWidget - posNs);
|
||||
const QByteArray type = ns.isEmpty() ? "QWidget*" : ("'" + ns + "QWidget'*");
|
||||
const QString exp = _("(*(%1)%2)").arg(_(type)).arg(_(addr));
|
||||
watchHandler()->watchExpression(exp);
|
||||
if (posWidget == -1 || posNs == 0 || pos0x == -1) {
|
||||
showStatusMessage(tr("Cannot read widget data: %1").arg(_(ba)));
|
||||
} else {
|
||||
const QByteArray addr = ba.mid(pos0x);
|
||||
//const QByteArray ns = ba.mid(posNs, posWidget - posNs);
|
||||
const QByteArray ns = qtNamespace();
|
||||
const QByteArray type = ns.isEmpty() ? "QWidget*" : ("'" + ns + "QWidget'*");
|
||||
const QString exp = _("(*(%1)%2)").arg(_(type)).arg(_(addr));
|
||||
// qDebug() << posNs << posWidget << pos0x << addr << ns << type;
|
||||
watchHandler()->watchExpression(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ private: ////////// General Interface //////////
|
||||
|
||||
virtual void executeDebuggerCommand(const QString &command);
|
||||
virtual QByteArray qtNamespace() const { return m_dumperHelper.qtNamespace(); }
|
||||
virtual void setQtNamespace(const QByteArray &ns)
|
||||
{ return m_dumperHelper.setQtNamespace(ns); }
|
||||
|
||||
private: ////////// General State //////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user