--- exec.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) --- a/exec.c +++ b/exec.c @@ -207,6 +207,8 @@ exec_file_clear (int from_tty) void exec_file_attach (char *filename, int from_tty) { + char **matching; + /* Remove any previous exec file. */ exec_close (); @@ -259,13 +261,26 @@ exec_file_attach (char *filename, int fr scratch_pathname = xstrdup (scratch_pathname); cleanups = make_cleanup (xfree, scratch_pathname); - if (!bfd_check_format (exec_bfd, bfd_object)) + if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) { /* Make sure to close exec_bfd, or else "run" might try to use it. */ exec_close (); - error (_("\"%s\": not in executable format: %s"), - scratch_pathname, bfd_errmsg (bfd_get_error ())); + + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + char **p = matching; + fprintf_filtered (gdb_stderr, _("\"%s\":Matching formats:"), + scratch_pathname); + while (*p) + fprintf_filtered (gdb_stderr, " %s", *p++); + fprintf_filtered (gdb_stderr, "\n"); + free (matching); + error (_("Use command \"set gnutarget\" handle it.")); + } + else + error (_("\"%s\": not in executable format: %s"), + scratch_pathname, bfd_errmsg (bfd_get_error ())); } /* FIXME - This should only be run for RS6000, but the ifdef is a poor