Commit 6da15db6 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by hjk
Browse files

Debugger: Prevent adding invalid breakpoints.



Check on session restore and add.
In particular, suppress watchpoints at 0x0,
which hang gdb.

Change-Id: I648f53a709fabdebe641e478f367f1354a315ab1
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 73482915
......@@ -396,7 +396,11 @@ void BreakHandler::loadBreakpoints()
v = map.value(_("message"));
if (v.isValid())
data.message = v.toString();
appendBreakpoint(data);
if (data.isValid()) {
appendBreakpoint(data);
} else {
qWarning("Not restoring invalid breakpoint: %s", qPrintable(data.toString()));
}
}
//qDebug() << "LOADED BREAKPOINTS" << this << list.size();
}
......@@ -1036,7 +1040,11 @@ static int currentId = 0;
void BreakHandler::appendBreakpoint(const BreakpointParameters &data)
{
QTC_ASSERT(data.type != UnknownType, return);
if (!data.isValid()) {
qWarning("Not adding invalid breakpoint: %s", qPrintable(data.toString()));
return;
}
BreakpointModelId id(++currentId);
const int row = m_storage.size();
beginInsertRows(QModelIndex(), row, row);
......
......@@ -220,6 +220,33 @@ BreakpointParts BreakpointParameters::differencesTo
return parts;
}
bool BreakpointParameters::isValid() const
{
switch (type) {
case Debugger::Internal::BreakpointByFileAndLine:
return !fileName.isEmpty() && lineNumber > 0;
case Debugger::Internal::BreakpointByFunction:
return !functionName.isEmpty();
case Debugger::Internal::WatchpointAtAddress:
case Debugger::Internal::BreakpointByAddress:
return address != 0;
case Debugger::Internal::BreakpointAtThrow:
case Debugger::Internal::BreakpointAtCatch:
case Debugger::Internal::BreakpointAtMain:
case Debugger::Internal::BreakpointAtFork:
case Debugger::Internal::BreakpointAtExec:
case Debugger::Internal::BreakpointAtSysCall:
case Debugger::Internal::BreakpointOnQmlSignalHandler:
case Debugger::Internal::BreakpointAtJavaScriptThrow:
break;
case Debugger::Internal::WatchpointAtExpression:
return !expression.isEmpty();
case Debugger::Internal::UnknownType:
return false;
}
return true;
}
bool BreakpointParameters::equals(const BreakpointParameters &rhs) const
{
return !differencesTo(rhs);
......
......@@ -203,6 +203,7 @@ class BreakpointParameters
public:
explicit BreakpointParameters(BreakpointType = UnknownType);
BreakpointParts differencesTo(const BreakpointParameters &rhs) const;
bool isValid() const;
bool equals(const BreakpointParameters &rhs) const;
bool conditionsMatch(const QByteArray &other) const;
bool isWatchpoint() const
......
Supports Markdown
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