public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/26999] New: replace_operator_with_call fails to set newexp->elts
@ 2020-12-02 19:37 vries at gcc dot gnu.org
  2020-12-02 19:47 ` [Bug ada/26999] " vries at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2020-12-02 19:37 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26999

            Bug ID: 26999
           Summary: replace_operator_with_call fails to set newexp->elts
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ada
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

In replace_operator_with_call, we allocate an expression:
...
  struct expression *newexp = (struct expression *)
    xzalloc (sizeof (struct expression)
             + EXP_ELEM_TO_BYTES ((*expp)->nelts + 7 - oplen));
  struct expression *exp = expp->get ();

  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));

  newexp->elts[pc].opcode = newexp->elts[pc + 2].opcode = OP_FUNCALL;
  newexp->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;
...

newexp->elts however is not set and remains NULL.

Setting it to the allocated chunk with:
...
  newexp->elts = (exp_element*)((uintptr_t)(void *)newexp + sizeof (struct
expression));
...
is not a good idea either, because it's freed later on.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/26999] replace_operator_with_call fails to set newexp->elts
  2020-12-02 19:37 [Bug ada/26999] New: replace_operator_with_call fails to set newexp->elts vries at gcc dot gnu.org
@ 2020-12-02 19:47 ` vries at gcc dot gnu.org
  2020-12-02 20:45 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2020-12-02 19:47 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26999

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Tentative patch:
...
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 906671155d..956cf52720 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4002,14 +4002,10 @@ replace_operator_with_call (expression_up *expp, int
pc, int n
args,
 {
   /* 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));
   struct expression *exp = expp->get ();
+  struct expression *newexp
+    = new expression (exp->language_defn, exp->gdbarch, exp->nelts + 7 -
oplen);

-  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));
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/26999] replace_operator_with_call fails to set newexp->elts
  2020-12-02 19:37 [Bug ada/26999] New: replace_operator_with_call fails to set newexp->elts vries at gcc dot gnu.org
  2020-12-02 19:47 ` [Bug ada/26999] " vries at gcc dot gnu.org
@ 2020-12-02 20:45 ` vries at gcc dot gnu.org
  2020-12-02 20:55 ` tromey at sourceware dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2020-12-02 20:45 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26999

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Hmm, this looks like fallout from:
...
commit 77bf7e991150d3fac70294910c027c43ae5789b6
Author: Tom Tromey <tom@tromey.com>
Date:   Tue Dec 1 17:22:05 2020 -0700

    Use new+delete for struct expression
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/26999] replace_operator_with_call fails to set newexp->elts
  2020-12-02 19:37 [Bug ada/26999] New: replace_operator_with_call fails to set newexp->elts vries at gcc dot gnu.org
  2020-12-02 19:47 ` [Bug ada/26999] " vries at gcc dot gnu.org
  2020-12-02 20:45 ` vries at gcc dot gnu.org
@ 2020-12-02 20:55 ` tromey at sourceware dot org
  2020-12-04 14:22 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at sourceware dot org @ 2020-12-02 20:55 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26999

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |tromey at sourceware dot org

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
Sigh.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/26999] replace_operator_with_call fails to set newexp->elts
  2020-12-02 19:37 [Bug ada/26999] New: replace_operator_with_call fails to set newexp->elts vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-12-02 20:55 ` tromey at sourceware dot org
@ 2020-12-04 14:22 ` vries at gcc dot gnu.org
  2020-12-07  4:36 ` cvs-commit at gcc dot gnu.org
  2020-12-07 14:21 ` tromey at sourceware dot org
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2020-12-04 14:22 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26999

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
Patch posted:
https://sourceware.org/pipermail/gdb-patches/2020-December/173716.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/26999] replace_operator_with_call fails to set newexp->elts
  2020-12-02 19:37 [Bug ada/26999] New: replace_operator_with_call fails to set newexp->elts vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-12-04 14:22 ` vries at gcc dot gnu.org
@ 2020-12-07  4:36 ` cvs-commit at gcc dot gnu.org
  2020-12-07 14:21 ` tromey at sourceware dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-07  4:36 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26999

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=00158a68d1c382f9afe16630ac327695a4904556

commit 00158a68d1c382f9afe16630ac327695a4904556
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Dec 6 21:34:25 2020 -0700

    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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/26999] replace_operator_with_call fails to set newexp->elts
  2020-12-02 19:37 [Bug ada/26999] New: replace_operator_with_call fails to set newexp->elts vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-12-07  4:36 ` cvs-commit at gcc dot gnu.org
@ 2020-12-07 14:21 ` tromey at sourceware dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at sourceware dot org @ 2020-12-07 14:21 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26999

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |11.1

--- Comment #6 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-12-07 14:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02 19:37 [Bug ada/26999] New: replace_operator_with_call fails to set newexp->elts vries at gcc dot gnu.org
2020-12-02 19:47 ` [Bug ada/26999] " vries at gcc dot gnu.org
2020-12-02 20:45 ` vries at gcc dot gnu.org
2020-12-02 20:55 ` tromey at sourceware dot org
2020-12-04 14:22 ` vries at gcc dot gnu.org
2020-12-07  4:36 ` cvs-commit at gcc dot gnu.org
2020-12-07 14:21 ` tromey at sourceware dot org

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).