Skip to content

Commit c615ce4

Browse files
author
Greg Clayton
committed
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
1 parent 416463f commit c615ce4

File tree

3 files changed

+68
-68
lines changed

3 files changed

+68
-68
lines changed

lldb/source/Expression/ClangExpressionDeclMap.cpp

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -970,45 +970,6 @@ ClangExpressionDeclMap::GetDecls
970970
if (m_exe_ctx.frame == NULL)
971971
return;
972972

973-
static ConstString g_lldb_class_name ("$__lldb_class");
974-
if (name == g_lldb_class_name)
975-
{
976-
// Clang is looking for the type of "this"
977-
978-
VariableList *vars = m_exe_ctx.frame->GetVariableList(false);
979-
980-
if (!vars)
981-
return;
982-
983-
lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
984-
985-
if (!this_var)
986-
return;
987-
988-
Type *this_type = this_var->GetType();
989-
990-
if (!this_type)
991-
return;
992-
993-
TypeFromUser this_user_type(this_type->GetClangType(),
994-
this_type->GetClangAST());
995-
996-
m_object_pointer_type = this_user_type;
997-
998-
void *pointer_target_type;
999-
1000-
if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(),
1001-
&pointer_target_type))
1002-
return;
1003-
1004-
TypeFromUser class_user_type(pointer_target_type,
1005-
this_type->GetClangAST());
1006-
1007-
AddOneType(context, class_user_type, true);
1008-
1009-
return;
1010-
}
1011-
1012973
SymbolContextList sym_ctxs;
1013974

1014975
// Only look for functions by name out in our symbols if the function
@@ -1066,6 +1027,45 @@ ClangExpressionDeclMap::GetDecls
10661027
}
10671028
else
10681029
{
1030+
static ConstString g_lldb_class_name ("$__lldb_class");
1031+
if (name == g_lldb_class_name)
1032+
{
1033+
// Clang is looking for the type of "this"
1034+
1035+
VariableList *vars = m_exe_ctx.frame->GetVariableList(false);
1036+
1037+
if (!vars)
1038+
return;
1039+
1040+
lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
1041+
1042+
if (!this_var)
1043+
return;
1044+
1045+
Type *this_type = this_var->GetType();
1046+
1047+
if (!this_type)
1048+
return;
1049+
1050+
TypeFromUser this_user_type(this_type->GetClangType(),
1051+
this_type->GetClangAST());
1052+
1053+
m_object_pointer_type = this_user_type;
1054+
1055+
void *pointer_target_type;
1056+
1057+
if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(),
1058+
&pointer_target_type))
1059+
return;
1060+
1061+
TypeFromUser class_user_type(pointer_target_type,
1062+
this_type->GetClangAST());
1063+
1064+
AddOneType(context, class_user_type, true);
1065+
1066+
return;
1067+
}
1068+
10691069
ClangExpressionVariable *pvar(m_persistent_vars->GetVariable(name));
10701070

10711071
if (pvar)

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,14 @@ AppleObjCRuntimeV2::CreateObjectChecker(const char *name)
268268
else
269269
{
270270
assert(snprintf(&buf->contents[0], sizeof(buf->contents),
271-
"extern \"C\" int gdb_class_getClass(void *); \n"
272-
"extern \"C\" void \n"
273-
"%s(void *$__lldb_arg_obj) \n"
274-
"{ \n"
275-
" void **isa_ptr = (void **)$__lldb_arg_obj; \n"
276-
" if (!isa_ptr || !gdb_class_getClass(*isa_ptr)) \n"
277-
" abort(); \n"
278-
"} \n",
271+
"extern \"C\" int gdb_class_getClass(void *); \n"
272+
"extern \"C\" void \n"
273+
"%s(void *$__lldb_arg_obj) \n"
274+
"{ \n"
275+
" void **$isa_ptr = (void **)$__lldb_arg_obj; \n"
276+
" if (!$isa_ptr || !gdb_class_getClass(*$isa_ptr)) \n"
277+
" abort(); \n"
278+
"} \n",
279279
name) < sizeof(buf->contents));
280280
}
281281

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,27 +2857,27 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
28572857
}
28582858

28592859

2860-
// if (is_forward_declaration)
2861-
// {
2862-
// // We have a forward declaration to a type and we need
2863-
// // to try and find a full declaration. We look in the
2864-
// // current type index just in case we have a forward
2865-
// // declaration followed by an actual declarations in the
2866-
// // DWARF. If this fails, we need to look elsewhere...
2867-
//
2868-
// type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
2869-
//
2870-
// if (!type_sp)
2871-
// {
2872-
// // We weren't able to find a full declaration in
2873-
// // this DWARF, see if we have a declaration anywhere
2874-
// // else...
2875-
// if (m_debug_map_symfile)
2876-
// type_sp = m_debug_map_symfile->FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
2877-
// }
2878-
// if (type_sp)
2879-
// return type_sp;
2880-
// }
2860+
if (is_forward_declaration)
2861+
{
2862+
// We have a forward declaration to a type and we need
2863+
// to try and find a full declaration. We look in the
2864+
// current type index just in case we have a forward
2865+
// declaration followed by an actual declarations in the
2866+
// DWARF. If this fails, we need to look elsewhere...
2867+
2868+
type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
2869+
2870+
if (!type_sp)
2871+
{
2872+
// We weren't able to find a full declaration in
2873+
// this DWARF, see if we have a declaration anywhere
2874+
// else...
2875+
if (m_debug_map_symfile)
2876+
type_sp = m_debug_map_symfile->FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
2877+
}
2878+
if (type_sp)
2879+
return type_sp;
2880+
}
28812881
assert (tag_decl_kind != -1);
28822882
bool clang_type_was_created = false;
28832883
clang_type = m_forward_decl_die_to_clang_type.lookup (die);

0 commit comments

Comments
 (0)