forked from qt-creator/qt-creator
Debugger: Privatize GdbMi::m_children
Change-Id: I6e51290c4521be40f516a452f32bdc82a4c051e6 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -296,7 +296,7 @@ void BreakpointParameters::updateFromGdbOutput(const GdbMi &bkpt)
|
||||
enabled = true;
|
||||
pending = false;
|
||||
condition.clear();
|
||||
for (const GdbMi &child : bkpt.children()) {
|
||||
for (const GdbMi &child : bkpt) {
|
||||
if (child.hasName("number")) {
|
||||
// Handled on caller side.
|
||||
} else if (child.hasName("func")) {
|
||||
|
||||
@@ -1321,8 +1321,7 @@ void CdbEngine::showScriptMessages(const QString &message) const
|
||||
gdmiMessage.fromString(message);
|
||||
if (!gdmiMessage.isValid())
|
||||
showMessage(message, LogMisc);
|
||||
const GdbMi &messages = gdmiMessage["msg"];
|
||||
for (const GdbMi &msg : messages.children()) {
|
||||
for (const GdbMi &msg : gdmiMessage["msg"]) {
|
||||
if (msg.name() == "bridgemessage")
|
||||
showMessage(msg["msg"].data(), LogMisc);
|
||||
else
|
||||
@@ -1529,7 +1528,7 @@ void CdbEngine::handleModules(const DebuggerResponse &response)
|
||||
if (response.data.type() == GdbMi::List) {
|
||||
ModulesHandler *handler = modulesHandler();
|
||||
handler->beginUpdateAll();
|
||||
foreach (const GdbMi &gdbmiModule, response.data.children()) {
|
||||
for (const GdbMi &gdbmiModule : response.data) {
|
||||
Module module;
|
||||
module.moduleName = gdbmiModule["name"].data();
|
||||
module.modulePath = gdbmiModule["image"].data();
|
||||
@@ -1555,7 +1554,7 @@ void CdbEngine::handleRegistersExt(const DebuggerResponse &response)
|
||||
if (response.resultClass == ResultDone) {
|
||||
if (response.data.type() == GdbMi::List) {
|
||||
RegisterHandler *handler = registerHandler();
|
||||
foreach (const GdbMi &item, response.data.children()) {
|
||||
for (const GdbMi &item : response.data) {
|
||||
Register reg;
|
||||
reg.name = item["name"].data();
|
||||
reg.description = item["description"].data();
|
||||
@@ -1593,8 +1592,8 @@ void CdbEngine::handleLocals(const DebuggerResponse &response, bool partialUpdat
|
||||
partial.m_data = QString::number(partialUpdate ? 1 : 0);
|
||||
|
||||
GdbMi all;
|
||||
all.m_children.push_back(response.data);
|
||||
all.m_children.push_back(partial);
|
||||
all.addChild(response.data);
|
||||
all.addChild(partial);
|
||||
updateLocalsView(all);
|
||||
} else {
|
||||
showMessage(response.data["msg"].data(), LogWarning);
|
||||
@@ -2141,7 +2140,7 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QString &what, c
|
||||
msg.m_data = message;
|
||||
msg.m_type = GdbMi::Tuple;
|
||||
response.data.m_type = GdbMi::Tuple;
|
||||
response.data.m_children.push_back(msg);
|
||||
response.data.addChild(msg);
|
||||
}
|
||||
command.callback(response);
|
||||
return;
|
||||
@@ -2899,7 +2898,7 @@ void CdbEngine::handleBreakPoints(const DebuggerResponse &response)
|
||||
QString message;
|
||||
QTextStream str(&message);
|
||||
BreakHandler *handler = breakHandler();
|
||||
foreach (const GdbMi &breakPointG, response.data.children()) {
|
||||
for (const GdbMi &breakPointG : response.data) {
|
||||
// Might not be valid if there is not id
|
||||
const QString responseId = breakPointG["id"].data();
|
||||
BreakpointParameters reportedResponse;
|
||||
|
||||
@@ -267,15 +267,19 @@ static QString ind(int indent)
|
||||
|
||||
void GdbMi::dumpChildren(QString * str, bool multiline, int indent) const
|
||||
{
|
||||
for (int i = 0; i < m_children.size(); ++i) {
|
||||
if (i != 0) {
|
||||
bool first = true;
|
||||
for (const GdbMi &child : *this) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
*str += ',';
|
||||
if (multiline)
|
||||
*str += '\n';
|
||||
}
|
||||
|
||||
if (multiline)
|
||||
*str += ind(indent);
|
||||
*str += m_children.at(i).toString(multiline, indent);
|
||||
*str += child.toString(multiline, indent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,9 +375,9 @@ void GdbMi::fromStringMultiple(const QString &ba)
|
||||
const GdbMi &GdbMi::operator[](const char *name) const
|
||||
{
|
||||
static GdbMi empty;
|
||||
for (int i = 0, n = int(m_children.size()); i < n; ++i)
|
||||
if (m_children.at(i).m_name == QLatin1String(name))
|
||||
return m_children.at(i);
|
||||
for (const GdbMi &child : *this)
|
||||
if (child.m_name == QLatin1String(name))
|
||||
return child;
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,12 +131,13 @@ public:
|
||||
|
||||
QString m_name;
|
||||
QString m_data;
|
||||
QVector<GdbMi> m_children;
|
||||
|
||||
using Children = QVector<GdbMi>;
|
||||
enum Type { Invalid, Const, Tuple, List };
|
||||
|
||||
Type m_type = Invalid;
|
||||
|
||||
void addChild(const GdbMi &child) { m_children.push_back(child); }
|
||||
|
||||
Type type() const { return m_type; }
|
||||
const QString &name() const { return m_name; }
|
||||
bool hasName(const QString &name) const { return m_name == name; }
|
||||
@@ -145,7 +146,8 @@ public:
|
||||
bool isList() const { return m_type == List; }
|
||||
|
||||
const QString &data() const { return m_data; }
|
||||
const QVector<GdbMi> &children() const { return m_children; }
|
||||
Children::const_iterator begin() const { return m_children.begin(); }
|
||||
Children::const_iterator end() const { return m_children.end(); }
|
||||
int childCount() const { return int(m_children.size()); }
|
||||
|
||||
const GdbMi &childAt(int index) const { return m_children[index]; }
|
||||
@@ -169,6 +171,7 @@ public:
|
||||
|
||||
private:
|
||||
void dumpChildren(QString *str, bool multiline, int indent) const;
|
||||
Children m_children;
|
||||
};
|
||||
|
||||
QString fromHex(const QString &str);
|
||||
|
||||
@@ -291,7 +291,7 @@ void GdbEngine::handleResponse(const QString &buff)
|
||||
data.parseResultOrValue(from, to);
|
||||
if (data.isValid()) {
|
||||
//qDebug() << "parsed result:" << data.toString();
|
||||
result.m_children.push_back(data);
|
||||
result.addChild(data);
|
||||
result.m_type = GdbMi::Tuple;
|
||||
}
|
||||
}
|
||||
@@ -566,7 +566,7 @@ void GdbEngine::handleAsyncOutput(const QString &asyncClass, const GdbMi &result
|
||||
res.fromString(ba);
|
||||
BreakHandler *handler = breakHandler();
|
||||
Breakpoint bp;
|
||||
for (const GdbMi &bkpt : res.children()) {
|
||||
for (const GdbMi &bkpt : res) {
|
||||
const QString nr = bkpt["number"].data();
|
||||
if (nr.contains('.')) {
|
||||
// A sub-breakpoint.
|
||||
@@ -590,7 +590,7 @@ void GdbEngine::handleAsyncOutput(const QString &asyncClass, const GdbMi &result
|
||||
// {bkpt={number="2",type="hw watchpoint",disp="keep",enabled="y",
|
||||
// what="*0xbfffed48",times="0",original-location="*0xbfffed48"}}
|
||||
BreakHandler *handler = breakHandler();
|
||||
for (const GdbMi &bkpt : result.children()) {
|
||||
for (const GdbMi &bkpt : result) {
|
||||
const QString nr = bkpt["number"].data();
|
||||
BreakpointParameters br;
|
||||
br.type = BreakpointByFileAndLine;
|
||||
@@ -1064,8 +1064,7 @@ void GdbEngine::handleQuerySources(const DebuggerResponse &response)
|
||||
m_fullToShortName.clear();
|
||||
// "^done,files=[{file="../../../../bin/dumper/dumper.cpp",
|
||||
// fullname="/data5/dev/ide/main/bin/dumper/dumper.cpp"},
|
||||
GdbMi files = response.data["files"];
|
||||
for (const GdbMi &item : files.children()) {
|
||||
for (const GdbMi &item : response.data["files"]) {
|
||||
GdbMi fileName = item["file"];
|
||||
if (fileName.data().endsWith("<built-in>"))
|
||||
continue;
|
||||
@@ -2240,7 +2239,7 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, const Breakpoint &bp)
|
||||
// http://permalink.gmane.org/gmane.comp.gdb.patches/83936
|
||||
const GdbMi locations = bkpt["locations"];
|
||||
if (locations.isValid()) {
|
||||
for (const GdbMi &location : locations.children()) {
|
||||
for (const GdbMi &location : locations) {
|
||||
// A sub-breakpoint.
|
||||
const QString subnr = location["number"].data();
|
||||
SubBreakpoint sub = bp->findOrCreateSubBreakpoint(subnr);
|
||||
@@ -2276,7 +2275,7 @@ void GdbEngine::handleBreakInsert1(const DebuggerResponse &response, const Break
|
||||
// the "main" entry. Use the "main" entry to retrieve the
|
||||
// already known data from the BreakpointManager, and then
|
||||
// iterate over all items to update main- and sub-data.
|
||||
for (const GdbMi &bkpt : response.data.children())
|
||||
for (const GdbMi &bkpt : response.data)
|
||||
handleBkpt(bkpt, bp);
|
||||
if (bp->needsChange()) {
|
||||
bp->gotoState(BreakpointUpdateRequested, BreakpointInsertionProceeding);
|
||||
@@ -2819,7 +2818,7 @@ void GdbEngine::handleModulesList(const DebuggerResponse &response)
|
||||
// state="Y",path="/usr/lib/dyld",description="/usr/lib/dyld",
|
||||
// loaded_addr="0x8fe00000",slide="0x0",prefix="__dyld_"},
|
||||
// shlib-info={...}...
|
||||
for (const GdbMi &item : response.data.children()) {
|
||||
for (const GdbMi &item : response.data) {
|
||||
module.modulePath = item["path"].data();
|
||||
module.moduleName = nameFromPath(module.modulePath);
|
||||
module.symbolsRead = (item["state"].data() == "Y")
|
||||
@@ -2861,8 +2860,7 @@ void GdbEngine::reloadSourceFiles()
|
||||
m_fullToShortName.clear();
|
||||
// "^done,files=[{file="../../../../bin/dumper/dumper.cpp",
|
||||
// fullname="/data5/dev/ide/main/bin/dumper/dumper.cpp"},
|
||||
GdbMi files = response.data["files"];
|
||||
for (const GdbMi &item : files.children()) {
|
||||
for (const GdbMi &item : response.data["files"]) {
|
||||
GdbMi fileName = item["file"];
|
||||
if (fileName.data().endsWith("<built-in>"))
|
||||
continue;
|
||||
@@ -3013,8 +3011,7 @@ void GdbEngine::handleThreadListIds(const DebuggerResponse &response)
|
||||
// "72^done,{thread-ids={thread-id="2",thread-id="1"},number-of-threads="2"}
|
||||
// In gdb 7.1+ additionally: current-thread-id="1"
|
||||
ThreadsHandler *handler = threadsHandler();
|
||||
const QVector<GdbMi> &items = response.data["thread-ids"].children();
|
||||
for (const GdbMi &item : items) {
|
||||
for (const GdbMi &item : response.data["thread-ids"]) {
|
||||
ThreadData thread;
|
||||
thread.id = item.data();
|
||||
handler->updateThread(thread);
|
||||
@@ -3028,7 +3025,7 @@ void GdbEngine::handleThreadNames(const DebuggerResponse &response)
|
||||
ThreadsHandler *handler = threadsHandler();
|
||||
GdbMi names;
|
||||
names.fromString(response.consoleStreamOutput);
|
||||
for (const GdbMi &name : names.children()) {
|
||||
for (const GdbMi &name : names) {
|
||||
ThreadData thread;
|
||||
thread.id = name["id"].data();
|
||||
// Core is unavailable in core dump. Allow the user to provide it.
|
||||
@@ -3180,10 +3177,9 @@ void GdbEngine::handleRegisterListNames(const DebuggerResponse &response)
|
||||
return;
|
||||
}
|
||||
|
||||
GdbMi names = response.data["register-names"];
|
||||
m_registers.clear();
|
||||
int gdbRegisterNumber = 0;
|
||||
for (const GdbMi &item : names.children()) {
|
||||
for (const GdbMi &item : response.data["register-names"]) {
|
||||
if (!item.data().isEmpty()) {
|
||||
Register reg;
|
||||
reg.name = item.data();
|
||||
@@ -3228,8 +3224,7 @@ void GdbEngine::handleRegisterListValues(const DebuggerResponse &response)
|
||||
|
||||
RegisterHandler *handler = registerHandler();
|
||||
// 24^done,register-values=[{number="0",value="0xf423f"},...]
|
||||
const GdbMi values = response.data["register-values"];
|
||||
for (const GdbMi &item : values.children()) {
|
||||
for (const GdbMi &item : response.data["register-values"]) {
|
||||
const int number = item["number"].toInt();
|
||||
Register reg = m_registers[number];
|
||||
QString data = item["value"].data();
|
||||
@@ -3364,18 +3359,18 @@ void GdbEngine::handleFetchMemory(const DebuggerResponse &response, MemoryAgentC
|
||||
QTC_ASSERT(ac.agent, return);
|
||||
if (response.resultClass == ResultDone) {
|
||||
GdbMi memory = response.data["memory"];
|
||||
QTC_ASSERT(memory.children().size() <= 1, return);
|
||||
if (memory.children().empty())
|
||||
QTC_ASSERT(memory.childCount() <= 1, return);
|
||||
if (memory.childCount() == 0)
|
||||
return;
|
||||
GdbMi memory0 = memory.children().at(0); // we asked for only one 'row'
|
||||
GdbMi memory0 = memory.childAt(0); // we asked for only one 'row'
|
||||
GdbMi data = memory0["data"];
|
||||
for (int i = 0, n = int(data.children().size()); i != n; ++i) {
|
||||
const GdbMi &child = data.children().at(i);
|
||||
int i = 0;
|
||||
for (const GdbMi &child : data) {
|
||||
bool ok = true;
|
||||
unsigned char c = '?';
|
||||
c = child.data().toUInt(&ok, 0);
|
||||
QTC_ASSERT(ok, return);
|
||||
(*ac.accumulator)[ac.offset + i] = c;
|
||||
(*ac.accumulator)[ac.offset + i++] = c;
|
||||
}
|
||||
} else {
|
||||
// We have an error
|
||||
|
||||
@@ -382,7 +382,7 @@ void LldbEngine::handleResponse(const QString &response)
|
||||
GdbMi all;
|
||||
all.fromStringMultiple(response);
|
||||
|
||||
foreach (const GdbMi &item, all.children()) {
|
||||
for (const GdbMi &item : all) {
|
||||
const QString name = item.name();
|
||||
if (name == "result") {
|
||||
QString msg = item["status"].data();
|
||||
@@ -557,9 +557,9 @@ void LldbEngine::updateBreakpointData(const Breakpoint &bp, const GdbMi &bkpt, b
|
||||
bp->setLineNumber(bkpt["line"].toInt());
|
||||
|
||||
GdbMi locations = bkpt["locations"];
|
||||
const int numChild = int(locations.children().size());
|
||||
const int numChild = locations.childCount();
|
||||
if (numChild > 1) {
|
||||
for (const GdbMi &location : locations.children()) {
|
||||
for (const GdbMi &location : locations) {
|
||||
const QString locid = QString("%1.%2").arg(rid).arg(location["locid"].data());
|
||||
SubBreakpoint loc = bp->findOrCreateSubBreakpoint(locid);
|
||||
QTC_ASSERT(loc, continue);
|
||||
@@ -614,7 +614,7 @@ void LldbEngine::reloadModules()
|
||||
const GdbMi &modules = response.data["modules"];
|
||||
ModulesHandler *handler = modulesHandler();
|
||||
handler->beginUpdateAll();
|
||||
for (const GdbMi &item : modules.children()) {
|
||||
for (const GdbMi &item : modules) {
|
||||
Module module;
|
||||
module.modulePath = item["file"].data();
|
||||
module.moduleName = item["name"].data();
|
||||
@@ -636,7 +636,7 @@ void LldbEngine::requestModuleSymbols(const QString &moduleName)
|
||||
const GdbMi &symbols = response.data["symbols"];
|
||||
QString moduleName = response.data["module"].data();
|
||||
Symbols syms;
|
||||
for (const GdbMi &item : symbols.children()) {
|
||||
for (const GdbMi &item : symbols) {
|
||||
Symbol symbol;
|
||||
symbol.address = item["address"].data();
|
||||
symbol.name = item["name"].data();
|
||||
@@ -914,8 +914,7 @@ void LldbEngine::reloadRegisters()
|
||||
DebuggerCommand cmd("fetchRegisters");
|
||||
cmd.callback = [this](const DebuggerResponse &response) {
|
||||
RegisterHandler *handler = registerHandler();
|
||||
GdbMi regs = response.data["registers"];
|
||||
for (const GdbMi &item : regs.children()) {
|
||||
for (const GdbMi &item : response.data["registers"]) {
|
||||
Register reg;
|
||||
reg.name = item["name"].data();
|
||||
reg.value.fromString(item["value"].data(), HexadecimalFormat);
|
||||
@@ -953,7 +952,7 @@ void LldbEngine::fetchDisassembler(DisassemblerAgent *agent)
|
||||
DisassemblerLines result;
|
||||
QPointer<DisassemblerAgent> agent = m_disassemblerAgents.key(id);
|
||||
if (!agent.isNull()) {
|
||||
for (const GdbMi &line : response.data["lines"].children()) {
|
||||
for (const GdbMi &line : response.data["lines"]) {
|
||||
DisassemblerLine dl;
|
||||
dl.address = line["address"].toAddress();
|
||||
//dl.data = line["data"].data();
|
||||
|
||||
@@ -303,7 +303,7 @@ void PdbEngine::refreshModules(const GdbMi &modules)
|
||||
{
|
||||
ModulesHandler *handler = modulesHandler();
|
||||
handler->beginUpdateAll();
|
||||
for (const GdbMi &item : modules.children()) {
|
||||
for (const GdbMi &item : modules) {
|
||||
Module module;
|
||||
module.moduleName = item["name"].data();
|
||||
QString path = item["value"].data();
|
||||
@@ -358,7 +358,7 @@ void PdbEngine::refreshSymbols(const GdbMi &symbols)
|
||||
{
|
||||
QString moduleName = symbols["module"].data();
|
||||
Symbols syms;
|
||||
for (const GdbMi &item : symbols["symbols"].children()) {
|
||||
for (const GdbMi &item : symbols["symbols"]) {
|
||||
Symbol symbol;
|
||||
symbol.name = item["name"].data();
|
||||
syms.append(symbol);
|
||||
@@ -524,7 +524,7 @@ void PdbEngine::refreshStack(const GdbMi &stack)
|
||||
{
|
||||
StackHandler *handler = stackHandler();
|
||||
StackFrames frames;
|
||||
for (const GdbMi &item : stack["frames"].children()) {
|
||||
for (const GdbMi &item : stack["frames"]) {
|
||||
StackFrame frame;
|
||||
frame.level = item["level"].data();
|
||||
frame.file = item["file"].data();
|
||||
|
||||
@@ -81,8 +81,8 @@ QString StackFrame::toString() const
|
||||
QList<StackFrame> StackFrame::parseFrames(const GdbMi &data, const DebuggerRunParameters &rp)
|
||||
{
|
||||
StackFrames frames;
|
||||
frames.reserve(data.children().size());
|
||||
for (const GdbMi &item : data.children())
|
||||
frames.reserve(data.childCount());
|
||||
for (const GdbMi &item : data)
|
||||
frames.append(parseFrame(item, rp));
|
||||
return frames;
|
||||
}
|
||||
|
||||
@@ -373,8 +373,8 @@ void ThreadsHandler::setThreads(const GdbMi &data)
|
||||
// file="/.../app.cpp",fullname="/../app.cpp",line="1175"},
|
||||
// state="stopped",core="0"}],current-thread-id="1"
|
||||
|
||||
const QVector<GdbMi> &items = data["threads"].children();
|
||||
for (const GdbMi &item : items) {
|
||||
const GdbMi &threads = data["threads"];
|
||||
for (const GdbMi &item : threads) {
|
||||
const GdbMi &frame = item["frame"];
|
||||
ThreadData thread;
|
||||
thread.id = item["id"].data();
|
||||
@@ -395,7 +395,7 @@ void ThreadsHandler::setThreads(const GdbMi &data)
|
||||
const QString ¤tId = data["current-thread-id"].data();
|
||||
m_currentThread = threadForId(currentId);
|
||||
|
||||
if (!m_currentThread && !items.isEmpty())
|
||||
if (!m_currentThread && threads.childCount() > 0)
|
||||
m_currentThread = rootItem()->childAt(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -407,8 +407,9 @@ void WatchItem::parseHelper(const GdbMi &input, bool maySort)
|
||||
qulonglong addressBase = input["addrbase"].data().toULongLong(&ok, 0);
|
||||
qulonglong addressStep = input["addrstep"].data().toULongLong(&ok, 0);
|
||||
|
||||
for (int i = 0, n = int(children.children().size()); i != n; ++i) {
|
||||
const GdbMi &subinput = children.children().at(i);
|
||||
int i = -1;
|
||||
for (const GdbMi &subinput : children) {
|
||||
++i;
|
||||
auto child = new WatchItem;
|
||||
if (childType.isValid())
|
||||
child->type = childType.data();
|
||||
|
||||
@@ -2007,7 +2007,7 @@ void WatchHandler::insertItems(const GdbMi &data)
|
||||
QSet<WatchItem *> itemsToSort;
|
||||
|
||||
const bool sortStructMembers = boolSetting(SortStructMembers);
|
||||
for (const GdbMi &child : data.children()) {
|
||||
for (const GdbMi &child : data) {
|
||||
auto item = new WatchItem;
|
||||
item->parse(child, sortStructMembers);
|
||||
const TypeInfo ti = m_model->m_reportedTypeInfo.value(item->type);
|
||||
@@ -2599,7 +2599,7 @@ void WatchHandler::appendWatchersAndTooltipRequests(DebuggerCommand *cmd)
|
||||
|
||||
void WatchHandler::addDumpers(const GdbMi &dumpers)
|
||||
{
|
||||
for (const GdbMi &dumper : dumpers.children()) {
|
||||
for (const GdbMi &dumper : dumpers) {
|
||||
DisplayFormats formats;
|
||||
formats.append(RawFormat);
|
||||
QString reportedFormats = dumper["formats"].data();
|
||||
@@ -2666,7 +2666,7 @@ QSet<QString> WatchHandler::expandedINames() const
|
||||
void WatchHandler::recordTypeInfo(const GdbMi &typeInfo)
|
||||
{
|
||||
if (typeInfo.type() == GdbMi::List) {
|
||||
for (const GdbMi &s : typeInfo.children()) {
|
||||
for (const GdbMi &s : typeInfo) {
|
||||
QString typeName = fromHex(s["name"].data());
|
||||
TypeInfo ti(s["size"].data().toUInt());
|
||||
m_model->m_reportedTypeInfo.insert(typeName, ti);
|
||||
|
||||
Reference in New Issue
Block a user