[RFA,02/15] Remove some unneeded psymtab initializations
Commit Message
allocate_psymtab has long cleared the new psymtab that is returned.
This patch documents this behavior and then removes some redundant
initializations.
gdb/ChangeLog
2018-05-09 Tom Tromey <tom@tromey.com>
* xcoffread.c (xcoff_end_psymtab): Remove some initializations.
* psymtab.c (allocate_psymtab): Add comment.
* psympriv.h (allocate_psymtab): Add comment.
* dwarf2read.c (dwarf2_create_include_psymtab): Remove some
initializations.
* dbxread.c (dbx_end_psymtab): Remove some initializations.
---
gdb/ChangeLog | 9 +++++++++
gdb/dbxread.c | 7 -------
gdb/dwarf2read.c | 6 ------
gdb/psympriv.h | 10 ++++++++--
gdb/psymtab.c | 2 ++
gdb/xcoffread.c | 7 -------
6 files changed, 19 insertions(+), 22 deletions(-)
Comments
Hi Tom,
This LGTM, I just have one comment. I think it can be pushed on its own
too.
On 2018-05-10 18:23, Tom Tromey wrote:
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 8960fdc38d..be477e3d30 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -6517,13 +6517,7 @@ dwarf2_create_include_psymtab (const char
> *name, struct partial_symtab *pst,
> subpst->dependencies[0] = pst;
> subpst->number_of_dependencies = 1;
>
> - subpst->globals_offset = 0;
> - subpst->n_global_syms = 0;
> - subpst->statics_offset = 0;
> - subpst->n_static_syms = 0;
> - subpst->compunit_symtab = NULL;
> subpst->read_symtab = pst->read_symtab;
> - subpst->readin = 0;
Just above this, there is:
subpst->textlow = 0;
subpst->texthigh = 0;
Can they be removed too? Same thing in xcoffread.
Simon
On 2018-07-17 11:27 AM, Simon Marchi wrote:
> Hi Tom,
>
> This LGTM, I just have one comment. I think it can be pushed on its own
> too.
>
> On 2018-05-10 18:23, Tom Tromey wrote:
>> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
>> index 8960fdc38d..be477e3d30 100644
>> --- a/gdb/dwarf2read.c
>> +++ b/gdb/dwarf2read.c
>> @@ -6517,13 +6517,7 @@ dwarf2_create_include_psymtab (const char
>> *name, struct partial_symtab *pst,
>> subpst->dependencies[0] = pst;
>> subpst->number_of_dependencies = 1;
>>
>> - subpst->globals_offset = 0;
>> - subpst->n_global_syms = 0;
>> - subpst->statics_offset = 0;
>> - subpst->n_static_syms = 0;
>> - subpst->compunit_symtab = NULL;
>> subpst->read_symtab = pst->read_symtab;
>> - subpst->readin = 0;
>
> Just above this, there is:
>
> subpst->textlow = 0;
> subpst->texthigh = 0;
>
> Can they be removed too? Same thing in xcoffread.
>
> Simon
>
Ahh, when the series is applied on top of the other psymtab series (as you
mention in the cover letter), these bits are already gone. Sorry about that.
Simon
@@ -2127,13 +2127,6 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
subpst->dependencies[0] = pst;
subpst->number_of_dependencies = 1;
- subpst->globals_offset =
- subpst->n_global_syms =
- subpst->statics_offset =
- subpst->n_static_syms = 0;
-
- subpst->readin = 0;
- subpst->compunit_symtab = 0;
subpst->read_symtab = pst->read_symtab;
}
@@ -6517,13 +6517,7 @@ dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
subpst->dependencies[0] = pst;
subpst->number_of_dependencies = 1;
- subpst->globals_offset = 0;
- subpst->n_global_syms = 0;
- subpst->statics_offset = 0;
- subpst->n_static_syms = 0;
- subpst->compunit_symtab = NULL;
subpst->read_symtab = pst->read_symtab;
- subpst->readin = 0;
/* No private part is necessary for include psymtabs. This property
can be used to differentiate between such include psymtabs and
@@ -295,8 +295,14 @@ extern struct partial_symtab *start_psymtab_common (struct objfile *,
extern void end_psymtab_common (struct objfile *, struct partial_symtab *);
-extern struct partial_symtab *allocate_psymtab (const char *,
- struct objfile *)
+/* Allocate a new partial symbol table associated with OBJFILE.
+ FILENAME (which must be non-NULL) is the filename of this partial
+ symbol table; it is copied into the appropriate storage. A new
+ partial symbol table is returned; aside from "next" and "filename",
+ its fields are initialized to zero. */
+
+extern struct partial_symtab *allocate_psymtab (const char *filename,
+ struct objfile *objfile)
ATTRIBUTE_NONNULL (1);
extern void discard_psymtab (struct objfile *, struct partial_symtab *);
@@ -1740,6 +1740,8 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
objfile->static_psymbols.reserve (total_symbols / 10);
}
+/* See psympriv.h. */
+
struct partial_symtab *
allocate_psymtab (const char *filename, struct objfile *objfile)
{
@@ -2109,13 +2109,6 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
subpst->dependencies[0] = pst;
subpst->number_of_dependencies = 1;
- subpst->globals_offset =
- subpst->n_global_syms =
- subpst->statics_offset =
- subpst->n_static_syms = 0;
-
- subpst->readin = 0;
- subpst->compunit_symtab = NULL;
subpst->read_symtab = pst->read_symtab;
}