From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 3C20338582A0; Fri, 14 Oct 2022 17:38:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C20338582A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665769088; bh=FbHYKrVBboHRXx7IuJzNekTHfFre6i1AFUI8AI5RNL4=; h=From:To:Subject:Date:From; b=p+tqqeKS7u28CfSyELfg4yClpYniSCUPNzFfW5NjxJl0Qu9p8HiNrjfYDxIXy5Q3V 4Il5nsVJ1tsAaN5sNgC9q6S84pVC3QaGe9V+EvDneBUO811uub+Wco4CrPeUly3CR5 /fCa9o3TqDN+FZ4UgT0Y8sJQ2etko3THmMf1kIbM= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Use scoped_value_mark in more places X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: ce6c3d253b97961801bc045d10b7fd022578fd03 X-Git-Newrev: 65558ca5df91470521fda6b0bfdfbbdbd37ce4d3 Message-Id: <20221014173808.3C20338582A0@sourceware.org> Date: Fri, 14 Oct 2022 17:38:08 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D65558ca5df91= 470521fda6b0bfdfbbdbd37ce4d3 commit 65558ca5df91470521fda6b0bfdfbbdbd37ce4d3 Author: Tom Tromey Date: Mon Oct 3 13:51:58 2022 -0600 Use scoped_value_mark in more places =20 I looked at all the spots using value_mark, and converted all the straightforward ones to use scoped_value_mark instead. =20 Regression tested on x86-64 Fedora 34. Diff: --- gdb/ada-lang.c | 12 ++++-------- gdb/ada-valprint.c | 5 ++--- gdb/breakpoint.c | 24 +++++++++--------------- gdb/cli/cli-script.c | 32 ++++++++++++++++---------------- gdb/gnu-nat.c | 4 +--- gdb/opencl-lang.c | 5 ++--- gdb/regcache.c | 6 ++---- gdb/valarith.c | 3 +-- 8 files changed, 37 insertions(+), 54 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 0e3f0daa416..1f26394208a 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -7858,7 +7858,6 @@ ada_template_to_fixed_record_type_1 (struct type *typ= e, CORE_ADDR address, struct value *dval0, int keep_dynamic_fields) { - struct value *mark =3D value_mark (); struct value *dval; struct type *rtype; int nfields, bit_len; @@ -7867,6 +7866,8 @@ ada_template_to_fixed_record_type_1 (struct type *typ= e, int fld_bit_len; int f; =20 + scoped_value_mark mark; + /* Compute the number of fields in this record type that are going to be processed: unless keep_dynamic_fields, this includes only fields whose position and length are static will be processed. */ @@ -8068,7 +8069,6 @@ ada_template_to_fixed_record_type_1 (struct type *typ= e, else rtype->set_length (align_up (rtype->length (), type->length ())); =20 - value_free_to_mark (mark); return rtype; } =20 @@ -8169,7 +8169,6 @@ static struct type * to_record_with_fixed_variant_part (struct type *type, const gdb_byte *vala= ddr, CORE_ADDR address, struct value *dval0) { - struct value *mark =3D value_mark (); struct value *dval; struct type *rtype; struct type *branch_type; @@ -8179,6 +8178,7 @@ to_record_with_fixed_variant_part (struct type *type,= const gdb_byte *valaddr, if (variant_field =3D=3D -1) return type; =20 + scoped_value_mark mark; if (dval0 =3D=3D NULL) { dval =3D value_from_contents_and_address (type, valaddr, address); @@ -8228,7 +8228,6 @@ to_record_with_fixed_variant_part (struct type *type,= const gdb_byte *valaddr, rtype->set_length (rtype->length () - type->field (variant_field).type ()->length ()); =20 - value_free_to_mark (mark); return rtype; } =20 @@ -12311,11 +12310,8 @@ should_stop_exception (const struct bp_location *b= l) stop =3D true; try { - struct value *mark; - - mark =3D value_mark (); + scoped_value_mark mark; stop =3D value_true (evaluate_expression (ada_loc->excep_cond_expr.g= et ())); - value_free_to_mark (mark); } catch (const gdb_exception &ex) { diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 59f0be480d4..40c26145224 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -127,9 +127,10 @@ val_print_packed_array_elements (struct type *type, co= nst gdb_byte *valaddr, unsigned len; struct type *elttype, *index_type; unsigned long bitsize =3D TYPE_FIELD_BITSIZE (type, 0); - struct value *mark =3D value_mark (); LONGEST low =3D 0; =20 + scoped_value_mark mark; + elttype =3D type->target_type (); index_type =3D type->index_type (); =20 @@ -251,8 +252,6 @@ val_print_packed_array_elements (struct type *type, con= st gdb_byte *valaddr, { gdb_printf (stream, "..."); } - - value_free_to_mark (mark); } =20 /* Print the character C on STREAM as part of the contents of a literal diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index e9aee6315fa..f6591d43871 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4837,11 +4837,8 @@ bpstat_print (bpstat *bs, target_waitkind kind) static bool breakpoint_cond_eval (expression *exp) { - struct value *mark =3D value_mark (); - bool res =3D value_true (evaluate_expression (exp)); - - value_free_to_mark (mark); - return res; + scoped_value_mark mark; + return value_true (evaluate_expression (exp)); } =20 /* Allocate a new bpstat. Link it to the FIFO list by BS_LINK_POINTER. */ @@ -5363,12 +5360,11 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thr= ead_info *thread) int within_current_scope =3D 1; struct watchpoint * w; =20 - /* We use value_mark and value_free_to_mark because it could - be a long time before we return to the command level and - call free_all_values. We can't call free_all_values - because we might be in the middle of evaluating a - function call. */ - struct value *mark =3D value_mark (); + /* We use scoped_value_mark because it could be a long time + before we return to the command level and call + free_all_values. We can't call free_all_values because we + might be in the middle of evaluating a function call. */ + scoped_value_mark mark; =20 if (is_watchpoint (b)) w =3D (struct watchpoint *) b; @@ -5427,7 +5423,6 @@ bpstat_check_breakpoint_conditions (bpstat *bs, threa= d_info *thread) watchpoint, unconditionally report it. */ } /* FIXME-someday, should give breakpoint #. */ - value_free_to_mark (mark); } =20 if (cond !=3D nullptr && !condition_result) @@ -9979,17 +9974,16 @@ watch_command_1 (const char *arg, int accessflag, i= nt from_tty, /* We've found a "mask" token, which means the user wants to create a hardware watchpoint that is going to have the mask facility. */ - struct value *mask_value, *mark; + struct value *mask_value; =20 if (use_mask) error(_("You can specify only one mask.")); =20 use_mask =3D just_location =3D true; =20 - mark =3D value_mark (); + scoped_value_mark mark; mask_value =3D parse_to_comma_and_eval (&value_start); mask =3D value_as_address (mask_value); - value_free_to_mark (mark); } else /* We didn't recognize what we found. We should stop here. */ diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 6c67b60e721..22e3efa5643 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -512,8 +512,6 @@ static enum command_control_type execute_control_command_1 (struct command_line *cmd, int from_tty) { struct command_line *current; - struct value *val; - struct value *val_mark; int loop; enum command_control_type ret; =20 @@ -567,10 +565,11 @@ execute_control_command_1 (struct command_line *cmd, = int from_tty) QUIT; =20 /* Evaluate the expression. */ - val_mark =3D value_mark (); - val =3D evaluate_expression (expr.get ()); - cond_result =3D value_true (val); - value_free_to_mark (val_mark); + { + scoped_value_mark mark; + value *val =3D evaluate_expression (expr.get ()); + cond_result =3D value_true (val); + } =20 /* If the value is false, then break out of the loop. */ if (!cond_result) @@ -621,16 +620,17 @@ execute_control_command_1 (struct command_line *cmd, = int from_tty) ret =3D simple_control; =20 /* Evaluate the conditional. */ - val_mark =3D value_mark (); - val =3D evaluate_expression (expr.get ()); - - /* Choose which arm to take commands from based on the value - of the conditional expression. */ - if (value_true (val)) - current =3D cmd->body_list_0.get (); - else if (cmd->body_list_1 !=3D nullptr) - current =3D cmd->body_list_1.get (); - value_free_to_mark (val_mark); + { + scoped_value_mark mark; + value *val =3D evaluate_expression (expr.get ()); + + /* Choose which arm to take commands from based on the value + of the conditional expression. */ + if (value_true (val)) + current =3D cmd->body_list_0.get (); + else if (cmd->body_list_1 !=3D nullptr) + current =3D cmd->body_list_1.get (); + } =20 /* Execute commands in the given arm. */ while (current) diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 5dd4d148c76..ae049cab3de 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -3062,7 +3062,7 @@ static void info_port_rights (const char *args, mach_port_type_t only) { struct inf *inf =3D active_inf (); - struct value *vmark =3D value_mark (); + scoped_value_mark vmark; =20 if (args) /* Explicit list of port rights. */ @@ -3088,8 +3088,6 @@ info_port_rights (const char *args, mach_port_type_t = only) if (err) error (_("%s."), safe_strerror (err)); } - - value_free_to_mark (vmark); } =20 static void diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index c88b3fe6bbd..e41db3dcbba 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -147,7 +147,8 @@ lval_func_read (struct value *v) static void lval_func_write (struct value *v, struct value *fromval) { - struct value *mark =3D value_mark (); + scoped_value_mark mark; + struct lval_closure *c =3D (struct lval_closure *) value_computed_closur= e (v); struct type *type =3D check_typedef (value_type (v)); struct type *eltype =3D check_typedef (value_type (c->val))->target_type= (); @@ -184,8 +185,6 @@ lval_func_write (struct value *v, struct value *fromval) elsize); value_assign (to_elm_val, from_elm_val); } - - value_free_to_mark (mark); } =20 /* Return nonzero if bits in V from OFFSET and LENGTH represent a diff --git a/gdb/regcache.c b/gdb/regcache.c index 279bf2258a9..11565909d7d 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -708,10 +708,10 @@ readable_regcache::cooked_read (int regnum, gdb_byte = *buf) } else if (gdbarch_pseudo_register_read_value_p (m_descr->gdbarch)) { - struct value *mark, *computed; + struct value *computed; enum register_status result =3D REG_VALID; =20 - mark =3D value_mark (); + scoped_value_mark mark; =20 computed =3D gdbarch_pseudo_register_read_value (m_descr->gdbarch, this, regnum); @@ -724,8 +724,6 @@ readable_regcache::cooked_read (int regnum, gdb_byte *b= uf) result =3D REG_UNAVAILABLE; } =20 - value_free_to_mark (mark); - return result; } else diff --git a/gdb/valarith.c b/gdb/valarith.c index c0e937d6c25..7a9e130a576 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -1615,7 +1615,7 @@ vector_binop (struct value *val1, struct value *val2,= enum exp_opcode op) =20 value *val =3D allocate_value (type1); gdb::array_view val_contents =3D value_contents_writeable (val= ); - value *mark =3D value_mark (); + scoped_value_mark mark; for (i =3D 0; i < high_bound1 - low_bound1 + 1; i++) { value *tmp =3D value_binop (value_subscript (val1, i), @@ -1623,7 +1623,6 @@ vector_binop (struct value *val1, struct value *val2,= enum exp_opcode op) copy (value_contents_all (tmp), val_contents.slice (i * elsize, elsize)); } - value_free_to_mark (mark); =20 return val; }