diff mbox

[2/5] Add a new 'info proc files' subcommand of 'info proc'.

Message ID 20180908003659.37482-3-jhb@FreeBSD.org
State New
Headers show

Commit Message

John Baldwin Sept. 8, 2018, 12:36 a.m. UTC
This command displays a list of open file descriptors.

gdb/ChangeLog:

	* defs.h (enum info_proc_what) [IP_FILES]: New value.
	* infcmd.c (info_proc_cmd_files): New function.
	(_initialize_infcmd): Register 'info proc files' command.
---
 gdb/ChangeLog |  6 ++++++
 gdb/defs.h    |  3 +++
 gdb/infcmd.c  | 12 ++++++++++++
 3 files changed, 21 insertions(+)

Comments

Eli Zaretskii Sept. 8, 2018, 6:49 a.m. UTC | #1
> From: John Baldwin <jhb@FreeBSD.org>
> Date: Fri,  7 Sep 2018 17:36:56 -0700
> 
> This command displays a list of open file descriptors.

Thanks.

> +  add_cmd ("files", class_info, info_proc_cmd_files, _("\
> +List of open files."),

IMO, this doc strings is too terse.  I suggest to expand it telling
that the command shows the files open by the process being debugged.
Simon Marchi Sept. 8, 2018, 10:30 p.m. UTC | #2
On 2018-09-08 07:49 AM, Eli Zaretskii wrote:
>> From: John Baldwin <jhb@FreeBSD.org>
>> Date: Fri,  7 Sep 2018 17:36:56 -0700
>>
>> This command displays a list of open file descriptors.
> 
> Thanks.
> 
>> +  add_cmd ("files", class_info, info_proc_cmd_files, _("\
>> +List of open files."),
> 
> IMO, this doc strings is too terse.  I suggest to expand it telling
> that the command shows the files open by the process being debugged.

The info proc commands accept a pid, which allows you to refer to any
process, not only those debugged by GDB.  Other info proc commands use
use the generic form "of the process"

  info proc cmdline -- List command line arguments of the process

I think that's sufficient, especially that users are likely to see it
in the context of "help info proc", which describes what argument you
can pass:

(gdb) help info proc
Show /proc process information about any running process.
Specify any process id, or use the program being debugged by default.

List of info proc subcommands:

info proc all -- List all available /proc info
info proc cmdline -- List command line arguments of the process
info proc cwd -- List current working directory of the process
info proc exe -- List absolute filename for executable of the process
info proc mappings -- List of mapped memory regions
info proc stat -- List process info from /proc/PID/stat
info proc status -- List process info from /proc/PID/status

Simon
Simon Marchi Sept. 8, 2018, 10:32 p.m. UTC | #3
On 2018-09-08 01:36 AM, John Baldwin wrote:
> This command displays a list of open file descriptors.
> 
> gdb/ChangeLog:
> 
> 	* defs.h (enum info_proc_what) [IP_FILES]: New value.
> 	* infcmd.c (info_proc_cmd_files): New function.
> 	(_initialize_infcmd): Register 'info proc files' command.
> ---
>  gdb/ChangeLog |  6 ++++++
>  gdb/defs.h    |  3 +++
>  gdb/infcmd.c  | 12 ++++++++++++
>  3 files changed, 21 insertions(+)
> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index d32b390778..2e5cd0a687 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,9 @@
> +2018-09-07  John Baldwin  <jhb@FreeBSD.org>
> +
> +	* defs.h (enum info_proc_what) [IP_FILES]: New value.
> +	* infcmd.c (info_proc_cmd_files): New function.
> +	(_initialize_infcmd): Register 'info proc files' command.
> +
>  2018-09-07  John Baldwin  <jhb@FreeBSD.org>
>  
>  	* fbsd-tdep.c (fbsd_core_vnode_path): Use KF_PATH instead of
> diff --git a/gdb/defs.h b/gdb/defs.h
> index fc4217005a..6e3f4df116 100644
> --- a/gdb/defs.h
> +++ b/gdb/defs.h
> @@ -389,6 +389,9 @@ enum info_proc_what
>      /* * Display `info proc cwd'.  */
>      IP_CWD,
>  
> +    /* * Display `info proc files'.  */
> +    IP_FILES,
> +
>      /* * Display all of the above.  */
>      IP_ALL
>    };
> diff --git a/gdb/infcmd.c b/gdb/infcmd.c
> index 860909f5e2..c6cfc10a49 100644
> --- a/gdb/infcmd.c
> +++ b/gdb/infcmd.c
> @@ -3218,6 +3218,14 @@ info_proc_cmd_exe (const char *args, int from_tty)
>    info_proc_cmd_1 (args, IP_EXE, from_tty);
>  }
>  
> +/* Implement `info proc files'.  */
> +
> +static void
> +info_proc_cmd_files (const char *args, int from_tty)
> +{
> +  info_proc_cmd_1 (args, IP_FILES, from_tty);
> +}
> +
>  /* Implement `info proc all'.  */
>  
>  static void
> @@ -3543,6 +3551,10 @@ List command line arguments of the process."),
>  List absolute filename for executable of the process."),
>  	   &info_proc_cmdlist);
>  
> +  add_cmd ("files", class_info, info_proc_cmd_files, _("\
> +List of open files."),
> +	   &info_proc_cmdlist);
> +
>    add_cmd ("all", class_info, info_proc_cmd_all, _("\
>  List all available /proc info."),
>  	   &info_proc_cmdlist);
The code LGTM, but please wait for Eli's reply on the doc bits.

