Commit 034bb72d authored by hjk's avatar hjk

debugger: make alphabetic sorting of struct members optional.

Task-number: QTCREATORBUG-1608
parent 6295208a
......@@ -265,6 +265,14 @@ DebuggerSettings *DebuggerSettings::instance()
item->setValue(true);
instance->insertItem(ShowQtNamespace, item);
item = new SavedAction(instance);
item->setSettingsKey(debugModeGroup, QLatin1String("SortStructMembers"));
item->setText(tr("Sort Members of Classes and Structs Alphabetically"));
item->setCheckable(true);
item->setDefaultValue(true);
item->setValue(true);
instance->insertItem(SortStructMembers, item);
//
// DebuggingHelper
//
......
......@@ -125,6 +125,7 @@ enum DebuggerActionCode
// Watchers & Locals
ShowStdNamespace,
ShowQtNamespace,
SortStructMembers,
// Source List
ListSourceFiles,
......
......@@ -569,6 +569,7 @@ QWidget *CommonOptionsPage::createPage(QWidget *parent)
m_ui.spinBoxMaximalStackDepth);
m_group.insert(theDebuggerAction(ShowStdNamespace), 0);
m_group.insert(theDebuggerAction(ShowQtNamespace), 0);
m_group.insert(theDebuggerAction(SortStructMembers), 0);
m_group.insert(theDebuggerAction(LogTimeStamps), 0);
m_group.insert(theDebuggerAction(VerboseLog), 0);
m_group.insert(theDebuggerAction(UsePreciseBreakpoints), 0);
......@@ -2347,6 +2348,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
const bool canDeref = actionsEnabled
&& (m_capabilities & AutoDerefPointersCapability);
theDebuggerAction(AutoDerefPointers)->setEnabled(canDeref);
theDebuggerAction(AutoDerefPointers)->setEnabled(true);
theDebuggerAction(ExpandStack)->setEnabled(actionsEnabled);
theDebuggerAction(ExecuteCommand)->setEnabled(m_state == InferiorStopOk);
......
......@@ -426,7 +426,9 @@ void GdbEngine::handleDebuggingHelperValue2Classic(const GdbResponse &response)
setWatchDataDisplayedType(data, response.data.findChild("displaytype"));
QList<WatchData> list;
parseWatchData(watchHandler()->expandedINames(),
data, contents, &list);
data, contents,
theDebuggerBoolSetting(SortStructMembers),
&list);
//for (int i = 0; i != list.size(); ++i)
// qDebug() << "READ: " << list.at(i).toString();
watchHandler()->insertBulkData(list);
......
......@@ -191,9 +191,11 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters)
m_gdbAdapter = createAdapter();
connect(theDebuggerAction(AutoDerefPointers), SIGNAL(valueChanged(QVariant)),
this, SLOT(setAutoDerefPointers(QVariant)));
SLOT(reloadLocals()));
connect(theDebuggerAction(SortStructMembers), SIGNAL(valueChanged(QVariant)),
SLOT(reloadLocals()));
connect(theDebuggerAction(CreateFullBacktrace), SIGNAL(triggered()),
this, SLOT(createFullBacktrace()));
SLOT(createFullBacktrace()));
}
DebuggerStartMode GdbEngine::startMode() const
......@@ -3342,9 +3344,8 @@ void GdbEngine::setToolTipExpression(const QPoint &mousePos,
//
//////////////////////////////////////////////////////////////////////
void GdbEngine::setAutoDerefPointers(const QVariant &on)
void GdbEngine::reloadLocals()
{
Q_UNUSED(on)
setTokenBarrier();
updateLocals();
}
......
......@@ -122,7 +122,7 @@ private: ////////// General State //////////
void initializeVariables();
DebuggerStartMode startMode() const;
Q_SLOT void setAutoDerefPointers(const QVariant &on);
Q_SLOT void reloadLocals();
bool m_registerNamesListed;
......
......@@ -133,12 +133,14 @@ void GdbEngine::handleStackFramePython(const GdbResponse &response)
GdbMi data = all.findChild("data");
QList<WatchData> list;
const bool sortMembers = theDebuggerBoolSetting(SortStructMembers);
foreach (const GdbMi &child, data.children()) {
WatchData dummy;
dummy.iname = child.findChild("iname").data();
dummy.name = _(child.findChild("name").data());
//qDebug() << "CHILD: " << child.toString();
parseWatchData(watchHandler()->expandedINames(), dummy, child, &list);
parseWatchData(watchHandler()->expandedINames(), dummy, child,
sortMembers, &list);
}
watchHandler()->insertBulkData(list);
//for (int i = 0; i != list.size(); ++i)
......
......@@ -827,12 +827,13 @@ void PdbEngine::handleListLocals(const PdbResponse &response)
//GdbMi data = all.findChild("data");
QList<WatchData> list;
WatchHandler *handler = watchHandler();
bool sortMembers = theDebuggerBoolSetting(SortStructMembers);
foreach (const GdbMi &child, all.children()) {
WatchData dummy;
dummy.iname = child.findChild("iname").data();
dummy.name = _(child.findChild("name").data());
//qDebug() << "CHILD: " << child.toString();
parseWatchData(handler->expandedINames(), dummy, child, &list);
parseWatchData(handler->expandedINames(), dummy, child, sortMembers, &list);
}
handler->insertBulkData(list);
}
......
......@@ -1206,6 +1206,8 @@ WatchHandler::WatchHandler(DebuggerEngine *engine)
SIGNAL(triggered()), this, SLOT(emitAllChanged()));
connect(theDebuggerAction(ShowQtNamespace),
SIGNAL(triggered()), this, SLOT(emitAllChanged()));
connect(theDebuggerAction(SortStructMembers),
SIGNAL(triggered()), this, SLOT(emitAllChanged()));
}
void WatchHandler::beginCycle(bool fullCycle)
......
......@@ -1498,7 +1498,9 @@ static void gbdMiToWatchData(const GdbMi &root,
}
}
if (w.name.isEmpty()) {
const QString msg = QString::fromLatin1("Internal error: Unable to determine name at level %1/%2 for %3").arg(ctx.recursionLevel).arg(w.iname, QLatin1String(root.toString(true, 2)));
const QString msg = QString::fromLatin1(
"Internal error: Unable to determine name at level %1/%2 for %3")
.arg(ctx.recursionLevel).arg(w.iname, QLatin1String(root.toString(true, 2)));
qWarning("%s\n", qPrintable(msg));
}
gdbMiGetStringValue(&w.displayedType, root, "displayedtype");
......@@ -1551,14 +1553,13 @@ static void gbdMiToWatchData(const GdbMi &root,
gdbMiGetStringValue(&nextLevelContext.childType, root, "childtype");
if (!gdbMiGetIntValue(&nextLevelContext.childNumChild, root, "childnumchild"))
nextLevelContext.childNumChild = -1;
foreach(const GdbMi &child, children) {
foreach (const GdbMi &child, children) {
gbdMiToWatchData(child, nextLevelContext, wl);
nextLevelContext.childIndex++;
}
}
bool QtDumperHelper::parseValue(const char *data,
QList<WatchData> *l)
bool QtDumperHelper::parseValue(const char *data, QList<WatchData> *l)
{
l->clear();
GdbMi root;
......@@ -1664,7 +1665,8 @@ void setWatchDataDisplayedType(WatchData &data, const GdbMi &item)
}
void parseWatchData(const QSet<QByteArray> &expandedINames,
const WatchData &data0, const GdbMi &item, QList<WatchData> *list)
const WatchData &data0, const GdbMi &item,
bool sortMembers, QList<WatchData> *list)
{
//qDebug() << "HANDLE CHILDREN: " << data0.toString() << item.toString();
WatchData data = data0;
......@@ -1715,10 +1717,18 @@ void parseWatchData(const QSet<QByteArray> &expandedINames,
else
data1.name = QString::number(i);
GdbMi iname = child.findChild("iname");
if (iname.isValid())
if (iname.isValid()) {
data1.iname = iname.data();
else
data1.iname = data.iname + '.' + data1.name.toLatin1();
} else {
data1.iname = data.iname;
data1.iname += '.';
if (!sortMembers) {
char buf[10];
qsnprintf(buf, sizeof(buf) - 1, "%04d", i);
data1.iname += buf;
}
data1.iname += data1.name.toLatin1();
}
if (!data1.name.isEmpty() && data1.name.at(0).isDigit())
data1.name = _c('[') + data1.name + _c(']');
if (addressStep) {
......@@ -1737,7 +1747,7 @@ void parseWatchData(const QSet<QByteArray> &expandedINames,
//data1.name += " (" + skey + ")";
data1.name = skey;
}
parseWatchData(expandedINames, data1, child, list);
parseWatchData(expandedINames, data1, child, sortMembers, list);
++i;
}
}
......
......@@ -257,7 +257,7 @@ void setWatchDataType(WatchData &data, const GdbMi &mi);
void setWatchDataDisplayedType(WatchData &data, const GdbMi &mi);
void parseWatchData(const QSet<QByteArray> &expandedINames,
const WatchData &parent, const GdbMi &child,
const WatchData &parent, const GdbMi &child, bool sortMembers,
QList<WatchData> *insertions);
} // namespace Internal
......
......@@ -415,6 +415,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(theDebuggerAction(AutoDerefPointers));
menu.addAction(theDebuggerAction(ShowStdNamespace));
menu.addAction(theDebuggerAction(ShowQtNamespace));
menu.addAction(theDebuggerAction(SortStructMembers));
QAction *actAdjustColumnWidths =
menu.addAction(tr("Adjust Column Widths to Contents"));
......
Markdown is supported
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