From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18851 invoked by alias); 21 Jan 2010 00:13:00 -0000 Received: (qmail 18843 invoked by uid 22791); 21 Jan 2010 00:12:58 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jan 2010 00:12:54 +0000 Received: from spaceape23.eur.corp.google.com (spaceape23.eur.corp.google.com [172.28.16.75]) by smtp-out.google.com with ESMTP id o0L0Cp9T015140 for ; Thu, 21 Jan 2010 00:12:51 GMT Received: from ey-out-2122.google.com (eye22.prod.google.com [10.208.5.22]) by spaceape23.eur.corp.google.com with ESMTP id o0L0CoeS003980 for ; Wed, 20 Jan 2010 16:12:50 -0800 Received: by ey-out-2122.google.com with SMTP id 22so832958eye.45 for ; Wed, 20 Jan 2010 16:12:50 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.85.69 with SMTP id t47mr270928wee.107.1264032769801; Wed, 20 Jan 2010 16:12:49 -0800 (PST) In-Reply-To: <20100120235605.607D284413@ruffy.mtv.corp.google.com> References: <20100120235605.607D284413@ruffy.mtv.corp.google.com> Date: Thu, 21 Jan 2010 00:13:00 -0000 Message-ID: Subject: Re: [patch] print a more useful error message for "gdb core" From: Doug Evans To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 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/msg00517.txt.bz2 On Wed, Jan 20, 2010 at 3:56 PM, Doug Evans wrote: > 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. As noted in irc, the joys of working between multiple trees. The previous patch didn't call exec_close. Here's an updated patch. 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 21 Jan 2010 00:10:17 -0000 @@ -253,6 +253,18 @@ 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 useful + error message. */ + if (bfd_check_format (exec_bfd, bfd_core)) + { + /* Make sure to close exec_bfd, or else "run" might try to use + it. */ + exec_close (); + 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