From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18671 invoked by alias); 10 Jan 2002 22:49:54 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 18621 invoked from network); 10 Jan 2002 22:49:50 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 10 Jan 2002 22:49:50 -0000 Received: from redhat.com (reddwarf.sfbay.redhat.com [205.180.231.12]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id OAA04322; Thu, 10 Jan 2002 14:49:46 -0800 (PST) Message-ID: <3C3E1954.CBCEE82F@redhat.com> Date: Thu, 10 Jan 2002 14:49:00 -0000 From: Michael Snyder Organization: Red Hat, Inc. X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2smp i686) X-Accept-Language: en MIME-Version: 1.0 To: Elena Zannoni CC: gdb-patches@sources.redhat.com Subject: Re: [RFA] Add new cmd line parameter "--pid" for attach. References: <200201050321.g053L6l16505@reddwarf.cygnus.com> <15418.21637.258565.54021@localhost.cygnus.com> <3C3B70ED.D8256B4A@redhat.com> <15421.63701.263775.202282@localhost.cygnus.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-01/txt/msg00255.txt.bz2 Elena Zannoni wrote: > > Michael Snyder writes: > > Elena Zannoni wrote: > > > > > > Michael Snyder writes: > > > > > > > > Currently if you invoke gdb as: > > > > > > > > gdb filename 12345 > > > > > > > > gdb will attempt to open a corefile called "12345", and if that > > > > fails it will print a "file not found" warning, and then attempt > > > > to attach to a process "12345". > > > > > > > > There is a "--core " command-line argument, > > > > so that you can specify a corefile without a symbol file: > > > > > > > > gdb --core > > > > > > > > but there is no "--pid" option to allow you to specify > > > > a process-id without a symbol file. > > > > > > > > This patch does two things: > > > > > > > > 1) Add a "--pid" option to allow specification of an attach pid. > > > > > > > > > > This bit is approved. > > > > > > > 2) If the second argument (after the symbol-file) begins with > > > > a digit, try attach first instead of trying to open it as a > > > > corefile first. This eliminates the "file not found" warning. > > > > > > > > > > About this, I have a question, what happens if you have a corefile > > > whose name starts with a digit? I tried it and I get an error: > > > > > > [ezannoni@localhost gdb]$ ./gdb -nw ./gdb 2222core > > > GNU gdb 2002-01-03-cvs > > > Copyright 2001 Free Software Foundation, Inc. > > > GDB is free software, covered by the GNU General Public License, and you are > > > welcome to change it and/or distribute copies of it under certain conditions. > > > Type "show copying" to see the conditions. > > > There is absolutely no warranty for GDB. Type "show warranty" for details. > > > This GDB was configured as "i686-pc-linux-gnu"... > > > Attaching to program: /home/ezannoni/sources/native/gdb/gdb, process 2222 > > > ptrace: No such process. > > > > > > then it proceeds normally to figure out it's a core file. > > > > Right -- this is actually the reverse of the old behavior > > (before my change). Previously the algorythm was this: > > > > Try to open a corefile > > on failure, if isdigit(string[0]) > > try to attach a pid. > > > > So if it was really a pid, you always got an error when > > it tried to open it as a corefile. Now the algorythm is: > > > > if isdigit (string[0]) > > try to attach a pid > > on failure, try to open a corefile > > else try to open a corefile > > > > So the only time you will get a failure warning is > > if you have a corefile whose name begins with a digit. > > I think that's an improvement (warning should be less > > frequent). > > > > Yes, that's what I wanted to point out. We are swapping an error > message with another. The advantage is that the warning shouldn't come > up as often. Can you commit this, adding the bit to the docs about > specifying './2222core' instead of '2222core'? Umm, I can't think of a way to say that, without more-than-doubling the amount of text currently devoted to the subject. I will check it in as is, and then we can add something about this if you wish. > > > I can be convinced that a digit is more likely to indicate a pid than > > > a corefile, but would there be a way to make that error be silent? I > > > realize that those error messages are generated in the bowels of gdb, > > > and it may be really hard to fix that (gee, isn't this something the > > > insight people have some opinion about? :-) > > > > > Just out of curiosity have you looked into this at all? No.