void GdbDebugger::handleResultStackListFrame(const GdbResponse &response, QMap<QString,QVariant> &map) { //10000015^done,stack=[frame={level="0",addr="0x0040113f",func="main.main",file="F:/hg/debug_test/hello/main.go",fullname="F:/hg/debug_test/hello/main.go",line="36"},frame={level="1",addr="0x00401f8a",func="runtime.mainstart",file="386/asm.s",fullname="c:/go/src/pkg/runtime/386/asm.s",line="96"},frame={level="2",addr="0x0040bcfe",func="runtime.initdone",file="/go/src/pkg/runtime/proc.c",fullname="c:/go/src/pkg/runtime/proc.c",line="242"},frame={level="3",addr="0x00000000",func="??"}] m_framesModel->removeRows(0,m_framesModel->rowCount()); if (response.resultClass != GdbResultDone) { return; } GdbMiValue stack = response.data.findChild("stack"); if (stack.isList()) { for (int i = 0; i < stack.childCount(); i++) { GdbMiValue child = stack.childAt(i); if (child.isValid() && child.name() == "frame") { QString level = child.findChild("level").data(); QString addr = child.findChild("addr").data(); QString func = child.findChild("func").data(); QString file = child.findChild("file").data(); QString line = child.findChild("line").data(); m_framesModel->appendRow(QList<QStandardItem*>() << new QStandardItem(level) << new QStandardItem(addr) << new QStandardItem(func) << new QStandardItem(file) << new QStandardItem(line) ); } } } }
static void GdbMiValueToItem(QStandardItem *item, const GdbMiValue &value) { switch (value.type()) { case GdbMiValue::Invalid: item->appendRow(new QStandardItem("Invalid")); break; case GdbMiValue::Const: if (value.name().isEmpty()) { item->appendRow(new QStandardItem(QString(value.data()))); } else { item->appendRow(new QStandardItem(QString(value.name()+"="+value.data()))); } break; case GdbMiValue::List: { QStandardItem *in = new QStandardItem(QString(value.name())); item->appendRow(in); for (int i = 0; i < value.childCount(); i++) { QStandardItem *iv = new QStandardItem(QString("[%1]").arg(i)); in->appendRow(iv); GdbMiValueToItem(iv,value.childAt(i)); } break; } case GdbMiValue::Tuple: { QStandardItem *iv = item; if (!value.name().isEmpty()) { iv = new QStandardItem(QString(value.name())); item->appendRow(iv); } foreach (const GdbMiValue &v, value.children()) { GdbMiValueToItem(iv,v); } break; } } }