Commit e99776d8 by Nicola Pero Committed by Nicola Pero

In libobjc/: 2010-12-23 Nicola Pero <nicola.pero@meta-innovation.com>

In libobjc/:
2010-12-23  Nicola Pero  <nicola.pero@meta-innovation.com>

	* init.c (create_tree_of_subclasses_inherited_from): Updated
	DEBUG_PRINTF messages.
	(__objc_tree_insert_class): Same.
	(__objc_send_load_using_method_list): Same.
	(__objc_send_load): Same.
	(__objc_exec_class): Same.  In particular, do not print the module
	name since it is no longer used.
	* sendmsg.c (__objc_send_initialize): Added DEBUG_PRINTFs for
	tracking +initialize calls.
	(__objc_update_dispatch_table_for_class): Added DEBUG_PRINTFs for
	tracking updates of dispatch tables.
	(__objc_install_dispatch_table_for_class): Same.

From-SVN: r168215
parent bd29eba2
2010-12-23 Nicola Pero <nicola.pero@meta-innovation.com>
* init.c (create_tree_of_subclasses_inherited_from): Updated
DEBUG_PRINTF messages.
(__objc_tree_insert_class): Same.
(__objc_send_load_using_method_list): Same.
(__objc_send_load): Same.
(__objc_exec_class): Same. In particular, do not print the module
name since it is no longer used.
* sendmsg.c (__objc_send_initialize): Added DEBUG_PRINTFs for
tracking +initialize calls.
(__objc_update_dispatch_table_for_class): Added DEBUG_PRINTFs for
tracking updates of dispatch tables.
(__objc_install_dispatch_table_for_class): Same.
2010-12-23 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2010-12-23 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* Makefile.in (libobjc$(libsuffix).la): Link with -Wc,-shared-libgcc. * Makefile.in (libobjc$(libsuffix).la): Link with -Wc,-shared-libgcc.
......
...@@ -24,6 +24,10 @@ a copy of the GCC Runtime Library Exception along with this program; ...@@ -24,6 +24,10 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
/* Uncommented the following line to enable debug logging. Use this
only while debugging the runtime. */
/* #define DEBUG 1 */
#include "objc-private/common.h" #include "objc-private/common.h"
#include "objc-private/error.h" #include "objc-private/error.h"
#include "objc/runtime.h" #include "objc/runtime.h"
...@@ -196,7 +200,7 @@ create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper) ...@@ -196,7 +200,7 @@ create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper)
superclass = Nil; superclass = Nil;
DEBUG_PRINTF ("create_tree_of_subclasses_inherited_from:"); DEBUG_PRINTF ("create_tree_of_subclasses_inherited_from:");
DEBUG_PRINTF ("bottom_class = %s, upper = %s\n", DEBUG_PRINTF (" bottom_class = %s, upper = %s\n",
(bottom_class ? bottom_class->name : NULL), (bottom_class ? bottom_class->name : NULL),
(upper ? upper->name : NULL)); (upper ? upper->name : NULL));
...@@ -232,7 +236,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class) ...@@ -232,7 +236,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
else if (class == tree->class) else if (class == tree->class)
{ {
/* `class' has been already inserted. */ /* `class' has been already inserted. */
DEBUG_PRINTF ("1. class %s was previously inserted\n", class->name); DEBUG_PRINTF (" 1. class %s was previously inserted\n", class->name);
return tree; return tree;
} }
else if (class_superclass_of_class (class) == tree->class) else if (class_superclass_of_class (class) == tree->class)
...@@ -249,7 +253,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class) ...@@ -249,7 +253,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
the tree. */ the tree. */
if (((objc_class_tree *) list->head)->class == class) if (((objc_class_tree *) list->head)->class == class)
{ {
DEBUG_PRINTF ("2. class %s was previously inserted\n", DEBUG_PRINTF (" 2. class %s was previously inserted\n",
class->name); class->name);
return tree; return tree;
} }
...@@ -261,7 +265,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class) ...@@ -261,7 +265,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
node = objc_calloc (1, sizeof (objc_class_tree)); node = objc_calloc (1, sizeof (objc_class_tree));
node->class = class; node->class = class;
tree->subclasses = list_cons (node, tree->subclasses); tree->subclasses = list_cons (node, tree->subclasses);
DEBUG_PRINTF ("3. class %s inserted\n", class->name); DEBUG_PRINTF (" 3. class %s inserted\n", class->name);
return tree; return tree;
} }
else else
...@@ -287,7 +291,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class) ...@@ -287,7 +291,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
since nothing has been changed. */ since nothing has been changed. */
subclasses->head subclasses->head
= __objc_tree_insert_class (subclasses->head, class); = __objc_tree_insert_class (subclasses->head, class);
DEBUG_PRINTF ("4. class %s inserted\n", class->name); DEBUG_PRINTF (" 4. class %s inserted\n", class->name);
return tree; return tree;
} }
} }
...@@ -299,7 +303,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class) ...@@ -299,7 +303,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
objc_class_tree *new_tree objc_class_tree *new_tree
= create_tree_of_subclasses_inherited_from (class, tree->class); = create_tree_of_subclasses_inherited_from (class, tree->class);
tree->subclasses = list_cons (new_tree, tree->subclasses); tree->subclasses = list_cons (new_tree, tree->subclasses);
DEBUG_PRINTF ("5. class %s inserted\n", class->name); DEBUG_PRINTF (" 5. class %s inserted\n", class->name);
return tree; return tree;
} }
} }
...@@ -414,10 +418,10 @@ __objc_send_load_using_method_list (struct objc_method_list *method_list, Class ...@@ -414,10 +418,10 @@ __objc_send_load_using_method_list (struct objc_method_list *method_list, Class
mth->method_imp, mth->method_imp,
mth->method_imp); mth->method_imp);
DEBUG_PRINTF ("sending +load in class: %s\n", class->name);
/* Call +load. */ /* Call +load. */
DEBUG_PRINTF (" begin of [%s +load]\n", class->name);
(*mth->method_imp) ((id)class, mth->method_name); (*mth->method_imp) ((id)class, mth->method_name);
DEBUG_PRINTF (" end of [%s +load]\n", class->name);
break; break;
} }
...@@ -433,6 +437,7 @@ __objc_send_load (objc_class_tree *tree, ...@@ -433,6 +437,7 @@ __objc_send_load (objc_class_tree *tree,
Class class = tree->class; Class class = tree->class;
struct objc_method_list *method_list = class->class_pointer->methods; struct objc_method_list *method_list = class->class_pointer->methods;
DEBUG_PRINTF ("+load: need to send load to class '%s'\n", class->name);
__objc_send_load_using_method_list (method_list, class); __objc_send_load_using_method_list (method_list, class);
} }
...@@ -578,7 +583,7 @@ __objc_exec_class (struct objc_module *module) ...@@ -578,7 +583,7 @@ __objc_exec_class (struct objc_module *module)
int i; int i;
DEBUG_PRINTF ("received module: %s\n", module->name); DEBUG_PRINTF ("\n__objc_exec_class (%p) - start processing module...\n", module);
/* Check gcc version. */ /* Check gcc version. */
init_check_module_version (module); init_check_module_version (module);
...@@ -615,11 +620,13 @@ __objc_exec_class (struct objc_module *module) ...@@ -615,11 +620,13 @@ __objc_exec_class (struct objc_module *module)
/* Replace referenced selectors from names to SELs. */ /* Replace referenced selectors from names to SELs. */
if (selectors) if (selectors)
__objc_register_selectors_from_module (selectors); {
DEBUG_PRINTF (" registering selectors\n");
__objc_register_selectors_from_module (selectors);
}
/* Parse the classes in the load module and gather selector /* Parse the classes in the load module and gather selector
information. */ information. */
DEBUG_PRINTF ("gathering selectors from module: %s\n", module->name);
for (i = 0; i < symtab->cls_def_cnt; ++i) for (i = 0; i < symtab->cls_def_cnt; ++i)
{ {
Class class = (Class) symtab->defs[i]; Class class = (Class) symtab->defs[i];
...@@ -628,7 +635,7 @@ __objc_exec_class (struct objc_module *module) ...@@ -628,7 +635,7 @@ __objc_exec_class (struct objc_module *module)
/* Make sure we have what we think. */ /* Make sure we have what we think. */
assert (CLS_ISCLASS (class)); assert (CLS_ISCLASS (class));
assert (CLS_ISMETA (class->class_pointer)); assert (CLS_ISMETA (class->class_pointer));
DEBUG_PRINTF ("phase 1, processing class: %s\n", class->name); DEBUG_PRINTF (" installing class '%s'\n", class->name);
/* Initialize the subclass list to be NULL. In some cases it /* Initialize the subclass list to be NULL. In some cases it
isn't and this crashes the program. */ isn't and this crashes the program. */
...@@ -653,10 +660,7 @@ __objc_exec_class (struct objc_module *module) ...@@ -653,10 +660,7 @@ __objc_exec_class (struct objc_module *module)
methods. */ methods. */
if (class) if (class)
{ {
DEBUG_PRINTF ("processing categories from (module,object): %s, %s\n", DEBUG_PRINTF (" installing category '%s (%s)'\n", category->class_name, category->category_name);
module->name,
class->name);
/* Do instance methods. */ /* Do instance methods. */
if (category->instance_methods) if (category->instance_methods)
class_add_method_list (class, category->instance_methods); class_add_method_list (class, category->instance_methods);
...@@ -678,6 +682,7 @@ __objc_exec_class (struct objc_module *module) ...@@ -678,6 +682,7 @@ __objc_exec_class (struct objc_module *module)
} }
else else
{ {
DEBUG_PRINTF (" delaying installation of category '%s (%s)'\n", category->class_name, category->category_name);
/* The object to which the category methods belong can't be /* The object to which the category methods belong can't be
found. Save the information. */ found. Save the information. */
unclaimed_categories = list_cons (category, unclaimed_categories); unclaimed_categories = list_cons (category, unclaimed_categories);
...@@ -698,9 +703,7 @@ __objc_exec_class (struct objc_module *module) ...@@ -698,9 +703,7 @@ __objc_exec_class (struct objc_module *module)
if (class) if (class)
{ {
DEBUG_PRINTF ("attaching stored categories to object: %s\n", DEBUG_PRINTF (" installing (delayed) category '%s (%s)'\n", category->class_name, category->category_name);
class->name);
list_remove_head (cell); list_remove_head (cell);
if (category->instance_methods) if (category->instance_methods)
...@@ -740,9 +743,14 @@ __objc_exec_class (struct objc_module *module) ...@@ -740,9 +743,14 @@ __objc_exec_class (struct objc_module *module)
"resolving the class links" at this point, which will setup all "resolving the class links" at this point, which will setup all
the class/superclass pointers. */ the class/superclass pointers. */
if (!unresolved_classes && objc_getClass ("Object")) if (!unresolved_classes && objc_getClass ("Object"))
__objc_resolve_class_links (); {
DEBUG_PRINTF (" resolving class links\n");
__objc_resolve_class_links ();
}
objc_mutex_unlock (__objc_runtime_mutex); objc_mutex_unlock (__objc_runtime_mutex);
DEBUG_PRINTF ("__objc_exec_class (%p) - finished processing module...\n\n", module);
} }
/* This function needs to be called with the objc_runtime_mutex /* This function needs to be called with the objc_runtime_mutex
...@@ -865,6 +873,7 @@ __objc_call_load_callback (struct objc_module *module) ...@@ -865,6 +873,7 @@ __objc_call_load_callback (struct objc_module *module)
if (!objc_hash_is_key_in_hash (duplicate_classes, class)) if (!objc_hash_is_key_in_hash (duplicate_classes, class))
{ {
/* Call the _objc_load_callback for this class. */ /* Call the _objc_load_callback for this class. */
DEBUG_PRINTF (" calling the load callback for class '%s'\n", class->name);
_objc_load_callback (class, 0); _objc_load_callback (class, 0);
} }
} }
...@@ -877,6 +886,8 @@ __objc_call_load_callback (struct objc_module *module) ...@@ -877,6 +886,8 @@ __objc_call_load_callback (struct objc_module *module)
struct objc_category *category = symtab->defs[i + symtab->cls_def_cnt]; struct objc_category *category = symtab->defs[i + symtab->cls_def_cnt];
Class class = objc_getClass (category->class_name); Class class = objc_getClass (category->class_name);
DEBUG_PRINTF (" calling the load callback for category '%s (%s)'\n",
category->class_name, category->category_name);
_objc_load_callback (class, category); _objc_load_callback (class, category);
} }
} }
...@@ -924,6 +935,7 @@ __objc_init_class (Class class) ...@@ -924,6 +935,7 @@ __objc_init_class (Class class)
{ {
/* The module contains a duplicate class. Remember it so that /* The module contains a duplicate class. Remember it so that
we will ignore it later. */ we will ignore it later. */
DEBUG_PRINTF (" duplicate class '%s' - will be ignored\n", class->name);
objc_hash_add (&duplicate_classes, class, class); objc_hash_add (&duplicate_classes, class, class);
return NO; return NO;
} }
......
...@@ -23,6 +23,9 @@ a copy of the GCC Runtime Library Exception along with this program; ...@@ -23,6 +23,9 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
/* Uncommented the following line to enable debug logging. Use this
only while debugging the runtime. */
/* #define DEBUG 1 */
/* FIXME: This file has no business including tm.h. */ /* FIXME: This file has no business including tm.h. */
/* FIXME: This should be using libffi instead of __builtin_apply /* FIXME: This should be using libffi instead of __builtin_apply
...@@ -543,6 +546,7 @@ __objc_send_initialize (Class class) ...@@ -543,6 +546,7 @@ __objc_send_initialize (Class class)
if (! CLS_ISINITIALIZED (class)) if (! CLS_ISINITIALIZED (class))
{ {
DEBUG_PRINTF ("+initialize: need to initialize class '%s'\n", class->name);
CLS_SETINITIALIZED (class); CLS_SETINITIALIZED (class);
CLS_SETINITIALIZED (class->class_pointer); CLS_SETINITIALIZED (class->class_pointer);
...@@ -579,7 +583,17 @@ __objc_send_initialize (Class class) ...@@ -579,7 +583,17 @@ __objc_send_initialize (Class class)
method_list = method_list->method_next; method_list = method_list->method_next;
} }
if (imp) if (imp)
(*imp) ((id) class, op); {
DEBUG_PRINTF (" begin of [%s +initialize]\n", class->name);
(*imp) ((id) class, op);
DEBUG_PRINTF (" end of [%s +initialize]\n", class->name);
}
#ifdef DEBUG
else
{
DEBUG_PRINTF (" class '%s' has no +initialize method\n", class->name);
}
#endif
} }
} }
} }
...@@ -621,6 +635,8 @@ __objc_install_dispatch_table_for_class (Class class) ...@@ -621,6 +635,8 @@ __objc_install_dispatch_table_for_class (Class class)
re-compute all class links. */ re-compute all class links. */
if (! CLS_ISRESOLV (class)) if (! CLS_ISRESOLV (class))
__objc_resolve_class_links (); __objc_resolve_class_links ();
DEBUG_PRINTF ("__objc_install_dispatch_table_for_class (%s)\n", class->name);
super = class->super_class; super = class->super_class;
...@@ -650,6 +666,8 @@ __objc_update_dispatch_table_for_class (Class class) ...@@ -650,6 +666,8 @@ __objc_update_dispatch_table_for_class (Class class)
if (class->dtable == __objc_uninstalled_dtable) if (class->dtable == __objc_uninstalled_dtable)
return; return;
DEBUG_PRINTF (" _objc_update_dispatch_table_for_class (%s)\n", class->name);
objc_mutex_lock (__objc_runtime_mutex); objc_mutex_lock (__objc_runtime_mutex);
arr = class->dtable; arr = class->dtable;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment