Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] print a more useful error message for "gdb core"
@ 2010-01-20 23:56 Doug Evans
  2010-01-21  0:13 ` Doug Evans
  2010-01-28 21:37 ` Jan Kratochvil
  0 siblings, 2 replies; 9+ messages in thread
From: Doug Evans @ 2010-01-20 23:56 UTC (permalink / raw)
  To: gdb-patches

Hi.

If the user accidentally does "gdb core" gdb currently prints:

"/foo/bar": not in executable format: File format not recognized

This patch prints a more useful error message for this particular case:

"/foo/bar" is a core file.
Please specify an executable to debug.

I will check this in in a few days if there are no objections.

2010-01-20  Doug Evans  <dje@google.com>

	* exec.c (exec_file_attach): Print a more useful error message if the
	user did "gdb core".

Index: exec.c
===================================================================
RCS file: /cvs/src/src/gdb/exec.c,v
retrieving revision 1.95
diff -u -p -r1.95 exec.c
--- exec.c	19 Jan 2010 09:47:47 -0000	1.95
+++ exec.c	20 Jan 2010 23:50:10 -0000
@@ -253,6 +253,13 @@ exec_file_attach (char *filename, int fr
       scratch_pathname = xstrdup (scratch_pathname);
       cleanups = make_cleanup (xfree, scratch_pathname);
 
+      /* If the user accidentally did "gdb core", print a more useful
+	 error message.  */
+      if (bfd_check_format (exec_bfd, bfd_core))
+	error (_("\"%s\" is a core file.\n"
+		 "Please specify an executable to debug."),
+		 scratch_pathname);
+
       if (!bfd_check_format (exec_bfd, bfd_object))
 	{
 	  /* Make sure to close exec_bfd, or else "run" might try to use


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

end of thread, other threads:[~2010-01-28 21:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-20 23:56 [patch] print a more useful error message for "gdb core" Doug Evans
2010-01-21  0:13 ` Doug Evans
2010-01-21  2:33   ` Hui Zhu
2010-01-21 13:58   ` Jan Kratochvil
2010-01-21 16:34     ` Tom Tromey
2010-01-21 17:17     ` Doug Evans
2010-01-25  4:22       ` Jan Kratochvil
2010-01-28 21:37 ` Jan Kratochvil
2010-01-28 21:39   ` Doug Evans

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