diff options
author | David Schulz <[email protected]> | 2024-02-12 14:03:00 +0100 |
---|---|---|
committer | David Schulz <[email protected]> | 2024-02-27 11:32:53 +0000 |
commit | a57a925b76785c1269ca5bcbacd553f01c0f238d (patch) | |
tree | ed9ce067b36ff045b3ec3a10a0478a12c25152e0 /src/libs/qtcreatorcdbext | |
parent | 5152a35048b7800ff8b10e1f254357a046a9543e (diff) |
Debugger: defer type look up
Change-Id: I425c2bfc3c88ebf46af161c5434c0c05a3bb9c97
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/libs/qtcreatorcdbext')
-rw-r--r-- | src/libs/qtcreatorcdbext/pytype.cpp | 46 | ||||
-rw-r--r-- | src/libs/qtcreatorcdbext/pytype.h | 1 |
2 files changed, 19 insertions, 28 deletions
diff --git a/src/libs/qtcreatorcdbext/pytype.cpp b/src/libs/qtcreatorcdbext/pytype.cpp index 0621793b7e0..9345c1d91af 100644 --- a/src/libs/qtcreatorcdbext/pytype.cpp +++ b/src/libs/qtcreatorcdbext/pytype.cpp @@ -121,6 +121,9 @@ static std::string stripPointerType(const std::string &typeNameIn) std::string typeName = typeNameIn; if (typeName.back() == '*') { typeName.pop_back(); + trimBack(typeName); + if (endsWith(typeName, "const")) + typeName = typeName.erase(typeName.size() - 5, 5); } else { const auto arrayPosition = typeName.find_first_of('['); if (arrayPosition != std::string::npos @@ -296,35 +299,19 @@ int PyType::code() const return std::nullopt; }; - if (!resolve()) - return parseTypeName(name()).value_or(TypeCodeUnresolvable); - - if (m_tag < 0) { - if (const std::optional<TypeCodes> typeCode = parseTypeName(name())) - return *typeCode; - - IDebugSymbolGroup2 *sg = 0; - if (FAILED(ExtensionCommandContext::instance()->symbols()->CreateSymbolGroup2(&sg))) - return TypeCodeStruct; - - const std::string helperValueName = SymbolGroupValue::pointedToSymbolName(0, name(true)); - ULONG index = DEBUG_ANY_ID; - if (SUCCEEDED(sg->AddSymbol(helperValueName.c_str(), &index))) - m_tag = PyValue(index, sg).tag(); - sg->Release(); - } - switch (m_tag) { - case SymTagUDT: return TypeCodeStruct; - case SymTagEnum: return TypeCodeEnum; - case SymTagTypedef: return TypeCodeTypedef; - case SymTagFunctionType: return TypeCodeFunction; - case SymTagPointerType: return TypeCodePointer; - case SymTagArrayType: return TypeCodeArray; - case SymTagBaseType: return isIntegralType(name()) ? TypeCodeIntegral : TypeCodeFloat; - default: break; + if (m_tag >= 0) { + switch (m_tag) { + case SymTagUDT: return TypeCodeStruct; + case SymTagEnum: return TypeCodeEnum; + case SymTagTypedef: return TypeCodeTypedef; + case SymTagFunctionType: return TypeCodeFunction; + case SymTagPointerType: return TypeCodePointer; + case SymTagArrayType: return TypeCodeArray; + case SymTagBaseType: return isIntegralType(name()) ? TypeCodeIntegral : TypeCodeFloat; + default: break; + } } - - return TypeCodeStruct; + return parseTypeName(name()).value_or(TypeCodeStruct); } PyType PyType::target() const @@ -533,6 +520,7 @@ PY_FUNC_RET_OBJECT_LIST(fields, PY_OBJ_NAME) PY_FUNC_RET_STD_STRING(module, PY_OBJ_NAME) PY_FUNC(moduleId, PY_OBJ_NAME, "K") PY_FUNC(arrayElements, PY_OBJ_NAME, "k") +PY_FUNC_RET_BOOL(resolved, PY_OBJ_NAME) PY_FUNC_DECL(templateArguments, PY_OBJ_NAME) { PY_IMPL_GUARD; @@ -568,6 +556,8 @@ static PyMethodDef typeMethods[] = { "Returns the number of elements in an array or 0 for non array types"}, {"templateArguments", PyCFunction(templateArguments), METH_NOARGS, "Returns all template arguments."}, + {"resolved", PyCFunction(resolved), METH_NOARGS, + "Returns whether the type is resolved"}, {NULL} /* Sentinel */ }; diff --git a/src/libs/qtcreatorcdbext/pytype.h b/src/libs/qtcreatorcdbext/pytype.h index 8b05fffe0ad..b71eae1ab02 100644 --- a/src/libs/qtcreatorcdbext/pytype.h +++ b/src/libs/qtcreatorcdbext/pytype.h @@ -29,6 +29,7 @@ public: std::string module() const; ULONG64 moduleId() const; int arrayElements() const; + bool resolved() const { return m_resolved.value_or(false); } struct TemplateArgument { |