This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
[patch] cleanp bfd_close() cleanups
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: [patch] cleanp bfd_close() cleanups
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Tue, 16 May 2000 12:40:18 +1000
- Organization: Cygnus Solutions
Next on the list,
enjoy,
Andrew
Tue May 16 10:54:55 2000 Andrew Cagney <cagney@b1.cygnus.com>
* defs.h (make_cleanup_bfd_close): Add declaration.
* utils.c (do_bfd_close_cleanup, make_cleanup_bfd_close): New
functions.
* symfile.c (generic_load), sparcl-tdep.c (download), remote-udi.c
(download), remote-e7000.c (e7000_load), corelow.c (core_open,
core_file_to_sym_file): Replace calls to make_cleanup.
Index: corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.2
diff -p -r1.2 corelow.c
*** corelow.c 2000/04/27 15:33:01 1.2
--- corelow.c 2000/05/16 02:37:00
*************** core_open (filename, from_tty)
*** 295,301 ****
/* 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 ((make_cleanup_func) bfd_close, temp_bfd);
error ("\"%s\" is not a core dump: %s",
filename, bfd_errmsg (bfd_get_error ()));
}
--- 295,301 ----
/* 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);
error ("\"%s\" is not a core dump: %s",
filename, bfd_errmsg (bfd_get_error ()));
}
*************** core_file_to_sym_file (core)
*** 493,499 ****
/* 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 ((make_cleanup_func) bfd_close, temp_bfd);
error ("\"%s\" is not a core dump: %s",
core, bfd_errmsg (bfd_get_error ()));
}
--- 493,499 ----
/* 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);
error ("\"%s\" is not a core dump: %s",
core, bfd_errmsg (bfd_get_error ()));
}
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.18
diff -p -r1.18 defs.h
*** defs.h 2000/05/15 03:56:30 1.18
--- defs.h 2000/05/16 02:37:02
*************** extern struct cleanup *make_cleanup_free
*** 332,337 ****
--- 332,339 ----
struct ui_file;
extern struct cleanup *make_cleanup_ui_file_delete (struct ui_file *);
+ extern struct cleanup *make_cleanup_bfd_close (bfd *abfd);
+
extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
extern struct cleanup *make_my_cleanup (struct cleanup **,
Index: remote-e7000.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-e7000.c,v
retrieving revision 1.2
diff -p -r1.2 remote-e7000.c
*** remote-e7000.c 2000/02/09 08:52:46 1.2
--- remote-e7000.c 2000/05/16 02:37:09
*************** e7000_load (args, from_tty)
*** 1580,1586 ****
perror_with_name (filename);
return;
}
! old_chain = make_cleanup ((make_cleanup_func) bfd_close, pbfd);
if (!bfd_check_format (pbfd, bfd_object))
error ("\"%s\" is not an object file: %s", filename,
--- 1580,1586 ----
perror_with_name (filename);
return;
}
! old_chain = make_cleanup_bfd_close (pbfd);
if (!bfd_check_format (pbfd, bfd_object))
error ("\"%s\" is not an object file: %s", filename,
Index: remote-udi.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-udi.c,v
retrieving revision 1.2
diff -p -r1.2 remote-udi.c
*** remote-udi.c 2000/02/09 08:52:47 1.2
--- remote-udi.c 2000/05/16 02:37:10
*************** download (load_arg_string, from_tty)
*** 1162,1168 ****
/* 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 ((make_cleanup_func) bfd_close, pbfd);
QUIT;
immediate_quit++;
--- 1162,1168 ----
/* 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 (pbfd);
QUIT;
immediate_quit++;
Index: sparcl-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparcl-tdep.c,v
retrieving revision 1.1.1.6
diff -p -r1.1.1.6 sparcl-tdep.c
*** sparcl-tdep.c 1999/08/31 01:06:04 1.1.1.6
--- sparcl-tdep.c 2000/05/16 02:37:13
*************** download (target_name, args, from_tty, w
*** 614,620 ****
perror_with_name (filename);
return;
}
! old_chain = make_cleanup ((make_cleanup_func) bfd_close, pbfd);
if (!bfd_check_format (pbfd, bfd_object))
error ("\"%s\" is not an object file: %s", filename,
--- 614,620 ----
perror_with_name (filename);
return;
}
! old_chain = make_cleanup_bfd_close (pbfd);
if (!bfd_check_format (pbfd, bfd_object))
error ("\"%s\" is not an object file: %s", filename,
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.8
diff -p -r1.8 symfile.c
*** symfile.c 2000/05/04 16:52:34 1.8
--- symfile.c 2000/05/16 02:37:28
*************** generic_load (char *args, int from_tty)
*** 1230,1236 ****
/* 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 ((make_cleanup_func) bfd_close, loadfile_bfd);
if (!bfd_check_format (loadfile_bfd, bfd_object))
{
--- 1230,1236 ----
/* 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 (loadfile_bfd);
if (!bfd_check_format (loadfile_bfd, bfd_object))
{
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.9
diff -p -r1.9 utils.c
*** utils.c 2000/05/15 03:56:30 1.9
--- utils.c 2000/05/16 02:37:38
*************** make_cleanup_freeargv (arg)
*** 204,209 ****
--- 204,221 ----
}
static void
+ do_bfd_close_cleanup (void *arg)
+ {
+ bfd_close (arg);
+ }
+
+ struct cleanup *
+ make_cleanup_bfd_close (bfd *abfd)
+ {
+ return make_cleanup (do_bfd_close_cleanup, abfd);
+ }
+
+ static void
do_ui_file_delete (void *arg)
{
ui_file_delete (arg);