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 /lldb/source/API | |
| 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
Diffstat (limited to 'lldb/source/API')
| -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 |
3 files changed, 90 insertions, 0 deletions
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; |

