Ejemplo n.º 1
0
static GuessChildrenResult guessChildren(const QByteArray &type)
{
    if (isIntOrFloatType(type))
        return HasNoChildren;
    if (isCharPointerType(type))
        return HasNoChildren;
    if (isPointerType(type))
        return HasChildren;
    if (type.endsWith("QString"))
        return HasNoChildren;
    return HasPossiblyChildren;
}
CdbDumperHelper::DumpResult CdbDumperHelper::dumpTypeI(const WatchData &wd, bool dumpChildren,
                                                      QList<WatchData> *result, QString *errorMessage)
{
    errorMessage->clear();
    // Check failure cache and supported types
    if (m_state == Disabled) {
        *errorMessage =m_msgDisabled;
        return DumpNotHandled;
    }
    if (wd.error) {
        *errorMessage =m_msgNotInScope;
        return DumpNotHandled;
    }
    if (m_failedTypes.contains(wd.type)) {
        *errorMessage = msgNotHandled(wd.type);
        return DumpNotHandled;
    }
    if (wd.addr.isEmpty()) {
        *errorMessage = QString::fromLatin1("Address is missing for '%1' (%2).").arg(wd.exp, wd.type);
        return DumpNotHandled;
    }

    // Do we have a thread
    if (m_dumperCallThread == InvalidDumperCallThread) {
        *errorMessage = QString::fromLatin1("No thread to call.");
        if (loadDebug)
            qDebug() << *errorMessage;
        return DumpNotHandled;
    }

    // Delay initialization as much as possible
    if (isIntOrFloatType(wd.type)) {
        *errorMessage = QString::fromLatin1("Unhandled POD: " ) + wd.type;
        return DumpNotHandled;
    }

    // Ensure types are parsed and known.
    if (!CdbDumperInitThread::ensureDumperInitialized(*this, errorMessage)) {
        *errorMessage = msgDumpFailed(wd, errorMessage);
        m_manager->showDebuggerOutput(LogError, *errorMessage);
        return DumpError;
    }

    // Known type?
    const QtDumperHelper::TypeData td = m_helper.typeData(wd.type);
    if (loadDebug)
        qDebug() << "dumpType" << wd.type << td;
    if (td.type == QtDumperHelper::UnknownType) {
        *errorMessage = msgNotHandled(wd.type);
        return DumpNotHandled;
    }

    // Now evaluate
    const QString message = QCoreApplication::translate("Debugger::Internal::CdbDumperHelper",
                                                        "Querying dumpers for '%1'/'%2' (%3)").
                                                        arg(QString::fromLatin1(wd.iname), wd.exp, wd.type);
    m_manager->showDebuggerOutput(LogMisc, message);

    const DumpExecuteResult der = executeDump(wd, td, dumpChildren, result, errorMessage);
    if (der == DumpExecuteOk)
        return DumpOk;
    if (der == CallSyntaxError) {
        m_failedTypes.push_back(wd.type);
        if (dumpDebug)
            qDebug() << "Caching failing type/expression evaluation failed for " << wd.type;
       }
    // log error
    *errorMessage = msgDumpFailed(wd, errorMessage);
    m_manager->showDebuggerOutput(LogWarning, *errorMessage);
    return DumpError;
}