diff options
Diffstat (limited to 'lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp')
-rw-r--r-- | lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 283e867..ab8e9883 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -381,6 +381,34 @@ GetDemangledScope(const SymbolContext &sc) { return demangled_name.slice(info->ScopeRange.first, info->ScopeRange.second); } +static bool PrintDemangledArgumentList(Stream &s, const SymbolContext &sc) { + assert(sc.symbol); + + Mangled mangled = sc.GetPossiblyInlinedFunctionName(); + if (!mangled) + return false; + + auto demangled_name = mangled.GetDemangledName().GetStringRef(); + if (demangled_name.empty()) + return false; + + const std::optional<DemangledNameInfo> &info = mangled.GetDemangledInfo(); + if (!info) + return false; + + // Function without a basename is nonsense. + if (!info->hasBasename()) + return false; + + if (info->ArgumentsRange.second < info->ArgumentsRange.first) + return false; + + s << demangled_name.slice(info->ArgumentsRange.first, + info->ArgumentsRange.second); + + return true; +} + bool CPlusPlusLanguage::CxxMethodName::TrySimplifiedParse() { // This method tries to parse simple method definitions which are presumably // most comman in user programs. Definitions that can be parsed by this @@ -1890,8 +1918,6 @@ bool CPlusPlusLanguage::GetFunctionDisplayName( bool CPlusPlusLanguage::HandleFrameFormatVariable( const SymbolContext &sc, const ExecutionContext *exe_ctx, FormatEntity::Entry::Type type, Stream &s) { - assert(sc.function); - switch (type) { case FormatEntity::Entry::Type::FunctionScope: { std::optional<llvm::StringRef> scope = GetDemangledScope(sc); @@ -1925,6 +1951,14 @@ bool CPlusPlusLanguage::HandleFrameFormatVariable( } case FormatEntity::Entry::Type::FunctionFormattedArguments: { + // This ensures we print the arguments even when no debug-info is available. + // + // FIXME: we should have a Entry::Type::FunctionArguments and + // use it in the plugin.cplusplus.display.function-name-format + // once we have a "fallback operator" in the frame-format language. + if (!sc.function && sc.symbol) + return PrintDemangledArgumentList(s, sc); + VariableList args; if (auto variable_list_sp = GetFunctionVariableList(sc)) variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, |