From: "Doug Evans" <dje@google.com>
To: "GDB Patches" <gdb-patches@sourceware.org>
Subject: [RFA] remove free_contents
Date: Thu, 03 Apr 2008 18:13:00 -0000 [thread overview]
Message-ID: <e394668d0804031054x10bfe737u5b915356f16f0c95@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 767 bytes --]
Hi.
symtab.h contains this:
struct general_symbol_info
{
/* Name of the symbol. This is a required field. Storage for the
name is allocated on the objfile_obstack for the associated
objfile. ... */
char *name;
[...]
#define DEPRECATED_SYMBOL_NAME(symbol) (symbol)->ginfo.name
but symmisc.c does this:
static void
free_symtab_block (struct objfile *objfile, struct block *b)
{
[...]
xfree (DEPRECATED_SYMBOL_NAME (sym));
[...]
}
Either the comment is incomplete (i.e. some names are not allocated
on an objfile_obstack), or the code is wrong (or in this case, outdated).
There's a FIXME that says free_symtab_block is likely never used
and that is the case. free_contents is never used, which
is how free_symtab_block would get called.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gdb-080403-free-contents.patch --]
[-- Type: text/x-patch; name=gdb-080403-free-contents.patch, Size: 3623 bytes --]
2008-04-03 Doug Evans <dje@sebabeach.org>
* symtab.h (enum free_code): Delete free_contents, unused.
* symmisc.c (free_symtab_block): Delete.
(free_symtab, case free_code): Delete.
Index: symmisc.c
===================================================================
RCS file: /cvs/src/src/gdb/symmisc.c,v
retrieving revision 1.48
diff -u -p -r1.48 symmisc.c
--- symmisc.c 17 Mar 2008 15:05:42 -0000 1.48
+++ symmisc.c 3 Apr 2008 17:39:09 -0000
@@ -70,8 +70,6 @@ static int block_depth (struct block *);
static void print_partial_symbols (struct partial_symbol **, int,
char *, struct ui_file *);
-static void free_symtab_block (struct objfile *, struct block *);
-
void _initialize_symmisc (void);
struct print_symbol_args
@@ -82,37 +80,12 @@ struct print_symbol_args
};
static int print_symbol (void *);
-
-static void free_symtab_block (struct objfile *, struct block *);
\f
-
-/* Free a struct block <- B and all the symbols defined in that block. */
-
-/* FIXME: carlton/2003-04-28: I don't believe this is currently ever
- used. */
-
-static void
-free_symtab_block (struct objfile *objfile, struct block *b)
-{
- struct dict_iterator iter;
- struct symbol *sym;
-
- ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- xfree (DEPRECATED_SYMBOL_NAME (sym));
- xfree (sym);
- }
-
- dict_free (BLOCK_DICT (b));
- xfree (b);
-}
-
/* Free all the storage associated with the struct symtab <- S.
- Note that some symtabs have contents malloc'ed structure by structure,
- while some 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).
+ 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
@@ -129,18 +102,6 @@ free_symtab (struct symtab *s)
Therefore, do nothing. */
break;
- case free_contents:
- /* Here all the contents were malloc'ed structure by structure
- and must be freed that way. */
- /* First free the blocks (and their symbols. */
- bv = BLOCKVECTOR (s);
- n = BLOCKVECTOR_NBLOCKS (bv);
- for (i = 0; i < n; i++)
- free_symtab_block (s->objfile, BLOCKVECTOR_BLOCK (bv, i));
- /* Free the blockvector itself. */
- xfree (bv);
- /* Also free the linetable. */
-
case free_linetable:
/* Everything will be freed either by our `free_func'
or by some other symtab, except for our linetable.
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.112
diff -u -p -r1.112 symtab.h
--- symtab.h 5 Feb 2008 22:17:40 -0000 1.112
+++ symtab.h 3 Apr 2008 17:39:10 -0000
@@ -809,7 +809,6 @@ struct symtab
char *dirname;
/* This component says how to free the data we point to:
- free_contents => do a tree walk and free each object.
free_nothing => do nothing; some other symtab will free
the data this one uses.
free_linetable => free just the linetable. FIXME: Is this redundant
@@ -817,7 +816,7 @@ struct symtab
enum free_code
{
- free_nothing, free_contents, free_linetable
+ free_nothing, free_linetable
}
free_code;
next reply other threads:[~2008-04-03 17:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-03 18:13 Doug Evans [this message]
2008-04-03 18:58 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e394668d0804031054x10bfe737u5b915356f16f0c95@mail.gmail.com \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox