This is the mail archive of the gdb-patches@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]

[PATCH 05/12] rename make_cleanup_bfd_close -> make_cleanup_bfd_unref


Now that BFDs are reference counted everywhere in GDB,
make_cleanup_bfd_close is a misnomer -- the cleanup does not
close the BFD, rather it unrefs it.

This patch renames the function.

	* utils.c (make_cleanup_bfd_unref): Rename from
	make_cleanup_bfd_close.
	* defs.h (make_cleanup_bfd_unref): Rename from
	make_cleanup_bfd_close.
	* cli/cli-dump.c (bfd_openr_with_cleanup): Update.
	(bfd_openw_with_cleanup): Update.
	* corelow.c (core_open): Update.
	* dsrec.c (load_srec): Update.
	* m32r-rom.c (m32r_load, m32r_upload_command): Update.
	* remote-m32r-sdi.c (m32r_load): Update.
	* remote-mips.c (mips_load_srec): Update.
	(pmon_load_fast): Update.
	* solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
	Update.
	(darwin_bfd_open): Update.
	* solib.c (solib_bfd_fopen): Update.
	* symfile-mem.c (symbol_file_add_from_memory): Update.
	* symfile.c (symbol_file_add_with_addrs_or_offsets): Update.
	(symfile_bfd_open): Update.
	(generic_load): Update.
---
 gdb/cli/cli-dump.c    |    4 ++--
 gdb/corelow.c         |    2 +-
 gdb/defs.h            |    2 +-
 gdb/dsrec.c           |    2 +-
 gdb/m32r-rom.c        |    4 ++--
 gdb/remote-m32r-sdi.c |    2 +-
 gdb/remote-mips.c     |    4 ++--
 gdb/solib-darwin.c    |    6 +++---
 gdb/solib.c           |    2 +-
 gdb/symfile-mem.c     |    2 +-
 gdb/symfile.c         |    8 ++++----
 gdb/utils.c           |    2 +-
 12 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 7dce32a..1244767 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -117,7 +117,7 @@ bfd_openr_with_cleanup (const char *filename, const char *target)
     error (_("Failed to open %s: %s."), filename, 
 	   bfd_errmsg (bfd_get_error ()));
 
-  make_cleanup_bfd_close (ibfd);
+  make_cleanup_bfd_unref (ibfd);
   if (!bfd_check_format (ibfd, bfd_object))
     error (_("'%s' is not a recognized file format."), filename);
 
@@ -136,7 +136,7 @@ bfd_openw_with_cleanup (const char *filename, const char *target,
       if (obfd == NULL)
 	error (_("Failed to open %s: %s."), filename, 
 	       bfd_errmsg (bfd_get_error ()));
-      make_cleanup_bfd_close (obfd);
+      make_cleanup_bfd_unref (obfd);
       if (!bfd_set_format (obfd, bfd_object))
 	error (_("bfd_openw_with_cleanup: %s."), bfd_errmsg (bfd_get_error ()));
     }
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 1fd60e4..380c0dc 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -333,7 +333,7 @@ core_open (char *filename, int from_tty)
       /* FIXME: should be checking for errors from bfd_close (for one
          thing, on error it does not free all the storage associated
          with the bfd).  */
-      make_cleanup_bfd_close (temp_bfd);
+      make_cleanup_bfd_unref (temp_bfd);
       error (_("\"%s\" is not a core dump: %s"),
 	     filename, bfd_errmsg (bfd_get_error ()));
     }
diff --git a/gdb/defs.h b/gdb/defs.h
index 03092aa..66e1f3a 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -315,7 +315,7 @@ extern struct cleanup *make_cleanup_close (int fd);
 
 extern struct cleanup *make_cleanup_fclose (FILE *file);
 
-extern struct cleanup *make_cleanup_bfd_close (bfd *abfd);
+extern struct cleanup *make_cleanup_bfd_unref (bfd *abfd);
 
 struct obstack;
 extern struct cleanup *make_cleanup_obstack_free (struct obstack *obstack);
diff --git a/gdb/dsrec.c b/gdb/dsrec.c
index 8eefe1e..66d4c13 100644
--- a/gdb/dsrec.c
+++ b/gdb/dsrec.c
@@ -68,7 +68,7 @@ load_srec (struct serial *desc, const char *file, bfd_vma load_offset,
       return;
     }
 
-  cleanup = make_cleanup_bfd_close (abfd);
+  cleanup = make_cleanup_bfd_unref (abfd);
   if (bfd_check_format (abfd, bfd_object) == 0)
     {
       printf_filtered (_("File is not an object file\n"));
diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c
index 9dbcd26..ffda6f9 100644
--- a/gdb/m32r-rom.c
+++ b/gdb/m32r-rom.c
@@ -133,7 +133,7 @@ m32r_load (char *filename, int from_tty)
   abfd = gdb_bfd_ref (bfd_openr (filename, 0));
   if (!abfd)
     error (_("Unable to open file %s."), filename);
-  cleanup = make_cleanup_bfd_close (abfd);
+  cleanup = make_cleanup_bfd_unref (abfd);
   if (bfd_check_format (abfd, bfd_object) == 0)
     error (_("File is not an object file."));
   gettimeofday (&start_time, NULL);
@@ -530,7 +530,7 @@ m32r_upload_command (char *args, int from_tty)
 
   gettimeofday (&end_time, NULL);
   abfd = gdb_bfd_ref (bfd_openr (args, 0));
-  cleanup = make_cleanup_bfd_close (abfd);
+  cleanup = make_cleanup_bfd_unref (abfd);
   if (abfd != NULL)
     {		/* Download is done -- print section statistics.  */
       if (bfd_check_format (abfd, bfd_object) == 0)
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 0536ccf..b4b7324 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1264,7 +1264,7 @@ m32r_load (char *args, int from_tty)
       perror_with_name (filename);
       return;
     }
-  old_chain = make_cleanup_bfd_close (pbfd);
+  old_chain = make_cleanup_bfd_unref (pbfd);
 
   if (!bfd_check_format (pbfd, bfd_object))
     error (_("\"%s\" is not an object file: %s"), filename,
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 5020d2a..b46325f 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -2796,7 +2796,7 @@ mips_load_srec (char *args)
       return;
     }
 
-  cleanup = make_cleanup_bfd_close (abfd);
+  cleanup = make_cleanup_bfd_unref (abfd);
   if (bfd_check_format (abfd, bfd_object) == 0)
     {
       printf_filtered ("File is not an object file\n");
@@ -3382,7 +3382,7 @@ pmon_load_fast (char *file)
       printf_filtered ("Unable to open file %s\n", file);
       return;
     }
-  cleanup = make_cleanup_bfd_close (abfd);
+  cleanup = make_cleanup_bfd_unref (abfd);
 
   if (bfd_check_format (abfd, bfd_object) == 0)
     {
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 8d8da7e..7109ead 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -376,13 +376,13 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
     {
       bfd *sub;
 
-      make_cleanup_bfd_close (dyld_bfd);
+      make_cleanup_bfd_unref (dyld_bfd);
       sub = bfd_mach_o_fat_extract (dyld_bfd, bfd_object,
 				    gdbarch_bfd_arch_info (target_gdbarch));
       if (sub)
 	{
 	  dyld_bfd = gdb_bfd_ref (sub);
-	  make_cleanup_bfd_close (sub);
+	  make_cleanup_bfd_unref (sub);
 	}
       else
 	dyld_bfd = NULL;
@@ -517,7 +517,7 @@ darwin_bfd_open (char *pathname)
 				gdbarch_bfd_arch_info (target_gdbarch));
   if (!res)
     {
-      make_cleanup_bfd_close (abfd);
+      make_cleanup_bfd_unref (abfd);
       error (_("`%s': not a shared-library: %s"),
 	     bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
     }
diff --git a/gdb/solib.c b/gdb/solib.c
index 4ddf91a..0fd955d 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -424,7 +424,7 @@ solib_bfd_open (char *pathname)
   /* Check bfd format.  */
   if (!bfd_check_format (abfd, bfd_object))
     {
-      make_cleanup_bfd_close (abfd);
+      make_cleanup_bfd_unref (abfd);
       error (_("`%s': not in executable format: %s"),
 	     bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
     }
diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c
index 20b8bd1..aa03c33 100644
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -113,7 +113,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
 
   if (!bfd_check_format (nbfd, bfd_object))
     {
-      make_cleanup_bfd_close (nbfd);
+      make_cleanup_bfd_unref (nbfd);
       error (_("Got object file from memory but can't read symbols: %s."),
 	     bfd_errmsg (bfd_get_error ()));
     }
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 6396aec..67c74ee 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1075,7 +1075,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
       add_flags &= ~SYMFILE_NO_READ;
     }
 
-  my_cleanups = make_cleanup_bfd_close (abfd);
+  my_cleanups = make_cleanup_bfd_unref (abfd);
 
   /* Give user a chance to burp if we'd be
      interactively wiping out any existing symbols.  */
@@ -1731,7 +1731,7 @@ symfile_bfd_open (char *name)
 
       if (!bfd_check_format (sym_bfd, bfd_object))
 	{
-	  make_cleanup_bfd_close (sym_bfd);
+	  make_cleanup_bfd_unref (sym_bfd);
 	  error (_("`%s': can't read symbols: %s."), name,
 		 bfd_errmsg (bfd_get_error ()));
 	}
@@ -1775,7 +1775,7 @@ symfile_bfd_open (char *name)
 
   if (!bfd_check_format (sym_bfd, bfd_object))
     {
-      make_cleanup_bfd_close (sym_bfd);
+      make_cleanup_bfd_unref (sym_bfd);
       error (_("`%s': can't read symbols: %s."), name,
 	     bfd_errmsg (bfd_get_error ()));
     }
@@ -2113,7 +2113,7 @@ generic_load (char *args, int from_tty)
       return;
     }
 
-  make_cleanup_bfd_close (loadfile_bfd);
+  make_cleanup_bfd_unref (loadfile_bfd);
 
   if (!bfd_check_format (loadfile_bfd, bfd_object))
     {
diff --git a/gdb/utils.c b/gdb/utils.c
index f8df20e..5c1aa03 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -202,7 +202,7 @@ do_bfd_close_cleanup (void *arg)
 }
 
 struct cleanup *
-make_cleanup_bfd_close (bfd *abfd)
+make_cleanup_bfd_unref (bfd *abfd)
 {
   return make_cleanup (do_bfd_close_cleanup, abfd);
 }
-- 
1.7.7.6


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