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] Remove cleanup in get_return_value


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

commit 0749542484129e77a30f1089d6d671197be5035f
Author: Yao Qi <yao.qi@linaro.org>
Date:   Fri Apr 28 22:48:42 2017 +0100

    Remove cleanup in get_return_value
    
    With regcache ctor, we can use it to create local object in
    get_return_value (), so that the cleanup can be removed.
    
    gdb:
    
    2017-04-28  Yao Qi  <yao.qi@linaro.org>
    
    	* infcmd.c (get_return_value): Use regcache ctor, and remove
    	cleanup.

Diff:
---
 gdb/ChangeLog |  5 +++++
 gdb/infcmd.c  | 14 +++-----------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 29e9cbd..990bfd5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,4 +1,9 @@
 2017-04-28  Yao Qi  <yao.qi@linaro.org>
+
+	* infcmd.c (get_return_value): Use regcache ctor, and remove
+	cleanup.
+
+2017-04-28  Yao Qi  <yao.qi@linaro.org>
 	    Pedro Alves  <palves@redhat.com>
 
 	* regcache.c (regcache::regcache): New tag dispatch ctor.
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 22b2c7a..56da56f 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1604,15 +1604,9 @@ advance_command (char *arg, int from_tty)
 struct value *
 get_return_value (struct value *function, struct type *value_type)
 {
-  struct regcache *stop_regs;
-  struct gdbarch *gdbarch;
+  regcache stop_regs (regcache::readonly, *get_current_regcache ());
+  struct gdbarch *gdbarch = stop_regs.arch ();
   struct value *value;
-  struct cleanup *cleanup;
-
-  stop_regs = regcache_dup (get_current_regcache ());
-  cleanup = make_cleanup_regcache_xfree (stop_regs);
-
-  gdbarch = get_regcache_arch (stop_regs);
 
   value_type = check_typedef (value_type);
   gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID);
@@ -1631,7 +1625,7 @@ get_return_value (struct value *function, struct type *value_type)
     case RETURN_VALUE_ABI_RETURNS_ADDRESS:
     case RETURN_VALUE_ABI_PRESERVES_ADDRESS:
       value = allocate_value (value_type);
-      gdbarch_return_value (gdbarch, function, value_type, stop_regs,
+      gdbarch_return_value (gdbarch, function, value_type, &stop_regs,
 			    value_contents_raw (value), NULL);
       break;
     case RETURN_VALUE_STRUCT_CONVENTION:
@@ -1641,8 +1635,6 @@ get_return_value (struct value *function, struct type *value_type)
       internal_error (__FILE__, __LINE__, _("bad switch"));
     }
 
-  do_cleanups (cleanup);
-
   return value;
 }


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