aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2010-04-14 17:26:11 +0000
committerPedro Alves <palves@redhat.com>2010-04-14 17:26:11 +0000
commit516ba659387ce98c4ff28b88a7f00f5003cac9eb (patch)
treec896f42701f1bd92109ca4e91a8ad59c2077374d /gdb
parent048d532d6e774418e2e7b40b645b4c249f636aa4 (diff)
downloadgdb-516ba659387ce98c4ff28b88a7f00f5003cac9eb.zip
gdb-516ba659387ce98c4ff28b88a7f00f5003cac9eb.tar.gz
gdb-516ba659387ce98c4ff28b88a7f00f5003cac9eb.tar.bz2
* 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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/corelow.c5
-rw-r--r--gdb/elfread.c4
-rw-r--r--gdb/exec.c8
-rw-r--r--gdb/objfiles.c21
-rw-r--r--gdb/objfiles.h1
6 files changed, 33 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6a6dd9f..7749adf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+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>
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 039573f..ead2377 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -46,6 +46,7 @@
#include "solib.h"
#include "filenames.h"
#include "progspace.h"
+#include "objfiles.h"
#ifndef O_LARGEFILE
@@ -221,9 +222,7 @@ core_close (int quitting)
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;
}
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 38b6208..42a1b73 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -618,9 +618,7 @@ build_id_verify (const char *filename, struct build_id *check)
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);
diff --git a/gdb/exec.c b/gdb/exec.c
index 51b33a5..89511bd 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -101,9 +101,7 @@ exec_close (void)
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.
@@ -141,9 +139,7 @@ exec_close_1 (int quitting)
}
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);
}
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 82ef45c..5be5c6a 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -1471,6 +1471,23 @@ objfiles_changed (void)
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)
@@ -1519,9 +1536,7 @@ gdb_bfd_unref (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);
}
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index df78c6d..76410fd 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -533,6 +533,7 @@ extern void *objfile_data (struct objfile *objfile,
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);
/* Traverse all object files in the current program space.