[Lldb-commits] [lldb] r123938 - in /lldb/trunk: include/lldb/Target/StackFrame.h source/Commands/CommandObjectFrame.cpp source/Target/StackFrame.cpp source/Target/Target.cpp
Greg Clayton
gclayton at apple.com
Thu Jan 20 11:27:18 PST 2011
Author: gclayton
Date: Thu Jan 20 13:27:18 2011
New Revision: 123938
URL: http://llvm.org/viewvc/llvm-project?rev=123938&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/Target/StackFrame.h
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=123938&r1=123937&r2=123938&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrame.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrame.h Thu Jan 20 13:27:18 2011
@@ -30,6 +30,11 @@
public ExecutionContextScope
{
public:
+ typedef enum ExpressionPathOption
+ {
+ eExpressionPathOptionCheckPtrVsMember = (1u << 0),
+ eExpressionPathOptionsNoFragileObjcIvar = (1u << 1)
+ };
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
@@ -96,8 +101,9 @@
VariableList *
GetVariableList (bool get_file_globals);
+ // See ExpressionPathOption enumeration for "options" values
lldb::ValueObjectSP
- GetValueForVariableExpressionPath (const char *var_expr, bool check_ptr_vs_member, Error &error);
+ GetValueForVariableExpressionPath (const char *var_expr, uint32_t options, Error &error);
bool
HasDebugInformation ();
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=123938&r1=123937&r2=123938&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Thu Jan 20 13:27:18 2011
@@ -588,8 +588,8 @@
else
{
Error error;
- const bool check_ptr_vs_member = true;
- valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, check_ptr_vs_member, error);
+ const uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember;
+ valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, expr_path_options, error);
if (valobj_sp)
{
if (m_options.show_decl && var_sp->GetDeclaration ().GetFile())
Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=123938&r1=123937&r2=123938&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Thu Jan 20 13:27:18 2011
@@ -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 '.':
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=123938&r1=123937&r2=123938&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Jan 20 13:27:18 2011
@@ -923,8 +923,9 @@
{
frame->CalculateExecutionContext(exe_ctx);
Error error;
- const bool check_ptr_vs_member = true;
- result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr, check_ptr_vs_member, error);
+ const uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember |
+ StackFrame::eExpressionPathOptionsNoFragileObjcIvar;
+ result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr, expr_path_options, error);
}
else if (m_process_sp)
{
More information about the lldb-commits
mailing list