This is the mail archive of the gdb-patches@sources.redhat.com 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]

[RFA] convert blocks to dictionaries, phase 1, jv-lang.c


This patch does phase 1 of converting blocks to dictionaries in the
file jv-lang.c.  It depends on the patches in
<http://sources.redhat.com/ml/gdb-patches/2002-09/msg00325.html>.

I've run it through the testsuite, but I don't think that the
testsuite really exercises this part of the code at all.  What this
code should be doing is two things:

1) Make sure that the blocks that jv-lang.c creates itself (as opposed
   to blocks created through buildsym.c) have a BLOCK_DICT member
   that's initialized correctly.

2) Make sure that all the code to add symbols to those blocks are
   added via DICT_TEMP_add_block_symbol.  (This should take care of
   resizing the block when necessary.)

David Carlton
carlton@math.stanford.edu

2002-09-16  David Carlton  <carlton@math.stanford.edu>

	* jv-lang.c (get_java_class_symtab): Initialize the BLOCK_DICT of
	the static and global blocks.
	(add_class_symtab_symbol): Add symbol via
	DICT_TEMP_add_block_symbol.
	Delete variable class_symtab_space.

Index: jv-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-lang.c,v
retrieving revision 1.12
diff -u -p -r1.12 jv-lang.c
--- jv-lang.c	11 Jul 2002 20:46:19 -0000	1.12
+++ jv-lang.c	16 Sep 2002 21:00:04 -0000
@@ -85,8 +85,6 @@ static struct symtab *class_symtab = NUL
 
 /* Maximum number of class in class_symtab before relocation is needed. */
 
-static int class_symtab_space;
-
 static struct symtab *
 get_java_class_symtab (void)
 {
@@ -111,15 +109,14 @@ get_java_class_symtab (void)
       BLOCK_END (bl) = 0;
       BLOCK_FUNCTION (bl) = NULL;
       BLOCK_SUPERBLOCK (bl) = NULL;
+      BLOCK_DICT (bl) = DICT_TEMP_create_block (bl);
       BLOCK_GCC_COMPILED (bl) = 0;
       BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl;
 
       /* Allocate GLOBAL_BLOCK.  This has to be relocatable. */
-      class_symtab_space = 128;
-      bl = xmmalloc (objfile->md,
-		     sizeof (struct block)
-		     + ((class_symtab_space - 1) * sizeof (struct symbol *)));
+      bl = xmmalloc (objfile->md, sizeof (struct block));
       *bl = *BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+      BLOCK_DICT (bl) = DICT_TEMP_create_block_expandable (bl);
       BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
       class_symtab->free_ptr = (char *) bl;
     }
@@ -132,19 +129,8 @@ add_class_symtab_symbol (struct symbol *
   struct symtab *symtab = get_java_class_symtab ();
   struct blockvector *bv = BLOCKVECTOR (symtab);
   struct block *bl = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-  if (BLOCK_NSYMS (bl) >= class_symtab_space)
-    {
-      /* Need to re-allocate. */
-      class_symtab_space *= 2;
-      bl = xmrealloc (symtab->objfile->md, bl,
-		      sizeof (struct block)
-		      + ((class_symtab_space - 1) * sizeof (struct symbol *)));
-      class_symtab->free_ptr = (char *) bl;
-      BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
-    }
-
-  BLOCK_SYM (bl, BLOCK_NSYMS (bl)) = sym;
-  BLOCK_NSYMS (bl) = BLOCK_NSYMS (bl) + 1;
+  BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)
+    = DICT_TEMP_add_block_symbol (BLOCK_DICT (bl), sym);
 }
 
 static struct symbol *add_class_symbol (struct type *type, CORE_ADDR addr);


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