From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 5/5] Don't memset non-POD types: struct breakpoint
Date: Thu, 20 Apr 2017 04:00:00 -0000 [thread overview]
Message-ID: <97e100ef6f6427505651a2c2a90b675a@polymtl.ca> (raw)
In-Reply-To: <1492050475-9238-6-git-send-email-palves@redhat.com>
On 2017-04-12 22:27, Pedro Alves wrote:
> Eh, struct breakpoint was made non-POD just today, with commit
> d28cd78ad820e3 ("Change breakpoint event locations to
> event_location_up"). :-)
>
> src/gdb/breakpoint.c: In function âvoid
> init_raw_breakpoint_without_location(breakpoint*, gdbarch*, bptype,
> const breakpoint_ops*)â:
> src/gdb/breakpoint.c:7447:28: error: use of deleted function âvoid*
> memset(T*, int, size_t) [with T = breakpoint; <template-parameter-1-2>
> = void; size_t = long unsigned int]â
> memset (b, 0, sizeof (*b));
> ^
> In file included from src/gdb/common/common-defs.h:85:0,
> from src/gdb/defs.h:28,
> from src/gdb/breakpoint.c:20:
> src/gdb/common/poison.h:56:7: note: declared here
> void *memset (T *s, int c, size_t n) = delete;
> ^
>
> gdb/ChangeLog:
> yyyy-mm-dd Pedro Alves <palves@redhat.com>
>
> * breakpoint.h (struct breakpoint): In-class initialize all
> fields. Make boolean fields "bool".
> * breakpoint.c (init_raw_breakpoint_without_location): Remove
> memset call and initializations no longer necessary.
> ---
> gdb/breakpoint.c | 10 ----------
> gdb/breakpoint.h | 60
> ++++++++++++++++++++++++++++----------------------------
> 2 files changed, 30 insertions(+), 40 deletions(-)
>
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 0796313..0e6aecc 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -7444,8 +7444,6 @@ init_raw_breakpoint_without_location (struct
> breakpoint *b,
> enum bptype bptype,
> const struct breakpoint_ops *ops)
> {
> - memset (b, 0, sizeof (*b));
> -
> gdb_assert (ops != NULL);
>
> b->ops = ops;
> @@ -7453,17 +7451,9 @@ init_raw_breakpoint_without_location (struct
> breakpoint *b,
> b->gdbarch = gdbarch;
> b->language = current_language->la_language;
> b->input_radix = input_radix;
> - b->thread = -1;
> b->enable_state = bp_enabled;
Is there a reason you don't assign bp_enabled in-class directly?
> - b->next = 0;
> - b->silent = 0;
> - b->ignore_count = 0;
> - b->commands = NULL;
> b->frame_id = null_frame_id;
I think you can remove the assignment to frame_id, since it's done
in-class.
> - b->condition_not_parsed = 0;
> - b->py_bp_object = NULL;
> b->related_breakpoint = b;
> - b->location = NULL;
> }
>
> /* Helper to set_raw_breakpoint below. Creates a breakpoint
> diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
> index 18b284f..ae84349 100644
> --- a/gdb/breakpoint.h
> +++ b/gdb/breakpoint.h
> @@ -681,45 +681,45 @@ extern int target_exact_watchpoints;
> struct breakpoint
> {
> /* Methods associated with this breakpoint. */
> - const struct breakpoint_ops *ops;
> + const breakpoint_ops *ops = NULL;
>
> - struct breakpoint *next;
> + breakpoint *next = NULL;
> /* Type of breakpoint. */
> - enum bptype type;
> + bptype type {bp_none};
For consistency, I think it would be nice to use = when possible
bptype type = bp_none;
next prev parent reply other threads:[~2017-04-20 4:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-13 2:27 [PATCH 0/4] Poison non-POD memset & non-trivially-copyable memcpy/memmove Pedro Alves
2017-04-13 2:28 ` [PATCH 4/5] Don't memset non-POD types: struct btrace_insn Pedro Alves
2017-04-13 7:57 ` Metzger, Markus T
2017-04-25 1:11 ` Pedro Alves
2017-04-13 2:28 ` [PATCH 1/5] Poison non-POD memset & non-trivially-copyable memcpy/memmove Pedro Alves
2017-04-20 3:27 ` Simon Marchi
2017-04-25 1:14 ` Pedro Alves
2017-04-25 1:19 ` Pedro Alves
2017-04-25 8:24 ` Yao Qi
2017-04-25 9:24 ` Pedro Alves
2017-04-25 10:02 ` Pedro Alves
2017-04-24 1:12 ` Simon Marchi
2017-04-24 1:53 ` Simon Marchi
2017-04-27 13:58 ` Pedro Alves
2017-04-30 1:51 ` Simon Marchi
2017-05-17 11:35 ` Pedro Alves
2017-05-17 13:11 ` Simon Marchi
2017-05-17 13:20 ` Pedro Alves
2017-04-27 13:57 ` Pedro Alves
2017-04-13 2:28 ` [PATCH 2/5] Don't memcpy non-trivially-copyable types: Make enum_flags triv. copyable Pedro Alves
2017-04-20 3:34 ` Simon Marchi
2017-04-25 1:10 ` Pedro Alves
2017-04-13 2:28 ` [PATCH 3/5] Don't memset non-POD types: struct bp_location Pedro Alves
2017-04-13 2:35 ` [PATCH 5/5] Don't memset non-POD types: struct breakpoint Pedro Alves
2017-04-20 4:00 ` Simon Marchi [this message]
2017-04-25 1:11 ` Pedro Alves
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=97e100ef6f6427505651a2c2a90b675a@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.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