Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA] Use std::unique_ptr in dwarf2_read_debug_names
Date: Sat, 19 May 2018 16:06:00 -0000	[thread overview]
Message-ID: <20180519152316.18973-1-tom@tromey.com> (raw)

This changes dwarf2_read_debug_names to use std::unique_ptr from the
outset.  This simplifies the code that installs the resulting map into
dwarf2_per_objfile.

Tested by the buildbot.

gdb/ChangeLog
2018-05-19  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (dwarf2_read_debug_names): Use std::unique_ptr.
---
 gdb/ChangeLog    |  4 ++++
 gdb/dwarf2read.c | 17 ++++++++---------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 0690785c5e..9a77502826 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -5603,17 +5603,18 @@ create_cus_from_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
 static bool
 dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile)
 {
-  mapped_debug_names local_map (dwarf2_per_objfile);
+  std::unique_ptr<mapped_debug_names> map
+    (new mapped_debug_names (dwarf2_per_objfile));
   mapped_debug_names dwz_map (dwarf2_per_objfile);
   struct objfile *objfile = dwarf2_per_objfile->objfile;
 
   if (!read_debug_names_from_section (objfile, objfile_name (objfile),
 				      &dwarf2_per_objfile->debug_names,
-				      local_map))
+				      *map))
     return false;
 
   /* Don't use the index if it's empty.  */
-  if (local_map.name_count == 0)
+  if (map->name_count == 0)
     return false;
 
   /* If there is a .dwz file, read it so we can get its CU list as
@@ -5631,9 +5632,9 @@ dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile)
 	}
     }
 
-  create_cus_from_debug_names (dwarf2_per_objfile, local_map, dwz_map);
+  create_cus_from_debug_names (dwarf2_per_objfile, *map, dwz_map);
 
-  if (local_map.tu_count != 0)
+  if (map->tu_count != 0)
     {
       /* We can only handle a single .debug_types when we have an
 	 index.  */
@@ -5644,15 +5645,13 @@ dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile)
 						dwarf2_per_objfile->types, 0);
 
       create_signatured_type_table_from_debug_names
-	(dwarf2_per_objfile, local_map, section, &dwarf2_per_objfile->abbrev);
+	(dwarf2_per_objfile, *map, section, &dwarf2_per_objfile->abbrev);
     }
 
   create_addrmap_from_aranges (dwarf2_per_objfile,
 			       &dwarf2_per_objfile->debug_aranges);
 
-  dwarf2_per_objfile->debug_names_table.reset
-    (new mapped_debug_names (dwarf2_per_objfile));
-  *dwarf2_per_objfile->debug_names_table = std::move (local_map);
+  dwarf2_per_objfile->debug_names_table = std::move (map);
   dwarf2_per_objfile->using_index = 1;
   dwarf2_per_objfile->quick_file_names_table =
     create_quick_file_names_table (dwarf2_per_objfile->all_comp_units.size ());
-- 
2.13.6


             reply	other threads:[~2018-05-19 15:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-19 16:06 Tom Tromey [this message]
2018-05-20 23:59 ` Simon Marchi
2018-05-21 15:52   ` Tom Tromey

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=20180519152316.18973-1-tom@tromey.com \
    --to=tom@tromey.com \
    --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