diff options
author | Sean Callanan <scallanan@apple.com> | 2010-12-13 22:46:15 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2010-12-13 22:46:15 +0000 |
commit | 1782783095b51000831c7d2fd1d763355b5adc0f (patch) | |
tree | fc296a108c96feda93188471be524ad16ed3e04c /lldb/source/Expression/ClangExpressionDeclMap.cpp | |
parent | 4efa445f3cd10e828a6022ca2ea53ca827dde6a7 (diff) | |
download | bcm5719-llvm-1782783095b51000831c7d2fd1d763355b5adc0f.tar.gz bcm5719-llvm-1782783095b51000831c7d2fd1d763355b5adc0f.zip |
Added support for generating expressions that have
access to the members of the Objective-C self object.
The approach we take is to generate the method as a
@category on top of the self object, and to pass the
"self" pointer to it. (_cmd is currently NULL.)
Most changes are in ClangExpressionDeclMap, but the
change that adds support to the ABIs to pass _cmd
touches a fair amount of code.
llvm-svn: 121722
Diffstat (limited to 'lldb/source/Expression/ClangExpressionDeclMap.cpp')
-rw-r--r-- | lldb/source/Expression/ClangExpressionDeclMap.cpp | 69 |
1 files changed, 62 insertions, 7 deletions
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index a93ff17340d..449db416fd2 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -371,6 +371,7 @@ bool ClangExpressionDeclMap::GetObjectPointer ( lldb::addr_t &object_ptr, + ConstString &object_name, ExecutionContext &exe_ctx, Error &err ) @@ -389,12 +390,11 @@ ClangExpressionDeclMap::GetObjectPointer return false; } - static ConstString g_this_const_str ("this"); - Variable *object_ptr_var = FindVariableInScope (*exe_ctx.frame, g_this_const_str, &m_struct_vars->m_object_pointer_type); + Variable *object_ptr_var = FindVariableInScope (*exe_ctx.frame, object_name, &m_struct_vars->m_object_pointer_type); if (!object_ptr_var) { - err.SetErrorString("Couldn't find 'this' with appropriate type in scope"); + err.SetErrorStringWithFormat("Couldn't find '%s' with appropriate type in scope", object_name.GetCString()); return false; } @@ -404,7 +404,7 @@ ClangExpressionDeclMap::GetObjectPointer if (!location_value.get()) { - err.SetErrorString("Couldn't get the location for 'this'"); + err.SetErrorStringWithFormat("Couldn't get the location for '%s'", object_name.GetCString()); return false; } @@ -417,7 +417,7 @@ ClangExpressionDeclMap::GetObjectPointer if (ClangASTType::GetClangTypeBitWidth(m_struct_vars->m_object_pointer_type.GetASTContext(), m_struct_vars->m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8) { - err.SetErrorStringWithFormat("'this' is not of an expected pointer size"); + err.SetErrorStringWithFormat("'%s' is not of an expected pointer size", object_name.GetCString()); return false; } @@ -427,7 +427,7 @@ ClangExpressionDeclMap::GetObjectPointer if (exe_ctx.process->ReadMemory (value_addr, data.GetBytes(), address_byte_size, read_error) != address_byte_size) { - err.SetErrorStringWithFormat("Coldn't read 'this' from the target: %s", read_error.AsCString()); + err.SetErrorStringWithFormat("Coldn't read '%s' from the target: %s", object_name.GetCString(), read_error.AsCString()); return false; } @@ -441,7 +441,7 @@ ClangExpressionDeclMap::GetObjectPointer } else { - err.SetErrorString("'this' is not in memory; LLDB must be extended to handle registers"); + err.SetErrorStringWithFormat("'%s' is not in memory; LLDB must be extended to handle registers", object_name.GetCString()); return false; } } @@ -1250,11 +1250,66 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString TypeFromUser class_user_type(pointer_target_type, this_type->GetClangAST()); + if (log) + { + StreamString type_stream; + class_user_type.DumpTypeCode(&type_stream); + type_stream.Flush(); + log->Printf("Adding type for $__lldb_class: %s", type_stream.GetString().c_str()); + } + AddOneType(context, class_user_type, true); return; } + static ConstString g_lldb_objc_class_name ("$__lldb_objc_class"); + if (name == g_lldb_objc_class_name) + { + // Clang is looking for the type of "*self" + + VariableList *vars = m_parser_vars->m_exe_ctx->frame->GetVariableList(false); + + if (!vars) + return; + + lldb::VariableSP self_var = vars->FindVariable(ConstString("self")); + + if (!self_var) + return; + + Type *self_type = self_var->GetType(); + + if (!self_type) + return; + + TypeFromUser self_user_type(self_type->GetClangType(), + self_type->GetClangAST()); + + m_struct_vars->m_object_pointer_type = self_user_type; + + void *pointer_target_type; + + if (!ClangASTContext::IsPointerType(self_user_type.GetOpaqueQualType(), + &pointer_target_type)) + return; + + TypeFromUser class_user_type(pointer_target_type, + self_type->GetClangAST()); + + if (log) + { + StreamString type_stream; + class_user_type.DumpTypeCode(&type_stream); + type_stream.Flush(); + log->Printf("Adding type for $__lldb_objc_class: %s", type_stream.GetString().c_str()); + } + + AddOneType(context, class_user_type, false); + + return; + } + ClangExpressionVariable *pvar(m_parser_vars->m_persistent_vars->GetVariable(name)); if (pvar) |