aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2015-04-02 13:38:29 +0100
committerGary Benson <gbenson@redhat.com>2015-04-02 13:38:29 +0100
commit97a41605e2473c67e82ef5147b4866768bd5a566 (patch)
tree36d96d8fec42324a62e0f0d94b6a345d740c6ef1 /gdb
parent2938e6cf0809cd81d1593f414ea5836812e68ed2 (diff)
downloadgdb-97a41605e2473c67e82ef5147b4866768bd5a566.zip
gdb-97a41605e2473c67e82ef5147b4866768bd5a566.tar.gz
gdb-97a41605e2473c67e82ef5147b4866768bd5a566.tar.bz2
Rearrange symfile_bfd_open
symfile_bfd_open handled what were remote files as a special case. Converting from "remote:" files to "target:" made symfile_bfd_open look like this: if remote: open bfd, check format, etc return local-specific stuff open bfd, check format, etc return This commit rearranges symfile_bfd_open to remove the duplicated code, like this: if local: local-specific stuff open bfd, check format, etc return gdb/ChangeLog: * symfile.c (symfile_bfd_open): Reorder to remove duplicated checks and error messages.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/symfile.c69
2 files changed, 35 insertions, 39 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9533235..ef04356 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2015-04-02 Gary Benson <gbenson@redhat.com>
+ * symfile.c (symfile_bfd_open): Reorder to remove duplicated
+ checks and error messages.
+
+2015-04-02 Gary Benson <gbenson@redhat.com>
+
* remote.h (REMOTE_SYSROOT_PREFIX): Remove definition.
(remote_filename_p): Remove declaration.
(remote_bfd_open): Likewise.
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 0d8dae7..0c35ffa 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1718,60 +1718,51 @@ set_initial_language (void)
absolute). In case of trouble, error() is called. */
bfd *
-symfile_bfd_open (const char *cname)
+symfile_bfd_open (const char *name)
{
bfd *sym_bfd;
- int desc;
- char *name, *absolute_name;
- struct cleanup *back_to;
+ int desc = -1;
+ struct cleanup *back_to = make_cleanup (null_cleanup, 0);
- if (is_target_filename (cname))
+ if (!is_target_filename (name))
{
- sym_bfd = gdb_bfd_open (cname, gnutarget, -1);
- if (!sym_bfd)
- error (_("`%s': can't open to read symbols: %s."), cname,
- bfd_errmsg (bfd_get_error ()));
-
- if (!bfd_check_format (sym_bfd, bfd_object))
- {
- make_cleanup_bfd_unref (sym_bfd);
- error (_("`%s': can't read symbols: %s."), cname,
- bfd_errmsg (bfd_get_error ()));
- }
+ char *expanded_name, *absolute_name;
- return sym_bfd;
- }
-
- name = tilde_expand (cname); /* Returns 1st new malloc'd copy. */
+ expanded_name = tilde_expand (name); /* Returns 1st new malloc'd copy. */
- /* Look down path for it, allocate 2nd new malloc'd copy. */
- desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, name,
- O_RDONLY | O_BINARY, &absolute_name);
+ /* Look down path for it, allocate 2nd new malloc'd copy. */
+ desc = openp (getenv ("PATH"),
+ OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
+ expanded_name, O_RDONLY | O_BINARY, &absolute_name);
#if defined(__GO32__) || defined(_WIN32) || defined (__CYGWIN__)
- if (desc < 0)
- {
- char *exename = alloca (strlen (name) + 5);
+ if (desc < 0)
+ {
+ char *exename = alloca (strlen (expanded_name) + 5);
- strcat (strcpy (exename, name), ".exe");
- desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
- exename, O_RDONLY | O_BINARY, &absolute_name);
- }
+ strcat (strcpy (exename, expanded_name), ".exe");
+ desc = openp (getenv ("PATH"),
+ OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
+ exename, O_RDONLY | O_BINARY, &absolute_name);
+ }
#endif
- if (desc < 0)
- {
- make_cleanup (xfree, name);
- perror_with_name (name);
- }
+ if (desc < 0)
+ {
+ make_cleanup (xfree, expanded_name);
+ perror_with_name (expanded_name);
+ }
- xfree (name);
- name = absolute_name;
- back_to = make_cleanup (xfree, name);
+ xfree (expanded_name);
+ make_cleanup (xfree, absolute_name);
+ name = absolute_name;
+ }
sym_bfd = gdb_bfd_open (name, gnutarget, desc);
if (!sym_bfd)
error (_("`%s': can't open to read symbols: %s."), name,
bfd_errmsg (bfd_get_error ()));
- bfd_set_cacheable (sym_bfd, 1);
+
+ if (!gdb_bfd_has_target_filename (sym_bfd))
+ bfd_set_cacheable (sym_bfd, 1);
if (!bfd_check_format (sym_bfd, bfd_object))
{