* mdebugread.c (psymtab_to_symtab_1): Copy linetable to obstack.
(new_symtab): Don't set `free_code' on symtab. (new_linetable): Properly handle size==0. * symtab.h (struct symtab) <free_code, free_func>: Remove. * symmisc.c (free_symtab): Don't free the linetable. Don't call free_func. * jv-lang.c (struct jv_per_objfile_data): New. (jv_per_objfile_free): Free the data. (get_dynamics_objfile): Allocate a jv_per_objfile_data. (get_java_class_symtab): Set the `dict' field on the jv_per_objfile_data. (free_class_block): Remove. * buildsym.c (end_symtab): Don't set `free_code' or `free_func' on the symtab.
This commit is contained in:
parent
0c2e60193c
commit
30cc903e7c
6 changed files with 57 additions and 73 deletions
|
@ -1,3 +1,20 @@
|
||||||
|
2011-04-04 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* mdebugread.c (psymtab_to_symtab_1): Copy linetable to obstack.
|
||||||
|
(new_symtab): Don't set `free_code' on symtab.
|
||||||
|
(new_linetable): Properly handle size==0.
|
||||||
|
* symtab.h (struct symtab) <free_code, free_func>: Remove.
|
||||||
|
* symmisc.c (free_symtab): Don't free the linetable. Don't call
|
||||||
|
free_func.
|
||||||
|
* jv-lang.c (struct jv_per_objfile_data): New.
|
||||||
|
(jv_per_objfile_free): Free the data.
|
||||||
|
(get_dynamics_objfile): Allocate a jv_per_objfile_data.
|
||||||
|
(get_java_class_symtab): Set the `dict' field on the
|
||||||
|
jv_per_objfile_data.
|
||||||
|
(free_class_block): Remove.
|
||||||
|
* buildsym.c (end_symtab): Don't set `free_code' or `free_func' on
|
||||||
|
the symtab.
|
||||||
|
|
||||||
2011-04-04 Tom Tromey <tromey@redhat.com>
|
2011-04-04 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* symfile.c (reread_symbols): Update.
|
* symfile.c (reread_symbols): Update.
|
||||||
|
|
|
@ -1100,8 +1100,6 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
|
||||||
{
|
{
|
||||||
symtab->dirname = NULL;
|
symtab->dirname = NULL;
|
||||||
}
|
}
|
||||||
symtab->free_code = free_linetable;
|
|
||||||
symtab->free_func = NULL;
|
|
||||||
|
|
||||||
/* Use whatever language we have been using for this
|
/* Use whatever language we have been using for this
|
||||||
subfile, not the one that was deduced in allocate_symtab
|
subfile, not the one that was deduced in allocate_symtab
|
||||||
|
|
|
@ -72,17 +72,30 @@ static struct symtab *class_symtab = NULL;
|
||||||
static struct type *java_link_class_type (struct gdbarch *,
|
static struct type *java_link_class_type (struct gdbarch *,
|
||||||
struct type *, struct value *);
|
struct type *, struct value *);
|
||||||
|
|
||||||
|
/* An instance of this structure is used to store some data that must
|
||||||
|
be freed. */
|
||||||
|
|
||||||
|
struct jv_per_objfile_data
|
||||||
|
{
|
||||||
|
/* The expandable dictionary we use. */
|
||||||
|
struct dictionary *dict;
|
||||||
|
};
|
||||||
|
|
||||||
/* A function called when the dynamics_objfile is freed. We use this
|
/* A function called when the dynamics_objfile is freed. We use this
|
||||||
to clean up some internal state. */
|
to clean up some internal state. */
|
||||||
static void
|
static void
|
||||||
jv_per_objfile_free (struct objfile *objfile, void *ignore)
|
jv_per_objfile_free (struct objfile *objfile, void *data)
|
||||||
{
|
{
|
||||||
|
struct jv_per_objfile_data *jv_data = data;
|
||||||
|
|
||||||
gdb_assert (objfile == dynamics_objfile);
|
gdb_assert (objfile == dynamics_objfile);
|
||||||
/* Clean up all our cached state. These objects are all allocated
|
/* Clean up all our cached state. */
|
||||||
in the dynamics_objfile, so we don't need to actually free
|
|
||||||
anything. */
|
|
||||||
dynamics_objfile = NULL;
|
dynamics_objfile = NULL;
|
||||||
class_symtab = NULL;
|
class_symtab = NULL;
|
||||||
|
|
||||||
|
if (jv_data->dict)
|
||||||
|
dict_free (jv_data->dict);
|
||||||
|
xfree (jv_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: carlton/2003-02-04: This is the main or only caller of
|
/* FIXME: carlton/2003-02-04: This is the main or only caller of
|
||||||
|
@ -96,22 +109,19 @@ get_dynamics_objfile (struct gdbarch *gdbarch)
|
||||||
{
|
{
|
||||||
if (dynamics_objfile == NULL)
|
if (dynamics_objfile == NULL)
|
||||||
{
|
{
|
||||||
|
struct jv_per_objfile_data *data;
|
||||||
|
|
||||||
/* Mark it as shared so that it is cleared when the inferior is
|
/* Mark it as shared so that it is cleared when the inferior is
|
||||||
re-run. */
|
re-run. */
|
||||||
dynamics_objfile = allocate_objfile (NULL, OBJF_SHARED);
|
dynamics_objfile = allocate_objfile (NULL, OBJF_SHARED);
|
||||||
dynamics_objfile->gdbarch = gdbarch;
|
dynamics_objfile->gdbarch = gdbarch;
|
||||||
/* We don't have any data to store, but this lets us get a
|
|
||||||
notification when the objfile is destroyed. Since we have to
|
data = XCNEW (struct jv_per_objfile_data);
|
||||||
store a non-NULL value, we just pick something arbitrary and
|
set_objfile_data (dynamics_objfile, jv_dynamics_objfile_data_key, data);
|
||||||
safe. */
|
|
||||||
set_objfile_data (dynamics_objfile, jv_dynamics_objfile_data_key,
|
|
||||||
&dynamics_objfile);
|
|
||||||
}
|
}
|
||||||
return dynamics_objfile;
|
return dynamics_objfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_class_block (struct symtab *symtab);
|
|
||||||
|
|
||||||
static struct symtab *
|
static struct symtab *
|
||||||
get_java_class_symtab (struct gdbarch *gdbarch)
|
get_java_class_symtab (struct gdbarch *gdbarch)
|
||||||
{
|
{
|
||||||
|
@ -120,6 +130,7 @@ get_java_class_symtab (struct gdbarch *gdbarch)
|
||||||
struct objfile *objfile = get_dynamics_objfile (gdbarch);
|
struct objfile *objfile = get_dynamics_objfile (gdbarch);
|
||||||
struct blockvector *bv;
|
struct blockvector *bv;
|
||||||
struct block *bl;
|
struct block *bl;
|
||||||
|
struct jv_per_objfile_data *jv_data;
|
||||||
|
|
||||||
class_symtab = allocate_symtab ("<java-classes>", objfile);
|
class_symtab = allocate_symtab ("<java-classes>", objfile);
|
||||||
class_symtab->language = language_java;
|
class_symtab->language = language_java;
|
||||||
|
@ -139,7 +150,10 @@ get_java_class_symtab (struct gdbarch *gdbarch)
|
||||||
bl = allocate_block (&objfile->objfile_obstack);
|
bl = allocate_block (&objfile->objfile_obstack);
|
||||||
BLOCK_DICT (bl) = dict_create_hashed_expandable ();
|
BLOCK_DICT (bl) = dict_create_hashed_expandable ();
|
||||||
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
|
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
|
||||||
class_symtab->free_func = free_class_block;
|
|
||||||
|
/* Arrange to free the dict. */
|
||||||
|
jv_data = objfile_data (objfile, jv_dynamics_objfile_data_key);
|
||||||
|
jv_data->dict = BLOCK_DICT (bl);
|
||||||
}
|
}
|
||||||
return class_symtab;
|
return class_symtab;
|
||||||
}
|
}
|
||||||
|
@ -172,16 +186,6 @@ add_class_symbol (struct type *type, CORE_ADDR addr)
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the dynamic symbols block. */
|
|
||||||
static void
|
|
||||||
free_class_block (struct symtab *symtab)
|
|
||||||
{
|
|
||||||
struct blockvector *bv = BLOCKVECTOR (symtab);
|
|
||||||
struct block *bl = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
|
|
||||||
|
|
||||||
dict_free (BLOCK_DICT (bl));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct type *
|
struct type *
|
||||||
java_lookup_class (char *name)
|
java_lookup_class (char *name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4204,7 +4204,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, const char *filename)
|
||||||
{
|
{
|
||||||
/* This symbol table contains ordinary ecoff entries. */
|
/* This symbol table contains ordinary ecoff entries. */
|
||||||
|
|
||||||
int maxlines;
|
int maxlines, size;
|
||||||
EXTR *ext_ptr;
|
EXTR *ext_ptr;
|
||||||
|
|
||||||
if (fh == 0)
|
if (fh == 0)
|
||||||
|
@ -4311,7 +4311,14 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, const char *filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LINETABLE (st) = lines;
|
size = lines->nitems;
|
||||||
|
if (size > 1)
|
||||||
|
--size;
|
||||||
|
LINETABLE (st) = obstack_copy (¤t_objfile->objfile_obstack,
|
||||||
|
lines,
|
||||||
|
(sizeof (struct linetable)
|
||||||
|
+ size * sizeof (lines->item)));
|
||||||
|
xfree (lines);
|
||||||
|
|
||||||
/* .. and our share of externals.
|
/* .. and our share of externals.
|
||||||
XXX use the global list to speed up things here. How?
|
XXX use the global list to speed up things here. How?
|
||||||
|
@ -4763,7 +4770,6 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
|
||||||
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)) =
|
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)) =
|
||||||
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
|
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
|
||||||
|
|
||||||
s->free_code = free_linetable;
|
|
||||||
s->debugformat = "ECOFF";
|
s->debugformat = "ECOFF";
|
||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
@ -4803,7 +4809,9 @@ new_linetable (int size)
|
||||||
{
|
{
|
||||||
struct linetable *l;
|
struct linetable *l;
|
||||||
|
|
||||||
size = (size - 1) * sizeof (l->item) + sizeof (struct linetable);
|
if (size > 1)
|
||||||
|
--size;
|
||||||
|
size = size * sizeof (l->item) + sizeof (struct linetable);
|
||||||
l = (struct linetable *) xmalloc (size);
|
l = (struct linetable *) xmalloc (size);
|
||||||
l->nitems = 0;
|
l->nitems = 0;
|
||||||
return l;
|
return l;
|
||||||
|
|
|
@ -79,37 +79,11 @@ struct print_symbol_args
|
||||||
|
|
||||||
static int print_symbol (void *);
|
static int print_symbol (void *);
|
||||||
|
|
||||||
/* Free all the storage associated with the struct symtab <- S.
|
/* Free all the storage associated with the struct symtab <- S. */
|
||||||
Note that some symtabs have contents that all live inside one big block of
|
|
||||||
memory, and some share the contents of another symbol table and so you
|
|
||||||
should not free the contents on their behalf (except sometimes the
|
|
||||||
linetable, which maybe per symtab even when the rest is not).
|
|
||||||
It is s->free_code that says which alternative to use. */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
free_symtab (struct symtab *s)
|
free_symtab (struct symtab *s)
|
||||||
{
|
{
|
||||||
switch (s->free_code)
|
|
||||||
{
|
|
||||||
case free_nothing:
|
|
||||||
/* All the contents are part of a big block of memory (an obstack),
|
|
||||||
and some other symtab is in charge of freeing that block.
|
|
||||||
Therefore, do nothing. */
|
|
||||||
break;
|
|
||||||
|
|
||||||
case free_linetable:
|
|
||||||
/* Everything will be freed either by our `free_func'
|
|
||||||
or by some other symtab, except for our linetable.
|
|
||||||
Free that now. */
|
|
||||||
if (LINETABLE (s))
|
|
||||||
xfree (LINETABLE (s));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If there is a single block of memory to free, free it. */
|
|
||||||
if (s->free_func != NULL)
|
|
||||||
s->free_func (s);
|
|
||||||
|
|
||||||
/* Free source-related stuff. */
|
/* Free source-related stuff. */
|
||||||
if (s->line_charpos != NULL)
|
if (s->line_charpos != NULL)
|
||||||
xfree (s->line_charpos);
|
xfree (s->line_charpos);
|
||||||
|
|
17
gdb/symtab.h
17
gdb/symtab.h
|
@ -781,23 +781,6 @@ struct symtab
|
||||||
|
|
||||||
char *dirname;
|
char *dirname;
|
||||||
|
|
||||||
/* This component says how to free the data we point to:
|
|
||||||
free_nothing => do nothing; some other symtab will free
|
|
||||||
the data this one uses.
|
|
||||||
free_linetable => free just the linetable. FIXME: Is this redundant
|
|
||||||
with the primary field? */
|
|
||||||
|
|
||||||
enum free_code
|
|
||||||
{
|
|
||||||
free_nothing, free_linetable
|
|
||||||
}
|
|
||||||
free_code;
|
|
||||||
|
|
||||||
/* A function to call to free space, if necessary. This is IN
|
|
||||||
ADDITION to the action indicated by free_code. */
|
|
||||||
|
|
||||||
void (*free_func)(struct symtab *symtab);
|
|
||||||
|
|
||||||
/* Total number of lines found in source file. */
|
/* Total number of lines found in source file. */
|
||||||
|
|
||||||
int nlines;
|
int nlines;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue