Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 3/5] Remove some usages of get_dwarf2_per_objfile
Date: Sun, 01 Apr 2018 00:04:00 -0000	[thread overview]
Message-ID: <20180401000444.13490-4-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20180401000444.13490-1-simon.marchi@polymtl.ca>

This patch removes some usages of get_dwarf2_per_objfile, where we can
get hold of the dwarf2_per_objfile object in a simpler way.  For
example, it's simpler (and slightly less work) to pass
dwarf2_per_objfile and get the objfile from it than to pass the objfile
and call get_dwarf2_per_objfile.

Ideally, get_dwarf2_per_objfile should only be used in the entry points
of the dwarf2 code, where we receive an objfile.

gdb/ChangeLog:

	* dwarf2read.c (create_cus_from_index_list): Replace objfile arg
	with dwarf2_per_objfile.
	(create_cus_from_index): Likewise.
	(create_signatured_type_table_from_index): Likewise.
	(dwarf2_read_index): Likewise.
	(dwarf2_initialize_objfile): Likewise.
	(dwarf2_fetch_die_loc_sect_off):  Get dwarf2_per_objfile from
	per_cu rather than get_dwarf2_per_objfile.
---
 gdb/dwarf2read.c | 60 +++++++++++++++++++++++---------------------------------
 1 file changed, 25 insertions(+), 35 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 695799e96f4f..9b77fcfda179 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2978,17 +2978,13 @@ create_cu_from_index_list (struct dwarf2_per_objfile *dwarf2_per_objfile,
    CUs.  */
 
 static void
-create_cus_from_index_list (struct objfile *objfile,
+create_cus_from_index_list (struct dwarf2_per_objfile *dwarf2_per_objfile,
 			    const gdb_byte *cu_list, offset_type n_elements,
 			    struct dwarf2_section_info *section,
 			    int is_dwz,
 			    int base_offset)
 {
-  offset_type i;
-  struct dwarf2_per_objfile *dwarf2_per_objfile
-    = get_dwarf2_per_objfile (objfile);
-
-  for (i = 0; i < n_elements; i += 2)
+  for (offset_type i = 0; i < n_elements; i += 2)
     {
       gdb_static_assert (sizeof (ULONGEST) >= 8);
 
@@ -3007,42 +3003,38 @@ create_cus_from_index_list (struct objfile *objfile,
    the CU objects for this objfile.  */
 
 static void
-create_cus_from_index (struct objfile *objfile,
+create_cus_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
 		       const gdb_byte *cu_list, offset_type cu_list_elements,
 		       const gdb_byte *dwz_list, offset_type dwz_elements)
 {
-  struct dwz_file *dwz;
-  struct dwarf2_per_objfile *dwarf2_per_objfile
-    = get_dwarf2_per_objfile (objfile);
+  struct objfile *objfile = dwarf2_per_objfile->objfile;
 
   dwarf2_per_objfile->n_comp_units = (cu_list_elements + dwz_elements) / 2;
   dwarf2_per_objfile->all_comp_units =
     XOBNEWVEC (&objfile->objfile_obstack, struct dwarf2_per_cu_data *,
 	       dwarf2_per_objfile->n_comp_units);
 
-  create_cus_from_index_list (objfile, cu_list, cu_list_elements,
+  create_cus_from_index_list (dwarf2_per_objfile, cu_list, cu_list_elements,
 			      &dwarf2_per_objfile->info, 0, 0);
 
   if (dwz_elements == 0)
     return;
 
-  dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
-  create_cus_from_index_list (objfile, dwz_list, dwz_elements, &dwz->info, 1,
-			      cu_list_elements / 2);
+  dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
+  create_cus_from_index_list (dwarf2_per_objfile, dwz_list, dwz_elements,
+			      &dwz->info, 1, cu_list_elements / 2);
 }
 
 /* Create the signatured type hash table from the index.  */
 
 static void
-create_signatured_type_table_from_index (struct objfile *objfile,
-					 struct dwarf2_section_info *section,
-					 const gdb_byte *bytes,
-					 offset_type elements)
+create_signatured_type_table_from_index
+  (struct dwarf2_per_objfile *dwarf2_per_objfile,
+   struct dwarf2_section_info *section,
+   const gdb_byte *bytes,
+   offset_type elements)
 {
-  offset_type i;
-  htab_t sig_types_hash;
-  struct dwarf2_per_objfile *dwarf2_per_objfile
-    = get_dwarf2_per_objfile (objfile);
+  struct objfile *objfile = dwarf2_per_objfile->objfile;
 
   dwarf2_per_objfile->n_type_units
     = dwarf2_per_objfile->n_allocated_type_units
@@ -3050,9 +3042,9 @@ create_signatured_type_table_from_index (struct objfile *objfile,
   dwarf2_per_objfile->all_type_units =
     XNEWVEC (struct signatured_type *, dwarf2_per_objfile->n_type_units);
 
-  sig_types_hash = allocate_signatured_type_table (objfile);
+  htab_t sig_types_hash = allocate_signatured_type_table (objfile);
 
-  for (i = 0; i < elements; i += 3)
+  for (offset_type i = 0; i < elements; i += 3)
     {
       struct signatured_type *sig_type;
       ULONGEST signature;
@@ -3559,14 +3551,13 @@ to use the section anyway."),
    elements of all the CUs and return 1.  Otherwise, return 0.  */
 
 static int
-dwarf2_read_index (struct objfile *objfile)
+dwarf2_read_index (struct dwarf2_per_objfile *dwarf2_per_objfile)
 {
   struct mapped_index local_map, *map;
   const gdb_byte *cu_list, *types_list, *dwz_list = NULL;
   offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0;
   struct dwz_file *dwz;
-  struct dwarf2_per_objfile *dwarf2_per_objfile
-    = get_dwarf2_per_objfile (objfile);
+  struct objfile *objfile = dwarf2_per_objfile->objfile;
 
   if (!read_index_from_section (objfile, objfile_name (objfile),
 				use_deprecated_index_sections,
@@ -3601,8 +3592,8 @@ dwarf2_read_index (struct objfile *objfile)
 	}
     }
 
-  create_cus_from_index (objfile, cu_list, cu_list_elements, dwz_list,
-			 dwz_list_elements);
+  create_cus_from_index (dwarf2_per_objfile, cu_list, cu_list_elements,
+			 dwz_list, dwz_list_elements);
 
   if (types_list_elements)
     {
@@ -3616,8 +3607,8 @@ dwarf2_read_index (struct objfile *objfile)
       section = VEC_index (dwarf2_section_info_def,
 			   dwarf2_per_objfile->types, 0);
 
-      create_signatured_type_table_from_index (objfile, section, types_list,
-					       types_list_elements);
+      create_signatured_type_table_from_index (dwarf2_per_objfile, section,
+					       types_list, types_list_elements);
     }
 
   create_addrmap_from_index (dwarf2_per_objfile, &local_map);
@@ -6259,7 +6250,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
       return true;
     }
 
-  if (dwarf2_read_index (objfile))
+  if (dwarf2_read_index (dwarf2_per_objfile))
     {
       *index_kind = dw_index_kind::GDB_INDEX;
       return true;
@@ -22927,9 +22918,8 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off,
   struct die_info *die;
   struct attribute *attr;
   struct dwarf2_locexpr_baton retval;
-  struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
-  struct dwarf2_per_objfile *dwarf2_per_objfile
-    = get_dwarf2_per_objfile (objfile);
+  struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
+  struct objfile *objfile = dwarf2_per_objfile->objfile;
 
   if (per_cu->cu == NULL)
     load_cu (per_cu);
-- 
2.16.3


  parent reply	other threads:[~2018-04-01  0:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-01  0:04 [PATCH 0/5] Random dwarf2read.c improvements Simon Marchi
2018-04-01  0:04 ` [PATCH 4/5] Make dwarf2_per_objfile::all_comp_units an std::vector Simon Marchi
2018-04-01  0:04 ` Simon Marchi [this message]
2018-04-01  0:04 ` [PATCH 1/5] Remove some unused variables in dwarf2read.c Simon Marchi
2018-04-02 16:00   ` Joel Brobecker
2018-04-01  0:16 ` [PATCH 2/5] Replace dw2_get_cu/dw2_get_cutu with methods of dwarf2_per_objfile Simon Marchi
2018-04-02 16:17   ` Joel Brobecker
2018-04-02 17:21     ` Simon Marchi
2018-04-01  0:16 ` [PATCH 5/5] Make dwarf2_per_objfile::all_type_units an std::vector Simon Marchi
2018-04-07 18:01 ` [PATCH 0/5] Random dwarf2read.c improvements Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180401000444.13490-4-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox