[Lldb-commits] [lldb] r140628 - in /lldb/trunk: include/lldb/Symbol/SymbolContext.h source/Commands/CommandCompletions.cpp source/Symbol/SymbolContext.cpp
Jim Ingham
jingham at apple.com
Tue Sep 27 12:48:21 PDT 2011
Author: jingham
Date: Tue Sep 27 14:48:20 2011
New Revision: 140628
URL: http://llvm.org/viewvc/llvm-project?rev=140628&view=rev
Log:
Added an API to SymbolContext to hide the complexity of getting the
function name from a symbol context. Use that in CommandCompletions
to get the right name.
Modified:
lldb/trunk/include/lldb/Symbol/SymbolContext.h
lldb/trunk/source/Commands/CommandCompletions.cpp
lldb/trunk/source/Symbol/SymbolContext.cpp
Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=140628&r1=140627&r2=140628&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Tue Sep 27 14:48:20 2011
@@ -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 @@
// 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,
Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=140628&r1=140627&r2=140628&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
+++ lldb/trunk/source/Commands/CommandCompletions.cpp Tue Sep 27 14:48:20 2011
@@ -627,14 +627,9 @@
{
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);
}
}
}
Modified: lldb/trunk/source/Symbol/SymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=140628&r1=140627&r2=140628&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolContext.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolContext.cpp Tue Sep 27 14:48:20 2011
@@ -575,6 +575,29 @@
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();
+ }
+}
//----------------------------------------------------------------------
//
More information about the lldb-commits
mailing list