Thanks,

Simon
Eli Zaretskii Sept. 9, 2018, 5:23 a.m. UTC | #4
> CC: <gdb-patches@sourceware.org>
> From: Simon Marchi <simon.marchi@ericsson.com>
> Date: Sat, 8 Sep 2018 23:30:36 +0100
> 
> >> +  add_cmd ("files", class_info, info_proc_cmd_files, _("\
> >> +List of open files."),
> > 
> > IMO, this doc strings is too terse.  I suggest to expand it telling
> > that the command shows the files open by the process being debugged.
> 
> The info proc commands accept a pid, which allows you to refer to any
> process, not only those debugged by GDB.

Then let's say

  List of files open by the specified process.
John Baldwin Sept. 10, 2018, 6:13 p.m. UTC | #5
On 9/8/18 10:23 PM, Eli Zaretskii wrote:
>> CC: <gdb-patches@sourceware.org>
>> From: Simon Marchi <simon.marchi@ericsson.com>
>> Date: Sat, 8 Sep 2018 23:30:36 +0100
>>
>>>> +  add_cmd ("files", class_info, info_proc_cmd_files, _("\
>>>> +List of open files."),
>>>
>>> IMO, this doc strings is too terse.  I suggest to expand it telling
>>> that the command shows the files open by the process being debugged.
>>
>> The info proc commands accept a pid, which allows you to refer to any
>> process, not only those debugged by GDB.
> 
> Then let's say
> 
>   List of files open by the specified process.

I'm fine with that, but we should probably make the descriptions under
'info proc' a bit more consistent in general as a followup.  Most of them
use 'of the process' without including "specified", and 'info proc mappings'
(which I based the original description off of) doesn't include
"process" in its description.
Eli Zaretskii Sept. 10, 2018, 7:11 p.m. UTC | #6
> Cc: gdb-patches@sourceware.org
> From: John Baldwin <jhb@FreeBSD.org>
> Date: Mon, 10 Sep 2018 11:13:19 -0700
> 
> > Then let's say
> > 
> >   List of files open by the specified process.
> 
> I'm fine with that, but we should probably make the descriptions under
> 'info proc' a bit more consistent in general as a followup.

Yes.
diff mbox

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d32b390778..2e5cd0a687 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@ 
+2018-09-07  John Baldwin  <jhb@FreeBSD.org>
+
+	* defs.h (enum info_proc_what) [IP_FILES]: New value.
+	* infcmd.c (info_proc_cmd_files): New function.
+	(_initialize_infcmd): Register 'info proc files' command.
+
 2018-09-07  John Baldwin  <jhb@FreeBSD.org>
 
 	* fbsd-tdep.c (fbsd_core_vnode_path): Use KF_PATH instead of
diff --git a/gdb/defs.h b/gdb/defs.h
index fc4217005a..6e3f4df116 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -389,6 +389,9 @@  enum info_proc_what
     /* * Display `info proc cwd'.  */
     IP_CWD,
 
+    /* * Display `info proc files'.  */
+    IP_FILES,
+
     /* * Display all of the above.  */
     IP_ALL
   };
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 860909f5e2..c6cfc10a49 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -3218,6 +3218,14 @@  info_proc_cmd_exe (const char *args, int from_tty)
   info_proc_cmd_1 (args, IP_EXE, from_tty);
 }
 
+/* Implement `info proc files'.  */
+
+static void
+info_proc_cmd_files (const char *args, int from_tty)
+{
+  info_proc_cmd_1 (args, IP_FILES, from_tty);
+}
+
 /* Implement `info proc all'.  */
 
 static void
@@ -3543,6 +3551,10 @@  List command line arguments of the process."),
 List absolute filename for executable of the process."),
 	   &info_proc_cmdlist);
 
+  add_cmd ("files", class_info, info_proc_cmd_files, _("\
+List of open files."),
+	   &info_proc_cmdlist);
+
   add_cmd ("all", class_info, info_proc_cmd_all, _("\
 List all available /proc info."),
 	   &info_proc_cmdlist);