From 7bc14bf3498ea6b1c19abacf85a5103772da26bc Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 14 Aug 2018 12:56:56 +0200 Subject: [PATCH] Debugger: add option to disable task entries for exceptions Task-number: QTCREATORBUG-20915 Change-Id: I3b7bda65f5b645cd4d8f9582b9185cb27b2c9f91 Reviewed-by: Leena Miettinen Reviewed-by: Christian Stenger --- src/libs/qtcreatorcdbext/eventcallback.cpp | 16 +++++----- src/libs/qtcreatorcdbext/extensioncontext.h | 2 ++ .../qtcreatorcdbext/qtcreatorcdbextension.cpp | 6 ++++ src/plugins/debugger/cdb/cdbengine.cpp | 15 +++++----- src/plugins/debugger/cdb/cdboptionspage.cpp | 2 ++ .../debugger/cdb/cdboptionspagewidget.ui | 29 +++++++++++++++++++ src/plugins/debugger/debuggeractions.cpp | 12 ++++++++ src/plugins/debugger/debuggeractions.h | 2 ++ 8 files changed, 70 insertions(+), 14 deletions(-) diff --git a/src/libs/qtcreatorcdbext/eventcallback.cpp b/src/libs/qtcreatorcdbext/eventcallback.cpp index 2e5e69abca9..caafd9c3e2f 100644 --- a/src/libs/qtcreatorcdbext/eventcallback.cpp +++ b/src/libs/qtcreatorcdbext/eventcallback.cpp @@ -173,14 +173,16 @@ STDMETHODIMP EventCallback::Exception( __in ULONG FirstChance ) { - // Report the exception as GBMI and set potential stop reason - const ExtensionContext::StopReasonMap parameters = - exceptionParameters(*Ex, FirstChance); + if ((FirstChance && ExtensionContext::instance().parameters().firstChanceException != 0) + || (!FirstChance && ExtensionContext::instance().parameters().secondChanceException != 0)) { + // Report the exception as GBMI and set potential stop reason + const ExtensionContext::StopReasonMap parameters = exceptionParameters(*Ex, FirstChance); - std::ostringstream str; - formatGdbmiHash(str, parameters); - ExtensionContext::instance().setStopReason(parameters, "exception"); - ExtensionContext::instance().report('E', 0, 0, "exception", "%s", str.str().c_str()); + std::ostringstream str; + formatGdbmiHash(str, parameters); + ExtensionContext::instance().setStopReason(parameters, "exception"); + ExtensionContext::instance().report('E', 0, 0, "exception", "%s", str.str().c_str()); + } return m_wrapped ? m_wrapped->Exception(Ex, FirstChance) : S_OK; } diff --git a/src/libs/qtcreatorcdbext/extensioncontext.h b/src/libs/qtcreatorcdbext/extensioncontext.h index e52abc4e86f..1cdbb77a927 100644 --- a/src/libs/qtcreatorcdbext/extensioncontext.h +++ b/src/libs/qtcreatorcdbext/extensioncontext.h @@ -43,6 +43,8 @@ struct Parameters unsigned maxStringLength = 10000; unsigned maxArraySize = 100; unsigned maxStackDepth = 1000; + unsigned firstChanceException = 1; + unsigned secondChanceException = 1; }; // Global singleton with context. diff --git a/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp b/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp index 61c41de7615..fad25230a34 100644 --- a/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp +++ b/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp @@ -965,6 +965,12 @@ extern "C" HRESULT CALLBACK setparameter(CIDebugClient *, PCSTR args) } else if (!token.compare(0, equalsPos, "maxArraySize")) { if (integerFromString(value, &ExtensionContext::instance().parameters().maxArraySize)) ++success; + } else if (!token.compare(0, equalsPos, "firstChance")) { + if (integerFromString(value, &ExtensionContext::instance().parameters().firstChanceException)) + ++success; + } else if (!token.compare(0, equalsPos, "secondChance")) { + if (integerFromString(value, &ExtensionContext::instance().parameters().secondChanceException)) + ++success; } else if (!token.compare(0, equalsPos, "maxStackDepth")) { if (integerFromString(value, &ExtensionContext::instance().parameters().maxStackDepth)) ++success; diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 9f7b257038d..55dbc5c8fb2 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -539,10 +539,12 @@ void CdbEngine::handleInitialSessionIdle() runCommand({"sxn 0x4000001f", NoFlags}); // Do not break on WowX86 exceptions. runCommand({"sxn ibp", NoFlags}); // Do not break on initial breakpoints. runCommand({".asm source_line", NoFlags}); // Source line in assembly - runCommand({m_extensionCommandPrefix + "setparameter maxStringLength=" - + action(MaximalStringLength)->value().toString() - + " maxStackDepth=" - + action(MaximalStackDepth)->value().toString(), NoFlags}); + runCommand({m_extensionCommandPrefix + + "setparameter maxStringLength=" + action(MaximalStringLength)->value().toString() + + " maxStackDepth=" + action(MaximalStackDepth)->value().toString() + + " firstChance=" + (action(FirstChanceExceptionTaskEntry)->value().toBool() ? "1" : "0") + + " secondChance=" + (action(SecondChanceExceptionTaskEntry)->value().toBool() ? "1" : "0") + , NoFlags}); if (boolSetting(CdbUsePythonDumper)) runCommand({"print(sys.version)", ScriptCommand, CB(setupScripting)}); @@ -2195,12 +2197,11 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QString &what, c if (!isDebuggerWinException(exception.exceptionCode)) { const Task::TaskType type = isFatalWinException(exception.exceptionCode) ? Task::Error : Task::Warning; - const FileName fileName = exception.file.isEmpty() - ? FileName() : FileName::fromUserInput(exception.file); + const FileName fileName = FileName::fromUserInput(exception.file); const QString taskEntry = tr("Debugger encountered an exception: %1").arg( exception.toString(false).trimmed()); TaskHub::addTask(type, taskEntry, - Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME, + Constants::TASK_CATEGORY_DEBUGGER_RUNTIME, fileName, exception.lineNumber); } return; diff --git a/src/plugins/debugger/cdb/cdboptionspage.cpp b/src/plugins/debugger/cdb/cdboptionspage.cpp index 736434fd07b..9dacfe34ec1 100644 --- a/src/plugins/debugger/cdb/cdboptionspage.cpp +++ b/src/plugins/debugger/cdb/cdboptionspage.cpp @@ -183,6 +183,8 @@ CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent) group.insert(action(UseCdbConsole), m_ui.consoleCheckBox); group.insert(action(CdbBreakPointCorrection), m_ui.breakpointCorrectionCheckBox); group.insert(action(CdbUsePythonDumper), m_ui.usePythonDumper); + group.insert(action(FirstChanceExceptionTaskEntry), m_ui.firstChance); + group.insert(action(SecondChanceExceptionTaskEntry), m_ui.secondChance); group.insert(action(IgnoreFirstChanceAccessViolation), m_ui.ignoreFirstChanceAccessViolationCheckBox); diff --git a/src/plugins/debugger/cdb/cdboptionspagewidget.ui b/src/plugins/debugger/cdb/cdboptionspagewidget.ui index 38f434688c5..e6d5646dea9 100644 --- a/src/plugins/debugger/cdb/cdboptionspagewidget.ui +++ b/src/plugins/debugger/cdb/cdboptionspagewidget.ui @@ -103,6 +103,35 @@ + + + + Task Entries for Exceptions + + + + + + First chance exceptions + + + true + + + + + + + Second chance exceptions + + + true + + + + + + diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index 8773f1a15d8..d148fc92028 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -232,6 +232,18 @@ DebuggerSettings::DebuggerSettings() item->setSettingsKey(cdbSettingsGroup, QLatin1String("UsePythonDumper")); insertItem(CdbUsePythonDumper, item); + item = new SavedAction(this); + item->setCheckable(true); + item->setDefaultValue(true); + item->setSettingsKey(cdbSettingsGroup, QLatin1String("FirstChanceExceptionTaskEntry")); + insertItem(FirstChanceExceptionTaskEntry, item); + + item = new SavedAction(this); + item->setCheckable(true); + item->setDefaultValue(true); + item->setSettingsKey(cdbSettingsGroup, QLatin1String("SecondChanceExceptionTaskEntry")); + insertItem(SecondChanceExceptionTaskEntry, item); + item = new SavedAction(this); item->setCheckable(true); item->setDefaultValue(false); diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 5a4ad951010..15f2e73d993 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -117,6 +117,8 @@ enum DebuggerActionCode UseCdbConsole, CdbBreakPointCorrection, CdbUsePythonDumper, + FirstChanceExceptionTaskEntry, + SecondChanceExceptionTaskEntry, IgnoreFirstChanceAccessViolation, // Gdb