diff options
| author | Enrico Granata <egranata@apple.com> | 2015-07-06 18:28:46 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2015-07-06 18:28:46 +0000 |
| commit | c1f705c2298d64edd5d54ca59816332cce34869b (patch) | |
| tree | 20efb79aae596fcc8f988114ee9d861a50c78477 | |
| parent | 95dd08e4c928d17464e9974ed98493f9ab87f257 (diff) | |
| download | bcm5719-llvm-c1f705c2298d64edd5d54ca59816332cce34869b.tar.gz bcm5719-llvm-c1f705c2298d64edd5d54ca59816332cce34869b.zip | |
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
| -rw-r--r-- | lldb/include/lldb/API/SBFrame.h | 4 | ||||
| -rw-r--r-- | lldb/include/lldb/API/SBFunction.h | 3 | ||||
| -rw-r--r-- | lldb/include/lldb/API/SBSymbol.h | 3 | ||||
| -rw-r--r-- | lldb/include/lldb/Core/Mangled.h | 9 | ||||
| -rw-r--r-- | lldb/include/lldb/Symbol/Function.h | 6 | ||||
| -rw-r--r-- | lldb/include/lldb/Symbol/Symbol.h | 3 | ||||
| -rw-r--r-- | lldb/scripts/interface/SBFrame.i | 3 | ||||
| -rw-r--r-- | lldb/scripts/interface/SBFunction.i | 3 | ||||
| -rw-r--r-- | lldb/scripts/interface/SBSymbol.i | 3 | ||||
| -rw-r--r-- | lldb/source/API/SBFrame.cpp | 56 | ||||
| -rw-r--r-- | lldb/source/API/SBFunction.cpp | 20 | ||||
| -rw-r--r-- | lldb/source/API/SBSymbol.cpp | 14 | ||||
| -rw-r--r-- | lldb/source/Core/Mangled.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Symbol/Function.cpp | 15 | ||||
| -rw-r--r-- | lldb/source/Symbol/Symbol.cpp | 8 |
15 files changed, 156 insertions, 0 deletions
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h index 2ca9e062490..3177b0cc5a6 100644 --- a/lldb/include/lldb/API/SBFrame.h +++ b/lldb/include/lldb/API/SBFrame.h @@ -90,6 +90,10 @@ public: /// See also IsInlined(). 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; diff --git a/lldb/include/lldb/API/SBFunction.h b/lldb/include/lldb/API/SBFunction.h index 7d578393eb2..86cfeb49bb5 100644 --- a/lldb/include/lldb/API/SBFunction.h +++ b/lldb/include/lldb/API/SBFunction.h @@ -36,6 +36,9 @@ public: GetName() const; const char * + GetDisplayName() const; + + const char * GetMangledName () const; lldb::SBInstructionList diff --git a/lldb/include/lldb/API/SBSymbol.h b/lldb/include/lldb/API/SBSymbol.h index 3d259a2c20c..5acebe97526 100644 --- a/lldb/include/lldb/API/SBSymbol.h +++ b/lldb/include/lldb/API/SBSymbol.h @@ -38,6 +38,9 @@ public: GetName() const; const char * + GetDisplayName() const; + + const char * GetMangledName () const; lldb::SBInstructionList diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index a2a2b5591d0..53645bc8dbc 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -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) { diff --git a/lldb/include/lldb/Symbol/Function.h b/lldb/include/lldb/Symbol/Function.h index 5954cf520d7..60298283834 100644 --- a/lldb/include/lldb/Symbol/Function.h +++ b/lldb/include/lldb/Symbol/Function.h @@ -245,6 +245,9 @@ public: const ConstString & GetName () const; + ConstString + GetDisplayName () const; + //------------------------------------------------------------------ /// Get accessor for the call site declaration information. /// @@ -529,6 +532,9 @@ public: { return m_mangled.GetName(); } + + ConstString + GetDisplayName () const; const Mangled & GetMangled() const diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h index ad11563634e..8b9811bceab 100644 --- a/lldb/include/lldb/Symbol/Symbol.h +++ b/lldb/include/lldb/Symbol/Symbol.h @@ -158,6 +158,9 @@ public: return m_mangled.GetName(); } + ConstString + GetDisplayName () const; + uint32_t GetID() const { diff --git a/lldb/scripts/interface/SBFrame.i b/lldb/scripts/interface/SBFrame.i index d87bc532b58..1c10a9b6e3e 100644 --- a/lldb/scripts/interface/SBFrame.i +++ b/lldb/scripts/interface/SBFrame.i @@ -127,6 +127,9 @@ public: ") GetFunctionName; const char * GetFunctionName(); + + const char * + GetDisplayFunctionName (); const char * GetFunctionName() const; diff --git a/lldb/scripts/interface/SBFunction.i b/lldb/scripts/interface/SBFunction.i index d3660aff08c..346237583e8 100644 --- a/lldb/scripts/interface/SBFunction.i +++ b/lldb/scripts/interface/SBFunction.i @@ -58,6 +58,9 @@ public: const char * GetName() const; + + const char * + GetDisplayName() const; const char * GetMangledName () const; diff --git a/lldb/scripts/interface/SBSymbol.i b/lldb/scripts/interface/SBSymbol.i index f6db14c0ee5..b6717055e48 100644 --- a/lldb/scripts/interface/SBSymbol.i +++ b/lldb/scripts/interface/SBSymbol.i @@ -33,6 +33,9 @@ public: GetName() const; const char * + GetDisplayName() const; + + const char * GetMangledName () const; lldb::SBInstructionList diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index e845aef41f4..70ee4d44c41 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -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; +} diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp index bf5e9180a43..d57307add03 100644 --- a/lldb/source/API/SBFunction.cpp +++ b/lldb/source/API/SBFunction.cpp @@ -76,6 +76,26 @@ SBFunction::GetName() const } 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 { const char *cstr = NULL; diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index 246a455d93a..171bfd84d0c 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -73,6 +73,20 @@ SBSymbol::GetName() const } 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 { const char *name = NULL; diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index 3e1a8bb8913..094710633ea 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -339,6 +339,12 @@ Mangled::GetDemangledName () const } +ConstString +Mangled::GetDisplayDemangledName () const +{ + return GetDemangledName(); +} + bool Mangled::NameMatches (const RegularExpression& regex) const { diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 0b7430ad75e..61b48eda862 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -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() { diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index dff15dd9261..3e8af2f0c9e 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -185,6 +185,14 @@ Symbol::ValueIsAddress() const } ConstString +Symbol::GetDisplayName () const +{ + if (!m_mangled) + return ConstString(); + return m_mangled.GetDisplayDemangledName(); +} + +ConstString Symbol::GetReExportedSymbolName() const { if (m_type == eSymbolTypeReExported) |

