From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7811 invoked by alias); 5 Jan 2009 23:04:36 -0000 Received: (qmail 7802 invoked by uid 22791); 5 Jan 2009 23:04:35 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_33,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 05 Jan 2009 23:04:28 +0000 Received: from spaceape7.eur.corp.google.com (spaceape7.eur.corp.google.com [172.28.16.141]) by smtp-out.google.com with ESMTP id n05N4OOm007541 for ; Mon, 5 Jan 2009 15:04:25 -0800 Received: from rv-out-0506.google.com (rvbf6.prod.google.com [10.140.82.6]) by spaceape7.eur.corp.google.com with ESMTP id n05N47K5010390 for ; Mon, 5 Jan 2009 15:04:22 -0800 Received: by rv-out-0506.google.com with SMTP id f6so7266151rvb.53 for ; Mon, 05 Jan 2009 15:04:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.141.132.1 with SMTP id j1mr790479rvn.282.1231196661782; Mon, 05 Jan 2009 15:04:21 -0800 (PST) In-Reply-To: <20081219053421.2D802412300@localhost> References: <20081219053421.2D802412300@localhost> Date: Mon, 05 Jan 2009 23:04:00 -0000 Message-ID: Subject: Re: [RFA] linux-nat.c minor cleanup From: Doug Evans To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 2009-01/txt/msg00033.txt.bz2 Ping. On Thu, Dec 18, 2008 at 9:34 PM, Doug Evans wrote: > Hi. > > linux-nat.c:linux_nat_info_proc_cmd uses a long long to record a pid. > There's not much point in that, so this patch changes it to a long. > [either that or it shouldn't use strtoul to parse it :-)] > > The handling of info proc cmd,cwd,exe is odd too. > They're always printed and yet argument parsing looks for them anyway, > and ignores invalid commands instead of flagging an error. > This patch adds a blurb about printing cmd,cwd,exe in the help text. > The manual already touches on this, though it doesn't precisely > say that cmd,cwd,exe are always printed. > I wouldn't mind also submitting a patch to flag unknown commands > as errors, but I'm not sure what's intended as far as the parsing > of cmd,cwd,exe. > > Ok to check in? > > 2008-12-18 Doug Evans > > * linux-nat.c (linux_nat_info_proc_cmd): Store pid in long instead > of long long. > (_initialize_linux_nat): For info proc command, document that it > always prints the command line, cwd, and exe path name. > > Index: linux-nat.c > =================================================================== > RCS file: /cvs/src/src/gdb/linux-nat.c,v > retrieving revision 1.113 > diff -u -p -r1.113 linux-nat.c > --- linux-nat.c 18 Dec 2008 21:35:22 -0000 1.113 > +++ linux-nat.c 19 Dec 2008 05:16:19 -0000 > @@ -3597,7 +3597,7 @@ linux_nat_make_corefile_notes (bfd *obfd > static void > linux_nat_info_proc_cmd (char *args, int from_tty) > { > - long long pid = PIDGET (inferior_ptid); > + long pid = PIDGET (inferior_ptid); > FILE *procfile; > char **argv = NULL; > char buffer[MAXPATHLEN]; > @@ -3661,14 +3661,14 @@ linux_nat_info_proc_cmd (char *args, int > if (pid == 0) > error (_("No current process: you must name one.")); > > - sprintf (fname1, "/proc/%lld", pid); > + sprintf (fname1, "/proc/%ld", pid); > if (stat (fname1, &dummy) != 0) > error (_("No /proc directory: '%s'"), fname1); > > - printf_filtered (_("process %lld\n"), pid); > + printf_filtered (_("process %ld\n"), pid); > if (cmdline_f || all) > { > - sprintf (fname1, "/proc/%lld/cmdline", pid); > + sprintf (fname1, "/proc/%ld/cmdline", pid); > if ((procfile = fopen (fname1, "r")) != NULL) > { > struct cleanup *cleanup = make_cleanup_fclose (procfile); > @@ -3681,7 +3681,7 @@ linux_nat_info_proc_cmd (char *args, int > } > if (cwd_f || all) > { > - sprintf (fname1, "/proc/%lld/cwd", pid); > + sprintf (fname1, "/proc/%ld/cwd", pid); > memset (fname2, 0, sizeof (fname2)); > if (readlink (fname1, fname2, sizeof (fname2)) > 0) > printf_filtered ("cwd = '%s'\n", fname2); > @@ -3690,7 +3690,7 @@ linux_nat_info_proc_cmd (char *args, int > } > if (exe_f || all) > { > - sprintf (fname1, "/proc/%lld/exe", pid); > + sprintf (fname1, "/proc/%ld/exe", pid); > memset (fname2, 0, sizeof (fname2)); > if (readlink (fname1, fname2, sizeof (fname2)) > 0) > printf_filtered ("exe = '%s'\n", fname2); > @@ -3699,7 +3699,7 @@ linux_nat_info_proc_cmd (char *args, int > } > if (mappings_f || all) > { > - sprintf (fname1, "/proc/%lld/maps", pid); > + sprintf (fname1, "/proc/%ld/maps", pid); > if ((procfile = fopen (fname1, "r")) != NULL) > { > long long addr, endaddr, size, offset, inode; > @@ -3761,7 +3761,7 @@ linux_nat_info_proc_cmd (char *args, int > } > if (status_f || all) > { > - sprintf (fname1, "/proc/%lld/status", pid); > + sprintf (fname1, "/proc/%ld/status", pid); > if ((procfile = fopen (fname1, "r")) != NULL) > { > struct cleanup *cleanup = make_cleanup_fclose (procfile); > @@ -3774,7 +3774,7 @@ linux_nat_info_proc_cmd (char *args, int > } > if (stat_f || all) > { > - sprintf (fname1, "/proc/%lld/stat", pid); > + sprintf (fname1, "/proc/%ld/stat", pid); > if ((procfile = fopen (fname1, "r")) != NULL) > { > int itmp; > @@ -4684,7 +4684,9 @@ _initialize_linux_nat (void) > add_info ("proc", linux_nat_info_proc_cmd, _("\ > Show /proc process information about any running process.\n\ > Specify any process id, or use the program being debugged by default.\n\ > -Specify any of the following keywords for detailed info:\n\ > +The command line, current working directory, and full path name of the\n\ > +executable are printed.\n\ > +Specify any of the following keywords for additional detailed info:\n\ > mappings -- list of mapped memory regions.\n\ > stat -- list a bunch of random process info.\n\ > status -- list a different bunch of random process info.\n\ >