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 05/14] Change increment_reading_symtab to return a scoped_restore
Date: Sat, 08 Apr 2017 20:23:00 -0000	[thread overview]
Message-ID: <20170408201208.2672-6-tom@tromey.com> (raw)
In-Reply-To: <20170408201208.2672-1-tom@tromey.com>

This changes increment_reading_symtab to return a scoped_resotre, then
fixes up the users.

2017-04-07  Tom Tromey  <tom@tromey.com>

	* symfile.h (increment_reading_symtab): Update type.
	* symfile.c (decrement_reading_symtab): Remove.
	(increment_reading_symtab): Return a scoped_restore_tmpl<int>.
	* psymtab.c (psymtab_to_symtab): Update.
	* dwarf2read.c (dw2_instantiate_symtab): Update.
---
 gdb/ChangeLog    |  8 ++++++++
 gdb/dwarf2read.c |  2 +-
 gdb/psymtab.c    |  3 +--
 gdb/symfile.c    | 15 +++------------
 gdb/symfile.h    |  2 +-
 5 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 296030c..9208eee 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
 2017-04-07  Tom Tromey  <tom@tromey.com>
 
+	* symfile.h (increment_reading_symtab): Update type.
+	* symfile.c (decrement_reading_symtab): Remove.
+	(increment_reading_symtab): Return a scoped_restore_tmpl<int>.
+	* psymtab.c (psymtab_to_symtab): Update.
+	* dwarf2read.c (dw2_instantiate_symtab): Update.
+
+2017-04-07  Tom Tromey  <tom@tromey.com>
+
 	* jit.c (struct jit_reader): Declare separately.  Add constructor
 	and destructor.  Change type of "handle".
 	(loaded_jit_reader): Define separately.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 966e1ee..091d665 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2885,7 +2885,7 @@ dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
   if (!per_cu->v.quick->compunit_symtab)
     {
       struct cleanup *back_to = make_cleanup (free_cached_comp_units, NULL);
-      increment_reading_symtab ();
+      scoped_restore decrementer = increment_reading_symtab ();
       dw2_do_instantiate_symtab (per_cu);
       process_cu_includes ();
       do_cleanups (back_to);
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index bdce8f2..bb482ee 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -770,10 +770,9 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
   /* If it has not yet been read in, read it.  */
   if (!pst->readin)
     {
-      struct cleanup *back_to = increment_reading_symtab ();
+      scoped_restore decrementer = increment_reading_symtab ();
 
       (*pst->read_symtab) (pst, objfile);
-      do_cleanups (back_to);
     }
 
   return pst->compunit_symtab;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 750039d..4d9fe54 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -91,8 +91,6 @@ static void add_symbol_file_command (char *, int);
 
 static const struct sym_fns *find_sym_fns (bfd *);
 
-static void decrement_reading_symtab (void *);
-
 static void overlay_invalidate_all (void);
 
 static void overlay_auto_command (char *, int);
@@ -193,22 +191,15 @@ print_symbol_loading_p (int from_tty, int exec, int full)
 
 int currently_reading_symtab = 0;
 
-static void
-decrement_reading_symtab (void *dummy)
-{
-  currently_reading_symtab--;
-  gdb_assert (currently_reading_symtab >= 0);
-}
-
 /* Increment currently_reading_symtab and return a cleanup that can be
    used to decrement it.  */
 
-struct cleanup *
+scoped_restore_tmpl<int>
 increment_reading_symtab (void)
 {
-  ++currently_reading_symtab;
+  return make_scoped_restore (&currently_reading_symtab,
+			      currently_reading_symtab + 1);
   gdb_assert (currently_reading_symtab > 0);
-  return make_cleanup (decrement_reading_symtab, NULL);
 }
 
 /* Remember the lowest-addressed loadable section we've seen.
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 6066481..ab536e8 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -556,7 +556,7 @@ extern int symfile_map_offsets_to_segments (bfd *,
 struct symfile_segment_data *get_symfile_segment_data (bfd *abfd);
 void free_symfile_segment_data (struct symfile_segment_data *data);
 
-extern struct cleanup *increment_reading_symtab (void);
+extern scoped_restore_tmpl<int> increment_reading_symtab (void);
 
 void expand_symtabs_matching
   (gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
-- 
2.9.3


  parent reply	other threads:[~2017-04-08 20:23 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-08 20:12 [RFA 00/14] miscellaneous C++-ificiation Tom Tromey
2017-04-08 20:12 ` [RFA 06/14] Remove cleanup_iconv Tom Tromey
2017-04-10  3:56   ` Simon Marchi
2017-04-10 23:20     ` Tom Tromey
2017-04-08 20:12 ` [RFA 01/14] Introduce event_location_up Tom Tromey
2017-04-10  1:33   ` Simon Marchi
2017-04-10 23:19     ` Tom Tromey
2017-04-08 20:12 ` [RFA 08/14] Remove some cleanups from gnu-v3-abi.c Tom Tromey
2017-04-10  4:09   ` Simon Marchi
2017-04-10 13:57     ` Tom Tromey
2017-04-08 20:12 ` [RFA 11/14] Use scoped_restore in more places Tom Tromey
2017-04-11  1:48   ` Simon Marchi
2017-04-08 20:12 ` [RFA 03/14] Change find_pcs_for_symtab_line to return a std::vector Tom Tromey
2017-04-10  2:49   ` Simon Marchi
2017-04-08 20:12 ` [RFA 09/14] Remove some cleanups from location.c Tom Tromey
2017-04-10  4:43   ` Simon Marchi
2017-04-08 20:12 ` [RFA 10/14] C++ify mi_parse Tom Tromey
2017-04-11  1:12   ` Simon Marchi
2017-04-08 20:12 ` [RFA 02/14] Introduce command_line_up Tom Tromey
2017-04-10  2:36   ` Simon Marchi
2017-04-10 23:21     ` Tom Tromey
2017-04-08 20:12 ` [RFA 14/14] Use std::vector in compile-loc2c.c Tom Tromey
2017-04-08 20:13 ` [RFA 13/14] Use std::vector in find_instruction_backward Tom Tromey
2017-04-08 20:13 ` [RFA 12/14] Use std::vector in reread_symbols Tom Tromey
2017-04-11  1:59   ` Simon Marchi
2017-04-08 20:13 ` [RFA 04/14] Introduce gdb_dlopen_up Tom Tromey
2017-04-10  3:13   ` Simon Marchi
2017-04-10  9:26   ` Pedro Alves
2017-04-10 23:31     ` Tom Tromey
2017-04-08 20:22 ` [RFA 07/14] Fix up wchar_iterator comment Tom Tromey
2017-04-10  4:05   ` Simon Marchi
2017-04-10 23:29     ` Tom Tromey
2017-04-08 20:23 ` Tom Tromey [this message]
2017-04-10  3:27   ` [RFA 05/14] Change increment_reading_symtab to return a scoped_restore 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=20170408201208.2672-6-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