Introduce partial_symtab::read_symtab method
[binutils-gdb.git] / gdb / ctfread.c
index e3931fbd3e4ed58621ebb1a5f86d615a4b30d37f..120c7b4017a6730b79f2119e14c1b57fd7ced8a7 100644 (file)
@@ -115,6 +115,19 @@ struct ctf_context
   struct buildsym_compunit *builder;
 };
 
+/* A partial symtab, specialized for this module.  */
+struct ctf_psymtab : public partial_symtab
+{
+  ctf_psymtab (const char *filename, struct objfile *objfile, CORE_ADDR addr)
+    : partial_symtab (filename, objfile, addr)
+  {
+  }
+
+  void read_symtab (struct objfile *) override;
+
+  struct ctf_context *context;
+};
+
 /* The routines that read and process fields/members of a C struct, union,
    or enumeration, pass lists of data member fields in an instance of a
    ctf_field_info structure. It is derived from dwarf2read.c.  */
@@ -147,7 +160,7 @@ struct ctf_field_info
 
 /* Local function prototypes */
 
-static void psymtab_to_symtab (struct partial_symtab *);
+static void psymtab_to_symtab (ctf_psymtab *);
 
 static int ctf_add_type_cb (ctf_id_t tid, void *arg);
 
@@ -1171,12 +1184,12 @@ get_objfile_text_range (struct objfile *of, int *tsize)
 /* Start a symtab for OBJFILE in CTF format.  */
 
 static void
-ctf_start_symtab (struct partial_symtab *pst,
+ctf_start_symtab (ctf_psymtab *pst,
                  struct objfile *of, CORE_ADDR text_offset)
 {
   struct ctf_context *ccp;
 
-  ccp = (struct ctf_context *) pst->read_symtab_private;
+  ccp = pst->context;
   ccp->builder = new buildsym_compunit
                       (of, of->original_name, NULL,
                       language_c, text_offset);
@@ -1188,12 +1201,12 @@ ctf_start_symtab (struct partial_symtab *pst,
    the .text section number.  */
 
 static struct compunit_symtab *
-ctf_end_symtab (struct partial_symtab *pst,
+ctf_end_symtab (ctf_psymtab *pst,
                CORE_ADDR end_addr, int section)
 {
   struct ctf_context *ccp;
 
-  ccp = (struct ctf_context *) pst->read_symtab_private;
+  ccp = pst->context;
   struct compunit_symtab *result
     = ccp->builder->end_symtab (end_addr, section);
   delete ccp->builder;
@@ -1204,14 +1217,14 @@ ctf_end_symtab (struct partial_symtab *pst,
 /* Read in full symbols for PST, and anything it depends on.  */
 
 static void
-psymtab_to_symtab (struct partial_symtab *pst)
+psymtab_to_symtab (ctf_psymtab *pst)
 {
   struct symbol *sym;
   struct ctf_context *ccp;
 
   gdb_assert (!pst->readin);
 
-  ccp = (struct ctf_context *) pst->read_symtab_private;
+  ccp = pst->context;
 
   /* Iterate over entries in data types section.  */
   if (ctf_type_iter (ccp->fp, ctf_add_type_cb, ccp) == CTF_ERR)
@@ -1247,31 +1260,31 @@ psymtab_to_symtab (struct partial_symtab *pst)
 /* Expand partial symbol table PST into a full symbol table.
    PST is not NULL.  */
 
-static void
-ctf_read_symtab (struct partial_symtab *pst, struct objfile *objfile)
+void
+ctf_psymtab::read_symtab (struct objfile *objfile)
 {
-  if (pst->readin)
-    warning (_("bug: psymtab for %s is already read in."), pst->filename);
+  if (readin)
+    warning (_("bug: psymtab for %s is already read in."), filename);
   else
     {
       if (info_verbose)
        {
-         printf_filtered (_("Reading in CTF data for %s..."), pst->filename);
+         printf_filtered (_("Reading in CTF data for %s..."), filename);
          gdb_flush (gdb_stdout);
        }
 
       /* Start a symtab.  */
-      CORE_ADDR text_offset;        /* Start of text segment.  */
+      CORE_ADDR offset;        /* Start of text segment.  */
       int tsize;
 
-      text_offset = get_objfile_text_range (objfile, &tsize);
-      ctf_start_symtab (pst, objfile, text_offset);
-      psymtab_to_symtab (pst);
+      offset = get_objfile_text_range (objfile, &tsize);
+      ctf_start_symtab (this, objfile, offset);
+      psymtab_to_symtab (this);
 
-      pst->set_text_low (text_offset);
-      pst->set_text_high (text_offset + tsize);
-      pst->compunit_symtab = ctf_end_symtab (pst, text_offset + tsize,
-                                            SECT_OFF_TEXT (objfile));
+      set_text_low (offset);
+      set_text_high (offset + tsize);
+      compunit_symtab = ctf_end_symtab (this, offset + tsize,
+                                       SECT_OFF_TEXT (objfile));
 
       /* Finish up the debug error message.  */
       if (info_verbose)
@@ -1291,21 +1304,20 @@ ctf_read_symtab (struct partial_symtab *pst, struct objfile *objfile)
    partial_symtab remains around.  They are allocated on an obstack,
    objfile_obstack.  */
 
-static struct partial_symtab *
+static ctf_psymtab *
 create_partial_symtab (const char *name,
                       ctf_file_t *cfp,
                       struct objfile *objfile)
 {
-  struct partial_symtab *pst;
+  ctf_psymtab *pst;
   struct ctf_context *ccx;
 
-  pst = new partial_symtab (name, objfile, 0);
+  pst = new ctf_psymtab (name, objfile, 0);
 
   ccx = XOBNEW (&objfile->objfile_obstack, struct ctf_context);
   ccx->fp = cfp;
   ccx->of = objfile;
-  pst->read_symtab_private = (void *) ccx;
-  pst->read_symtab = ctf_read_symtab;
+  pst->context = ccx;
 
   return pst;
 }
@@ -1393,7 +1405,7 @@ scan_partial_symbols (ctf_file_t *cfp, struct objfile *of)
   struct ctf_context ccx;
   bfd *abfd = of->obfd;
   const char *name = bfd_get_filename (abfd);
-  struct partial_symtab *pst = create_partial_symtab (name, cfp, of);
+  ctf_psymtab *pst = create_partial_symtab (name, cfp, of);
 
   ccx.fp = cfp;
   ccx.of = of;