]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: small cleanups in dwarf2_psymtab constructors
authorSimon Marchi <simon.marchi@polymtl.ca>
Tue, 7 Apr 2020 15:48:46 +0000 (11:48 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 7 Apr 2020 15:48:46 +0000 (11:48 -0400)
I noticed that only one of the two dwarf2_psymtab constructors are
actually used.  The one that is used accepts an `addr` parameter (the
base text offset), but its sole caller passes a constant, 0.  We want to
keep calling the three-arguments standard_psymtab constructor form,
however, since it differs from the two-arguments form in subtle ways.

Also, I believe the dwarf2_per_cu_data associated to the created
dwarf2_psymtab should be passed as a constructor argument.  That will
help me in a future patchset, to convince myself that the `per_cu_data`
field can't be NULL.

So this patch:

- Removes the two-parameters constructor of dwarf2_psymtab, as it is
  unused.
- Removes the `addr` parameter of the remaining constructor, passing 0
  directly to the base class' constructor.
- Adds a `per_cu` parameter, to assign the `per_cu_data` field at
  construction.

gdb/ChangeLog:

* dwarf2/read.h (struct dwarf2_psymtab): Remove two-parameters
constructor.  Remove `addr` parameter from other constructor and
add `per_cu` parameter.
* dwarf2/read.c (create_partial_symtab): Update.

gdb/ChangeLog
gdb/dwarf2/read.c
gdb/dwarf2/read.h

index e24011dbb0900e9a8c54ca386e17b16d72763eac..af53206af4673fc6ac06eaef47ea02ebfd7b0818 100644 (file)
@@ -1,3 +1,10 @@
+2020-04-07  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * dwarf2/read.h (struct dwarf2_psymtab): Remove two-parameters
+       constructor.  Remove `addr` parameter from other constructor and
+       add `per_cu` parameter.
+       * dwarf2/read.c (create_partial_symtab): Update.
+
 2020-04-07  Tom de Vries  <tdevries@suse.de>
 
        PR symtab/25796
index 61e288ab83aeede676bbc6e4e8863191b1dd64c1..1e593b390652683be2f00b6c1d1f5ea47ce7fd4e 100644 (file)
@@ -7161,12 +7161,11 @@ create_partial_symtab (struct dwarf2_per_cu_data *per_cu, const char *name)
   struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
   dwarf2_psymtab *pst;
 
-  pst = new dwarf2_psymtab (name, objfile, 0);
+  pst = new dwarf2_psymtab (name, objfile, per_cu);
 
   pst->psymtabs_addrmap_supported = true;
 
   /* This is the glue that links PST into GDB's symbol API.  */
-  pst->per_cu_data = per_cu;
   per_cu->v.psymtab = pst;
 
   return pst;
index 039113f87e992c3bb412d2ff3afba66ccdf15997..bd743acc7150583a110cafd7440433b5547f5401 100644 (file)
@@ -253,14 +253,10 @@ dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile);
 /* A partial symtab specialized for DWARF.  */
 struct dwarf2_psymtab : public standard_psymtab
 {
-  dwarf2_psymtab (const char *filename, struct objfile *objfile)
-    : standard_psymtab (filename, objfile)
-  {
-  }
-
   dwarf2_psymtab (const char *filename, struct objfile *objfile,
-                 CORE_ADDR addr)
-    : standard_psymtab (filename, objfile, addr)
+                 dwarf2_per_cu_data *per_cu)
+    : standard_psymtab (filename, objfile, 0),
+      per_cu_data (per_cu)
   {
   }