From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1529 invoked by alias); 21 Jan 2010 02:33:59 -0000 Received: (qmail 1515 invoked by uid 22791); 21 Jan 2010 02:33:58 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-pw0-f49.google.com (HELO mail-pw0-f49.google.com) (209.85.160.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jan 2010 02:33:53 +0000 Received: by pwj12 with SMTP id 12so4006344pwj.8 for ; Wed, 20 Jan 2010 18:33:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.249.24 with SMTP id w24mr548643wfh.254.1264041231949; Wed, 20 Jan 2010 18:33:51 -0800 (PST) In-Reply-To: References: <20100120235605.607D284413@ruffy.mtv.corp.google.com> From: Hui Zhu Date: Thu, 21 Jan 2010 02:33:00 -0000 Message-ID: Subject: Re: [patch] print a more useful error message for "gdb core" To: Doug Evans Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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/msg00518.txt.bz2 Hello, If you don't mind, I suggest change bfd_check_format to bfd_check_format_matches like http://sourceware.org/ml/gdb-patches/2010-01/msg00468.html It will give user more help when he got bfd_error_file_ambiguously_recogniz= ed. Thanks, Hui On Thu, Jan 21, 2010 at 08:12, Doug Evans wrote: > 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 =A0Doug Evans =A0 > > =A0 =A0 =A0 =A0* exec.c (exec_file_attach): Print a more useful error mes= sage if the > =A0 =A0 =A0 =A0user did "gdb core". > > Index: exec.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/exec.c,v > retrieving revision 1.95 > diff -u -p -r1.95 exec.c > --- exec.c =A0 =A0 =A019 Jan 2010 09:47:47 -0000 =A0 =A0 =A01.95 > +++ exec.c =A0 =A0 =A021 Jan 2010 00:10:17 -0000 > @@ -253,6 +253,18 @@ exec_file_attach (char *filename, int fr > =A0 =A0 =A0 scratch_pathname =3D xstrdup (scratch_pathname); > =A0 =A0 =A0 cleanups =3D make_cleanup (xfree, scratch_pathname); > > + =A0 =A0 =A0/* If the user accidentally did "gdb core", print a useful > + =A0 =A0 =A0 =A0error message. =A0*/ > + =A0 =A0 =A0if (bfd_check_format (exec_bfd, bfd_core)) > + =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 /* Make sure to close exec_bfd, or else "run" might try= to use > + =A0 =A0 =A0 =A0 =A0 =A0it. =A0*/ > + =A0 =A0 =A0 =A0 exec_close (); > + =A0 =A0 =A0 =A0 error (_("\"%s\" is a core file.\n" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"Please specify an executable to deb= ug."), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0scratch_pathname); > + =A0 =A0 =A0 } > + > =A0 =A0 =A0 if (!bfd_check_format (exec_bfd, bfd_object)) > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0/* Make sure to close exec_bfd, or else "run" might tr= y to use >