Fixed an issue in the DWARF parser that was causing forward declarations

to not get resolved.

Fixed the "void **isa_ptr" variable inside the objective C verifier to start
with a '$' character so we don't go looking for it in our program.

Moved the lookup for "$__lldb_class" into the part that knows we are looking
for internal types that start with a '$'.

llvm-svn: 118488
This commit is contained in:
Greg Clayton 2010-11-09 04:42:43 +00:00
parent 416463f7f3
commit c615ce4964
3 changed files with 68 additions and 68 deletions

View File

@ -970,45 +970,6 @@ ClangExpressionDeclMap::GetDecls
if (m_exe_ctx.frame == NULL)
return;
static ConstString g_lldb_class_name ("$__lldb_class");
if (name == g_lldb_class_name)
{
// Clang is looking for the type of "this"
VariableList *vars = m_exe_ctx.frame->GetVariableList(false);
if (!vars)
return;
lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
if (!this_var)
return;
Type *this_type = this_var->GetType();
if (!this_type)
return;
TypeFromUser this_user_type(this_type->GetClangType(),
this_type->GetClangAST());
m_object_pointer_type = this_user_type;
void *pointer_target_type;
if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(),
&pointer_target_type))
return;
TypeFromUser class_user_type(pointer_target_type,
this_type->GetClangAST());
AddOneType(context, class_user_type, true);
return;
}
SymbolContextList sym_ctxs;
// Only look for functions by name out in our symbols if the function
@ -1066,6 +1027,45 @@ ClangExpressionDeclMap::GetDecls
}
else
{
static ConstString g_lldb_class_name ("$__lldb_class");
if (name == g_lldb_class_name)
{
// Clang is looking for the type of "this"
VariableList *vars = m_exe_ctx.frame->GetVariableList(false);
if (!vars)
return;
lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
if (!this_var)
return;
Type *this_type = this_var->GetType();
if (!this_type)
return;
TypeFromUser this_user_type(this_type->GetClangType(),
this_type->GetClangAST());
m_object_pointer_type = this_user_type;
void *pointer_target_type;
if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(),
&pointer_target_type))
return;
TypeFromUser class_user_type(pointer_target_type,
this_type->GetClangAST());
AddOneType(context, class_user_type, true);
return;
}
ClangExpressionVariable *pvar(m_persistent_vars->GetVariable(name));
if (pvar)

View File

@ -268,14 +268,14 @@ AppleObjCRuntimeV2::CreateObjectChecker(const char *name)
else
{
assert(snprintf(&buf->contents[0], sizeof(buf->contents),
"extern \"C\" int gdb_class_getClass(void *); \n"
"extern \"C\" void \n"
"%s(void *$__lldb_arg_obj) \n"
"{ \n"
" void **isa_ptr = (void **)$__lldb_arg_obj; \n"
" if (!isa_ptr || !gdb_class_getClass(*isa_ptr)) \n"
" abort(); \n"
"} \n",
"extern \"C\" int gdb_class_getClass(void *); \n"
"extern \"C\" void \n"
"%s(void *$__lldb_arg_obj) \n"
"{ \n"
" void **$isa_ptr = (void **)$__lldb_arg_obj; \n"
" if (!$isa_ptr || !gdb_class_getClass(*$isa_ptr)) \n"
" abort(); \n"
"} \n",
name) < sizeof(buf->contents));
}

View File

@ -2857,27 +2857,27 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
}
// if (is_forward_declaration)
// {
// // We have a forward declaration to a type and we need
// // to try and find a full declaration. We look in the
// // current type index just in case we have a forward
// // declaration followed by an actual declarations in the
// // DWARF. If this fails, we need to look elsewhere...
//
// type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
//
// if (!type_sp)
// {
// // We weren't able to find a full declaration in
// // this DWARF, see if we have a declaration anywhere
// // else...
// if (m_debug_map_symfile)
// type_sp = m_debug_map_symfile->FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
// }
// if (type_sp)
// return type_sp;
// }
if (is_forward_declaration)
{
// We have a forward declaration to a type and we need
// to try and find a full declaration. We look in the
// current type index just in case we have a forward
// declaration followed by an actual declarations in the
// DWARF. If this fails, we need to look elsewhere...
type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
if (!type_sp)
{
// We weren't able to find a full declaration in
// this DWARF, see if we have a declaration anywhere
// else...
if (m_debug_map_symfile)
type_sp = m_debug_map_symfile->FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
}
if (type_sp)
return type_sp;
}
assert (tag_decl_kind != -1);
bool clang_type_was_created = false;
clang_type = m_forward_decl_die_to_clang_type.lookup (die);