forked from qt-creator/qt-creator
Debugger: Simplify calls to parseChildrenData
Having access to the expanded inames doesn't make a difference. Change-Id: Ic833f647c2c135f213dd621e28a9be98809e0b04 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -1933,7 +1933,7 @@ void CdbEngine::handleLocals(const CdbExtensionCommandPtr &reply)
|
|||||||
WatchData dummy;
|
WatchData dummy;
|
||||||
dummy.iname = child["iname"].data();
|
dummy.iname = child["iname"].data();
|
||||||
dummy.name = QLatin1String(child["name"].data());
|
dummy.name = QLatin1String(child["name"].data());
|
||||||
parseWatchData(handler->expandedINames(), dummy, child, &watchData);
|
parseWatchData(dummy, child, &watchData);
|
||||||
}
|
}
|
||||||
// Fix the names of watch data.
|
// Fix the names of watch data.
|
||||||
for (int i =0; i < watchData.size(); ++i) {
|
for (int i =0; i < watchData.size(); ++i) {
|
||||||
|
@@ -4968,7 +4968,7 @@ void GdbEngine::handleStackFramePython(const GdbResponse &response)
|
|||||||
name = _(child["name"].data());
|
name = _(child["name"].data());
|
||||||
|
|
||||||
WatchItem *item = new WatchItem(iname, name);
|
WatchItem *item = new WatchItem(iname, name);
|
||||||
item->parseWatchData(handler->expandedINames(), child);
|
item->parseWatchData(child);
|
||||||
|
|
||||||
const TypeInfo ti = m_typeInfoCache.value(item->d.type);
|
const TypeInfo ti = m_typeInfoCache.value(item->d.type);
|
||||||
if (ti.size)
|
if (ti.size)
|
||||||
|
@@ -1029,7 +1029,7 @@ void LldbEngine::refreshLocals(const GdbMi &vars)
|
|||||||
name = QString::fromLatin1(child["name"].data());
|
name = QString::fromLatin1(child["name"].data());
|
||||||
|
|
||||||
WatchItem *item = new WatchItem(iname, name);
|
WatchItem *item = new WatchItem(iname, name);
|
||||||
item->parseWatchData(handler->expandedINames(), child);
|
item->parseWatchData(child);
|
||||||
|
|
||||||
if (wname.isValid())
|
if (wname.isValid())
|
||||||
item->d.exp = name.toUtf8();
|
item->d.exp = name.toUtf8();
|
||||||
|
@@ -808,7 +808,7 @@ void PdbEngine::handleListLocals(const PdbResponse &response)
|
|||||||
|
|
||||||
foreach (const GdbMi &child, all.children()) {
|
foreach (const GdbMi &child, all.children()) {
|
||||||
WatchItem *item = new WatchItem(child["iname"].data(), _(child["name"].data()));
|
WatchItem *item = new WatchItem(child["iname"].data(), _(child["name"].data()));
|
||||||
item->parseWatchData(handler->expandedINames(), child);
|
item->parseWatchData(child);
|
||||||
handler->insertItem(item);
|
handler->insertItem(item);
|
||||||
toDelete.remove(item->d.iname);
|
toDelete.remove(item->d.iname);
|
||||||
}
|
}
|
||||||
|
@@ -594,21 +594,16 @@ void decodeArrayData(std::function<void(const WatchData &)> itemHandler, const W
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseChildrenData(const QSet<QByteArray> &expandedINames,
|
void parseChildrenData(const WatchData &data0, const GdbMi &item,
|
||||||
const WatchData &data0, const GdbMi &item,
|
|
||||||
std::function<void(const WatchData &)> itemHandler,
|
std::function<void(const WatchData &)> itemHandler,
|
||||||
std::function<void(const QSet<QByteArray> &, const WatchData &, const GdbMi &)> childHandler,
|
std::function<void(const WatchData &, const GdbMi &)> childHandler,
|
||||||
std::function<void(const WatchData &childTemplate, const QByteArray &encodedData, int encoding)> arrayDecoder)
|
std::function<void(const WatchData &childTemplate, const QByteArray &encodedData, int encoding)> arrayDecoder)
|
||||||
{
|
{
|
||||||
//qDebug() << "HANDLE CHILDREN: " << data0.toString() << item.toString();
|
//qDebug() << "HANDLE CHILDREN: " << data0.toString() << item.toString();
|
||||||
WatchData data = data0;
|
WatchData data = data0;
|
||||||
bool isExpanded = expandedINames.contains(data.iname);
|
|
||||||
if (!isExpanded)
|
|
||||||
data.setChildrenUnneeded();
|
data.setChildrenUnneeded();
|
||||||
|
|
||||||
GdbMi children = item["children"];
|
GdbMi children = item["children"];
|
||||||
if (children.isValid() || !isExpanded)
|
|
||||||
data.setChildrenUnneeded();
|
|
||||||
|
|
||||||
data.updateType(item["type"]);
|
data.updateType(item["type"]);
|
||||||
GdbMi mi = item["editvalue"];
|
GdbMi mi = item["editvalue"];
|
||||||
@@ -698,28 +693,26 @@ void parseChildrenData(const QSet<QByteArray> &expandedINames,
|
|||||||
int encoding = child["keyencoded"].toInt();
|
int encoding = child["keyencoded"].toInt();
|
||||||
data1.name = decodeData(key, encoding);
|
data1.name = decodeData(key, encoding);
|
||||||
}
|
}
|
||||||
childHandler(expandedINames, data1, child);
|
childHandler(data1, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseWatchData(const QSet<QByteArray> &expandedINames,
|
void parseWatchData(const WatchData &data0, const GdbMi &input,
|
||||||
const WatchData &data0, const GdbMi &input,
|
|
||||||
QList<WatchData> *list)
|
QList<WatchData> *list)
|
||||||
{
|
{
|
||||||
auto itemHandler = [list](const WatchData &data) {
|
auto itemHandler = [list](const WatchData &data) {
|
||||||
list->append(data);
|
list->append(data);
|
||||||
};
|
};
|
||||||
auto childHandler = [list](const QSet<QByteArray> &expandedINames,
|
auto childHandler = [list](const WatchData &innerData, const GdbMi &innerInput) {
|
||||||
const WatchData &innerData, const GdbMi &innerInput) {
|
parseWatchData(innerData, innerInput, list);
|
||||||
parseWatchData(expandedINames, innerData, innerInput, list);
|
|
||||||
};
|
};
|
||||||
auto arrayDecoder = [itemHandler](const WatchData &childTemplate,
|
auto arrayDecoder = [itemHandler](const WatchData &childTemplate,
|
||||||
const QByteArray &encodedData, int encoding) {
|
const QByteArray &encodedData, int encoding) {
|
||||||
decodeArrayData(itemHandler, childTemplate, encodedData, encoding);
|
decodeArrayData(itemHandler, childTemplate, encodedData, encoding);
|
||||||
};
|
};
|
||||||
|
|
||||||
parseChildrenData(expandedINames, data0, input, itemHandler, childHandler, arrayDecoder);
|
parseChildrenData(data0, input, itemHandler, childHandler, arrayDecoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -159,18 +159,14 @@ void decodeArrayData(std::function<void(const WatchData &)> itemHandler,
|
|||||||
const QByteArray &rawData,
|
const QByteArray &rawData,
|
||||||
int encoding);
|
int encoding);
|
||||||
|
|
||||||
void parseChildrenData(const QSet<QByteArray> &expandedINames,
|
void parseChildrenData(const WatchData &parent, const GdbMi &child,
|
||||||
const WatchData &parent, const GdbMi &child,
|
|
||||||
std::function<void(const WatchData &)> itemHandler,
|
std::function<void(const WatchData &)> itemHandler,
|
||||||
std::function<void(const QSet<QByteArray> &,
|
std::function<void(const WatchData &, const GdbMi &)> childHandler,
|
||||||
const WatchData &,
|
|
||||||
const GdbMi &)> childHandler,
|
|
||||||
std::function<void(const WatchData &childTemplate,
|
std::function<void(const WatchData &childTemplate,
|
||||||
const QByteArray &encodedData,
|
const QByteArray &encodedData,
|
||||||
int encoding)> arrayDecoder);
|
int encoding)> arrayDecoder);
|
||||||
|
|
||||||
void parseWatchData(const QSet<QByteArray> &expandedINames,
|
void parseWatchData(const WatchData &parent, const GdbMi &child,
|
||||||
const WatchData &parent, const GdbMi &child,
|
|
||||||
QList<WatchData> *insertions);
|
QList<WatchData> *insertions);
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -1928,15 +1928,14 @@ WatchModel *WatchItem::watchModel()
|
|||||||
return static_cast<WatchModel *>(model());
|
return static_cast<WatchModel *>(model());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchItem::parseWatchData(const QSet<QByteArray> &expandedINames, const GdbMi &input)
|
void WatchItem::parseWatchData(const GdbMi &input)
|
||||||
{
|
{
|
||||||
auto itemHandler = [this](const WatchData &data) {
|
auto itemHandler = [this](const WatchData &data) {
|
||||||
d = data;
|
d = data;
|
||||||
};
|
};
|
||||||
auto childHandler = [this](const QSet<QByteArray> &expandedINames,
|
auto childHandler = [this](const WatchData &innerData, const GdbMi &innerInput) {
|
||||||
const WatchData &innerData, const GdbMi &innerInput) {
|
|
||||||
WatchItem *item = new WatchItem(innerData);
|
WatchItem *item = new WatchItem(innerData);
|
||||||
item->parseWatchData(expandedINames, innerInput);
|
item->parseWatchData(innerInput);
|
||||||
appendChild(item);
|
appendChild(item);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1949,7 +1948,7 @@ void WatchItem::parseWatchData(const QSet<QByteArray> &expandedINames, const Gdb
|
|||||||
decodeArrayData(itemAdder, childTemplate, encodedData, encoding);
|
decodeArrayData(itemAdder, childTemplate, encodedData, encoding);
|
||||||
};
|
};
|
||||||
|
|
||||||
parseChildrenData(expandedINames, d, input, itemHandler, childHandler, arrayDecoder);
|
parseChildrenData(d, input, itemHandler, childHandler, arrayDecoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -75,7 +75,7 @@ public:
|
|||||||
void formatRequests(QByteArray *out) const;
|
void formatRequests(QByteArray *out) const;
|
||||||
void showInEditorHelper(QString *contents, int depth) const;
|
void showInEditorHelper(QString *contents, int depth) const;
|
||||||
WatchItem *findItem(const QByteArray &iname);
|
WatchItem *findItem(const QByteArray &iname);
|
||||||
void parseWatchData(const QSet<QByteArray> &expandedINames, const GdbMi &input);
|
void parseWatchData(const GdbMi &input);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WatchData d;
|
WatchData d;
|
||||||
|
Reference in New Issue
Block a user