From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2 29/31] 'struct agent_expr *' -> unique_ptr<agent_expr>
Date: Wed, 19 Oct 2016 23:58:00 -0000 [thread overview]
Message-ID: <3cfca740-279c-5ade-23b6-14a7dc94e953@redhat.com> (raw)
In-Reply-To: <57020f6d8d6c087cc8ea35f49860e7d8@simark.ca>
On 10/20/2016 12:19 AM, Simon Marchi wrote:
> On 2016-10-18 21:12, Pedro Alves wrote:
>> diff --git a/gdb/ax-general.c b/gdb/ax-general.c
>> index 7f27a45..35225f6 100644
>> --- a/gdb/ax-general.c
>> +++ b/gdb/ax-general.c
>> @@ -37,52 +37,30 @@ static void generic_ext (struct agent_expr *x,
>> enum agent_op op, int n);
>> \f
>> /* Functions for building expressions. */
>>
>> -/* Allocate a new, empty agent expression. */
>> -struct agent_expr *
>> -new_agent_expr (struct gdbarch *gdbarch, CORE_ADDR scope)
>> +agent_expr::agent_expr (struct gdbarch *gdbarch, CORE_ADDR scope)
>> {
>> - struct agent_expr *x = XNEW (struct agent_expr);
>> -
>> - x->len = 0;
>> - x->size = 1; /* Change this to a larger value once
>> + this->len = 0;
>> + this->size = 1; /* Change this to a larger value once
>> reallocation code is tested. */
>> - x->buf = (unsigned char *) xmalloc (x->size);
>> + this->buf = (unsigned char *) xmalloc (this->size);
>>
>> - x->gdbarch = gdbarch;
>> - x->scope = scope;
>> + this->gdbarch = gdbarch;
>> + this->scope = scope;
>>
>> /* Bit vector for registers used. */
>> - x->reg_mask_len = 1;
>> - x->reg_mask = XCNEWVEC (unsigned char, x->reg_mask_len);
>> -
>> - x->tracing = 0;
>> - x->trace_string = 0;
>> + this->reg_mask_len = 1;
>> + this->reg_mask = XCNEWVEC (unsigned char, this->reg_mask_len);
>>
>> - return x;
>> + this->tracing = 0;
>> + this->trace_string = 0;
>> }
>
> In one of Tom's patches, you said to drop the "this->". Did you leave
> them here for clarity? Would you remove them if the structure was
> completely converted, with m_ prefixed members (given that the m_ prefix
> makes it clear enough that it's a member)?
m_ is supposed to used for private data fields. In this case,
the fields are still public (and referenced from outside the class
in many places). I think in such cases using this-> makes the code
much clearer.
>
>> @@ -12385,13 +12378,9 @@ force_breakpoint_reinsertion (struct
>> bp_location *bl)
>> that have already been marked. */
>> loc->condition_changed = condition_updated;
>>
>> - /* Free the agent expression bytecode as well. We will compute
>> - it later on. */
>> - if (loc->cond_bytecode)
>> - {
>> - free_agent_expr (loc->cond_bytecode);
>> - loc->cond_bytecode = NULL;
>> - }
>> + /* Release the agent expression bytecode as well. We will
>> + compute it later on. */
>> + loc->cond_bytecode.reset ();
>
> Why did you change Free for Release in the comment? Since release has a
> different meaning when using unique pointers, it sounds more confusing
> like this I think.
Hmm, I saw the "Free" and thought that since we now use "delete", release
would be a generic term that would be clearer. But you have a good point.
Free -> Delete ? Or I can just keep it was Free.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2016-10-19 23:58 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-19 1:13 [PATCH v2 00/31] More cleanup elimination & unlimited args to user-defined funcs Pedro Alves
2016-10-19 1:12 ` [PATCH v2 21/31] Use ui_file_as_string in gdb/compile/ Pedro Alves
2016-10-19 23:08 ` Simon Marchi
2016-10-19 23:48 ` Pedro Alves
2016-10-20 3:17 ` Simon Marchi
2016-10-20 12:13 ` Pedro Alves
2016-10-19 1:12 ` [PATCH v2 22/31] Use ui_file_as_string in gdb/c-exp.y Pedro Alves
2016-10-19 1:12 ` [PATCH v2 12/31] Use ui_file_as_string in gdb/utils.c Pedro Alves
2016-10-19 1:12 ` [PATCH v2 19/31] Use ui_file_as_string in gdb/remote.c Pedro Alves
2016-10-19 1:12 ` [PATCH v2 24/31] Use ui_file_as_string in gdb/ada-lang.c Pedro Alves
2016-10-19 1:12 ` [PATCH v2 06/31] Introduce ui_file_as_string Pedro Alves
2016-10-19 1:12 ` [PATCH v2 07/31] Clean up tracepoint.h/c:collection_list Pedro Alves
2016-10-19 1:12 ` [PATCH v2 20/31] Use ui_file_as_string in gdb/cli/cli-setshow.c Pedro Alves
2016-10-19 1:12 ` [PATCH v2 01/31] Introduce string_printf Pedro Alves
2016-10-19 13:43 ` Trevor Saunders
2016-10-19 14:41 ` Pedro Alves
2016-10-19 17:18 ` Simon Marchi
2016-10-19 21:02 ` Pedro Alves
2016-11-08 15:35 ` Pedro Alves
2016-10-19 1:13 ` [PATCH v2 03/31] breakpoint.c:commands_command_1 constification and cleanup Pedro Alves
2016-10-19 1:13 ` [PATCH v2 14/31] Use ui_file_as_string in gdb/guile/ Pedro Alves
2016-10-19 1:13 ` [PATCH v2 27/31] Use ui_file_as_string in gdb/language.c Pedro Alves
2016-10-19 1:13 ` [PATCH v2 29/31] 'struct agent_expr *' -> unique_ptr<agent_expr> Pedro Alves
2016-10-19 23:19 ` Simon Marchi
2016-10-19 23:58 ` Pedro Alves [this message]
2016-10-19 1:13 ` [PATCH v2 23/31] Use ui_file_as_string in gdbarch.sh/gdbarch.c Pedro Alves
2016-10-19 1:13 ` [PATCH v2 26/31] Use ui_file_as_string in gdb/rust-lang.c Pedro Alves
2016-10-19 1:13 ` [PATCH v2 08/31] Use ui_file_as_string in dwarf2_compute_name Pedro Alves
2016-10-19 1:13 ` [PATCH v2 31/31] Support an "unlimited" number of user-defined arguments Pedro Alves
2016-10-19 6:29 ` Eli Zaretskii
2016-10-19 11:33 ` Philipp Rudo
2016-10-19 12:47 ` Pedro Alves
2016-10-19 17:40 ` Philipp Rudo
2016-10-19 17:45 ` Pedro Alves
2016-11-08 15:41 ` Pedro Alves
2016-10-19 1:13 ` [PATCH v2 02/31] cli/cli-script.c: Remove some dead NULL checks Pedro Alves
2016-10-19 17:24 ` Simon Marchi
2016-10-19 21:18 ` Pedro Alves
2016-10-19 1:13 ` [PATCH v2 15/31] Use ui_file_as_string in execute_command_to_string Pedro Alves
2016-10-19 1:17 ` [PATCH v2 11/31] Use ui_file_as_string in gdb/ui-out.c Pedro Alves
2016-10-19 1:17 ` [PATCH v2 10/31] Use ui_file_as_string in gdb/ada-valprint.c Pedro Alves
2016-10-19 1:17 ` [PATCH v2 25/31] Use ui_file_as_string in gdb/infrun.c Pedro Alves
2016-10-19 1:17 ` [PATCH v2 09/31] Use ui_file_as_string in gdb/xtensa-tdep.c Pedro Alves
2016-10-19 1:18 ` [PATCH v2 30/31] Eliminate agent_expr_p; VEC -> std::vector in struct bp_target_info Pedro Alves
2016-10-19 1:18 ` [PATCH v2 05/31] 'struct expression *' -> gdb::unique_xmalloc_ptr<expression> Pedro Alves
2016-10-19 18:45 ` Simon Marchi
2016-10-19 21:50 ` Pedro Alves
2016-10-19 22:25 ` Simon Marchi
2016-10-19 22:36 ` Pedro Alves
2016-10-19 1:19 ` [PATCH v2 04/31] cli-script.c: Simplify using std::string, eliminate cleanups Pedro Alves
2016-10-19 18:25 ` Simon Marchi
2016-10-19 21:45 ` Pedro Alves
2016-10-19 1:21 ` [PATCH v2 16/31] Use ui_file_as_string in gdb/top.c Pedro Alves
2016-10-19 1:21 ` [PATCH v2 18/31] Use ui_file_as_string in gdb/python/ Pedro Alves
2016-10-19 1:21 ` [PATCH v2 13/31] Use ui_file_as_string in gdb/arm-tdep.c Pedro Alves
2016-10-19 22:54 ` Simon Marchi
2016-10-19 1:21 ` [PATCH v2 17/31] Use ui_file_as_string in gdb/printcmd.c Pedro Alves
2016-10-20 13:08 ` [PATCH v2 28/31] Use ui_file_as_string throughout more Pedro Alves
2017-02-23 10:23 ` Yao Qi
2017-02-23 10:53 ` Pedro Alves
2017-02-23 10:35 ` Yao Qi
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=3cfca740-279c-5ade-23b6-14a7dc94e953@redhat.com \
--to=palves@redhat.com \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).