diff options
author | Tom Tromey <tom@tromey.com> | 2020-12-06 21:34:25 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-12-06 21:34:25 -0700 |
commit | 00158a68d1c382f9afe16630ac327695a4904556 (patch) | |
tree | 24ab9542af6751f6651d90e6d20fb32b1443d108 | |
parent | 13f11b0b61ca2620611b08eeaece0ce62c862f4b (diff) | |
download | gdb-00158a68d1c382f9afe16630ac327695a4904556.zip gdb-00158a68d1c382f9afe16630ac327695a4904556.tar.gz gdb-00158a68d1c382f9afe16630ac327695a4904556.tar.bz2 |
Fix struct expression regression
The patch to change struct expression to use new introduced a
regression -- there is a spot that reallocates expressions that I
failed to update.
This patch rewrites this code to follow the new approach. Now the
rewriting is done in place.
gdb/ChangeLog
2020-12-06 Tom Tromey <tom@tromey.com>
PR ada/26999
* ada-lang.c (replace_operator_with_call): Rewrite.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/ada-lang.c | 31 |
2 files changed, 18 insertions, 18 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2111506..3c21cff 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-12-06 Tom Tromey <tom@tromey.com> + + PR ada/26999 + * ada-lang.c (replace_operator_with_call): Rewrite. + 2020-12-06 Giancarlo Frix <gfrix@rocketsoftware.com> (tiny change) PR breakpoints/27009 diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9066711..7d06229 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -4000,28 +4000,23 @@ replace_operator_with_call (expression_up *expp, int pc, int nargs, int oplen, struct symbol *sym, const struct block *block) { - /* A new expression, with 6 more elements (3 for funcall, 4 for function - symbol, -oplen for operator being replaced). */ - struct expression *newexp = (struct expression *) - xzalloc (sizeof (struct expression) - + EXP_ELEM_TO_BYTES ((*expp)->nelts + 7 - oplen)); + /* We want to add 6 more elements (3 for funcall, 4 for function + symbol, -OPLEN for operator being replaced) to the + expression. */ struct expression *exp = expp->get (); + int save_nelts = exp->nelts; + exp->nelts = exp->nelts + 7 - oplen; + exp->resize (exp->nelts); - newexp->nelts = exp->nelts + 7 - oplen; - newexp->language_defn = exp->language_defn; - newexp->gdbarch = exp->gdbarch; - memcpy (newexp->elts, exp->elts, EXP_ELEM_TO_BYTES (pc)); - memcpy (newexp->elts + pc + 7, exp->elts + pc + oplen, - EXP_ELEM_TO_BYTES (exp->nelts - pc - oplen)); + memmove (exp->elts + pc + 7, exp->elts + pc + oplen, + EXP_ELEM_TO_BYTES (save_nelts - pc - oplen)); - newexp->elts[pc].opcode = newexp->elts[pc + 2].opcode = OP_FUNCALL; - newexp->elts[pc + 1].longconst = (LONGEST) nargs; + exp->elts[pc].opcode = exp->elts[pc + 2].opcode = OP_FUNCALL; + exp->elts[pc + 1].longconst = (LONGEST) nargs; - newexp->elts[pc + 3].opcode = newexp->elts[pc + 6].opcode = OP_VAR_VALUE; - newexp->elts[pc + 4].block = block; - newexp->elts[pc + 5].symbol = sym; - - expp->reset (newexp); + exp->elts[pc + 3].opcode = exp->elts[pc + 6].opcode = OP_VAR_VALUE; + exp->elts[pc + 4].block = block; + exp->elts[pc + 5].symbol = sym; } /* Type-class predicates */ |