Add a GetDisplayName() API to SBFrame, SBFunction and SBSymbol

This API is currently a no-op (in the sense that it has the same behavior as the already existing GetName()), but is meant long-term to provide a best-for-visualization version of the name of a function

It is still not hooked up to the command line 'bt' command, nor to the 'gui' mode, but I do have ideas on how to make that work going forward

rdar://21203242

llvm-svn: 241482
This commit is contained in:
Enrico Granata 2015-07-06 18:28:46 +00:00
parent 95dd08e4c9
commit c1f705c229
15 changed files with 156 additions and 0 deletions

View File

@ -91,6 +91,10 @@ public:
const char *
GetFunctionName();
// Get an appropriate function name for this frame that is suitable for display to a user
const char *
GetDisplayFunctionName ();
const char *
GetFunctionName() const;

View File

@ -35,6 +35,9 @@ public:
const char *
GetName() const;
const char *
GetDisplayName() const;
const char *
GetMangledName () const;

View File

@ -37,6 +37,9 @@ public:
const char *
GetName() const;
const char *
GetDisplayName() const;
const char *
GetMangledName () const;

View File

@ -184,6 +184,15 @@ public:
const ConstString&
GetDemangledName () const;
//----------------------------------------------------------------------
/// Display demangled name get accessor.
///
/// @return
/// A const reference to the display demangled name string object.
//----------------------------------------------------------------------
ConstString
GetDisplayDemangledName () const;
void
SetDemangledName (const ConstString &name)
{

View File

@ -245,6 +245,9 @@ public:
const ConstString &
GetName () const;
ConstString
GetDisplayName () const;
//------------------------------------------------------------------
/// Get accessor for the call site declaration information.
///
@ -530,6 +533,9 @@ public:
return m_mangled.GetName();
}
ConstString
GetDisplayName () const;
const Mangled &
GetMangled() const
{

View File

@ -158,6 +158,9 @@ public:
return m_mangled.GetName();
}
ConstString
GetDisplayName () const;
uint32_t
GetID() const
{

View File

@ -128,6 +128,9 @@ public:
const char *
GetFunctionName();
const char *
GetDisplayFunctionName ();
const char *
GetFunctionName() const;

View File

@ -59,6 +59,9 @@ public:
const char *
GetName() const;
const char *
GetDisplayName() const;
const char *
GetMangledName () const;

View File

@ -32,6 +32,9 @@ public:
const char *
GetName() const;
const char *
GetDisplayName() const;
const char *
GetMangledName () const;

View File

@ -1602,3 +1602,59 @@ SBFrame::GetFunctionName() const
}
return name;
}
const char *
SBFrame::GetDisplayFunctionName()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *name = NULL;
ExecutionContext exe_ctx(m_opaque_sp.get());
StackFrame *frame = NULL;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
{
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock()))
{
frame = exe_ctx.GetFramePtr();
if (frame)
{
SymbolContext sc (frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol));
if (sc.block)
{
Block *inlined_block = sc.block->GetContainingInlinedBlock ();
if (inlined_block)
{
const InlineFunctionInfo* inlined_info = inlined_block->GetInlinedFunctionInfo();
name = inlined_info->GetDisplayName().AsCString();
}
}
if (name == NULL)
{
if (sc.function)
name = sc.function->GetDisplayName().GetCString();
}
if (name == NULL)
{
if (sc.symbol)
name = sc.symbol->GetDisplayName().GetCString();
}
}
else
{
if (log)
log->Printf ("SBFrame::GetDisplayFunctionName () => error: could not reconstruct frame object for this SBFrame.");
}
}
else
{
if (log)
log->Printf ("SBFrame::GetDisplayFunctionName() => error: process is running");
}
}
return name;
}

View File

@ -75,6 +75,26 @@ SBFunction::GetName() const
return cstr;
}
const char *
SBFunction::GetDisplayName() const
{
const char *cstr = NULL;
if (m_opaque_ptr)
cstr = m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString();
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
log->Printf ("SBFunction(%p)::GetDisplayName () => \"%s\"",
static_cast<void*>(m_opaque_ptr), cstr);
else
log->Printf ("SBFunction(%p)::GetDisplayName () => NULL",
static_cast<void*>(m_opaque_ptr));
}
return cstr;
}
const char *
SBFunction::GetMangledName () const
{

View File

@ -72,6 +72,20 @@ SBSymbol::GetName() const
return name;
}
const char *
SBSymbol::GetDisplayName() const
{
const char *name = NULL;
if (m_opaque_ptr)
name = m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString();
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBSymbol(%p)::GetDisplayName () => \"%s\"",
static_cast<void*>(m_opaque_ptr), name ? name : "");
return name;
}
const char *
SBSymbol::GetMangledName () const
{

View File

@ -339,6 +339,12 @@ Mangled::GetDemangledName () const
}
ConstString
Mangled::GetDisplayDemangledName () const
{
return GetDemangledName();
}
bool
Mangled::NameMatches (const RegularExpression& regex) const
{

View File

@ -159,6 +159,13 @@ InlineFunctionInfo::GetName () const
return m_name;
}
ConstString
InlineFunctionInfo::GetDisplayName () const
{
if (m_mangled)
return m_mangled.GetDisplayDemangledName();
return m_name;
}
Declaration &
InlineFunctionInfo::GetCallSite ()
@ -459,6 +466,14 @@ Function::MemorySize () const
return mem_size;
}
ConstString
Function::GetDisplayName () const
{
if (!m_mangled)
return ConstString();
return m_mangled.GetDisplayDemangledName();
}
clang::DeclContext *
Function::GetClangDeclContext()
{

View File

@ -184,6 +184,14 @@ Symbol::ValueIsAddress() const
return m_addr_range.GetBaseAddress().GetSection().get() != nullptr;
}
ConstString
Symbol::GetDisplayName () const
{
if (!m_mangled)
return ConstString();
return m_mangled.GetDisplayDemangledName();
}
ConstString
Symbol::GetReExportedSymbolName() const
{