[PATCH] Rename psymtab_to_symtab to read_symtab

Yao Qi
2013-01-16T15:30:49Z

Hi,
During review the patch, we find it is more clear to either rename
FOO_psymtab_to_symtab to FOO_read_symtab or rename field 'read_symtab'
in 'struct partial_symtab' to 'psymtab_to_symtab'. See the discussion
here <http://sourceware.org/ml/gdb-patches/2013-01/msg00238.html>

This patch renames these functions from FOO_psymtab_to_symtab to
FOO_read_symtab and exchange the order of two arguments. The reasons I
choose this approach (instead of renaming field 'read_symtab' to
'psymtab_to_symtab') are:
1) there is also a field 'read_symtab_private' and we'd better keep
using fields 'read_symtab' and 'read_symtab_private'.
2) these functions are hook methods in "class" 'psymtab', so it is a
little redundant to have 'psymtab' in the name of these functions.

I don't recursively exchange parameters order of helper functions such
as dbx_psymtab_to_symtab_1 and xcoff_psymtab_to_symtab_1.

The patch is tested by rebuilding GDB with enable-all-targets on linux
host.

gdb:

2013-01-15 Yao Qi <yao@codesourcery.com>

* dbxread.c (dbx_psymtab_to_symtab): Delete the declaration.
(dbx_read_symtab): New declaration.
(dbx_psymtab_to_symtab): Delete.
(dbx_read_symtab): Rename from dbx_psymtab_to_symtab.
Rename parameter PST to SELF. Exchanged two parameters.
(start_psymtab): Caller update.
* dwarf2read.c (dwarf2_psymtab_to_symtab): Delete the declaration.
(dwarf2_read_symtab): New declaration.
(dwarf2_psymtab_to_symtab): Delete.
(dwarf2_read_symtab): Rename from dwarf2_psymtab_to_symtab.
Rename parameter PST to SELF. Exchanged two parameters.
(create_partial_symtab): Caller update.
* mdebugread.c (mdebug_psymtab_to_symtab): Delete.
(mdebug_read_symtab): Rename from mdebug_psymtab_to_symtab.
Rename parameter PST to SELF. Exchanged two parameters.
(parse_partial_symbols, new_psymtab): Caller update.
* psympriv.h (struct partial_symtab) <read_symtab>: Exchange
two parameters.
* psymtab.c (psymtab_to_symtab): Caller update.
* xcoffread.c (xcoff_psymtab_to_symtab): Delete.
(xcoff_read_symtab): Rename from xcoff_psymtab_to_symtab.
Rename parameter PST to SELF. Exchanged two parameters.
(xcoff_start_psymtab): Caller update.
---
gdb/dbxread.c | 19 ++++++++++---------
gdb/dwarf2read.c | 19 ++++++++++---------
gdb/mdebugread.c | 16 ++++++++--------
gdb/psympriv.h | 2 +-
gdb/psymtab.c | 2 +-
gdb/xcoffread.c | 18 +++++++++---------
6 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 16496d1..cfd8df6 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -261,7 +261,8 @@ extern void _initialize_dbxread (void);

static void read_ofile_symtab (struct objfile *, struct partial_symtab *);

-static void dbx_psymtab_to_symtab (struct objfile *, struct partial_symtab *);
+static void dbx_read_symtab (struct partial_symtab *self,
+ struct objfile *objfile);

static void dbx_psymtab_to_symtab_1 (struct objfile *, struct partial_symtab *);

@@ -2209,7 +2210,7 @@ start_psymtab (struct objfile *objfile, char *filename, CORE_ADDR textlow,
result->read_symtab_private = obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symloc));
LDSYMOFF (result) = ldsymoff;
- result->read_symtab = dbx_psymtab_to_symtab;
+ result->read_symtab = dbx_read_symtab;
SYMBOL_SIZE (result) = symbol_size;
SYMBOL_OFFSET (result) = symbol_table_offset;
STRING_OFFSET (result) = string_table_offset;
@@ -2452,29 +2453,29 @@ dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
}

