Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH][gdb/symtab] Fix element type modification in read_array_type
Date: Fri, 5 Feb 2021 13:28:15 +0100	[thread overview]
Message-ID: <20210205122814.GA19232@delia> (raw)

Hi,

When running test-case gdb.fortran/function-calls.exp with target board
unix/gdb:debug_flags=-gdwarf-5, I run into:
...
(gdb) PASS: gdb.fortran/function-calls.exp: \
  p derived_types_and_module_calls::pass_cart(c)
p derived_types_and_module_calls::pass_cart_nd(c_nd)^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0x0000000000400f73 in derived_types_and_module_calls::pass_cart_nd \
  (c=<error reading variable: Cannot access memory at address 0xc>) at \
  function-calls.f90:130^M
130             pass_cart_nd = ubound(c%d,1,4)^M
The program being debugged was signaled while in a function called from GDB.^M
GDB has restored the context to what it was before the call.^M
To change this behavior use "set unwindonsignal off".^M
Evaluation of the expression containing the function^M
(derived_types_and_module_calls::pass_cart_nd) will be abandoned.^M
(gdb) FAIL: gdb.fortran/function-calls.exp: p
...

The problem originates in read_array_type, when reading a DW_TAG_array_type
with a dwarf-5 DW_TAG_generic_subrange child.  This is not supported, and the
fallout of this is that rather than constructing a new array type, the code
proceeds to modify the element type.

Fix this conservatively by bailing out in read_array_type when not being able
to construct an array type.

Tested on x86_64-linux.

Any comments?

Thanks,
- Tom

[gdb/symtab] Fix element type modification in read_array_type

gdb/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	PR symtab/27341
	* dwarf2/read.c (read_array_type): Return NULL when not being able to
	construct an array type.

---
 gdb/dwarf2/read.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index f60e418172c..98189f7b566 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -17243,6 +17243,9 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
 	}
     }
 
+  if (type == element_type)
+    return NULL;
+
   /* Understand Dwarf2 support for vector types (like they occur on
      the PowerPC w/ AltiVec).  Gcc just adds another attribute to the
      array type.  This is not part of the Dwarf2/3 standard yet, but a

             reply	other threads:[~2021-02-05 12:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-05 12:28 Tom de Vries [this message]
2021-02-05 16:30 ` Tom Tromey
2021-02-07  8:38   ` Tom de Vries
2021-02-09 20:24     ` Tom Tromey
2021-02-09 22:29       ` Tom de Vries
2021-02-10 12:23         ` Tom Tromey

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=20210205122814.GA19232@delia \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /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