From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Fix DW_AT_lower_bound DWARF-4+ defaults
Date: Thu, 26 Apr 2012 16:16:00 -0000 [thread overview]
Message-ID: <20120426160952.GA18206@host2.jankratochvil.net> (raw)
In-Reply-To: <87ipgm8pnd.fsf@fleche.redhat.com>
On Thu, 26 Apr 2012 17:43:34 +0200, Tom Tromey wrote:
> I think the nicest thing would be to pick the DWARF 4 defaults, and
> complain for other versions.
OK.
Thanks,
Jan
gdb/
2012-04-26 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix DW_AT_lower_bound defaults for DWARF-4+.
* dwarf2read.c (read_subrange_type): Remove initialization of low and
high. New variable low_default_is_valid. Implement DWARF-4+
DW_AT_lower_bound defaults. Print complaint for DW_AT_lower_bound with
no default by the DWARF standard.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index bd2d6f2..99bba9f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9086,8 +9086,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
struct type *base_type;
struct type *range_type;
struct attribute *attr;
- LONGEST low = 0;
- LONGEST high = -1;
+ LONGEST low, high;
+ int low_default_is_valid;
char *name;
LONGEST negative_mask;
@@ -9100,10 +9100,35 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
if (range_type)
return range_type;
- if (cu->language == language_fortran)
+ /* Set LOW_DEFAULT_IS_VALID if current language and DWARF version allow
+ omitting DW_AT_lower_bound. */
+ switch (cu->language)
{
- /* FORTRAN implies a lower bound of 1, if not given. */
+ case language_c:
+ case language_cplus:
+ low = 0;
+ low_default_is_valid = 1;
+ break;
+ case language_fortran:
+ low = 1;
+ low_default_is_valid = 1;
+ break;
+ case language_d:
+ case language_java:
+ case language_objc:
+ low = 0;
+ low_default_is_valid = (cu->header.version >= 4);
+ break;
+ case language_ada:
+ case language_m2:
+ case language_pascal:
low = 1;
+ low_default_is_valid = (cu->header.version >= 4);
+ break;
+ default:
+ low = 0;
+ low_default_is_valid = 0;
+ break;
}
/* FIXME: For variable sized arrays either of these could be
@@ -9111,7 +9136,11 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
but we don't know how to handle it. */
attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
if (attr)
- low = dwarf2_get_attr_constant_value (attr, 0);
+ low = dwarf2_get_attr_constant_value (attr, low);
+ else if (!low_default_is_valid)
+ complaint (&symfile_complaints, _("Missing DW_AT_lower_bound "
+ "- DIE at 0x%x [in module %s]"),
+ die->offset.sect_off, cu->objfile->name);
attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
if (attr)
next prev parent reply other threads:[~2012-04-26 16:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-26 15:08 Jan Kratochvil
2012-04-26 16:09 ` Tom Tromey
2012-04-26 15:39 ` Jan Kratochvil
2012-04-26 15:55 ` Tom Tromey
2012-04-26 16:16 ` Jan Kratochvil [this message]
2012-04-26 20:35 ` [commit] " Jan Kratochvil
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=20120426160952.GA18206@host2.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/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