forked from qt-creator/qt-creator
Debugger: Introduce common messages to engine.
Try to achieve consistency in reporting stop messages for all engines. Report by BreakpointId if available.
This commit is contained in:
@@ -66,6 +66,7 @@
|
|||||||
#include <QtGui/QStandardItemModel>
|
#include <QtGui/QStandardItemModel>
|
||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
#include <QtGui/QTreeWidget>
|
#include <QtGui/QTreeWidget>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Debugger;
|
using namespace Debugger;
|
||||||
@@ -1366,6 +1367,71 @@ bool DebuggerEngine::isDying() const
|
|||||||
return targetState() == DebuggerFinished;
|
return targetState() == DebuggerFinished;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DebuggerEngine::msgWatchpointTriggered(BreakpointId id, const int number, quint64 address)
|
||||||
|
{
|
||||||
|
return id != BreakpointId(-1) ?
|
||||||
|
tr("Watchpoint %1 (%2) at 0x%3 triggered.").arg(id).arg(number).arg(address, 0, 16) :
|
||||||
|
tr("Internal watchpoint %1 at 0x%2 triggered.").arg(number).arg(address, 0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DebuggerEngine::msgWatchpointTriggered(BreakpointId id, const int number,
|
||||||
|
quint64 address, const QString &threadId)
|
||||||
|
{
|
||||||
|
return id != BreakpointId(-1) ?
|
||||||
|
tr("Watchpoint %1 (%2) at 0x%3 in thread %4 triggered.").
|
||||||
|
arg(id).arg(number).arg(address, 0, 16).arg(threadId) :
|
||||||
|
tr("Internal watchpoint %1 at 0x%2 in thread %3 triggered.").
|
||||||
|
arg(id).arg(number).arg(address, 0, 16).arg(threadId);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DebuggerEngine::msgBreakpointTriggered(BreakpointId id, const int number, const QString &threadId)
|
||||||
|
{
|
||||||
|
return id != BreakpointId(-1) ?
|
||||||
|
tr("Stopped at breakpoint %1 (%2) in thread %3.").arg(id).arg(number).arg(threadId) :
|
||||||
|
tr("Stopped at internal breakpoint %1 in thread %2.").arg(number).arg(threadId);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DebuggerEngine::msgStopped(const QString &reason)
|
||||||
|
{
|
||||||
|
return reason.isEmpty() ? tr("Stopped.") : tr("Stopped: \"%1\"").arg(reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DebuggerEngine::msgStoppedBySignal(const QString &meaning, const QString &name)
|
||||||
|
{
|
||||||
|
return tr("Stopped: %1 by signal %2.").arg(meaning, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DebuggerEngine::msgStoppedByException(const QString &description, const QString &threadId)
|
||||||
|
{
|
||||||
|
return tr("Stopped in thread %1 by: %2.").arg(threadId, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DebuggerEngine::msgInterrupted()
|
||||||
|
{
|
||||||
|
return tr("Interrupted.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerEngine::showStoppedBySignalMessageBox(QString meaning, QString name)
|
||||||
|
{
|
||||||
|
if (name.isEmpty())
|
||||||
|
name = tr(" <Unknown> ", "name");
|
||||||
|
if (meaning.isEmpty())
|
||||||
|
meaning = tr(" <Unknown> ", "meaning");
|
||||||
|
const QString msg = tr("<p>The inferior stopped because it received a "
|
||||||
|
"signal from the Operating System.<p>"
|
||||||
|
"<table><tr><td>Signal name : </td><td>%1</td></tr>"
|
||||||
|
"<tr><td>Signal meaning : </td><td>%2</td></tr></table>")
|
||||||
|
.arg(name, meaning);
|
||||||
|
showMessageBox(QMessageBox::Information, tr("Signal received"), msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerEngine::showStoppedByExceptionMessageBox(const QString &description)
|
||||||
|
{
|
||||||
|
const QString msg = tr("<p>The inferior stopped because it triggered an exception.<p>%1").
|
||||||
|
arg(description);
|
||||||
|
showMessageBox(QMessageBox::Information, tr("Exception Triggered"), msg);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|
||||||
#include "debuggerengine.moc"
|
#include "debuggerengine.moc"
|
||||||
|
|||||||
@@ -336,6 +336,17 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
DebuggerRunControl *runControl() const;
|
DebuggerRunControl *runControl() const;
|
||||||
|
|
||||||
|
static QString msgWatchpointTriggered(BreakpointId id, int number, quint64 address);
|
||||||
|
static QString msgWatchpointTriggered(BreakpointId id, int number, quint64 address,
|
||||||
|
const QString &threadId);
|
||||||
|
static QString msgBreakpointTriggered(BreakpointId id, int number, const QString &threadId);
|
||||||
|
static QString msgStopped(const QString &reason = QString());
|
||||||
|
static QString msgStoppedBySignal(const QString &meaning, const QString &name);
|
||||||
|
static QString msgStoppedByException(const QString &description, const QString &threadId);
|
||||||
|
static QString msgInterrupted();
|
||||||
|
void showStoppedBySignalMessageBox(QString meaning, QString name);
|
||||||
|
void showStoppedByExceptionMessageBox(const QString &description);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// wrapper engine needs access to state of its subengines
|
// wrapper engine needs access to state of its subengines
|
||||||
friend class QmlCppEngine;
|
friend class QmlCppEngine;
|
||||||
|
|||||||
@@ -1372,18 +1372,20 @@ void GdbEngine::handleStop1(const GdbMi &data)
|
|||||||
// {name="p",value="0x0"}],file="x.h",fullname="/home/.../x.h",line="95"},
|
// {name="p",value="0x0"}],file="x.h",fullname="/home/.../x.h",line="95"},
|
||||||
// thread-id="1",stopped-threads="all",core="2"
|
// thread-id="1",stopped-threads="all",core="2"
|
||||||
GdbMi wpt = data.findChild("wpt");
|
GdbMi wpt = data.findChild("wpt");
|
||||||
QByteArray bpNumber = wpt.findChild("number").data();
|
const int bpNumber = wpt.findChild("number").data().toInt();
|
||||||
QByteArray bpAddress = wpt.findChild("exp").data();
|
const BreakpointId id = breakHandler()->findBreakpointByNumber(bpNumber);
|
||||||
//QByteArray threadId = data.findChild("thread-id").data();
|
const quint64 bpAddress = wpt.findChild("exp").data().toULongLong(0, 0);
|
||||||
showStatusMessage(tr("Watchpoint %1 at %2 triggered:")
|
showStatusMessage(msgWatchpointTriggered(id, bpNumber, bpAddress));
|
||||||
.arg(_(bpNumber), _(bpAddress)));
|
|
||||||
} else if (reason == "breakpoint-hit") {
|
} else if (reason == "breakpoint-hit") {
|
||||||
QByteArray bpNumber = data.findChild("bkptno").data();
|
GdbMi gNumber = data.findChild("bkptno"); // 'number' or 'bkptno'?
|
||||||
QByteArray threadId = data.findChild("thread-id").data();
|
if (!gNumber.isValid())
|
||||||
showStatusMessage(tr("Stopped at breakpoint %1 in thread %2")
|
gNumber = data.findChild("number");
|
||||||
.arg(_(bpNumber), _(threadId)));
|
const int bpNumber = gNumber.data().toInt();
|
||||||
|
const QByteArray threadId = data.findChild("thread-id").data();
|
||||||
|
const BreakpointId id = breakHandler()->findBreakpointByNumber(bpNumber);
|
||||||
|
showStatusMessage(msgBreakpointTriggered(id, bpNumber, QString::fromAscii(threadId)));
|
||||||
} else {
|
} else {
|
||||||
QString reasontr = tr("Stopped: \"%1\"").arg(_(reason));
|
QString reasontr = msgStopped(_(reason));
|
||||||
if (reason == "signal-received"
|
if (reason == "signal-received"
|
||||||
&& debuggerCore()->boolSetting(UseMessageBoxForSignals)) {
|
&& debuggerCore()->boolSetting(UseMessageBoxForSignals)) {
|
||||||
QByteArray name = data.findChild("signal-name").data();
|
QByteArray name = data.findChild("signal-name").data();
|
||||||
@@ -1393,22 +1395,14 @@ void GdbEngine::handleStop1(const GdbMi &data)
|
|||||||
if (name != STOP_SIGNAL
|
if (name != STOP_SIGNAL
|
||||||
&& (startParameters().startMode != AttachToRemote
|
&& (startParameters().startMode != AttachToRemote
|
||||||
|| name != CROSS_STOP_SIGNAL)) {
|
|| name != CROSS_STOP_SIGNAL)) {
|
||||||
QString msg = tr("<p>The inferior stopped because it received a "
|
showStoppedBySignalMessageBox(_(meaning), _(name));
|
||||||
"signal from the Operating System.<p>"
|
|
||||||
"<table><tr><td>Signal name : </td><td>%1</td></tr>"
|
|
||||||
"<tr><td>Signal meaning : </td><td>%2</td></tr></table>")
|
|
||||||
.arg(name.isEmpty() ? tr(" <Unknown> ", "name") : _(name))
|
|
||||||
.arg(meaning.isEmpty() ? tr(" <Unknown> ", "meaning") : _(meaning));
|
|
||||||
showMessageBox(QMessageBox::Information,
|
|
||||||
tr("Signal received"), msg);
|
|
||||||
if (!name.isEmpty() && !meaning.isEmpty())
|
if (!name.isEmpty() && !meaning.isEmpty())
|
||||||
reasontr = tr("Stopped: %1 by signal %2")
|
reasontr = msgStoppedBySignal(_(meaning), _(name));
|
||||||
.arg(_(meaning)).arg(_(name));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reason.isEmpty())
|
if (reason.isEmpty())
|
||||||
showStatusMessage(tr("Stopped."));
|
showStatusMessage(msgStopped());
|
||||||
else
|
else
|
||||||
showStatusMessage(reasontr);
|
showStatusMessage(reasontr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user