From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24238 invoked by alias); 20 Jan 2010 23:56:12 -0000 Received: (qmail 24228 invoked by uid 22791); 20 Jan 2010 23:56:11 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 Jan 2010 23:56:08 +0000 Received: from wpaz5.hot.corp.google.com (wpaz5.hot.corp.google.com [172.24.198.69]) by smtp-out.google.com with ESMTP id o0KNu6JP016830 for ; Wed, 20 Jan 2010 15:56:06 -0800 Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.18.118.116]) by wpaz5.hot.corp.google.com with ESMTP id o0KNu5Ak005853 for ; Wed, 20 Jan 2010 15:56:05 -0800 Received: by ruffy.mtv.corp.google.com (Postfix, from userid 67641) id 607D284413; Wed, 20 Jan 2010 15:56:05 -0800 (PST) To: gdb-patches@sourceware.org Subject: [patch] print a more useful error message for "gdb core" Message-Id: <20100120235605.607D284413@ruffy.mtv.corp.google.com> Date: Wed, 20 Jan 2010 23:56:00 -0000 From: dje@google.com (Doug Evans) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00516.txt.bz2 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 * 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