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
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index e845aef..70ee4d4 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -1602,3 +1602,59 @@
}
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;
+}