2009-05-13 Paul Pluzhnikov <ppluzhnikov@google.com>

* objc-lang.c (objc_objfile_data): New variable.
	(find_methods): Skip objfiles without Obj-C methods.
	(_initialize_objc_lang): New function.
This commit is contained in:
Paul Pluzhnikov 2009-05-13 17:36:24 +00:00
parent 3da9440a2c
commit 57a9e6afe1
2 changed files with 110 additions and 68 deletions

View File

@ -1,3 +1,9 @@
2009-05-13 Paul Pluzhnikov <ppluzhnikov@google.com>
* objc-lang.c (objc_objfile_data): New variable.
(find_methods): Skip objfiles without Obj-C methods.
(_initialize_objc_lang): New function.
2009-05-13 Joel Brobecker <brobecker@adacore.com> 2009-05-13 Joel Brobecker <brobecker@adacore.com>
* c-lang.c (print_wchar): Remove unnecessary cast. * c-lang.c (print_wchar): Remove unnecessary cast.

View File

@ -76,6 +76,8 @@ struct objc_method {
CORE_ADDR imp; CORE_ADDR imp;
}; };
static const struct objfile_data *objc_objfile_data;
/* Lookup a structure type named "struct NAME", visible in lexical /* Lookup a structure type named "struct NAME", visible in lexical
block BLOCK. If NOERR is nonzero, return zero if NAME is not block BLOCK. If NOERR is nonzero, return zero if NAME is not
suitably defined. */ suitably defined. */
@ -1154,7 +1156,23 @@ find_methods (struct symtab *symtab, char type,
if (symtab) if (symtab)
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK); block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
ALL_MSYMBOLS (objfile, msymbol) ALL_OBJFILES (objfile)
{
unsigned int *objc_csym;
/* The objfile_csym variable counts the number of ObjC methods
that this objfile defines. We save that count as a private
objfile data. If we have already determined that this objfile
provides no ObjC methods, we can skip it entirely. */
unsigned int objfile_csym = 0;
objc_csym = objfile_data (objfile, objc_objfile_data);
if (objc_csym != NULL && *objc_csym == 0)
/* There are no ObjC symbols in this objfile. Skip it entirely. */
continue;
ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
{ {
QUIT; QUIT;
@ -1187,6 +1205,8 @@ find_methods (struct symtab *symtab, char type,
if (parse_method (tmp, &ntype, &nclass, &ncategory, &nselector) == NULL) if (parse_method (tmp, &ntype, &nclass, &ncategory, &nselector) == NULL)
continue; continue;
objfile_csym++;
if ((type != '\0') && (ntype != type)) if ((type != '\0') && (ntype != type))
continue; continue;
@ -1237,6 +1257,16 @@ find_methods (struct symtab *symtab, char type,
csym++; csym++;
} }
} }
if (objc_csym == NULL)
{
objc_csym = xmalloc (sizeof (*objc_csym));
*objc_csym = objfile_csym;
set_objfile_data (objfile, objc_objfile_data, objc_csym);
}
else
/* Count of ObjC methods in this objfile should be constant. */
gdb_assert (*objc_csym == objfile_csym);
}
if (nsym != NULL) if (nsym != NULL)
*nsym = csym; *nsym = csym;
@ -1792,3 +1822,9 @@ resolve_msgsend_super_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
return 1; return 1;
return 0; return 0;
} }
void
_initialize_objc_lang (void)
{
objc_objfile_data = register_objfile_data ();
}