Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: John Baldwin <jhb@freebsd.org>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: Re: [PATCH 2/3] Replace remaining cleanups in fbsd-nat.c.
Date: Tue, 08 Aug 2017 15:22:00 -0000	[thread overview]
Message-ID: <4557151.QeCK76vByr@ralph.baldwin.cx> (raw)
In-Reply-To: <c8f24d24375562fc28fa8ef3c0a00d41@polymtl.ca>

On Tuesday, August 08, 2017 11:16:28 AM Simon Marchi wrote:
> Hi John,
> 
> > @@ -84,20 +92,17 @@ fbsd_find_memory_regions (struct target_ops *self,
> >  			  find_memory_region_ftype func, void *obfd)
> >  {
> >    pid_t pid = ptid_get_pid (inferior_ptid);
> > -  struct kinfo_vmentry *vmentl, *kve;
> > +  struct kinfo_vmentry *kve;
> >    uint64_t size;
> > -  struct cleanup *cleanup;
> >    int i, nitems;
> > 
> > -  vmentl = kinfo_getvmmap (pid, &nitems);
> > +  std::unique_ptr<struct kinfo_vmentry, free_deleter<struct 
> > kinfo_vmentry>>
> > +    vmentl (kinfo_getvmmap (pid, &nitems));
> 
> Doesn't this essentially do the same thing as gdb::unique_xmalloc_ptr, 
> since xfree calls free?

Well, this calls an API in a system library that allocates memory via libc's
malloc() and requires it to be free'd via libc's free() rather than any
interpositions.  Thus, it isn't allocated via xmalloc() and that is why
the existing code uses free() rather than xfree().

> > @@ -392,7 +392,7 @@ fbsd_xfer_partial (struct target_ops *ops, enum
> > target_object object,
> >  #endif
> >      case TARGET_OBJECT_AUXV:
> >        {
> > -	struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
> > +	gdb::unique_xmalloc_ptr<unsigned char> buf_storage(nullptr);
> 
> You don't need to initialize explicitly to nullptr, that's the default 
> value.  But if you still want to, then add a space before parenthesis 
> :).

Oh, duh.

> Otherwise, gdb::byte_vector with a .resize() would probably be 
> appropriate to use here.

Ok, I'll rework it with that.

-- 
John Baldwin


  reply	other threads:[~2017-08-08 15:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-08  6:20 [PATCH 0/3] Some C++-ification of the FreeBSD target John Baldwin
2017-08-08  6:20 ` [PATCH 2/3] Replace remaining cleanups in fbsd-nat.c John Baldwin
2017-08-08  9:16   ` Simon Marchi
2017-08-08 15:22     ` John Baldwin [this message]
2017-08-08  6:20 ` [PATCH 3/3] Replace home-grown linked-lists in FreeBSD's native target with std::list John Baldwin
2017-08-08  9:21   ` Simon Marchi
2017-08-08 15:22     ` John Baldwin
2017-08-08  6:20 ` [PATCH 1/3] Fix compile in the !HAVE_KINFO_GETVMMAP case 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=4557151.QeCK76vByr@ralph.baldwin.cx \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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