forked from qt-creator/qt-creator
febugger: prepare for saner handling of changed breakpoints
This commit is contained in:
@@ -1092,21 +1092,21 @@ void BreakHandler::setResponse(BreakpointId id,
|
||||
updateMarker(id);
|
||||
}
|
||||
|
||||
void BreakHandler::setBreakpointData(BreakpointId id,
|
||||
const BreakpointParameters &data)
|
||||
void BreakHandler::changeBreakpointData(BreakpointId id,
|
||||
const BreakpointParameters &data, BreakpointParts parts)
|
||||
{
|
||||
Iterator it = m_storage.find(id);
|
||||
QTC_ASSERT(it != m_storage.end(), return);
|
||||
if (data == it->data)
|
||||
return;
|
||||
it->data = data;
|
||||
if (it->needsChange() && it->engine && it->state != BreakpointNew) {
|
||||
setState(id, BreakpointChangeRequested);
|
||||
scheduleSynchronization();
|
||||
} else {
|
||||
if (parts == NoParts) {
|
||||
it->destroyMarker();
|
||||
updateMarker(id);
|
||||
layoutChanged();
|
||||
} else if (it->needsChange() && it->engine && it->state != BreakpointNew) {
|
||||
setState(id, BreakpointChangeRequested);
|
||||
scheduleSynchronization();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,8 @@ public:
|
||||
quint64 address(BreakpointId id) const;
|
||||
void setAddress(BreakpointId id, const quint64 &address);
|
||||
int lineNumber(BreakpointId id) const;
|
||||
void setBreakpointData(BreakpointId id, const BreakpointParameters &data);
|
||||
void changeBreakpointData(BreakpointId id, const BreakpointParameters &data,
|
||||
BreakpointParts parts);
|
||||
const BreakpointParameters &breakpointData(BreakpointId id) const;
|
||||
BreakpointState state(BreakpointId id) const;
|
||||
bool isEnabled(BreakpointId id) const;
|
||||
|
||||
@@ -58,21 +58,42 @@ BreakpointParameters::BreakpointParameters(BreakpointType t)
|
||||
tracepoint(false)
|
||||
{}
|
||||
|
||||
BreakpointParts BreakpointParameters::differencesTo
|
||||
(const BreakpointParameters &rhs) const
|
||||
{
|
||||
BreakpointParts parts = BreakpointParts();
|
||||
if (type != rhs.type)
|
||||
parts |= TypePart;
|
||||
if (enabled != rhs.enabled)
|
||||
parts |= EnabledPart;
|
||||
if (pathUsage != rhs.pathUsage)
|
||||
parts |= PathUsagePart;
|
||||
if (fileName != rhs.fileName)
|
||||
parts |= FileAndLinePart;
|
||||
if (conditionsMatch(rhs.condition))
|
||||
parts |= ConditionPart;
|
||||
if (ignoreCount != rhs.ignoreCount)
|
||||
parts |= IgnoreCountPart;
|
||||
if (lineNumber != rhs.lineNumber)
|
||||
parts |= FileAndLinePart;
|
||||
if (address != rhs.address)
|
||||
parts |= AddressPart;
|
||||
if (threadSpec != rhs.threadSpec)
|
||||
parts |= ThreadSpecPart;
|
||||
if (functionName != rhs.functionName)
|
||||
parts |= FunctionPart;
|
||||
if (tracepoint != rhs.tracepoint)
|
||||
parts |= TracePointPart;
|
||||
if (module != rhs.module)
|
||||
parts |= ModulePart;
|
||||
if (command != rhs.command)
|
||||
parts |= CommandPart;
|
||||
return parts;
|
||||
}
|
||||
|
||||
bool BreakpointParameters::equals(const BreakpointParameters &rhs) const
|
||||
{
|
||||
return type == rhs.type
|
||||
&& enabled == rhs.enabled
|
||||
&& pathUsage == rhs.pathUsage
|
||||
&& fileName == rhs.fileName
|
||||
&& conditionsMatch(rhs.condition)
|
||||
&& ignoreCount == rhs.ignoreCount
|
||||
&& lineNumber == rhs.lineNumber
|
||||
&& address == rhs.address
|
||||
&& threadSpec == rhs.threadSpec
|
||||
&& functionName == rhs.functionName
|
||||
&& tracepoint == rhs.tracepoint
|
||||
&& module == rhs.module
|
||||
&& command == rhs.command;
|
||||
return !differencesTo(rhs);
|
||||
}
|
||||
|
||||
bool BreakpointParameters::conditionsMatch(const QByteArray &other) const
|
||||
|
||||
@@ -88,10 +88,40 @@ enum BreakpointPathUsage
|
||||
BreakpointUseShortPath //!< Use filename only, in case source files are relocated.
|
||||
};
|
||||
|
||||
enum BreakpointParts
|
||||
{
|
||||
NoParts = 0,
|
||||
FileAndLinePart = 0x1,
|
||||
FunctionPart = 0x2,
|
||||
AddressPart = 0x4,
|
||||
ConditionPart = 0x8,
|
||||
IgnoreCountPart = 0x10,
|
||||
ThreadSpecPart = 0x20,
|
||||
AllConditionParts = ConditionPart|IgnoreCountPart|ThreadSpecPart,
|
||||
ModulePart = 0x40,
|
||||
TracePointPart = 0x80,
|
||||
|
||||
EnabledPart = 0x100,
|
||||
TypePart = 0x200,
|
||||
PathUsagePart = 0x400,
|
||||
CommandPart = 0x400,
|
||||
|
||||
AllParts = FileAndLinePart|FunctionPart|AddressPart|ConditionPart
|
||||
|IgnoreCountPart|ThreadSpecPart|ModulePart|TracePointPart
|
||||
|EnabledPart|TypePart|PathUsagePart|CommandPart
|
||||
};
|
||||
|
||||
inline void operator|=(BreakpointParts &p, BreakpointParts r)
|
||||
{
|
||||
p = BreakpointParts(int(p) | int(r));
|
||||
}
|
||||
|
||||
|
||||
class BreakpointParameters
|
||||
{
|
||||
public:
|
||||
explicit BreakpointParameters(BreakpointType = UnknownType);
|
||||
BreakpointParts differencesTo(const BreakpointParameters &rhs) const;
|
||||
bool equals(const BreakpointParameters &rhs) const;
|
||||
bool conditionsMatch(const QByteArray &other) const;
|
||||
bool isWatchpoint() const { return type == Watchpoint; }
|
||||
|
||||
@@ -71,7 +71,7 @@ class BreakpointDialog : public QDialog
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BreakpointDialog(unsigned engineCapabilities, QWidget *parent = 0);
|
||||
bool showDialog(BreakpointParameters *data);
|
||||
bool showDialog(BreakpointParameters *data, BreakpointParts *parts);
|
||||
|
||||
void setParameters(const BreakpointParameters &data);
|
||||
BreakpointParameters parameters() const;
|
||||
@@ -385,7 +385,8 @@ void BreakpointDialog::typeChanged(int)
|
||||
}
|
||||
}
|
||||
|
||||
bool BreakpointDialog::showDialog(BreakpointParameters *data)
|
||||
bool BreakpointDialog::showDialog(BreakpointParameters *data,
|
||||
BreakpointParts *parts)
|
||||
{
|
||||
setParameters(*data);
|
||||
if (exec() != QDialog::Accepted)
|
||||
@@ -393,7 +394,8 @@ bool BreakpointDialog::showDialog(BreakpointParameters *data)
|
||||
|
||||
// Check if changed.
|
||||
const BreakpointParameters newParameters = parameters();
|
||||
if (data->equals(newParameters))
|
||||
*parts = data->differencesTo(newParameters);
|
||||
if (!*parts)
|
||||
return false;
|
||||
|
||||
*data = newParameters;
|
||||
@@ -651,17 +653,19 @@ void BreakWindow::editBreakpoint(BreakpointId id, QWidget *parent)
|
||||
unsigned engineCapabilities = AllDebuggerCapabilities;
|
||||
if (const DebuggerEngine *engine = breakHandler()->engine(id))
|
||||
engineCapabilities = engine->debuggerCapabilities();
|
||||
BreakpointParts parts = NoParts;
|
||||
BreakpointDialog dialog(engineCapabilities, parent);
|
||||
if (dialog.showDialog(&data))
|
||||
breakHandler()->setBreakpointData(id, data);
|
||||
if (dialog.showDialog(&data, &parts))
|
||||
breakHandler()->changeBreakpointData(id, data, parts);
|
||||
}
|
||||
|
||||
void BreakWindow::addBreakpoint()
|
||||
{
|
||||
BreakpointParameters data(BreakpointByFileAndLine);
|
||||
BreakpointParts parts = NoParts;
|
||||
BreakpointDialog dialog(AllDebuggerCapabilities, this);
|
||||
dialog.setWindowTitle(tr("Add Breakpoint"));
|
||||
if (dialog.showDialog(&data))
|
||||
if (dialog.showDialog(&data, &parts))
|
||||
breakHandler()->appendBreakpoint(data);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user