/* Read in all of the symbols for a given psymtab for real.
- Be verbose about it if the user wants that. PST is not NULL. */
+ Be verbose about it if the user wants that. SELF is not NULL. */

static void
-dbx_psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
+dbx_read_symtab (struct partial_symtab *self, struct objfile *objfile)
{
bfd *sym_bfd;
struct cleanup *back_to = NULL;

- if (pst->readin)
+ if (self->readin)
{
fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. "
"Shouldn't happen.\n",
- pst->filename);
+ self->filename);
return;
}

- if (LDSYMLEN (pst) || pst->number_of_dependencies)
+ if (LDSYMLEN (self) || self->number_of_dependencies)
{
/* Print the message now, before reading the string table,
to avoid disconcerting pauses. */
if (info_verbose)
{
- printf_filtered ("Reading in symbols for %s...", pst->filename);
+ printf_filtered ("Reading in symbols for %s...", self->filename);
gdb_flush (gdb_stdout);
}

@@ -2494,7 +2495,7 @@ dbx_psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
(void *) &stabs_data);
}

- dbx_psymtab_to_symtab_1 (objfile, pst);
+ dbx_psymtab_to_symtab_1 (objfile, self);

if (back_to)
do_cleanups (back_to);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 519eee8..6f63472 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1284,8 +1284,8 @@ static void add_partial_subprogram (struct partial_die_info *pdi,
CORE_ADDR *lowpc, CORE_ADDR *highpc,
int need_pc, struct dwarf2_cu *cu);

-static void dwarf2_psymtab_to_symtab (struct objfile *,
- struct partial_symtab *);
+static void dwarf2_read_symtab (struct partial_symtab *,
+ struct objfile *);

static void psymtab_to_symtab_1 (struct partial_symtab *);

@@ -4890,7 +4890,7 @@ create_partial_symtab (struct dwarf2_per_cu_data *per_cu, const char *name)

/* This is the glue that links PST into GDB's symbol API. */
pst->read_symtab_private = per_cu;
- pst->read_symtab = dwarf2_psymtab_to_symtab;
+ pst->read_symtab = dwarf2_read_symtab;
per_cu->v.psymtab = pst;

return pst;
@@ -6418,23 +6418,24 @@ locate_pdi_sibling (const struct die_reader_specs *reader,
return skip_children (reader, info_ptr);
}

-/* Expand this partial symbol table into a full symbol table. PST is
+/* Expand this partial symbol table into a full symbol table. SELF is
not NULL. */

static void
-dwarf2_psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
+dwarf2_read_symtab (struct partial_symtab *self,
+ struct objfile *objfile)
{
- if (pst->readin)
+ if (self->readin)
{
warning (_("bug: psymtab for %s is already read in."),
- pst->filename);
+ self->filename);
}
else
{
if (info_verbose)
{
printf_filtered (_("Reading in symbols for %s..."),
- pst->filename);
+ self->filename);
gdb_flush (gdb_stdout);
}

@@ -6457,7 +6458,7 @@ dwarf2_psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)

dwarf2_per_objfile->reading_partial_symbols = 0;

- psymtab_to_symtab_1 (pst);
+ psymtab_to_symtab_1 (self);

