Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Show some tips when file cmd get bfd_error_file_ambiguously_recognized
@ 2010-01-14  2:44 Hui Zhu
  2010-01-14 10:15 ` Jan Kratochvil
  0 siblings, 1 reply; 16+ messages in thread
From: Hui Zhu @ 2010-01-14  2:44 UTC (permalink / raw)
  To: gdb-patches ml; +Cc: Tristan Gingold, Daniel Jacobowitz, Jan Kratochvil

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]

Hello guys,

This patch is part of patch
http://sourceware.org/ml/gdb-patches/2010-01/msg00327.html

I removed the cmd "set bfd".  Keep the tips:
"/ls":Matching formats: elf32-nbigmips elf32-ntradbigmips
Use command "set gnutarget" handle it.

Please help me review it.

Thanks,
Hui

2010-01-14  Hui Zhu  <teawater@gmail.com>

	* exec.c (exec_file_attach): Output some tips when
	bfd_get_error is bfd_error_file_ambiguously_recognized.

[-- Attachment #2: tips.txt --]
[-- Type: text/plain, Size: 1548 bytes --]

---
 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

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-02-05  2:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-14  2:44 [RFA] Show some tips when file cmd get bfd_error_file_ambiguously_recognized Hui Zhu
2010-01-14 10:15 ` Jan Kratochvil
2010-01-19  7:01   ` Hui Zhu
2010-01-19  7:57     ` Jan Kratochvil
2010-01-19  8:08       ` Hui Zhu
2010-01-26  8:01         ` Hui Zhu
2010-01-26 21:04           ` Doug Evans
2010-01-27  9:01             ` Hui Zhu
2010-01-28 18:18               ` Doug Evans
2010-01-28 21:56               ` Jan Kratochvil
2010-01-28 21:59                 ` Doug Evans
2010-01-29  3:51                   ` Joel Brobecker
2010-01-29  9:06                     ` Hui Zhu
2010-02-04  7:09                       ` Hui Zhu
2010-02-04 17:38                         ` Doug Evans
2010-02-05  2:44                           ` Hui Zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox