* objfiles.c (gdb_bfd_close_or_warn): New.
* corelow.c: Include objfiles.h
(core_close): Use gdb_bfd_close_or_warn.
* elfread.c (build_id_verify): Ditto.
* exec.c (exec_close, exec_close_1): Ditto.
+2010-04-14 Pedro Alves <pedro@codesourcery.com>
+
+ * objfiles.h (gdb_bfd_close_or_warn): Declare.
+ * objfiles.c (gdb_bfd_close_or_warn): New.
+ * corelow.c: Include objfiles.h
+ (core_close): Use gdb_bfd_close_or_warn.
+ * elfread.c (build_id_verify): Ditto.
+ * exec.c (exec_close, exec_close_1): Ditto.
+
2010-04-14 Daniel Jacobowitz <dan@codesourcery.com>
Pedro Alves <pedro@codesourcery.com>
#include "solib.h"
#include "filenames.h"
#include "progspace.h"
+#include "objfiles.h"
#ifndef O_LARGEFILE
core_has_fake_pid = 0;
name = bfd_get_filename (core_bfd);
- if (!bfd_close (core_bfd))
- warning (_("cannot close \"%s\": %s"),
- name, bfd_errmsg (bfd_get_error ()));
+ gdb_bfd_close_or_warn (core_bfd);
xfree (name);
core_bfd = NULL;
}
else
retval = 1;
- if (!bfd_close (abfd))
- warning (_("cannot close \"%s\": %s"), filename,
- bfd_errmsg (bfd_get_error ()));
+ gdb_bfd_close_or_warn (abfd);
xfree (found);
bfd *abfd = exec_bfd;
char *name = bfd_get_filename (abfd);
- if (!bfd_close (abfd))
- warning (_("cannot close \"%s\": %s"),
- name, bfd_errmsg (bfd_get_error ()));
+ gdb_bfd_close_or_warn (abfd);
xfree (name);
/* Removing target sections may close the exec_ops target.
}
else if (vp->bfd != exec_bfd)
/* FIXME-leak: We should be freeing vp->name too, I think. */
- if (!bfd_close (vp->bfd))
- warning (_("cannot close \"%s\": %s"),
- vp->name, bfd_errmsg (bfd_get_error ()));
+ gdb_bfd_close_or_warn (vp->bfd);
xfree (vp);
}
get_objfile_pspace_data (current_program_space)->objfiles_changed_p = 1;
}
+/* Close ABFD, and warn if that fails. */
+
+int
+gdb_bfd_close_or_warn (struct bfd *abfd)
+{
+ int ret;
+ char *name = bfd_get_filename (abfd);
+
+ ret = bfd_close (abfd);
+
+ if (!ret)
+ warning (_("cannot close \"%s\": %s"),
+ name, bfd_errmsg (bfd_get_error ()));
+
+ return ret;
+}
+
/* Add reference to ABFD. Returns ABFD. */
struct bfd *
gdb_bfd_ref (struct bfd *abfd)
bfd_usrdata (abfd) = NULL; /* Paranoia. */
name = bfd_get_filename (abfd);
- if (!bfd_close (abfd))
- warning (_("cannot close \"%s\": %s"),
- name, bfd_errmsg (bfd_get_error ()));
+ gdb_bfd_close_or_warn (abfd);
xfree (name);
}
extern struct bfd *gdb_bfd_ref (struct bfd *abfd);
extern void gdb_bfd_unref (struct bfd *abfd);
+extern int gdb_bfd_close_or_warn (struct bfd *abfd);
\f
/* Traverse all object files in the current program space.