From: Andrew Burgess <andrew.burgess@embecosm.com>
To: "Metzger, Markus T" <markus.t.metzger@intel.com>
Cc: gdb-patches <gdb-patches@sourceware.org>,
Simon Marchi <simark@simark.ca>, Tom Tromey <tom@tromey.com>
Subject: Re: [PATCHv3 1/3] gdb: Remove a VEC from gdbsupport/btrace-common.h
Date: Thu, 26 Sep 2019 11:32:00 -0000 [thread overview]
Message-ID: <20190926113219.GS4962@embecosm.com> (raw)
In-Reply-To: <A78C989F6D9628469189715575E55B236B4D90B9@IRSMSX104.ger.corp.intel.com>
* Metzger, Markus T <markus.t.metzger@intel.com> [2019-09-26 08:47:23 +0000]:
> Hello Andrew,
>
> I can help you run the gdb.btrace suite. Do you have a user branch
> with these patches?
You can find this branch here:
https://github.com/T-J-Teru/binutils-gdb/tree/gdb-remove-vec
Any additional testing is always welcome, though from Simon's feedback
I believe that I should be testing this OK - I'm running on a
post-Broadwell Intel CPU, and I am linking GDB against libipt, and see
no regressions over the entire testsuite.
>
>
> > @@ -1068,13 +1069,12 @@ btrace_compute_ftrace_bts (struct thread_info *tp,
> >
> > while (blk != 0)
> > {
> > - btrace_block_s *block;
> > CORE_ADDR pc;
> >
> > blk -= 1;
> >
> > - block = VEC_index (btrace_block_s, btrace->blocks, blk);
> > - pc = block->begin;
> > + const btrace_block &block = btrace->blocks->at (blk);
> > + pc = block.begin;
>
> We could also turn BTRACE->BLOCKS into a const & outside the loop.
I was worried about the case where we get here and btrace->blocks ==
nullptr. I don't know if such a path is possible, I had a little
through the code and my conclusion was that the answer is not
obvious. So ideally I'd leave the code as close to the original as
possible to avoid introducing bugs.
>
>
> > @@ -1581,11 +1580,9 @@ btrace_add_pc (struct thread_info *tp)
> > pc = regcache_read_pc (regcache);
> >
> > btrace.format = BTRACE_FORMAT_BTS;
> > - btrace.variant.bts.blocks = NULL;
> > + btrace.variant.bts.blocks = new std::vector <btrace_block>;
>
> A stack-allocated vector should do. Looks like we leaked the one-entry
> vector before.
Nope the btrace object is stack local, and its destructor deletes the
vector, so its easier if this just stays being new'd for now.
>
>
> > @@ -2052,9 +2048,8 @@ parse_xml_btrace_block (struct gdb_xml_parser *parser,
> > begin = (ULONGEST *) xml_find_attribute (attributes, "begin")->value.get ();
> > end = (ULONGEST *) xml_find_attribute (attributes, "end")->value.get ();
> >
> > - block = VEC_safe_push (btrace_block_s, btrace->variant.bts.blocks, NULL);
> > - block->begin = *begin;
> > - block->end = *end;
> > + gdb_assert (btrace->variant.bts.blocks != nullptr);
>
> We don't check most pointers in GDB. Besides, we just allocated the vector.
> The invariant is that if BTRACE->FORMAT == BTRACE_FORMAT_BTS, the vector
> is non-null.
You are correct. Thanks. I've removed this assertion.
>
>
> > @@ -3095,7 +3090,8 @@ btrace_maint_update_packets (struct btrace_thread_info
> > *btinfo,
> > case BTRACE_FORMAT_BTS:
> > /* Nothing to do - we operate directly on BTINFO->DATA. */
> > *begin = 0;
> > - *end = VEC_length (btrace_block_s, btinfo->data.variant.bts.blocks);
> > + gdb_assert (btinfo->data.variant.bts.blocks != nullptr);
>
> See above. More below.
I think you've convinced me that having all of these assertions around
isn't great. So I've taken a slightly different approach. I'll post
another iteration soon.
Thanks,
Andrew
next prev parent reply other threads:[~2019-09-26 11:32 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-25 15:54 [PATCHv2 0/3] Remove some uses of VEC Andrew Burgess
2019-09-23 22:09 ` [PATCH 0/2] Remove 2 uses of VEC from gdb Andrew Burgess
2019-09-23 22:09 ` [PATCH 1/2] gdb: Remove a VEC from gdbsupport/btrace-common.h Andrew Burgess
2019-09-24 2:09 ` Simon Marchi
2019-09-23 22:09 ` [PATCH 2/2] gdb: Change a VEC to std::vector in btrace.{c,h} Andrew Burgess
2019-09-24 2:19 ` Simon Marchi
2019-09-24 19:54 ` [PATCH 0/2] Remove 2 uses of VEC from gdb Tom Tromey
2019-09-25 15:54 ` [PATCHv2 3/3] gdb: Remove a use of VEC from dwarf2read.{c,h} Andrew Burgess
2019-09-25 22:08 ` Tom Tromey
2019-09-26 0:00 ` [PATCHv3 1/3] gdb: Remove a VEC from gdbsupport/btrace-common.h Andrew Burgess
2019-09-26 8:47 ` Metzger, Markus T
2019-09-26 11:32 ` Andrew Burgess [this message]
2019-09-26 13:07 ` Metzger, Markus T
2019-09-26 0:00 ` [PATCHv3 2/3] gdb: Change a VEC to std::vector in btrace.{c,h} Andrew Burgess
2019-09-26 8:47 ` Metzger, Markus T
2019-09-26 11:33 ` Andrew Burgess
2019-09-26 0:00 ` [PATCHv3 3/3] gdb: Remove a use of VEC from dwarf2read.{c,h} Andrew Burgess
2019-09-26 0:00 ` [PATCHv3 0/3] Remove some uses of VEC Andrew Burgess
2019-09-26 2:52 ` Simon Marchi
2019-09-26 11:41 ` [PATCHv4 3/3] gdb: Remove a use of VEC from dwarf2read.{c,h} Andrew Burgess
2019-09-26 11:41 ` [PATCHv4 1/3] gdb: Remove a VEC from gdbsupport/btrace-common.h Andrew Burgess
2019-09-26 13:40 ` Metzger, Markus T
2019-09-26 11:41 ` [PATCHv4 0/3] Remove some uses of VEC Andrew Burgess
2019-10-01 11:42 ` [PATCHv5 3/3] gdb: Remove a use of VEC from dwarf2read.{c,h} Andrew Burgess
2019-10-02 15:51 ` Pedro Alves
2019-10-02 22:21 ` Andrew Burgess
2019-10-03 8:06 ` Pedro Alves
2019-10-01 11:42 ` [PATCHv5 1/3] gdb: Remove a VEC from gdbsupport/btrace-common.h Andrew Burgess
2019-10-01 19:59 ` Tom Tromey
2019-10-01 11:42 ` [PATCHv5 2/3] gdb: Change a VEC to std::vector in btrace.{c,h} Andrew Burgess
[not found] ` <cover.1569929785.git.andrew.burgess@embecosm.com>
2019-10-01 12:04 ` [PATCHv5 0/3] Remove some uses of VEC Metzger, Markus T
2019-09-26 11:41 ` [PATCHv4 2/3] gdb: Change a VEC to std::vector in btrace.{c,h} Andrew Burgess
2019-09-25 15:54 ` [PATCHv2 1/3] gdb: Remove a VEC from gdbsupport/btrace-common.h Andrew Burgess
2019-09-25 15:54 ` [PATCHv2 2/3] gdb: Change a VEC to std::vector in btrace.{c,h} Andrew Burgess
2019-09-26 2:35 ` Simon Marchi
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=20190926113219.GS4962@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=simark@simark.ca \
--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