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] Use std::string in reopen_exec_file


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

commit 0638b7f90293ac01233dc6406e4c9d5da0ed9e24
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Aug 14 00:18:06 2017 -0600

    Use std::string in reopen_exec_file
    
    This changes reopen_exec_file to use a std::string, removing a
    cleanup.
    
    ChangeLog
    2017-09-03  Tom Tromey  <tom@tromey.com>
    
    	* corefile.c (reopen_exec_file): Use std::string.

Diff:
---
 gdb/ChangeLog  |  4 ++++
 gdb/corefile.c | 11 +++--------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6e4f394..1a688df 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2017-09-03  Tom Tromey  <tom@tromey.com>
 
+	* corefile.c (reopen_exec_file): Use std::string.
+
+2017-09-03  Tom Tromey  <tom@tromey.com>
+
 	* compile/compile.c (compile_register_name_mangled): Return
 	std::string.
 	* compile/compile-loc2c.c (pushf_register_address): Update.
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 5631347..0996f9c 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -130,29 +130,24 @@ specify_exec_file_hook (void (*hook) (const char *))
 void
 reopen_exec_file (void)
 {
-  char *filename;
   int res;
   struct stat st;
-  struct cleanup *cleanups;
 
   /* Don't do anything if there isn't an exec file.  */
   if (exec_bfd == NULL)
     return;
 
   /* If the timestamp of the exec file has changed, reopen it.  */
-  filename = xstrdup (bfd_get_filename (exec_bfd));
-  cleanups = make_cleanup (xfree, filename);
-  res = stat (filename, &st);
+  std::string filename = bfd_get_filename (exec_bfd);
+  res = stat (filename.c_str (), &st);
 
   if (res == 0 && exec_bfd_mtime && exec_bfd_mtime != st.st_mtime)
-    exec_file_attach (filename, 0);
+    exec_file_attach (filename.c_str (), 0);
   else
     /* If we accessed the file since last opening it, close it now;
        this stops GDB from holding the executable open after it
        exits.  */
     bfd_cache_close_all ();
-
-  do_cleanups (cleanups);
 }
 
 /* If we have both a core file and an exec file,


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