Re: [PATCH] Add extra 'info os' information types for Linux (trunk and 7.4)

Doug Evans
2011-12-29T20:32:42Z

On Mon, Dec 26, 2011 at 8:28 PM, Stan Shebs <stanshebs@earthlink.net> wrote:
> Here is a third revision of the 'info os' additions for Linux; it rolls up
> Kwok's original patch plus requested edits, plus a few more comments and
> tweaks.  I plan to commit this in a day or so, if there are no objections.
>
> I'd also like to get this pushed into 7.4; although it's getting late in the
> release cycle, this code is purely Linux-native and does not have any effect
> outside of 'info os'.  The urgency is partly due to snafu on my part - Kwok
> originally posted this patch in October - and partly due to interdependency
> with Eclipse, who is doing GUI for these commands.  (And yes, there is an
> approved-but-uncommitted MI patch connected with this, that I'll be pushing
> soon.)
>
> Stan
>
> 2011-12-26  Stan Shebs <stan@codesourcery.com>
>        Kwok Cheung Yeung <kcy@codesourcery.com>
>
>    * NEWS: Describe new info os commands.
>    * common/linux-osdata.c (PID_T, TIME_T): Define.
>    (MAX_PID_T_STRLEN): New.
>    (linux_common_core_of_thread): Add comment.  Change to use PID_T and
>    MAX_PID_T_STRLEN.
>    (command_from_pid): Add comment.  Change to use PID_T.
>    (commandline_from_pid):  Change to use PID_T.
>    (user_from_pid): Add comment.
>    (get_process_owner): Add comment. Change to use PID_T and
>    MAX_PID_T_STRLEN.
>    (get_number_of_cpu_cores): Add comment.
>    (get_cores_used_by_process): Add comment.  Change to use PID_T and
>    MAX_PID_T_STRLEN.
>    (linux_xfer_osdata_processes): Change to use PID_T and
>    MAX_PID_T_STRLEN.
>    (compare_processes): New function.
>    (linux_xfer_osdata_processgroups): New function.
>    (linux_xfer_osdata_threads): Change to use PID_T.
>    (linux_xfer_osdata_fds): New function.
>    (format_socket_state, print_sockets): New functions.
>    (union socket_addr): New union.
>    (linux_xfer_osdata_isockets): New function.
>    (time_from_time_t, group_from_gid): New functions.
>    (linux_xfer_osdata_shm): New function.
>    (linux_xfer_osdata_sem): New function.
>    (linux_xfer_osdata_msg): New function.
>    (linux_xfer_osdata_modules): New function.
>    (osdata_table): Add new entries.
>    * common/buffer.c (buffer_xml_printf): Add support for long and
>    long long format specifiers.
>
>    * gdb.texinfo (Operating System Auxiliary Information): Document new
>    'info os' subcommands.
>
>    * gdb.base/info-os.exp: New file.
>    * gdb.base/info-os.c: New file.

One nit:

In info-os.exp, at the end:

+# The SysV IPC primitives linger on after the creating process is killed
+# unless they are destroyed explicitly, so allow the test program to tidy
+# up after itself. Note that the test program attempts to delete and
+# recreate the shared-memory region if it already exists, in case a
+# previous run failed before having a chance to clean up. The tests for
+# semaphores and message queues should still work with primitives from
+# previous runs.
+send_gdb "continue\n"

Is that robust enough?
Seems like you should also wait for the program to exit.