This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Eliminate quadratic slow-down on number of solibs (part 2).


On Tue, May 12, 2009 at 2:10 AM, Joel Brobecker <brobecker@adacore.com> wrote:

> Looks good to me. If I may, would you mind adding a comment explaining
> *why* you count the number of symbols? I think it can help understanding
> the added code a little bit faster...
>
> ? ?/* If we haven't done so for this objfile yet, count the number
> ? ? ? of objc methods that this objfile defines and save it as a private
> ? ? ? objfile data. ?That way, if have already determined that this
> ? ? ? objfile provides no objc methods, we can skip it entirely. ?*/

I've slightly reworded and added this. Thanks.

> I wonder how well support for ObjC works. It looks like this file hasn't
> really be worked on for a long time... Did you have an objc compiler in
> your path when you did the testing, by any chance?

Yes, I tested with objc-enabled gcc. Here are results from current
CVS Head:

$ grep '\.objc' gdb.sum
Running ../../../gdb/testsuite/gdb.objc/basicclass.exp ...
PASS: gdb.objc/basicclass.exp: successfully compiled objc with posix
threads test case
PASS: gdb.objc/basicclass.exp: deduced language is Objective-C, before
full symbols
PASS: gdb.objc/basicclass.exp: deduced language is Objective-C, after
full symbols
PASS: gdb.objc/basicclass.exp: breakpoint method
PASS: gdb.objc/basicclass.exp: breakpoint method with colon
PASS: gdb.objc/basicclass.exp: breakpoint class method with colon
PASS: gdb.objc/basicclass.exp: continue until method breakpoint
PASS: gdb.objc/basicclass.exp: resetting breakpoints when rerunning
PASS: gdb.objc/basicclass.exp: continue until method breakpoint
PASS: gdb.objc/basicclass.exp: print an ivar of self
PASS: gdb.objc/basicclass.exp: print self
PASS: gdb.objc/basicclass.exp: print contents of self
PASS: gdb.objc/basicclass.exp: breakpoint in category method
PASS: gdb.objc/basicclass.exp: continue until category method
PASS: gdb.objc/basicclass.exp: Call an Objective-C method with no arguments
PASS: gdb.objc/basicclass.exp: Call an Objective-C method with one argument
PASS: gdb.objc/basicclass.exp: Use of the print-object command
PASS: gdb.objc/basicclass.exp: Use of the po (print-object) command
Running ../../../gdb/testsuite/gdb.objc/nondebug.exp ...
PASS: gdb.objc/nondebug.exp: successfully compiled objc with posix
threads test case
KFAIL: gdb.objc/nondebug.exp: break on non-debuggable method (PRMS: gdb/1236)
Running ../../../gdb/testsuite/gdb.objc/objcdecode.exp ...
PASS: gdb.objc/objcdecode.exp: successfully compiled objc with posix
threads test case
PASS: gdb.objc/objcdecode.exp: break on multiply defined method
FAIL: gdb.objc/objcdecode.exp: continue after break on multiply
defined symbol (GDB internal error)

No changes after the patch.

Here is 'diff -w' again:

diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 9b8d801..aa55baf 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -76,6 +76,8 @@ struct objc_method {
   CORE_ADDR imp;
 };

+static const struct objfile_data *objc_objfile_data;
+
 /* Lookup a structure type named "struct NAME", visible in lexical
    block BLOCK.  If NOERR is nonzero, return zero if NAME is not
    suitably defined.  */
@@ -1154,7 +1156,23 @@ find_methods (struct symtab *symtab, char type,
   if (symtab)
     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;

@@ -1187,6 +1205,8 @@ find_methods (struct symtab *symtab, char type,
       if (parse_method (tmp, &ntype, &nclass, &ncategory, &nselector) == NULL)
 	continue;

+	  objfile_csym++;
+
       if ((type != '\0') && (ntype != type))
 	continue;

@@ -1237,6 +1257,16 @@ find_methods (struct symtab *symtab, char type,
 	  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)
     *nsym = csym;
@@ -1792,3 +1822,9 @@ resolve_msgsend_super_stret (CORE_ADDR pc,
CORE_ADDR *new_pc)
     return 1;
   return 0;
 }
+
+void
+_initialize_objc_lang (void)
+{
+  objc_objfile_data = register_objfile_data ();
+}


OK to commit?

Thanks,
-- 
Paul Pluzhnikov

2009-05-12  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.

Attachment: gdb-objc-20090512.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]