public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: John Baldwin <jhb@freebsd.org>
Cc: gdb-patches@sourceware.org, binutils@sourceware.org
Subject: Re: [PATCH 3/4] Support 'info proc' for native FreeBSD processes.
Date: Wed, 03 Jan 2018 19:13:00 -0000	[thread overview]
Message-ID: <fa25abff20db4c10f7bfed366a07c582@simark.ca> (raw)
In-Reply-To: <137803623.10H6MxTIBr@ralph.baldwin.cx>

Hi John,

>> > +#ifdef HAVE_KINFO_GETVMMAP
>> > +  if (do_mappings)
>> > +    {
>> > +      int nvment;
>> > +      std::unique_ptr<struct kinfo_vmentry, free_deleter<struct kinfo_vmentry>>
>> 
>> Is there a reason to have and use free_deleter rather than 
>> gdb::unique_xmalloc_ptr?
>> 
>> > +	vmentl (kinfo_getvmmap (pid, &nvment));
> 
> This function (kinfo_getvmmap) which is defined in the libutil library
> included in
> FreeBSD's base system calls malloc() internally, so the memory returned 
> must be
> freed with free() rather than xfree().  This deleter is already used 
> earlier in
> fbsd_find_memory_regions() for another call to kinfo_getvmmap() for
> the same reason.

But isn't xfree just a wrapper around free?

>> > +
>> > +      if (vmentl)
>> 
>> vmentl != NULL
>> 
>> There are a few other instances of if (ptr) that should be changed to 
>> if (ptr != NULL).
> 
> Ok.  The style in GDB doesn't seem consistent in this regard (I
> largely based this
> code on the 'info proc' implementation in linux-tdep.c which doesn't 
> explicitly
> compare against NULL/nullptr (though I prefer the explicit comparison 
> myself)).
> Also, I feel like we should use nullptr rather than NULL when working
> with "smart"
> pointer types like unique_ptr<> at least?

You are right, there is code that comes from an era where the coding 
style wasn't as strictly enforced, it seems.  I don't think we should go 
fix coding style issues just for fun, but when we modify or copy 
existing code, we should make it respect the style.

Thanks,

Simon

  reply	other threads:[~2018-01-03 19:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-22 22:05 [PATCH 0/4] Support for 'info proc' on FreeBSD cores and native John Baldwin
2017-12-22 22:05 ` [PATCH 2/4] Support 'info proc' for FreeBSD process core dumps John Baldwin
2017-12-27  1:56   ` Simon Marchi
2018-01-03 19:05     ` John Baldwin
2017-12-22 22:05 ` [PATCH 3/4] Support 'info proc' for native FreeBSD processes John Baldwin
2017-12-27  2:23   ` Simon Marchi
2018-01-03 19:05     ` John Baldwin
2018-01-03 19:13       ` Simon Marchi [this message]
2018-01-03 21:56         ` John Baldwin
2017-12-22 22:05 ` [PATCH 1/4] Create psuedo sections for FreeBSD NT_PROCSTAT_(PROC|FILES|VMMAP) notes John Baldwin
2017-12-27  1:18   ` Simon Marchi
2018-01-02 11:49   ` Nick Clifton
2017-12-22 22:13 ` [PATCH 4/4] Document support for 'info proc' on FreeBSD John Baldwin
2017-12-23  8:46   ` Eli Zaretskii
2017-12-27  1:53 ` [PATCH 0/4] Support for 'info proc' on FreeBSD cores and native Simon Marchi
2018-01-03 19:05   ` John Baldwin
2018-01-03 19:15     ` Simon Marchi
2018-01-03 23:39       ` John Baldwin

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=fa25abff20db4c10f7bfed366a07c582@simark.ca \
    --to=simark@simark.ca \
    --cc=binutils@sourceware.org \
    --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).