This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 3/6] Add support for 'info proc files' on FreeBSD core dumps.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]