public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: John Baldwin <jhb@FreeBSD.org>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 3/6] Add support for 'info proc files' on FreeBSD core dumps.
Date: Sun, 16 Sep 2018 02:27:00 -0000	[thread overview]
Message-ID: <eacbb74e-2f6c-441a-90b2-ddbbe6dbc03a@simark.ca> (raw)
In-Reply-To: <20180912233707.43492-4-jhb@FreeBSD.org>

Some nits about the comments, otherwise LGTM (I didn't check the
bits-reading code in detail, I assumed it wash largely unchanged).

On 2018-09-12 7:37 p.m., John Baldwin wrote:
> +static void
> +fbsd_print_sockaddr_in6 (const void *sockaddr)
> +{
> +  const struct fbsd_sockaddr_in6 *sin6 =
> +    reinterpret_cast<const struct fbsd_sockaddr_in6 *>(sockaddr);
> +  uint16_t words[ARRAY_SIZE(sin6->sin6_addr) / 2];
> +
> +  /* Populate the array of 16-bit words from network-order bytes.  */
> +  for (int i = 0; i < ARRAY_SIZE(words); i++)
> +    words[i] = (sin6->sin6_addr[i * 2] << 8) | sin6->sin6_addr[i * 2 + 1];
> +
> +  /* Find the longest run of zero words.  */
> +  int best, bestlen, current, len;
> +
> +  best = -1;
> +  bestlen = 0;
> +  current = -1;
> +  len = 0;
> +  for (int i = 0; i < ARRAY_SIZE(words); i++)
> +    {
> +      if (words[i] == 0)
> +	{
> +	  if (current >= 0)
> +	    len++;
> +	  else
> +	    {
> +	      current = i;
> +	      len = 1;
> +	    }
> +	}
> +      else
> +	{
> +	  if (current >= 0 && len > bestlen)
> +	    {
> +	      best = current;
> +	      bestlen = len;
> +	    }
> +	  current = -1;
> +	  len = 0;
> +	}
> +    }
> +  if (current >= 0 && len > bestlen)
> +    {
> +      best = current;
> +      bestlen = len;
> +    }
> +  if (bestlen < 2)
> +    best = -1;
> +
> +  for (int i = 0; i < ARRAY_SIZE(words); i++)
> +    {
> +      if (best >= 0 && i >= best && i < best + bestlen)
> +	{
> +	  if (i == best || i == ARRAY_SIZE(words) - 1)
> +	    printf_filtered (":");
> +	}
> +      else
> +	{
> +	  if (i != 0)
> +	    printf_filtered (":");
> +	  printf_filtered ("%x", words[i]);
> +	}
> +    }
> +  printf_filtered (".%u", (sin6->sin6_port[0] << 8) | sin6->sin6_port[1]);
> +}
> +
> +/* Output the header for "info proc files".  */

This should be /* See fbsd-tdep.h.  */, same for fbsd_info_proc_files_entry.

> +void
> +fbsd_info_proc_files_header ()
> +{
> +  printf_filtered (_("Open files:\n\n"));
> +  printf_filtered ("  %6s %6s %10s %9s %s\n",
> +		   "FD", "Type", "Offset", "Flags  ", "Name");
> +}

...

> +/* Output description of a single file descriptor for "info proc
> +   files".  The KF_TYPE, KF_FD, KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE,
> +   KF_SOCK_DOMAIN, KF_SOCK_TYPE, and KF_SOCK_PROTOCOL parameters
> +   should contain the value of the corresponding fields in a 'struct
> +   kinfo_file'.  The KF_SA_LOCAL, KF_SA_PEER, and KF_PATH parameters
> +   should contain pointers to the corresponding fields in a 'struct
> +   kinfo_file'. */

Some parameters name in the doc here don't match the actual names below.

> +extern void fbsd_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags,
> +					LONGEST kf_offset, int kf_vnode_type,
> +					int kf_sock_domain, int kf_sock_type,
> +					int kf_sock_protocol,
> +					const void *kf_sa_local,
> +					const void *fa_sa_peer,
> +					const void *path);
> +

Simon

  reply	other threads:[~2018-09-16  2:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12 23:37 [PATCH v2 0/6] Add a new 'info proc files' command John Baldwin
2018-09-12 23:37 ` [PATCH v2 6/6] Make the "info proc" documentation more consistent John Baldwin
2018-09-13 13:40   ` Eli Zaretskii
2018-09-12 23:37 ` [PATCH v2 2/6] Add a new 'info proc files' subcommand of 'info proc' John Baldwin
2018-09-12 23:37 ` [PATCH v2 5/6] Document the 'info proc files' command John Baldwin
2018-09-13 13:39   ` Eli Zaretskii
2018-09-12 23:37 ` [PATCH v2 1/6] Use KF_PATH to verify the size of a struct kinfo_file John Baldwin
2018-09-12 23:37 ` [PATCH v2 3/6] Add support for 'info proc files' on FreeBSD core dumps John Baldwin
2018-09-16  2:27   ` Simon Marchi [this message]
2018-09-17 16:54     ` John Baldwin
2018-09-12 23:43 ` [PATCH v2 4/6] Support 'info proc files' on live FreeBSD processes John Baldwin
2018-09-16  2:34 ` [PATCH v2 0/6] Add a new 'info proc files' command Simon Marchi
2018-09-17 16:59   ` John Baldwin
2018-09-17 17:17     ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eacbb74e-2f6c-441a-90b2-ddbbe6dbc03a@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).