Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org, Jerome Guitton <guitton@adacore.com>
Subject: Re: [RFA v2] arm-pikeos: software single step
Date: Tue, 11 Sep 2018 13:51:00 -0000	[thread overview]
Message-ID: <20180911135101.GE3379@adacore.com> (raw)
In-Reply-To: <dd7f2060ed67248e02d93dd5a636b189@polymtl.ca>

> > Attached is the patch I am testing. I am wondering if this is the best
> > way, though. What do you think?
> 
> It looks good to me.  You could use a range-for, because it's cool:
> 
>   for (asymbol *sym : symbol_table)
> 
> but what you have is also fine.

Unfortunately, it looks like the change is causing regressions, and
it is a bit obscure at the moment, which is not entirely surprising
when one deals with memory.

> > One question I asked myself is whether we needed the std::vector at
> > all, as the building of the vector is a bit clunky in this situation.
> > As I understand it, this is mostly to automate the destruction of
> > the array. I was wondering whether we could do without the std::vector
> > entirely, and just handle the array without a cleanup, since the code
> > is simple enough that we can make sure it doesn't throw (I was hoping
> > that eg marking the function noexcept would help guaranty that). But
> > at the end of the day, although it's manageable in this case, I felt
> > it was better to go with the safer approach.
> 
> Well, it would be fine to not use a vector, but in any case I would
> recommend the use of an object that ensures the memory is de-allocated in
> any case, whether it is an std::vector, an std::unique_ptr or a
> gdb::unique_xmalloc_ptr.  I don't see any advantage of doing a manual free
> over using one of those.
> 
> An alternative would be to use a VLA:
> 
>   asymbol *symbol_table[max_number_of_symbols];
> 
> which I think ends up being like an alloca.  But in this case there could be
> a huge number of symbols I suppose, so I would avoid that.

Yes, the table might be too large and blow the stack. All things
considered, I think the better model here seems to be to use a
gdb::unique_xmalloc_ptr. I tried that, and the code looks simpler,
but I get the same kind of regressions as above.

And unfortunately at this point, I have to hold off for a while,
because I am out of license, and then I will be traveling home.
But thanks a lot for all the feedback received so far; when I pick
things up again, I will not be starting from scratch.

-- 
Joel


  reply	other threads:[~2018-09-11 13:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 15:13 [RFA] " Joel Brobecker
2018-09-10 17:28 ` Tom Tromey
2018-09-10 17:43   ` Joel Brobecker
2018-09-10 18:39     ` [RFA v2] " y
2018-09-10 20:01       ` Simon Marchi
2018-09-10 20:53         ` Tom Tromey
2018-09-11  8:56         ` Joel Brobecker
2018-09-11  9:58           ` Simon Marchi
2018-09-11 13:51             ` Joel Brobecker [this message]
2018-09-11 15:41           ` Tom Tromey
2018-09-11 21:17             ` Joel Brobecker
2018-09-14  0:47               ` Joel Brobecker
2018-09-14 10:57                 ` Simon Marchi
2018-11-01 21:44                 ` Joel Brobecker
2018-09-11  9:08 ` [RFA] " Pedro Alves
2018-09-11 11:04   ` Joel Brobecker
2018-09-11 11:27     ` Pedro Alves
2018-09-11 20:57       ` Joel Brobecker
2018-09-12 13:22         ` Pedro Alves
2018-09-14  0:38           ` Joel Brobecker

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=20180911135101.GE3379@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=guitton@adacore.com \
    --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