Commit 41a5461c authored by Friedemann Kleint's avatar Friedemann Kleint Committed by hjk

Debugger: Log exceptions in build pane.

- Introduce constants for task categories, add "RunTime".
- Log exceptions under "RunTime".
- Clear pane on debugger start.
- Add 'first chance'

Task-number: QTCREATORBUG-8141
Change-Id: Icf68def06c42a0f3bb86dcc2ae74750b5397ca52
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 2e40c54e
......@@ -62,6 +62,8 @@
#include <texteditor/itexteditor.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/task.h>
#include <projectexplorer/taskhub.h>
#include <utils/synchronousprocess.h>
#include <utils/winutils.h>
......@@ -2380,10 +2382,20 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what
exception.fromGdbMI(gdbmi);
const QString message = exception.toString(true);
showStatusMessage(message);
#ifdef Q_OS_WIN // Report C++ exception in application output as well.
// Report C++ exception in application output as well.
if (exception.exceptionCode == winExceptionCppException)
showMessage(message + QLatin1Char('\n'), AppOutput);
#endif
if (!isDebuggerWinException(exception.exceptionCode)) {
const Task::TaskType type =
isFatalWinException(exception.exceptionCode) ? Task::Error : Task::Warning;
const Utils::FileName fileName = exception.file.isEmpty() ?
Utils::FileName() :
Utils::FileName::fromUserInput(QString::fromLocal8Bit(exception.file));
const Task task(type, exception.toString(false),
fileName, exception.lineNumber,
Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME));
taskHub()->addTask(task);
}
return;
}
......
......@@ -415,6 +415,8 @@ QString WinException::toString(bool includeLocation) const
QTextStream str(&rc);
formatWindowsException(exceptionCode, exceptionAddress,
exceptionFlags, info1, info2, str);
if (firstChance)
str << " (first chance)";
if (includeLocation) {
if (lineNumber) {
str << " at " << QLatin1String(file) << ':' << lineNumber;
......
......@@ -75,6 +75,10 @@ const char DOCKWIDGET_WATCHERS[] = "Debugger.Docks.LocalsAndWatchers";
const char DOCKWIDGET_QML_INSPECTOR[] = "Debugger.Docks.QmlInspector";
const char DOCKWIDGET_DEFAULT_AREA[] = "Debugger.Docks.DefaultArea";
const char TASK_CATEGORY_DEBUGGER_TEST[] = "DebuggerTest";
const char TASK_CATEGORY_DEBUGGER_DEBUGINFO[] = "Debuginfo";
const char TASK_CATEGORY_DEBUGGER_RUNTIME[] = "DebugRuntime";
} // namespace Constants
enum DebuggerState
......
......@@ -1929,8 +1929,12 @@ TaskHub *DebuggerEnginePrivate::taskHub()
{
if (!m_taskHub) {
m_taskHub = ProjectExplorerPlugin::instance()->taskHub();
m_taskHub->addCategory(Core::Id("Debuginfo"), tr("Debug Information"));
m_taskHub->addCategory(Core::Id("DebuggerTest"), tr("Debugger Test"));
m_taskHub->addCategory(Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO),
tr("Debug Information"));
m_taskHub->addCategory(Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_TEST),
tr("Debugger Test"));
m_taskHub->addCategory(Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME),
tr("Debugger Runtime"));
}
return m_taskHub;
}
......
......@@ -53,6 +53,7 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h>
#include <projectexplorer/taskhub.h>
#include <projectexplorer/toolchain.h>
#include <utils/outputformat.h>
......@@ -596,6 +597,12 @@ DebuggerRunControl *DebuggerRunControlFactory::doCreate
(const DebuggerStartParameters &sp0, RunConfiguration *rc, QString *errorMessage)
{
Q_UNUSED(errorMessage);
TaskHub *th = ProjectExplorerPlugin::instance()->taskHub();
th->clearTasks(Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO));
th->clearTasks(Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_TEST));
th->clearTasks(Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME));
DebuggerStartParameters sp = sp0;
if (!debuggerCore()->boolSetting(AutoEnrichParameters)) {
const QString sysroot = sp.sysRoot;
......
......@@ -344,14 +344,18 @@ static void dump(const char *first, const char *middle, const QString & to)
// Parse "~:gdb: unknown target exception 0xc0000139 at 0x77bef04e\n"
// and return an exception message
static inline QString msgWinException(const QByteArray &data)
static inline QString msgWinException(const QByteArray &data, unsigned *exCodeIn = 0)
{
if (exCodeIn)
*exCodeIn = 0;
const int exCodePos = data.indexOf("0x");
const int blankPos = exCodePos != -1 ? data.indexOf(' ', exCodePos + 1) : -1;
const int addressPos = blankPos != -1 ? data.indexOf("0x", blankPos + 1) : -1;
if (addressPos < 0)
return GdbEngine::tr("An exception was triggered.");
const unsigned exCode = data.mid(exCodePos, blankPos - exCodePos).toUInt(0, 0);
if (exCodeIn)
*exCodeIn = exCode;
const quint64 address = data.mid(addressPos).trimmed().toULongLong(0, 0);
QString rc;
QTextStream str(&rc);
......@@ -692,8 +696,13 @@ void GdbEngine::handleResponse(const QByteArray &buff)
// [Windows, most likely some DLL/Entry point not found]:
// "gdb: unknown target exception 0xc0000139 at 0x77bef04e"
// This may be fatal and cause the target to exit later
m_lastWinException = msgWinException(data);
unsigned exCode;
m_lastWinException = msgWinException(data, &exCode);
showMessage(m_lastWinException, LogMisc);
const Task::TaskType type = isFatalWinException(exCode) ? Task::Error : Task::Warning;
const Task task(type, m_lastWinException, Utils::FileName(), 0,
Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME));
taskHub()->addTask(task);
}
if (data.startsWith("QMLBP:")) {
......@@ -735,7 +744,7 @@ void GdbEngine::handleResponse(const QByteArray &buff)
Task task(Task::Warning,
tr("Missing debug information for %1\nTry: %2")
.arg(m_lastMissingDebugInfo).arg(cmd),
FileName(), 0, Core::Id("Debuginfo"));
FileName(), 0, Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO));
taskHub()->addTask(task);
......
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