Debugger[New CDB]: Refine type detection, dump nested containers.

Introduce test commands.
This commit is contained in:
Friedemann Kleint
2011-01-06 15:28:57 +01:00
parent 7a068d655e
commit ef48b33127
5 changed files with 81 additions and 20 deletions

View File

@@ -16,5 +16,6 @@ idle
help help
memory memory
shutdownex shutdownex
test
stack stack
KnownStructOutput KnownStructOutput

View File

@@ -96,7 +96,8 @@ enum Command {
CmdHelp, CmdHelp,
CmdMemory, CmdMemory,
CmdStack, CmdStack,
CmdShutdownex CmdShutdownex,
CmdTest
}; };
static const CommandDescription commandDescriptions[] = { static const CommandDescription commandDescriptions[] = {
@@ -136,7 +137,8 @@ static const CommandDescription commandDescriptions[] = {
{"help","Prints help.",""}, {"help","Prints help.",""},
{"memory","Prints memory contents in Base64 encoding.","[-t token] <address> <length>"}, {"memory","Prints memory contents in Base64 encoding.","[-t token] <address> <length>"},
{"stack","Prints stack in GDBMI format.","[-t token] [max-frames]"}, {"stack","Prints stack in GDBMI format.","[-t token] [max-frames]"},
{"shutdownex","Unhooks output callbacks.\nNeeds to be called explicitly only in case of remote debugging.",""} {"shutdownex","Unhooks output callbacks.\nNeeds to be called explicitly only in case of remote debugging.",""},
{"test","Testing command","-T type"}
}; };
typedef std::vector<std::string> StringVector; typedef std::vector<std::string> StringVector;
@@ -725,6 +727,45 @@ extern "C" HRESULT CALLBACK shutdownex(CIDebugClient *, PCSTR)
return S_OK; return S_OK;
} }
extern "C" HRESULT CALLBACK test(CIDebugClient *client, PCSTR argsIn)
{
enum Mode { Invalid, TestType };
ExtensionCommandContext exc(client);
std::string testType;
Mode mode = Invalid;
int token = 0;
StringList tokens = commandTokens<StringList>(argsIn, &token);
// Parse away options
while (!tokens.empty() && tokens.front().size() == 2 && tokens.front().at(0) == '-') {
const char option = tokens.front().at(1);
tokens.pop_front();
switch (option) {
case 'T':
mode = TestType;
if (!tokens.empty()) {
testType = tokens.front();
tokens.pop_front();
}
break;
} // case option
} // for options
// Frame and iname
if (mode == Invalid || testType.empty()) {
ExtensionContext::instance().report('N', token, 0, "test", singleLineUsage(commandDescriptions[CmdTest]).c_str());
} else {
const KnownType kt = knownType(testType, 0);
std::ostringstream str;
str << testType << ' ' << kt << " [";
formatKnownTypeFlags(str, kt);
str << ']';
ExtensionContext::instance().reportLong('R', token, "test", str.str());
}
return S_OK;
}
// Hook for dumping Known Structs. Not currently used. // Hook for dumping Known Structs. Not currently used.
// Shows up in 'dv' as well as IDebugSymbolGroup::GetValueText. // Shows up in 'dv' as well as IDebugSymbolGroup::GetValueText.

View File

@@ -251,6 +251,8 @@ std::string SymbolGroup::dump(const std::string &iname,
// After expansion, run the complex dumpers // After expansion, run the complex dumpers
if (p.dumpFlags & DumpParameters::DumpComplexDumpers) if (p.dumpFlags & DumpParameters::DumpComplexDumpers)
node->runComplexDumpers(ctx); node->runComplexDumpers(ctx);
if (symbolGroupDebug)
DebugPrint() << "SymbolGroup::dump(" << iname << ") ran complex dumpers 0x" << std::hex << node->flags();
} }
std::ostringstream str; std::ostringstream str;
@@ -262,7 +264,7 @@ std::string SymbolGroup::dump(const std::string &iname,
str << ']'; str << ']';
QTC_TRACE_OUT QTC_TRACE_OUT
if (symbolGroupDebug) if (symbolGroupDebug)
DebugPrint() << "<SymbolGroup::dump(" << iname << ")"; DebugPrint() << "<SymbolGroup::dump(" << iname << ')';
return str.str(); return str.str();
} }

View File