/* Finish up the debug error message. */
if (info_verbose)
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 2eb0536..79644be 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -270,23 +270,23 @@ static void handle_psymbol_enumerators (struct objfile *, FDR *, int,

static char *mdebug_next_symbol_text (struct objfile *);
\f
-/* Exported procedure: Builds a symtab from the PST partial one.
- Restores the environment in effect when PST was created, delegates
+/* Exported procedure: Builds a symtab from the partial symtab SELF.
+ Restores the environment in effect when SELF was created, delegates
most of the work to an ancillary procedure, and sorts
- and reorders the symtab list at the end. PST is not NULL. */
+ and reorders the symtab list at the end. SELF is not NULL. */

static void
-mdebug_psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
+mdebug_read_symtab (struct partial_symtab *self, struct objfile *objfile)
{
if (info_verbose)
{
- printf_filtered (_("Reading in symbols for %s..."), pst->filename);
+ printf_filtered (_("Reading in symbols for %s..."), self->filename);
gdb_flush (gdb_stdout);
}

next_symbol_text_func = mdebug_next_symbol_text;

- psymtab_to_symtab_1 (objfile, pst, pst->filename);
+ psymtab_to_symtab_1 (objfile, self, self->filename);

/* Match with global symbols. This only needs to be done once,
after all of the symtabs and dependencies have been read in. */
@@ -2696,7 +2696,7 @@ parse_partial_symbols (struct objfile *objfile)
PENDING_LIST (pst) = pending_list;

/* The way to turn this into a symtab is to call... */
- pst->read_symtab = mdebug_psymtab_to_symtab;
+ pst->read_symtab = mdebug_read_symtab;

/* Set up language for the pst.
The language from the FDR is used if it is unambigious (e.g. cfront
@@ -4796,7 +4796,7 @@ new_psymtab (char *name, struct objfile *objfile)
PENDING_LIST (psymtab) = pending_list;

/* The way to turn this into a symtab is to call... */
- psymtab->read_symtab = mdebug_psymtab_to_symtab;
+ psymtab->read_symtab = mdebug_read_symtab;
return (psymtab);
}

diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 815cc08..cd8d06f 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -196,7 +196,7 @@ struct partial_symtab
/* Pointer to function which will read in the symtab corresponding to
this psymtab. */

- void (*read_symtab) (struct objfile *, struct partial_symtab *);
+ void (*read_symtab) (struct partial_symtab *, struct objfile *);

/* Information that lets read_symtab() locate the part of the symbol table
that this psymtab corresponds to. This information is private to the
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 24aef99..08eff07 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -786,7 +786,7 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
{
struct cleanup *back_to = increment_reading_symtab ();

- (*pst->read_symtab) (objfile, pst);
+ (*pst->read_symtab) (pst, objfile);
do_cleanups (back_to);
}

diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 41aaf02..ce28eb7 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1855,33 +1855,33 @@ xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
}

/* Read in all of the symbols for a given psymtab for real.
- Be verbose about it if the user wants that. PST is not NULL. */
+ Be verbose about it if the user wants that. SELF is not NULL. */

static void
-xcoff_psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
+xcoff_read_symtab (struct partial_symtab *self, struct objfile *objfile)
{
- if (pst->readin)
+ if (self->readin)
{
fprintf_unfiltered
(gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
- pst->filename);
+ self->filename);
return;
}

- if (((struct symloc *) pst->read_symtab_private)->numsyms != 0
- || pst->number_of_dependencies)
+ if (((struct symloc *) self->read_symtab_private)->numsyms != 0
+ || self->number_of_dependencies)
{
/* Print the message now, before reading the string table,
to avoid disconcerting pauses. */
if (info_verbose)
{
- printf_filtered ("Reading in symbols for %s...", pst->filename);
+ printf_filtered ("Reading in symbols for %s...", self->filename);
gdb_flush (gdb_stdout);
}

next_symbol_text_func = xcoff_next_symbol_text;

- xcoff_psymtab_to_symtab_1 (objfile, pst);
+ xcoff_psymtab_to_symtab_1 (objfile, self);

/* Match with global symbols. This only needs to be done once,
after all of the symtabs and dependencies have been read in. */
@@ -2017,7 +2017,7 @@ xcoff_start_psymtab (struct objfile *objfile,
result->read_symtab_private = obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symloc));
((struct symloc *) result->read_symtab_private)->first_symnum = first_symnum;
- result->read_symtab = xcoff_psymtab_to_symtab;
+ result->read_symtab = xcoff_read_symtab;

/* Deduce the source language from the filename for this psymtab. */
psymtab_language = deduce_language_from_filename (filename);
--
1.7.7.6