我目前正在将我使用 DIA SDK 检索到的 PDB 文件中的大量信息转储到 XML 文件中,以便我可以使用这些信息来显示有关项目结构等的内容。
为了命名 XML 节点,我有一个简单的函数,它将枚举的值转换为字符串,然后用于节点:
string symTagTypeToString(DWORD type) {
string symTagTypename = "";
switch(type) {
case SymTagNull:
symTagTypename = "null";
break;
case SymTagExe:
symTagTypename = "exe";
break;
case SymTagCompiland:
symTagTypename = "compiland";
break;
case SymTagCompilandDetails:
symTagTypename = "compilandDetails";
break;
case SymTagCompilandEnv:
symTagTypename = "compilandEnvironmentVar";
break;
case SymTagFunction:
symTagTypename = "function";
break;
case SymTagBlock:
symTagTypename = "block";
break;
case SymTagData:
symTagTypename = "data";
break;
case SymTagAnnotation:
symTagTypename = "annotation";
break;
case SymTagLabel:
symTagTypename = "label";
break;
case SymTagPublicSymbol:
symTagTypename = "publicSymbol";
break;
case SymTagUDT:
symTagTypename = "userDefinedType";
break;
case SymTagEnum:
symTagTypename = "enumerator";
break;
case SymTagFunctionType:
symTagTypename = "functionType";
break;
case SymTagPointerType:
symTagTypename = "pointer";
break;
case SymTagArrayType:
symTagTypename = "array";
break;
case SymTagBaseType:
symTagTypename = "baseType";
break;
case SymTagTypedef:
symTagTypename = "typedef";
break;
case SymTagBaseClass:
symTagTypename = "baseClass";
break;
case SymTagFriend:
symTagTypename = "friend";
break;
case SymTagFunctionArgType:
symTagTypename = "functionArgumentType";
break;
case SymTagFuncDebugStart:
symTagTypename = "funcDebugStart";
break;
case SymTagFuncDebugEnd:
symTagTypename = "funcDebugEnd";
break;
case SymTagUsingNamespace:
symTagTypename = "usingNamespace";
break;
case SymTagVTableShape:
symTagTypename = "vTableShape";
break;
case SymTagVTable:
symTagTypename = "vTable";
break;
case SymTagCustom:
symTagTypename = "custom";
break;
case SymTagThunk:
symTagTypename = "thunk";
break;
case SymTagCustomType:
symTagTypename = "customType";
break;
case SymTagManagedType:
symTagTypename = "managedType";
break;
case SymTagDimension:
symTagTypename = "dimension";
break;
default:
ostringstream s;
s << "other" << type;
symTagTypename = s.str();
break;
}
return symTagTypename;
}
此函数包含此处列出的所有值:http: //msdn.microsoft.com/de-de/library/bkedss5f.aspx
现在,为了转储 DIA 信息,我基本上只是递归我使用的所有符号的子代pGlobal->findChildren(SymTagUDT, NULL, nsCaseSensitive, &pIDiaEnumSymbols)
。奇怪的是,生成的 XML 包含很多看起来像这样的东西:
<function name="consumer::main">
<funcDebugStart name="unknown">
</funcDebugStart>
<funcDebugEnd name="unknown">
</funcDebugEnd>
<data name="">
</data>
<data name="">
</data>
<data name="">
</data>
<data name="this">
</data>
<data name="c">
</data>
<other31 name="unknown">
</other31>
<other31 name="unknown">
</other31>
<other31 name="unknown">
</other31>
<other31 name="unknown">
</other31>
<other31 name="unknown">
</other31>
<other31 name="unknown">
</other31>
<other31 name="unknown">
</other31>
<other31 name="unknown">
</other31>
</function>
现在,不要管空的名称信息和其他东西,到目前为止,这一切都还没有完成。我真的很想知道什么样的符号的symTag 为 31。枚举器似乎包含 31 个元素,因此从 0 到 30 的值应该是有效的。有人知道这 31 可能是什么吗?有问题的函数如下所示:
void main()
{
char c;
cout << endl << endl;
while (true) {
in->read(c);
cout << c << flush;
if (in->num_available() == 1)
cout << "<1>" << flush;
if (in->num_available() == 9)
cout << "<9>" << flush;
}
}
它是 SystemC fifo 示例项目的一部分。没什么太花哨的,真的。