Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kamil Rytarowski <n54@gmx.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Implement "info proc mappings" for NetBSD
Date: Fri, 20 Mar 2020 17:58:18 +0100	[thread overview]
Message-ID: <2b16c08b-330f-1aa8-7c69-c14774847047@gmx.com> (raw)
In-Reply-To: <875zezm421.fsf@tromey.com>


[-- Attachment #1.1: Type: text/plain, Size: 3411 bytes --]

On 20.03.2020 16:36, Tom Tromey wrote:
>>>>>> "Kamil" == Kamil Rytarowski <n54@gmx.com> writes:
> 
> Kamil> Define nbsd_nat_target::find_memory_regions and
> Kamil> nbsd_nat_target::info_proc. info_proc handles as of now only
> Kamil> the "mappings" command.
> 
> Thank you for the patch.
> 
> Kamil> +/* Retrieve all the memory regions in the specified process.  */
> Kamil> +
> Kamil> +static struct kinfo_vmentry *
> Kamil> +kinfo_get_vmmap(pid_t pid, size_t *size)
> 
> Space before paren.
> There are multiple instances of this in the patch.
> 

Done.

> Kamil> +{
> Kamil> +  int mib[5] = {CTL_VM, VM_PROC, VM_PROC_MAP, pid, sizeof(struct kinfo_vmentry)};
> Kamil> +
> Kamil> +  size_t length = 0;
> Kamil> +  if (sysctl(mib, ARRAY_SIZE (mib), NULL, &length, NULL, 0)) {
> 
> GNU style is to put the open brace on its own line.
> There are several cases of this as well.
> 

Done.

> Kamil> +  if (sysctl(mib, ARRAY_SIZE (mib), kiv, &length, NULL, 0)) {
> Kamil> +    *size = 0;
> Kamil> +    free(kiv);
> 
> xfree, though these days in gdb it's better to create and return a
> self-managing object, like gdb::unique_xmalloc_ptr<>.
> 

Done.

> Kamil> +
> Kamil> +int
> Kamil> +nbsd_nat_target::find_memory_regions (find_memory_region_ftype func,
> Kamil> +				      void *obfd)
> 
> I wouldn't name that parameter "obfd" but rather "data" or "user_data"
> or something like that.  The name "obfd" in gdb normally implies that it
> is a "BFD *", but this is just opaque data that's shared by the caller
> and the callback.
> 

I see. I prefer to keep this called obfd, as it matches the FreeBSD code
more closely. If we want to rename it, we shall do it also in FreeBSD.

> Kamil> diff --git a/gdb/nbsd-tdep.c b/gdb/nbsd-tdep.c
> [...]
> Kamil> +/* Flags in the 'kve_protection' field in struct kinfo_vmentry.  These
> Kamil> +   match the KVME_PROT_* constants in <sys/sysctl.h>.  */
> 
> What if they stop matching?
> 

Not a concern.

If that will ever change, it will be patched, same as the other existing
NetBSD support.

> I wonder if this code really ought to be in the tdep file.  I suppose
> so, if it will be used somehow when cross debugging... but will that
> happen?
> 

This code follows the structure of FreeBSD.

> If not then maybe putting it in the -nat file is better; and then the
> appropriate NetBSD headers could be used.
> 

I prefer to keep similarity with FreeBSD. If we want to change it,
FreeBSD shall be changed too.

> Kamil> +  printf_filtered (_("Mapped address spaces:\n\n"));
> Kamil> +  if (addr_bit == 64)
> Kamil> +    {
> Kamil> +      printf_filtered ("  %18s %18s %10s %10s %9s %s\n",
> Kamil> +		       "Start Addr",
> Kamil> +		       "  End Addr",
> Kamil> +		       "      Size", "    Offset", "Flags  ", "File");
> Kamil> +    }
> Kamil> +  else
> Kamil> +    {
> Kamil> +      printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
> Kamil> +		       "Start Addr",
> Kamil> +		       "  End Addr",
> Kamil> +		       "      Size", "    Offset", "Flags  ", "File");
> 
> Personally I like using ui-out tables instead of this kind of thing.
> 

I will keep this as is. If we want to change it, we shall change FreeBSD
in one go.

I don't have chance to work or test on FreeBSD myself so I defer
refactoring it into future.

Please see v2.

> Tom
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-03-20 16:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-16 17:34 Kamil Rytarowski
2020-03-19 13:07 ` Kamil Rytarowski
2020-03-20 15:36 ` Tom Tromey
2020-03-20 16:58   ` Kamil Rytarowski [this message]
2020-03-20 18:50     ` Tom Tromey
2020-03-20 19:13       ` Kamil Rytarowski
2020-03-25 16:36       ` John Baldwin
2020-03-26 23:24         ` Kamil Rytarowski
2020-03-20 16:58 ` [PATCH v2] " Kamil Rytarowski
2020-04-02 20:09 ` Kamil Rytarowski
2020-04-03  1:12   ` Kamil Rytarowski
2020-04-06  9:37   ` [PATCH v3] " Kamil Rytarowski
2020-04-10 10:20     ` Kamil Rytarowski
2020-04-11 21:05     ` Simon Marchi
2020-04-11 21:28       ` Kamil Rytarowski
2020-04-11 21:53         ` Simon Marchi
2020-04-11 23:45     ` [PATCH v4] " Kamil Rytarowski
2020-04-11 23:49       ` Simon Marchi
2020-04-12  0:09         ` Kamil Rytarowski
2020-04-12  0:09       ` [PATCH v5] " Kamil Rytarowski
2020-04-12  0:56         ` Simon Marchi
2020-04-12 10:17           ` Kamil Rytarowski

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=2b16c08b-330f-1aa8-7c69-c14774847047@gmx.com \
    --to=n54@gmx.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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