gdb: add compunit_symtab::add_filetab method
authorSimon Marchi <simon.marchi@efficios.com>
Sat, 20 Nov 2021 01:59:59 +0000 (20:59 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Sun, 6 Feb 2022 20:48:18 +0000 (15:48 -0500)
Add a method to append a filetab/symtab to a compunit_symtab.  There is
a single place where this is done currently, in allocate_symtab.

Change-Id: Ie86c6e34d175728173d1cffdce44acd6cff6c31d

gdb/symfile.c
gdb/symtab.h

index a660422b51e07d2e9d1828eaca6ebba78d66534a..8ec214fb8e65cfd992e1c063117956f582de8093 100644 (file)
@@ -2804,16 +2804,7 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename)
     }
 
   /* Add it to CUST's list of symtabs.  */
-  if (cust->filetabs == NULL)
-    {
-      cust->filetabs = symtab;
-      cust->last_filetab = symtab;
-    }
-  else
-    {
-      cust->last_filetab->next = symtab;
-      cust->last_filetab = symtab;
-    }
+  cust->add_filetab (symtab);
 
   /* Backlink to the containing compunit symtab.  */
   symtab->compunit_symtab = cust;
index f6d787c45c84523bbcf4792db8b0c8fe499cbc5b..3fa4d5f5d0eb611160a541f95ef1ae8d7a9c963e 100644 (file)
@@ -1459,6 +1459,20 @@ struct compunit_symtab
     m_objfile = objfile;
   }
 
+  void add_filetab (symtab *filetab)
+  {
+    if (this->filetabs == nullptr)
+      {
+       this->filetabs = filetab;
+       this->last_filetab = filetab;
+      }
+    else
+      {
+       this->last_filetab->next = filetab;
+       this->last_filetab = filetab;
+      }
+  }
+
   /* Return the primary filetab of the compunit.  */
   symtab *primary_filetab () const;