📄 gdbmacros.cpp
字号:
if (isInternal) {
//qDumpInnerValue(d, d.innertype, p);
P(d, "addr", p);
qDumpInnerValueHelper(d, d.innertype, p);
} else {
//qDumpInnerValue(d, d.innertype, deref(p));
P(d, "addr", deref(p));
qDumpInnerValueHelper(d, d.innertype, deref(p));
}
}
d.endHash();
}
if (n < nn)
d.putEllipsis();
d << "]";
}
d.disarm();
}
static void qDumpQLocale(QDumper &d)
{
const QLocale &locale = *reinterpret_cast<const QLocale *>(d.data);
P(d, "value", locale.name());
P(d, "valueencoded", "1");
P(d, "type", NS"QLocale");
P(d, "numchild", "8");
if (d.dumpChildren) {
d << ",children=[";
d.beginHash();
P(d, "name", "country");
P(d, "exp", "(("NSX"QLocale"NSY"*)" << d.data << ")->country()");
d.endHash();
d.beginHash();
P(d, "name", "language");
P(d, "exp", "(("NSX"QLocale"NSY"*)" << d.data << ")->language()");
d.endHash();
d.beginHash();
P(d, "name", "measurementSystem");
P(d, "exp", "(("NSX"QLocale"NSY"*)" << d.data << ")->measurementSystem()");
d.endHash();
d.beginHash();
P(d, "name", "numberOptions");
P(d, "exp", "(("NSX"QLocale"NSY"*)" << d.data << ")->numberOptions()");
d.endHash();
S(d, "timeFormat_(short)", locale.timeFormat(QLocale::ShortFormat));
S(d, "timeFormat_(long)", locale.timeFormat(QLocale::LongFormat));
QC(d, "decimalPoint", locale.decimalPoint());
QC(d, "exponential", locale.exponential());
QC(d, "percent", locale.percent());
QC(d, "zeroDigit", locale.zeroDigit());
QC(d, "groupSeparator", locale.groupSeparator());
QC(d, "negativeSign", locale.negativeSign());
d << "]";
}
d.disarm();
}
static void qDumpQMap(QDumper &d)
{
QMapData *h = *reinterpret_cast<QMapData *const*>(d.data);
const char *keyType = d.templateParameters[0];
const char *valueType = d.templateParameters[1];
int n = h->size;
if (n < 0)
qCheck(false);
if (n > 0) {
qCheckAccess(h->backward);
qCheckAccess(h->forward[0]);
qCheckPointer(h->backward->backward);
qCheckPointer(h->forward[0]->backward);
}
P(d, "value", "<" << n << " items>");
P(d, "numchild", n);
if (d.dumpChildren) {
if (n > 1000)
n = 1000;
//unsigned keySize = d.extraInt[0];
//unsigned valueSize = d.extraInt[1];
unsigned mapnodesize = d.extraInt[2];
unsigned valueOff = d.extraInt[3];
bool simpleKey = isShortKey(keyType);
bool simpleValue = isShortKey(valueType);
// both negative:
int keyOffset = 2 * sizeof(void*) - int(mapnodesize);
int valueOffset = 2 * sizeof(void*) - int(mapnodesize) + valueOff;
P(d, "extra", "simplekey: " << simpleKey << " simpleValue: " << simpleValue
<< " keyOffset: " << keyOffset << " valueOffset: " << valueOffset
<< " mapnodesize: " << mapnodesize);
d << ",children=[";
QMapData::Node *node = reinterpret_cast<QMapData::Node *>(h->forward[0]);
QMapData::Node *end = reinterpret_cast<QMapData::Node *>(h);
int i = 0;
while (node != end) {
d.beginHash();
if (simpleKey) {
P(d, "type", valueType);
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "name");
P(d, "nameisindex", "1");
if (simpleValue)
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
P(d, "type", valueType);
P(d, "addr", addOffset(node, valueOffset));
} else {
P(d, "name", "[" << i << "]");
P(d, "type", NS"QMapNode<" << keyType << "," << valueType << " >");
// actually, any type (even 'char') will do...
P(d, "exp", "*('"NS"QMapNode<" << keyType << "," << valueType << " >'*)" << node);
//P(d, "exp", "*('"NS"QMapData'*)" << (void*)node);
//P(d, "exp", "*(char*)" << (void*)node);
// P(d, "addr", node); does not work as gdb fails to parse
// e.g. &((*('"NS"QMapNode<QString,Foo>'*)0x616658))
}
d.endHash();
++i;
node = node->forward[0];
}
d << "]";
}
d.disarm();
}
static void qDumpQModelIndex(QDumper &d)
{
const QModelIndex *mi = reinterpret_cast<const QModelIndex *>(d.data);
P(d, "type", NS"QModelIndex");
if (mi->isValid()) {
P(d, "value", "(" << mi->row() << ", " << mi->column() << ")");
P(d, "numchild", 5);
if (d.dumpChildren) {
d << ",children=[";
I(d, "row", mi->row());
I(d, "column", mi->column());
d.beginHash();
P(d, "name", "parent");
const QModelIndex parent = mi->parent();
if (parent.isValid())
P(d, "value", "(" << mi->row() << ", " << mi->column() << ")");
else
P(d, "value", "<invalid>");
P(d, "exp", "(("NSX"QModelIndex"NSY"*)" << d.data << ")->parent()");
P(d, "type", NS"QModelIndex");
P(d, "numchild", "1");
d.endHash();
S(d, "internalId", QString::number(mi->internalId(), 10));
d.beginHash();
P(d, "name", "model");
P(d, "value", static_cast<const void *>(mi->model()));
P(d, "type", NS"QAbstractItemModel*");
P(d, "numchild", "1");
d.endHash();
d << "]";
}
} else {
P(d, "value", "<invalid>");
P(d, "numchild", 0);
}
d.disarm();
}
static void qDumpQMapNode(QDumper &d)
{
const QMapData *h = reinterpret_cast<const QMapData *>(d.data);
const char *keyType = d.templateParameters[0];
const char *valueType = d.templateParameters[1];
qCheckAccess(h->backward);
qCheckAccess(h->forward[0]);
P(d, "value", "");
P(d, "numchild", 2);
if (d.dumpChildren) {
//unsigned keySize = d.extraInt[0];
//unsigned valueSize = d.extraInt[1];
unsigned mapnodesize = d.extraInt[2];
unsigned valueOff = d.extraInt[3];
unsigned keyOffset = 2 * sizeof(void*) - mapnodesize;
unsigned valueOffset = 2 * sizeof(void*) - mapnodesize + valueOff;
d << ",children=[";
d.beginHash();
P(d, "name", "key");
qDumpInnerValue(d, keyType, addOffset(h, keyOffset));
d.endHash();
d.beginHash();
P(d, "name", "value");
qDumpInnerValue(d, valueType, addOffset(h, valueOffset));
d.endHash();
d << "]";
}
d.disarm();
}
static void qDumpQObject(QDumper &d)
{
const QObject *ob = reinterpret_cast<const QObject *>(d.data);
const QMetaObject *mo = ob->metaObject();
unsigned childrenOffset = d.extraInt[0];
P(d, "value", ob->objectName());
P(d, "valueencoded", "1");
P(d, "type", NS"QObject");
P(d, "displayedtype", mo->className());
P(d, "numchild", 4);
if (d.dumpChildren) {
const QObjectList &children = ob->children();
int slotCount = 0;
int signalCount = 0;
for (int i = mo->methodCount(); --i >= 0; ) {
QMetaMethod::MethodType mt = mo->method(i).methodType();
signalCount += (mt == QMetaMethod::Signal);
slotCount += (mt == QMetaMethod::Slot);
}
d << ",children=[";
d.beginHash();
P(d, "name", "properties");
// FIXME: Note that when simply using '(QObject*)'
// in the cast below, Gdb/MI _sometimes_ misparses
// expressions further down in the tree.
P(d, "exp", "*(class '"NS"QObject'*)" << d.data);
P(d, "type", NS"QObjectPropertyList");
P(d, "value", "<" << mo->propertyCount() << " items>");
P(d, "numchild", mo->propertyCount());
d.endHash();
#if 0
d.beginHash();
P(d, "name", "methods");
P(d, "exp", "*(class '"NS"QObject'*)" << d.data);
P(d, "value", "<" << mo->methodCount() << " items>");
P(d, "numchild", mo->methodCount());
d.endHash();
#endif
#if 0
d.beginHash();
P(d, "name", "senders");
P(d, "exp", "(*(class '"NS"QObjectPrivate'*)" << dfunc(ob) << ")->senders");
P(d, "type", NS"QList<"NS"QObjectPrivateSender>");
d.endHash();
#endif
#if PRIVATE_OBJECT_ALLOWED
d.beginHash();
P(d, "name", "signals");
P(d, "exp", "*(class '"NS"QObject'*)" << d.data);
P(d, "type", NS"QObjectSignalList");
P(d, "value", "<" << signalCount << " items>");
P(d, "numchild", signalCount);
d.endHash();
d.beginHash();
P(d, "name", "slots");
P(d, "exp", "*(class '"NS"QObject'*)" << d.data);
P(d, "type", NS"QObjectSlotList");
P(d, "value", "<" << slotCount << " items>");
P(d, "numchild", slotCount);
d.endHash();
#endif
d.beginHash();
P(d, "name", "children");
// works always, but causes additional traffic on the list
//P(d, "exp", "((class '"NS"QObject'*)" << d.data << ")->children()");
//
//P(d, "addr", addOffset(dfunc(ob), childrenOffset));
//P(d, "type", NS"QList<QObject *>");
//P(d, "value", "<" << children.size() << " items>");
qDumpInnerValue(d, NS"QList<"NS"QObject *>",
addOffset(dfunc(ob), childrenOffset));
P(d, "numchild", children.size());
d.endHash();
#if 0
// Unneeded (and not working): Connections are listes as childen
// of the signal or slot they are connected to.
// d.beginHash();
// P(d, "name", "connections");
// P(d, "exp", "*(*(class "NS"QObjectPrivate*)" << dfunc(ob) << ")->connectionLists");
// P(d, "type", NS"QVector<"NS"QList<"NS"QObjectPrivate::Connection> >");
// d.endHash();
#endif
#if 0
d.beginHash();
P(d, "name", "objectprivate");
P(d, "type", NS"QObjectPrivate");
P(d, "addr", dfunc(ob));
P(d, "value", "");
P(d, "numchild", "1");
d.endHash();
#endif
d.beginHash();
P(d, "name", "parent");
qDumpInnerValueHelper(d, NS"QObject *", ob->parent());
d.endHash();
#if 1
d.beginHash();
P(d, "name", "className");
P(d, "value",ob->metaObject()->className());
P(d, "type", "");
P(d, "numchild", "0");
d.endHash();
#endif
d << "]";
}
d.disarm();
}
static void qDumpQObjectPropertyList(QDumper &d)
{
const QObject *ob = (const QObject *)d.data;
const QMetaObject *mo = ob->metaObject();
P(d, "addr", "<synthetic>");
P(d, "type", NS"QObjectPropertyList");
P(d, "numchild", mo->propertyCount());
if (d.dumpChildren) {
d << ",children=[";
for (int i = mo->propertyCount(); --i >= 0; ) {
const QMetaProperty & prop = mo->property(i);
d.beginHash();
P(d, "name", prop.name());
P(d, "exp", "((" << mo->className() << "*)" << ob
<< ")->" << prop.name() << "()");
if (isEqual(prop.typeName(), "QString")) {
P(d, "value", prop.read(ob).toString());
P(d, "valueencoded", "1");
P(d, "type", NS"QString");
P(d, "numchild", "0");
} else if (isEqual(prop.typeName(), "bool")) {
P(d, "value", (prop.read(ob).toBool() ? "true" : "false"));
P(d, "numchild", "0");
} else if (isEqual(prop.typeName(), "int")) {
P(d, "value", prop.read(ob).toInt());
P(d, "numchild", "0");
}
P(d, "type", prop.typeName());
P(d, "numchild", "1");
d.endHash();
}
d << "]";
}
d.disarm();
}
static void qDumpQObjectMethodList(QDumper &d)
{
const QObject *ob = (const QObject *)d.data;
const QMetaObject *mo = ob->metaObject();
P(d, "addr", "<synthetic>");
P(d, "type", NS"QObjectMethodList");
P(d, "numchild", mo->methodCount());
P(d, "childtype", "QMetaMethod::Method");
P(d, "childnumchild", "0");
if (d.dumpChildren) {
d << ",children=[";
for (int i = 0; i != mo->methodCount(); ++i) {
const QMetaMethod & method = mo->method(i);
int mt = method.methodType();
d.beginHash();
P(d, "name", "[" << i << "] " << mo->indexOfMethod(method.signature())
<< " " << method.signature());
P(d, "value", (mt == QMetaMethod::Signal ? "<Signal>" : "<Slot>") << " (" << mt << ")");
d.endHash();
}
d << "]";
}
d.disarm();
}
#if PRIVATE_OBJECT_ALLOWED
const char * qConnectionTypes[] ={
"auto",
"direct",
"queued",
"autocompat",
"blockingqueued"
};
#if QT_VERSION >= 0x040400
static const QObjectPrivate::ConnectionList &qConnectionList(const QObject *ob, int signalNumber)
{
static const QObjectPrivate::ConnectionList emptyList;
const QObjectPrivate *p = reinterpret_cast<const QObjectPrivate *>(dfunc(ob));
if (!p->connectionLists)
return emptyList;
typedef QVector<QObjectPrivate::ConnectionList> ConnLists;
const ConnLists *lists = reinterpret_cast<const ConnLists *>(p->connectionLists);
// there's an optimization making the lists only large enough to hold the
// last non-empty item
if (signalNumber >= lists->size())
return emptyList;
return lists->at(signalNumber);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -