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

Pedro Alves
2012-01-02T12:08:57Z

On 12/27/2011 11:30 PM, Stan Shebs wrote:
> On 12/26/11 10:29 PM, Eli Zaretskii wrote:
> >> Date: Mon, 26 Dec 2011 20:28:43 -0800 From: Stan
> >> Shebs<stanshebs@earthlink.net>
> >>
> >> 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 already voiced an objection the first time: I think
> > Linux-specific OS information doesn't belong to "info os", which
> > should be for commands generally available on all supported
> > systems. I would support an "info linux" command for what you
> > want here.
> >
>
> Yeah, I see that went by without comment at the time, but it's a
> fair point.
>
> I think the answer is that there would be few if any "info os"
> subcommands that would be genuinely common to all operating systems
> that GDB supports; embedded OSes may not even have a well-defined
> concept of processes. On the other hand, one could argue that
> anything that is not totally general should be given a OS-specific
> subcommand, a la "info dos".
>
> For my part, I would tend to favor "info os" for those kinds of data
> that are generic enough to be found on more than one target OS.
> Things like processes, semaphores, and sockets are found across a
> broad range of systems large and small, and it seems unduly pedantic
> to require users to do "info linux semaphores" when targeting Linux,
> but "info bsd sem" for BSD - or worse, "info freebsd sem" vs "info
> openbsd sem" - and which flavor of BSD is Darwin most like, again?
> :-) Putting things under "info os" means less detail for users to
> remember.

The idea of "info os" is to leave GDB completely agnostic of what is it the
backend decides to present to the user/frontend. GDB only knows that it is
being given a table with columns and lines. We should not assume that
"info os FOO"
means the same thing on different OSs. FOO in "info os FOO" is
completely not standardized.
We're already suffering somewhat from one bit in gdb (MI) that is
assuming it is
(Mentor is working on a target where "info os processes" would make much
more sense to
display its own concept of "processes", but MI uses "info os processes"
for -list-thread-groups.) If we want to have standard classes of
objects, and assume
some concepts and fields are present, we should put those objects in some
namespace, so that GDB can give them special treatment, like with target
description
features. E.g., something like "org.gdb.mutex", "org.gdb.sem", etc.

It may be important to this discussion to consider that in its present form,
"info os" is more useful in its MI variant, where the frontend queries
GDB for what tables does the backend expose (with "info os"), and then
presents them in spreadsheet-like format, all without any hardcoding.
Exposing
more bits in the GNU/Linux backends serves the purpose of being the
reference implementation / proof-of-concept.