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/QAction>
|
||||
#include <QtGui/QTreeWidget>
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Debugger;
|
||||
@@ -1366,6 +1367,71 @@ bool DebuggerEngine::isDying() const
|
||||
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
|
||||
|
||||
#include "debuggerengine.moc"
|
||||
|
||||
@@ -336,6 +336,17 @@ protected:
|
||||
protected:
|
||||
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:
|
||||
// wrapper engine needs access to state of its subengines
|
||||
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"},
|
||||
// thread-id="1",stopped-threads="all",core="2"
|
||||
GdbMi wpt = data.findChild("wpt");
|
||||
QByteArray bpNumber = wpt.findChild("number").data();
|
||||
QByteArray bpAddress = wpt.findChild("exp").data();
|
||||
//QByteArray threadId = data.findChild("thread-id").data();
|
||||
showStatusMessage(tr("Watchpoint %1 at %2 triggered:")
|
||||
.arg(_(bpNumber), _(bpAddress)));
|
||||
const int bpNumber = wpt.findChild("number").data().toInt();
|
||||
const BreakpointId id = breakHandler()->findBreakpointByNumber(bpNumber);
|
||||
const quint64 bpAddress = wpt.findChild("exp").data().toULongLong(0, 0);
|
||||
showStatusMessage(msgWatchpointTriggered(id, bpNumber, bpAddress));
|
||||
} else if (reason == "breakpoint-hit") {
|
||||
QByteArray bpNumber = data.findChild("bkptno").data();
|
||||
QByteArray threadId = data.findChild("thread-id").data();
|
||||
showStatusMessage(tr("Stopped at breakpoint %1 in thread %2")
|
||||
.arg(_(bpNumber), _(threadId)));
|
||||
GdbMi gNumber = data.findChild("bkptno"); // 'number' or 'bkptno'?
|
||||
if (!gNumber.isValid())
|
||||
gNumber = data.findChild("number");
|
||||
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 {
|
||||
QString reasontr = tr("Stopped: \"%1\"").arg(_(reason));
|
||||
QString reasontr = msgStopped(_(reason));
|
||||
if (reason == "signal-received"
|
||||
&& debuggerCore()->boolSetting(UseMessageBoxForSignals)) {
|
||||
QByteArray name = data.findChild("signal-name").data();
|
||||
@@ -1393,22 +1395,14 @@ void GdbEngine::handleStop1(const GdbMi &data)
|
||||
if (name != STOP_SIGNAL
|
||||
&& (startParameters().startMode != AttachToRemote
|
||||
|| name != CROSS_STOP_SIGNAL)) {
|
||||
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.isEmpty() ? tr(" <Unknown> ", "name") : _(name))
|
||||
.arg(meaning.isEmpty() ? tr(" <Unknown> ", "meaning") : _(meaning));
|
||||
showMessageBox(QMessageBox::Information,
|
||||
tr("Signal received"), msg);
|
||||
showStoppedBySignalMessageBox(_(meaning), _(name));
|
||||
if (!name.isEmpty() && !meaning.isEmpty())
|
||||
reasontr = tr("Stopped: %1 by signal %2")
|
||||
.arg(_(meaning)).arg(_(name));
|
||||
reasontr = msgStoppedBySignal(_(meaning), _(name));
|
||||
}
|
||||
}
|
||||
|
||||
if (reason.isEmpty())
|
||||
showStatusMessage(tr("Stopped."));
|
||||
showStatusMessage(msgStopped());
|
||||
else
|
||||
showStatusMessage(reasontr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user