This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Make save_infcall_*_state return unique pointers


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cb5248409d7a5a10748c2aa70824ecddf2f913d5

commit cb5248409d7a5a10748c2aa70824ecddf2f913d5
Author: Tom Tromey <tom@tromey.com>
Date:   Wed Jul 11 13:29:59 2018 -0600

    Make save_infcall_*_state return unique pointers
    
    Simon pointed out that save_infcall_suspend_state and
    save_infcall_control_state could return unique pointers.  This patch
    implements this idea.
    
    gdb/ChangeLog
    2018-09-17  Tom Tromey  <tom@tromey.com>
    
    	* infrun.c (save_infcall_suspend_state): Return
    	infcall_suspend_state_up.
    	(save_infcall_control_state): Return infcall_control_state_up.
    	* inferior.h (save_infcall_suspend_state)
    	(save_infcall_control_state): Declare later.  Return unique
    	pointers.

Diff:
---
 gdb/ChangeLog  |  9 +++++++++
 gdb/inferior.h |  7 ++++---
 gdb/infrun.c   | 13 ++++++-------
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cfb3e7b..351dc2d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
 2018-09-17  Tom Tromey  <tom@tromey.com>
 
+	* infrun.c (save_infcall_suspend_state): Return
+	infcall_suspend_state_up.
+	(save_infcall_control_state): Return infcall_control_state_up.
+	* inferior.h (save_infcall_suspend_state)
+	(save_infcall_control_state): Declare later.  Return unique
+	pointers.
+
+2018-09-17  Tom Tromey  <tom@tromey.com>
+
 	* infrun.c (struct stop_context): Declare constructor,
 	destructor, "changed" method.
 	(stop_context::stop_context): Rename from save_stop_context.
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 5c8ef33..af5e920 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -57,9 +57,6 @@ struct thread_info;
 struct infcall_suspend_state;
 struct infcall_control_state;
 
-extern struct infcall_suspend_state *save_infcall_suspend_state (void);
-extern struct infcall_control_state *save_infcall_control_state (void);
-
 extern void restore_infcall_suspend_state (struct infcall_suspend_state *);
 extern void restore_infcall_control_state (struct infcall_control_state *);
 
@@ -77,6 +74,8 @@ struct infcall_suspend_state_deleter
 typedef std::unique_ptr<infcall_suspend_state, infcall_suspend_state_deleter>
     infcall_suspend_state_up;
 
+extern infcall_suspend_state_up save_infcall_suspend_state ();
+
 /* A deleter for infcall_control_state that calls
    restore_infcall_control_state.  */
 struct infcall_control_state_deleter
@@ -91,6 +90,8 @@ struct infcall_control_state_deleter
 typedef std::unique_ptr<infcall_control_state, infcall_control_state_deleter>
     infcall_control_state_up;
 
+extern infcall_control_state_up save_infcall_control_state ();
+
 extern void discard_infcall_suspend_state (struct infcall_suspend_state *);
 extern void discard_infcall_control_state (struct infcall_control_state *);
 
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 3c3bb96..f1cd85c 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8813,10 +8813,9 @@ struct infcall_suspend_state
   gdb::unique_xmalloc_ptr<gdb_byte> siginfo_data;
 };
 
-struct infcall_suspend_state *
-save_infcall_suspend_state (void)
+infcall_suspend_state_up
+save_infcall_suspend_state ()
 {
-  struct infcall_suspend_state *inf_state;
   struct thread_info *tp = inferior_thread ();
   struct regcache *regcache = get_current_regcache ();
   struct gdbarch *gdbarch = regcache->arch ();
@@ -8837,7 +8836,7 @@ save_infcall_suspend_state (void)
 	}
     }
 
-  inf_state = new struct infcall_suspend_state;
+  infcall_suspend_state_up inf_state (new struct infcall_suspend_state);
 
   if (siginfo_data)
     {
@@ -8917,10 +8916,10 @@ struct infcall_control_state
 /* Save all of the information associated with the inferior<==>gdb
    connection.  */
 
-struct infcall_control_state *
-save_infcall_control_state (void)
+infcall_control_state_up
+save_infcall_control_state ()
 {
-  struct infcall_control_state *inf_status = new struct infcall_control_state;
+  infcall_control_state_up inf_status (new struct infcall_control_state);
   struct thread_info *tp = inferior_thread ();
   struct inferior *inf = current_inferior ();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]