Debugger: add option to disable task entries for exceptions

Task-number: QTCREATORBUG-20915
Change-Id: I3b7bda65f5b645cd4d8f9582b9185cb27b2c9f91
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2018-08-14 12:56:56 +02:00
parent 1cd522374a
commit 7bc14bf349
8 changed files with 70 additions and 14 deletions

View File

@@ -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;
}

View File

@@ -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.

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -103,6 +103,35 @@
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="exceptions">
<property name="title">
<string>Task Entries for Exceptions </string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="firstChance">
<property name="text">
<string>First chance exceptions</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="secondChance">
<property name="text">
<string>Second chance exceptions</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@@ -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);

View File

@@ -117,6 +117,8 @@ enum DebuggerActionCode
UseCdbConsole,
CdbBreakPointCorrection,
CdbUsePythonDumper,
FirstChanceExceptionTaskEntry,
SecondChanceExceptionTaskEntry,
IgnoreFirstChanceAccessViolation,
// Gdb