@@ -759,7 +759,7 @@ void SymbolGroupNode::runComplexDumpers(const SymbolGroupValueContext &ctx)
{ {
if (symbolGroupDebug) if (symbolGroupDebug)
DebugPrint() << "SymbolGroupNode::runComplexDumpers " << name() << '/' DebugPrint() << "SymbolGroupNode::runComplexDumpers " << name() << '/'
<< absoluteFullIName() << ' ' << m_index << DebugNodeFlags(flags()); << absoluteFullIName() << ' ' << m_index << ' ' << DebugNodeFlags(flags());
if (m_dumperContainerSize <= 0 || (testFlags(ComplexDumperOk) || !testFlags(SimpleDumperOk))) if (m_dumperContainerSize <= 0 || (testFlags(ComplexDumperOk) || !testFlags(SimpleDumperOk)))
return; return;
@@ -786,7 +786,7 @@ void SymbolGroupNode::runComplexDumpers(const SymbolGroupValueContext &ctx)
bool SymbolGroupNode::runSimpleDumpers(const SymbolGroupValueContext &ctx) bool SymbolGroupNode::runSimpleDumpers(const SymbolGroupValueContext &ctx)
{ {
if (symbolGroupDebug) if (symbolGroupDebug)
DebugPrint() << "SymbolGroupNode::runSimpleDumpers " << name() << '/' DebugPrint() << ">SymbolGroupNode::runSimpleDumpers " << name() << '/'
<< absoluteFullIName() << ' ' << m_index << DebugNodeFlags(flags()); << absoluteFullIName() << ' ' << m_index << DebugNodeFlags(flags());
if (testFlags(Uninitialized)) if (testFlags(Uninitialized))
return false; return false;
@@ -797,7 +797,8 @@ bool SymbolGroupNode::runSimpleDumpers(const SymbolGroupValueContext &ctx)
addFlags(dumpSimpleType(this , ctx, &m_dumperValue, addFlags(dumpSimpleType(this , ctx, &m_dumperValue,
&m_dumperType, &m_dumperContainerSize)); &m_dumperType, &m_dumperContainerSize));
if (symbolGroupDebug) if (symbolGroupDebug)
DebugPrint() << "-> '" << wStringToString(m_dumperValue) << "' Type=" DebugPrint() << "<SymbolGroupNode::runSimpleDumpers " << name() << " '"
<< wStringToString(m_dumperValue) << "' Type="
<< m_dumperType << ' ' << DebugNodeFlags(flags()); << m_dumperType << ' ' << DebugNodeFlags(flags());
return testFlags(SimpleDumperOk); return testFlags(SimpleDumperOk);
} }
@@ -1194,9 +1195,9 @@ SymbolGroupNodeVisitor::VisitResult
const std::string &fullIname, const std::string &fullIname,
unsigned /* child */, unsigned depth) unsigned /* child */, unsigned depth)
{ {
// Show container children only, no additional symbol below root. // Show container children only, no additional symbol below root. Also, skip expanded by dumper
const unsigned flags = node->flags(); const unsigned flags = node->flags();
if (flags & (SymbolGroupNode::Obscured|SymbolGroupNode::AdditionalSymbol)) if (flags & (SymbolGroupNode::Obscured|SymbolGroupNode::AdditionalSymbol|SymbolGroupNode::ExpandedByDumper))
return VisitSkipChildren; return VisitSkipChildren;
// Recurse to children only if expanded by explicit watchmodel request // Recurse to children only if expanded by explicit watchmodel request
// and initialized. // and initialized.

View File

@@ -659,37 +659,53 @@ static KnownType knownPODTypeHelper(const std::string &type, std::string::size_t
{ {
if (type.empty() || !endPos) if (type.empty() || !endPos)
return KT_Unknown; return KT_Unknown;
// Strip pointer types.
const bool isPointer = type.at(endPos - 1) == '*'; const bool isPointer = type.at(endPos - 1) == '*';
if (isPointer) {
endPos--;
if (endPos > 0 && type.at(endPos - 1) == ' ')
endPos--;
}
switch (type.at(0)) { switch (type.at(0)) {
case 'c': case 'c':
if (!type.compare(0, endPos, "char")) if (endPos == 4 && !type.compare(0, endPos, "char"))
return isPointer ? KT_POD_PointerType : KT_Char; return isPointer ? KT_POD_PointerType : KT_Char;
break; break;
case 'd': case 'd':
if (!type.compare(0, endPos, "double")) if (endPos == 6 && !type.compare(0, endPos, "double"))
return isPointer ? KT_POD_PointerType : KT_FloatType; return isPointer ? KT_POD_PointerType : KT_FloatType;
break; break;
case 'f': case 'f':
if (!type.compare(0, endPos, "float")) if (endPos == 5 && !type.compare(0, endPos, "float"))
return isPointer ? KT_POD_PointerType : KT_FloatType; return isPointer ? KT_POD_PointerType : KT_FloatType;
break; break;
case 'l': case 'l':
if (!type.compare(0, 4, "long")) if (endPos >= 4 && !type.compare(0, 4, "long"))
if (endPos == 4 || type.at(4) == ' ')
return isPointer ? KT_POD_PointerType : KT_IntType; return isPointer ? KT_POD_PointerType : KT_IntType;
break; break;
case 'i': case 'i':
if (!type.compare(0, 3, "int")) // 'int' 'int64'
if (endPos >= 3 && !type.compare(0, 3, "int"))
if (endPos == 3 || type.at(3) == ' ' || type.at(3) == '6')
return isPointer ? KT_POD_PointerType : KT_IntType; return isPointer ? KT_POD_PointerType : KT_IntType;
break; break;
case 's': case 's':
if (!type.compare(0, 5, "short")) if (endPos == 5 && !type.compare(0, 5, "short"))
return isPointer ? KT_POD_PointerType : KT_IntType;
if (endPos >= 6 && !type.compare(0, 6, "signed"))
if (endPos == 6 || type.at(6) == ' ')
return isPointer ? KT_POD_PointerType : KT_IntType; return isPointer ? KT_POD_PointerType : KT_IntType;
break; break;
case 'u': case 'u':
if (!type.compare(0, 8, "unsigned")) { if (endPos >= 8 && !type.compare(0, 8, "unsigned")) {
if (endPos == 8 || type.at(8) == ' ') {
if (isPointer) if (isPointer)
return KT_POD_PointerType; return KT_POD_PointerType;
return type == "unsigned char" ? KT_UnsignedChar : KT_UnsignedIntType; return type.compare(0, 13, "unsigned char") ?
KT_UnsignedIntType :
KT_UnsignedChar;
}
} }
break; break;
} }