diff options
| -rw-r--r-- | lldb/include/lldb/Symbol/SymbolContext.h | 18 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandCompletions.cpp | 11 | ||||
| -rw-r--r-- | lldb/source/Symbol/SymbolContext.cpp | 23 |
3 files changed, 44 insertions, 8 deletions
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index 0175b9150cc..be2fd32a6a1 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -15,6 +15,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/Address.h" +#include "lldb/Core/Mangled.h" #include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/LineEntry.h" @@ -266,6 +267,23 @@ public: // const char *line_number, // const char *symbol); + //------------------------------------------------------------------ + /// Find a name of the innermost function for the symbol context. + /// + /// For instance, if the symbol context contains an inlined block, + /// it will return the inlined function name. + /// + /// @param[in] prefer_mangled + /// if \btrue, then the mangled name will be returned if there + /// is one. Otherwise the unmangled name will be returned if it + /// is available. + /// + /// @return + /// The name of the function represented by this symbol context. + //------------------------------------------------------------------ + ConstString + GetFunctionName (Mangled::NamePreference preference = Mangled::ePreferDemangled); + bool GetParentInlinedFrameInfo (const Address &curr_frame_pc, bool is_concrete_frame, diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 3ea62aa0ed1..4fb2d970677 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -627,14 +627,9 @@ CommandCompletions::SymbolCompleter::SearchCallback ( { if (sc_list.GetContextAtIndex(i, sc)) { - if (sc.function) - { - m_match_set.insert (sc.function->GetMangled().GetDemangledName()); - } - else if (sc.symbol && sc.symbol->GetAddressRangePtr()) - { - m_match_set.insert (sc.symbol->GetMangled().GetName()); - } + ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled); + if (!func_name.IsEmpty()) + m_match_set.insert (func_name); } } } diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index c7b2fb26613..80ffd342379 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -575,6 +575,29 @@ SymbolContext::GetParentInlinedFrameInfo (const Address &curr_frame_pc, return false; } +ConstString +SymbolContext::GetFunctionName (Mangled::NamePreference preference) +{ + if (function) + { + if (block) + { + const InlineFunctionInfo *inline_info = block->GetInlinedFunctionInfo(); + if (inline_info) + return inline_info->GetName(); + } + return function->GetMangled().GetName(preference); + } + else if (symbol && symbol->GetAddressRangePtr()) + { + return symbol->GetMangled().GetName(preference); + } + else + { + // No function, return an empty string. + return ConstString(); + } +} //---------------------------------------------------------------------- // |

