Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Andrew Burgess <andrew.burgess@embecosm.com>,
	gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 2/2] gdb: Change a VEC to std::vector in btrace.{c,h}
Date: Tue, 24 Sep 2019 02:19:00 -0000	[thread overview]
Message-ID: <7ad80184-704d-c939-a0e1-a85bf7ac7ea8@simark.ca> (raw)
In-Reply-To: <2754d81c341f0cbb6240e309f93d3b9efb38c3e3.1569276387.git.andrew.burgess@embecosm.com>

On 2019-09-23 6:09 p.m., Andrew Burgess wrote:
> Replace a VEC with a std::vector in btrace.h, and update btrace.c to
> match.  This code is currently untested, so I've been quite
> conservative with the changes - where previously we used VEC_safe_push
> which would allocate the vector if it isn't already allocated - I now
> check and allocate the std::vector using 'new' before pushing to the
> vector.
> 
> As the new vector is inside a union I've currently used a pointer to
> vector, which makes the code slightly uglier than it might otherwise
> be, but again, due to lack of testing I'm reluctant to start
> refactoring the code in a big way.

Hi Andrew,

Looks fine to me, just a few nits:

> diff --git a/gdb/btrace.c b/gdb/btrace.c
> index 5013b568a45..59e2a49bcd8 100644
> --- a/gdb/btrace.c
> +++ b/gdb/btrace.c
> @@ -1828,7 +1828,7 @@ btrace_maint_clear (struct btrace_thread_info *btinfo)
>  
>  #if defined (HAVE_LIBIPT)
>      case BTRACE_FORMAT_PT:
> -      xfree (btinfo->maint.variant.pt.packets);
> +      delete (btinfo->maint.variant.pt.packets);

You can remove the parenthesis.

>  
>        btinfo->maint.variant.pt.packets = NULL;
>        btinfo->maint.variant.pt.packet_history.begin = 0;
> @@ -2987,8 +2987,10 @@ btrace_maint_decode_pt (struct btrace_maint_info *maint,
>  	  if (maint_btrace_pt_skip_pad == 0 || packet.packet.type != ppt_pad)
>  	    {
>  	      packet.errcode = pt_errcode (errcode);
> -	      VEC_safe_push (btrace_pt_packet_s, maint->variant.pt.packets,
> -			     &packet);
> +	      if (maint->variant.pt.packets == NULL)
> +		maint->variant.pt.packets
> +		  = new std::vector <btrace_pt_packet_s>;

This will fit on a single line once you remove the `_s` :).

> --- a/gdb/btrace.h
> +++ b/gdb/btrace.h
> @@ -29,7 +29,6 @@
>  #include "gdbsupport/btrace-common.h"
>  #include "target/waitstatus.h" /* For enum target_stop_reason.  */
>  #include "gdbsupport/enum-flags.h"
> -#include "gdbsupport/vec.h"
>  
>  #if defined (HAVE_LIBIPT)
>  #  include <intel-pt.h>
> @@ -267,7 +266,6 @@ struct btrace_pt_packet
>  
>  /* Define functions operating on a vector of packets.  */
>  typedef struct btrace_pt_packet btrace_pt_packet_s;
> -DEF_VEC_O (btrace_pt_packet_s);

Like in the previous patch, you can drop this typedef.  It was only useful to define the VEC.

Simon


  reply	other threads:[~2019-09-24  2:19 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 [this message]
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
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 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 3/3] gdb: Remove a use of VEC from dwarf2read.{c,h} Andrew Burgess
2019-09-26 11:41         ` [PATCHv4 0/3] Remove some uses of VEC Andrew Burgess
2019-10-01 11:42           ` [PATCHv5 2/3] gdb: Change a VEC to std::vector in btrace.{c,h} Andrew Burgess
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 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
     [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=7ad80184-704d-c939-a0e1-a85bf7ac7ea8@simark.ca \
    --to=simark@simark.ca \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.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