[Lldb-commits] [lldb] r133357 - in /lldb/trunk: include/lldb/API/SBFrame.h source/API/SBFrame.cpp
Greg Clayton
gclayton at apple.com
Sat Jun 18 13:06:08 PDT 2011
Author: gclayton
Date: Sat Jun 18 15:06:08 2011
New Revision: 133357
URL: http://llvm.org/viewvc/llvm-project?rev=133357&view=rev
Log:
Added two new API functions to SBFrame:
const char *
SBFrame::GetFunctionName();
bool
SBFrame::IsInlined();
The first one will return the correct name for a frame. The name of a frame is:
- the name of the inlined function (if there is one)
- the name of the concrete function (if there is one)
- the name of the symbol (if there is one)
- NULL
We also can now easily check if a frame is an inline function or not.
Modified:
lldb/trunk/include/lldb/API/SBFrame.h
lldb/trunk/source/API/SBFrame.cpp
Modified: lldb/trunk/include/lldb/API/SBFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=133357&r1=133356&r2=133357&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFrame.h (original)
+++ lldb/trunk/include/lldb/API/SBFrame.h Sat Jun 18 15:06:08 2011
@@ -71,6 +71,18 @@
lldb::SBBlock
GetBlock () const;
+ // Get the appropriate function name for this frame. Inlined functions in
+ // LLDB are represented by Blocks that have inlined function information, so
+ // just looking at the SBFunction or SBSymbol for a frame isn't enough.
+ // This function will return the appriopriate function, symbol or inlined
+ // function name for the frame.
+ const char *
+ GetFunctionName();
+
+ // Return true if this frame represents and an inlined function.
+ bool
+ IsInlined();
+
// The version that doesn't supply a "use_dynamic" value will use the target's default.
lldb::SBValue
EvaluateExpression (const char *expr);
Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=133357&r1=133356&r2=133357&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Sat Jun 18 15:06:08 2011
@@ -343,8 +343,13 @@
SBValue
SBFrame::FindVariable (const char *name)
{
- lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
- return FindVariable (name, use_dynamic);
+ SBValue value;
+ if (m_opaque_sp)
+ {
+ lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
+ value = FindVariable (name, use_dynamic);
+ }
+ return value;
}
SBValue
@@ -373,11 +378,12 @@
var_sp = variable_list.FindVariable (ConstString(name));
}
}
+
+ if (var_sp)
+ *sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic));
+
}
- if (var_sp)
- *sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic));
-
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)",
@@ -389,8 +395,13 @@
SBValue
SBFrame::FindValue (const char *name, ValueType value_type)
{
- lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
- return FindValue (name, value_type, use_dynamic);
+ SBValue value;
+ if (m_opaque_sp)
+ {
+ lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
+ value = FindValue (name, value_type, use_dynamic);
+ }
+ return value;
}
SBValue
@@ -579,8 +590,13 @@
bool statics,
bool in_scope_only)
{
- lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
- return GetVariables (arguments, locals, statics, in_scope_only, use_dynamic);
+ SBValueList value_list;
+ if (m_opaque_sp)
+ {
+ lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
+ value_list = GetVariables (arguments, locals, statics, in_scope_only, use_dynamic);
+ }
+ return value_list;
}
SBValueList
@@ -706,15 +722,18 @@
SBValue
SBFrame::EvaluateExpression (const char *expr)
{
- lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
- return EvaluateExpression (expr, use_dynamic);
+ SBValue result;
+ if (m_opaque_sp)
+ {
+ lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
+ result = EvaluateExpression (expr, use_dynamic);
+ }
+ return result;
}
SBValue
SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value)
{
- Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -725,6 +744,8 @@
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
+
ExecutionResults exe_results;
const bool unwind_on_error = true;
const bool keep_in_memory = false;
@@ -749,3 +770,48 @@
return expr_result;
}
+
+bool
+SBFrame::IsInlined()
+{
+ if (m_opaque_sp)
+ {
+ Block *block = m_opaque_sp->GetSymbolContext(eSymbolContextBlock).block;
+ if (block)
+ return block->GetContainingInlinedBlock () != NULL;
+ }
+ return false;
+}
+
+const char *
+SBFrame::GetFunctionName()
+{
+ const char *name = NULL;
+ if (m_opaque_sp)
+ {
+ SymbolContext sc (m_opaque_sp->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->GetName().AsCString();
+ }
+ }
+
+ if (name == NULL)
+ {
+ if (sc.function)
+ name = sc.function->GetName().GetCString();
+ }
+
+ if (name == NULL)
+ {
+ if (sc.symbol)
+ name = sc.symbol->GetName().GetCString();
+ }
+ }
+ return name;
+}
+
More information about the lldb-commits
mailing list