From patchwork Thu Dec 23 19:46:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 76550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E1F01B70A3 for ; Fri, 24 Dec 2010 06:47:02 +1100 (EST) Received: (qmail 3019 invoked by alias); 23 Dec 2010 19:47:00 -0000 Received: (qmail 3004 invoked by uid 22791); 23 Dec 2010 19:46:56 -0000 X-SWARE-Spam-Status: No, hits=0.4 required=5.0 tests=AWL, BAYES_50, SARE_MONEYTERMS, SARE_SUB_ENC_UTF8, TW_BF, TW_BJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 23 Dec 2010 19:46:51 +0000 Received: from eggs.gnu.org ([140.186.70.92]:35931) by fencepost.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PVr7e-00031C-0n for gcc-patches@gnu.org; Thu, 23 Dec 2010 14:46:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PVr7b-0003Je-0z for gcc-patches@gnu.org; Thu, 23 Dec 2010 14:46:48 -0500 Received: from smtp151.iad.emailsrvr.com ([207.97.245.151]:48211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PVr7a-0003JT-Tz for gcc-patches@gnu.org; Thu, 23 Dec 2010 14:46:42 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp45.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 0DC4990898 for ; Thu, 23 Dec 2010 14:46:42 -0500 (EST) Received: from dynamic10.wm-web.iad.mlsrvr.com (dynamic10.wm-web.iad1a.rsapps.net [192.168.2.217]) by smtp45.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id EE836905DF for ; Thu, 23 Dec 2010 14:46:41 -0500 (EST) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic10.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id CBEF8478807F for ; Thu, 23 Dec 2010 14:46:41 -0500 (EST) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Thu, 23 Dec 2010 20:46:41 +0100 (CET) Date: Thu, 23 Dec 2010 20:46:41 +0100 (CET) Subject: =?UTF-8?Q?libobjc:=20update=20of=20DEBUG=5FPRINTFs?= From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 X-Type: plain Message-ID: <1293133601.833323639@192.168.4.58> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch updates the DEBUG_PRINTFs in two files in libobjc. In particular, removes some irrelevant information (module names, which are no longer generated by the compiler), adds some useful information (explicit name of classes and categories as they are loaded) and adds logs to some more operations (+load and +initialize in particular). DEBUG_PRINTF expands to nothing unless you #define DEBUG 1, which you have to manually #define if you want to debug the runtime. So this patch does nothing other then helping with debugging libobjc. But I had to do some debugging yesterday, and it seems valuable to commit the tidied up debug logs to subversion so that they are available next time I (or someone else) need to debug it. ;-) Committed to trunk. Thanks Index: sendmsg.c =================================================================== --- sendmsg.c (revision 168211) +++ sendmsg.c (working copy) @@ -23,6 +23,9 @@ a copy of the GCC Runtime Library Except see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +/* 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 should be using libffi instead of __builtin_apply @@ -543,6 +546,7 @@ __objc_send_initialize (Class class) if (! CLS_ISINITIALIZED (class)) { + DEBUG_PRINTF ("+initialize: need to initialize class '%s'\n", class->name); CLS_SETINITIALIZED (class); CLS_SETINITIALIZED (class->class_pointer); @@ -579,7 +583,17 @@ __objc_send_initialize (Class class) method_list = method_list->method_next; } 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 re-compute all class links. */ if (! CLS_ISRESOLV (class)) __objc_resolve_class_links (); + + DEBUG_PRINTF ("__objc_install_dispatch_table_for_class (%s)\n", class->name); super = class->super_class; @@ -650,6 +666,8 @@ __objc_update_dispatch_table_for_class ( if (class->dtable == __objc_uninstalled_dtable) return; + DEBUG_PRINTF (" _objc_update_dispatch_table_for_class (%s)\n", class->name); + objc_mutex_lock (__objc_runtime_mutex); arr = class->dtable; Index: init.c =================================================================== --- init.c (revision 168211) +++ init.c (working copy) @@ -24,6 +24,10 @@ a copy of the GCC Runtime Library Except see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +/* 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/error.h" #include "objc/runtime.h" @@ -196,7 +200,7 @@ create_tree_of_subclasses_inherited_from superclass = Nil; 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), (upper ? upper->name : NULL)); @@ -232,7 +236,7 @@ __objc_tree_insert_class (objc_class_tre else if (class == tree->class) { /* `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; } else if (class_superclass_of_class (class) == tree->class) @@ -249,7 +253,7 @@ __objc_tree_insert_class (objc_class_tre the tree. */ 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); return tree; } @@ -261,7 +265,7 @@ __objc_tree_insert_class (objc_class_tre node = objc_calloc (1, sizeof (objc_class_tree)); node->class = class; 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; } else @@ -287,7 +291,7 @@ __objc_tree_insert_class (objc_class_tre since nothing has been changed. */ subclasses->head = __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; } } @@ -299,7 +303,7 @@ __objc_tree_insert_class (objc_class_tre objc_class_tree *new_tree = create_tree_of_subclasses_inherited_from (class, tree->class); 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; } } @@ -414,10 +418,10 @@ __objc_send_load_using_method_list (stru mth->method_imp, mth->method_imp); - DEBUG_PRINTF ("sending +load in class: %s\n", class->name); - /* Call +load. */ + DEBUG_PRINTF (" begin of [%s +load]\n", class->name); (*mth->method_imp) ((id)class, mth->method_name); + DEBUG_PRINTF (" end of [%s +load]\n", class->name); break; } @@ -433,6 +437,7 @@ __objc_send_load (objc_class_tree *tree, Class class = tree->class; 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); } @@ -578,7 +583,7 @@ __objc_exec_class (struct objc_module *m 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. */ init_check_module_version (module); @@ -615,11 +620,13 @@ __objc_exec_class (struct objc_module *m /* Replace referenced selectors from names to SELs. */ 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 information. */ - DEBUG_PRINTF ("gathering selectors from module: %s\n", module->name); for (i = 0; i < symtab->cls_def_cnt; ++i) { Class class = (Class) symtab->defs[i]; @@ -628,7 +635,7 @@ __objc_exec_class (struct objc_module *m /* Make sure we have what we think. */ assert (CLS_ISCLASS (class)); 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 isn't and this crashes the program. */ @@ -653,10 +660,7 @@ __objc_exec_class (struct objc_module *m methods. */ if (class) { - DEBUG_PRINTF ("processing categories from (module,object): %s, %s\n", - module->name, - class->name); - + DEBUG_PRINTF (" installing category '%s (%s)'\n", category->class_name, category->category_name); /* Do instance methods. */ if (category->instance_methods) class_add_method_list (class, category->instance_methods); @@ -678,6 +682,7 @@ __objc_exec_class (struct objc_module *m } 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 found. Save the information. */ unclaimed_categories = list_cons (category, unclaimed_categories); @@ -698,9 +703,7 @@ __objc_exec_class (struct objc_module *m if (class) { - DEBUG_PRINTF ("attaching stored categories to object: %s\n", - class->name); - + DEBUG_PRINTF (" installing (delayed) category '%s (%s)'\n", category->class_name, category->category_name); list_remove_head (cell); if (category->instance_methods) @@ -740,9 +743,14 @@ __objc_exec_class (struct objc_module *m "resolving the class links" at this point, which will setup all the class/superclass pointers. */ 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); + + DEBUG_PRINTF ("__objc_exec_class (%p) - finished processing module...\n\n", module); } /* This function needs to be called with the objc_runtime_mutex @@ -865,6 +873,7 @@ __objc_call_load_callback (struct objc_m if (!objc_hash_is_key_in_hash (duplicate_classes, 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); } } @@ -877,6 +886,8 @@ __objc_call_load_callback (struct objc_m struct objc_category *category = symtab->defs[i + symtab->cls_def_cnt]; 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); } } @@ -924,6 +935,7 @@ __objc_init_class (Class class) { /* The module contains a duplicate class. Remember it so that we will ignore it later. */ + DEBUG_PRINTF (" duplicate class '%s' - will be ignored\n", class->name); objc_hash_add (&duplicate_classes, class, class); return NO; } Index: ChangeLog =================================================================== --- ChangeLog (revision 168211) +++ ChangeLog (working copy) @@ -1,3 +1,18 @@ +2010-12-23 Nicola Pero + + * 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 * Makefile.in (libobjc$(libsuffix).la): Link with -Wc,-shared-libgcc.