Added the ability to StackFrame::GetValueForVariableExpressionPath(...) to avoid
fragile ivars if requested. This was done by changing the previous second parameter
to an options bitfield that can be populated by logical OR'ing the new
StackFrame::ExpressionPathOption enum values together:
typedef enum ExpressionPathOption
{
eExpressionPathOptionCheckPtrVsMember = (1u << 0),
eExpressionPathOptionsNoFragileObjcIvar = (1u << 1),
};
So the old function was:
lldb::ValueObjectSP
StackFrame::GetValueForVariableExpressionPath (const char *var_expr, bool check_ptr_vs_member, Error &error);
But it is now:
lldb::ValueObjectSP
StackFrame::GetValueForVariableExpressionPath (const char *var_expr, uint32_t options, Error &error);
This allows the expression parser in Target::EvaluateExpression(...) to avoid
using simple frame variable expression paths when evaluating something that might
be a fragile ivar.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@123938 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index eb86f46..633d394 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -480,11 +480,13 @@
}
ValueObjectSP
-StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, bool check_ptr_vs_member, Error &error)
+StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, uint32_t options, Error &error)
{
if (var_expr_cstr && var_expr_cstr[0])
{
+ const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0;
+ const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0;
error.Clear();
bool deref = false;
bool address_of = false;
@@ -536,6 +538,20 @@
if (var_path.size() >= 2 && var_path[1] != '>')
return ValueObjectSP();
+ if (no_fragile_ivar)
+ {
+ // Make sure we aren't trying to deref an objective
+ // C ivar if this is not allowed
+ const uint32_t pointer_type_flags = ClangASTContext::GetTypeInfo (valobj_sp->GetClangType(), NULL, NULL);
+ if ((pointer_type_flags & ClangASTContext::eTypeIsObjC) &&
+ (pointer_type_flags & ClangASTContext::eTypeIsPointer))
+ {
+ // This was an objective C object pointer and
+ // it was requested we skip any fragile ivars
+ // so return nothing here
+ return ValueObjectSP();
+ }
+ }
var_path.erase (0, 1); // Remove the '-'
// Fall through
case '.':