forked from qt-creator/qt-creator
debugger: more breakpoint refactoring
This commit is contained in:
@@ -195,8 +195,8 @@ void BreakHandler::setWatchpointByAddress(quint64 address)
|
|||||||
{
|
{
|
||||||
const int id = findWatchpointByAddress(address);
|
const int id = findWatchpointByAddress(address);
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
BreakpointData data(Watchpoint);
|
BreakpointParameters data(Watchpoint);
|
||||||
data.setAddress(address);
|
data.address = address;
|
||||||
appendBreakpoint(data);
|
appendBreakpoint(data);
|
||||||
scheduleSynchronization();
|
scheduleSynchronization();
|
||||||
} else {
|
} else {
|
||||||
@@ -257,39 +257,37 @@ void BreakHandler::loadBreakpoints()
|
|||||||
//clear();
|
//clear();
|
||||||
foreach (const QVariant &var, list) {
|
foreach (const QVariant &var, list) {
|
||||||
const QMap<QString, QVariant> map = var.toMap();
|
const QMap<QString, QVariant> map = var.toMap();
|
||||||
BreakpointData data(BreakpointByFileAndLine);
|
BreakpointParameters data(BreakpointByFileAndLine);
|
||||||
QVariant v = map.value(_("filename"));
|
QVariant v = map.value(_("filename"));
|
||||||
if (v.isValid())
|
if (v.isValid())
|
||||||
data.setFileName(v.toString());
|
data.fileName = v.toString();
|
||||||
v = map.value(_("linenumber"));
|
v = map.value(_("linenumber"));
|
||||||
if (v.isValid())
|
if (v.isValid())
|
||||||
data.setLineNumber(v.toString().toInt());
|
data.lineNumber = v.toString().toInt();
|
||||||
v = map.value(_("condition"));
|
v = map.value(_("condition"));
|
||||||
if (v.isValid())
|
if (v.isValid())
|
||||||
data.setCondition(v.toString().toLatin1());
|
data.condition = v.toString().toLatin1();
|
||||||
v = map.value(_("address"));
|
v = map.value(_("address"));
|
||||||
if (v.isValid())
|
if (v.isValid())
|
||||||
data.setAddress(v.toString().toULongLong());
|
data.address = v.toString().toULongLong();
|
||||||
v = map.value(_("ignorecount"));
|
v = map.value(_("ignorecount"));
|
||||||
if (v.isValid())
|
if (v.isValid())
|
||||||
data.setIgnoreCount(v.toString().toInt());
|
data.ignoreCount = v.toString().toInt();
|
||||||
v = map.value(_("threadspec"));
|
v = map.value(_("threadspec"));
|
||||||
if (v.isValid())
|
if (v.isValid())
|
||||||
data.setThreadSpec(v.toString().toLatin1());
|
data.threadSpec = v.toString().toLatin1();
|
||||||
v = map.value(_("funcname"));
|
v = map.value(_("funcname"));
|
||||||
if (v.isValid())
|
if (v.isValid())
|
||||||
data.setFunctionName(v.toString());
|
data.functionName = v.toString();
|
||||||
v = map.value(_("disabled"));
|
v = map.value(_("disabled"));
|
||||||
if (v.isValid())
|
if (v.isValid())
|
||||||
data.setEnabled(!v.toInt());
|
data.enabled = !v.toInt();
|
||||||
v = map.value(_("usefullpath"));
|
v = map.value(_("usefullpath"));
|
||||||
if (v.isValid())
|
if (v.isValid())
|
||||||
data.setUseFullPath(bool(v.toInt()));
|
data.useFullPath = bool(v.toInt());
|
||||||
v = map.value(_("type"));
|
v = map.value(_("type"));
|
||||||
if (v.isValid() && v.toInt() != UnknownType)
|
if (v.isValid() && v.toInt() != UnknownType)
|
||||||
data.setType(BreakpointType(v.toInt()));
|
data.type = BreakpointType(v.toInt());
|
||||||
data.setMarkerFileName(data.fileName());
|
|
||||||
data.setMarkerLineNumber(data.lineNumber());
|
|
||||||
appendBreakpoint(data);
|
appendBreakpoint(data);
|
||||||
}
|
}
|
||||||
//qDebug() << "LOADED BREAKPOINTS" << this << list.size();
|
//qDebug() << "LOADED BREAKPOINTS" << this << list.size();
|
||||||
@@ -618,9 +616,9 @@ void BreakHandler::removeBreakpoint(BreakpointId id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakHandler::appendBreakpoint(const BreakpointData &data)
|
void BreakHandler::appendBreakpoint(const BreakpointParameters &data)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(data.type() != UnknownType, return);
|
QTC_ASSERT(data.type != UnknownType, return);
|
||||||
|
|
||||||
// Ok to be not thread-safe. The order does not matter and only the gui
|
// Ok to be not thread-safe. The order does not matter and only the gui
|
||||||
// produces authoritative ids.
|
// produces authoritative ids.
|
||||||
@@ -628,7 +626,9 @@ void BreakHandler::appendBreakpoint(const BreakpointData &data)
|
|||||||
|
|
||||||
BreakpointId id(++currentId);
|
BreakpointId id(++currentId);
|
||||||
BreakpointItem item;
|
BreakpointItem item;
|
||||||
item.data = data;
|
BreakpointData d;
|
||||||
|
d.m_parameters = data;
|
||||||
|
item.data = d;
|
||||||
m_storage.insert(id, item);
|
m_storage.insert(id, item);
|
||||||
scheduleSynchronization();
|
scheduleSynchronization();
|
||||||
}
|
}
|
||||||
@@ -649,17 +649,15 @@ void BreakHandler::toggleBreakpoint(const QString &fileName, int lineNumber,
|
|||||||
if (id != BreakpointId(-1)) {
|
if (id != BreakpointId(-1)) {
|
||||||
removeBreakpoint(id);
|
removeBreakpoint(id);
|
||||||
} else {
|
} else {
|
||||||
BreakpointData data;
|
BreakpointParameters data;
|
||||||
if (address) {
|
if (address) {
|
||||||
data.setType(BreakpointByAddress);
|
data.type = BreakpointByAddress;
|
||||||
data.setAddress(address);
|
data.address = address;
|
||||||
} else {
|
} else {
|
||||||
data.setType(BreakpointByFileAndLine);
|
data.type = BreakpointByFileAndLine;
|
||||||
data.setFileName(fileName);
|
data.fileName = fileName;
|
||||||
data.setLineNumber(lineNumber);
|
data.lineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
data.setMarkerFileName(fileName);
|
|
||||||
data.setMarkerLineNumber(lineNumber);
|
|
||||||
appendBreakpoint(data);
|
appendBreakpoint(data);
|
||||||
}
|
}
|
||||||
debuggerCore()->synchronizeBreakpoints();
|
debuggerCore()->synchronizeBreakpoints();
|
||||||
@@ -688,8 +686,8 @@ void BreakHandler::breakByFunction(const QString &functionName)
|
|||||||
&& data.ignoreCount() == 0)
|
&& data.ignoreCount() == 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BreakpointData data(BreakpointByFunction);
|
BreakpointParameters data(BreakpointByFunction);
|
||||||
data.setFunctionName(functionName);
|
data.functionName = functionName;
|
||||||
appendBreakpoint(data);
|
appendBreakpoint(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,6 +855,16 @@ void BreakHandler::setResponse(BreakpointId id, const BreakpointResponse &data)
|
|||||||
updateMarker(id);
|
updateMarker(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BreakHandler::setData(BreakpointId id, const BreakpointParameters &data)
|
||||||
|
{
|
||||||
|
Iterator it = m_storage.find(id);
|
||||||
|
QTC_ASSERT(it != m_storage.end(), return);
|
||||||
|
if (data == it->data.m_parameters)
|
||||||
|
return;
|
||||||
|
it->data.m_parameters = data;
|
||||||
|
updateMarker(id);
|
||||||
|
layoutChanged();
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@@ -65,7 +65,7 @@ public:
|
|||||||
QAbstractItemModel *model() { return this; }
|
QAbstractItemModel *model() { return this; }
|
||||||
|
|
||||||
// The only way to add a new breakpoint.
|
// The only way to add a new breakpoint.
|
||||||
void appendBreakpoint(const BreakpointData &data);
|
void appendBreakpoint(const BreakpointParameters &data);
|
||||||
|
|
||||||
BreakpointIds allBreakpointIds() const;
|
BreakpointIds allBreakpointIds() const;
|
||||||
BreakpointIds engineBreakpointIds(DebuggerEngine *engine) const;
|
BreakpointIds engineBreakpointIds(DebuggerEngine *engine) const;
|
||||||
@@ -100,6 +100,7 @@ public:
|
|||||||
QIcon icon(BreakpointId id) const;
|
QIcon icon(BreakpointId id) const;
|
||||||
|
|
||||||
void gotoLocation(BreakpointId id) const;
|
void gotoLocation(BreakpointId id) const;
|
||||||
|
void setData(BreakpointId id, const BreakpointParameters &data);
|
||||||
|
|
||||||
// Getter retrieves property value.
|
// Getter retrieves property value.
|
||||||
// Setter sets property value and triggers update if changed.
|
// Setter sets property value and triggers update if changed.
|
||||||
|
@@ -67,7 +67,7 @@ class BreakpointDialog : public QDialog, public Ui::BreakpointDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit BreakpointDialog(QWidget *parent);
|
explicit BreakpointDialog(QWidget *parent);
|
||||||
bool showDialog(BreakpointData *data);
|
bool showDialog(BreakpointParameters *data);
|
||||||
|
|
||||||
void setParameters(const BreakpointParameters &p);
|
void setParameters(const BreakpointParameters &p);
|
||||||
BreakpointParameters parameters() const;
|
BreakpointParameters parameters() const;
|
||||||
@@ -160,28 +160,19 @@ void BreakpointDialog::typeChanged(int)
|
|||||||
lineEditFunction->setText(QLatin1String("main"));
|
lineEditFunction->setText(QLatin1String("main"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BreakpointDialog::showDialog(BreakpointData *data)
|
bool BreakpointDialog::showDialog(BreakpointParameters *data)
|
||||||
{
|
{
|
||||||
setParameters(data->parameters());
|
setParameters(*data);
|
||||||
if (exec() != QDialog::Accepted)
|
if (exec() != QDialog::Accepted)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check if changed.
|
// Check if changed.
|
||||||
const BreakpointParameters newParameters = parameters();
|
const BreakpointParameters newParameters = parameters();
|
||||||
if (newParameters == data->parameters())
|
if (data->equals(newParameters))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool result = false;
|
*data = newParameters;
|
||||||
result |= data->setType(newParameters.type);
|
return true;
|
||||||
result |= data->setAddress(newParameters.address);
|
|
||||||
result |= data->setFunctionName(newParameters.functionName);
|
|
||||||
result |= data->setUseFullPath(newParameters.useFullPath);
|
|
||||||
result |= data->setFileName(newParameters.fileName);
|
|
||||||
result |= data->setLineNumber(newParameters.lineNumber);
|
|
||||||
result |= data->setCondition(newParameters.condition);
|
|
||||||
result |= data->setIgnoreCount(newParameters.ignoreCount);
|
|
||||||
result |= data->setThreadSpec(newParameters.threadSpec);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
@@ -396,11 +387,10 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
setBreakpointsEnabled(si, !enabled);
|
setBreakpointsEnabled(si, !enabled);
|
||||||
else if (act == addBreakpointAction)
|
else if (act == addBreakpointAction)
|
||||||
addBreakpoint();
|
addBreakpoint();
|
||||||
else if (act == breakAtThrowAction) {
|
else if (act == breakAtThrowAction)
|
||||||
handler->appendBreakpoint(BreakpointData(BreakpointAtThrow));
|
handler->appendBreakpoint(BreakpointParameters(BreakpointAtThrow));
|
||||||
} else if (act == breakAtCatchAction) {
|
else if (act == breakAtCatchAction)
|
||||||
handler->appendBreakpoint(BreakpointData(BreakpointAtCatch));
|
handler->appendBreakpoint(BreakpointParameters(BreakpointAtCatch));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakWindow::setBreakpointsEnabled(const QModelIndexList &list, bool enabled)
|
void BreakWindow::setBreakpointsEnabled(const QModelIndexList &list, bool enabled)
|
||||||
@@ -427,12 +417,14 @@ void BreakWindow::deleteBreakpoints(const QModelIndexList &list)
|
|||||||
void BreakWindow::editBreakpoint(BreakpointId id, QWidget *parent)
|
void BreakWindow::editBreakpoint(BreakpointId id, QWidget *parent)
|
||||||
{
|
{
|
||||||
BreakpointDialog dialog(parent);
|
BreakpointDialog dialog(parent);
|
||||||
dialog.showDialog(breakHandler()->breakpointById(id));
|
BreakpointParameters data = breakHandler()->breakpointById(id)->parameters();
|
||||||
|
if (dialog.showDialog(&data))
|
||||||
|
breakHandler()->setData(id, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakWindow::addBreakpoint()
|
void BreakWindow::addBreakpoint()
|
||||||
{
|
{
|
||||||
BreakpointData data(BreakpointByFileAndLine);
|
BreakpointParameters data(BreakpointByFileAndLine);
|
||||||
BreakpointDialog dialog(this);
|
BreakpointDialog dialog(this);
|
||||||
if (dialog.showDialog(&data))
|
if (dialog.showDialog(&data))
|
||||||
breakHandler()->appendBreakpoint(data);
|
breakHandler()->appendBreakpoint(data);
|
||||||
|
@@ -62,7 +62,7 @@ IPCEngineHost::IPCEngineHost (const DebuggerStartParameters &startParameters)
|
|||||||
, m_cookie(1)
|
, m_cookie(1)
|
||||||
, m_device(0)
|
, m_device(0)
|
||||||
{
|
{
|
||||||
connect(this, SIGNAL(stateChanged(const DebuggerState &)), this, SLOT(m_stateChanged(const DebuggerState &)));
|
connect(this, SIGNAL(stateChanged(DebuggerState)), this, SLOT(m_stateChanged(DebuggerState)));
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCEngineHost::~IPCEngineHost()
|
IPCEngineHost::~IPCEngineHost()
|
||||||
|
Reference in New Issue
Block a user