From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>, Dodji Seketeli <dseketel@redhat.com>
Subject: [patch] DWARF-3+ DW_AT_accessibility defaults #3 (GCC PR debug/45124)
Date: Fri, 01 Apr 2011 21:03:00 -0000 [thread overview]
Message-ID: <20110401210345.GA31785@host1.jankratochvil.net> (raw)
In-Reply-To: <20110328091943.GA21984@host1.jankratochvil.net>
Hi,
so here is a patch which works for everything but regresses gcc-4.5.x
-gdwarf-4, as suggested/allowed by Jakub:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48229#c6
As it has been regression tested enough I will check it in in some time (and
definitely for gdb-7.3).
FSF GDB HEAD without the patch:
-gdwarf-2 -gdwarf-3 -gdwarf-4
gcc-4.4.fsf pass pass pass
gcc-4.5.fsf pass pass PASS
gcc-4.6.fsf pass FAIL FAIL
gcc-4.7.fsf pass FAIL FAIL
gcc-4.4.fc13 pass
gcc-4.5.fc14 pass
gcc-4.6.fc15 FAIL
FSF GDB HEAD with the patch:
-gdwarf-2 -gdwarf-3 -gdwarf-4
gcc-4.4.fsf pass pass pass
gcc-4.5.fsf pass pass FAIL
gcc-4.6.fsf pass PASS PASS
gcc-4.7.fsf pass PASS PASS
gcc-4.4.fc13 pass
gcc-4.5.fc14 pass
gcc-4.6.fc15 PASS
GNU gdb (GDB) 7.2.50.20110401-cvs
gcc (GCC) 4.4.6 20110401 (prerelease)
gcc (GCC) 4.5.3 20110401 (prerelease)
gcc (GCC) 4.6.1 20110401 (prerelease)
gcc (GCC) 4.7.0 20110401 (experimental)
gcc-4.4.5-2.fc13
gcc-4.5.1-4.fc14
gcc-4.6.0-0.15.fc15
Only x86_64 host was being tested, the results match for both the default arch
(-m64) and for explicit -m32 arch.
DW_AT_accessibility affects also class's typedefs, these are implemented in
GCCs but not in GDB (GDB PR c++/11757).
The regression for gcc-4.5.x -gdwarf-3 could be fixed in the next gcc-4.5.x
release but no such fix exists now for the filed GCC PR debug/48229.
FSF GCCs default to -gdwarf-2; but they always had an explicit -gdwarf-*
parameter under this test.
Fedora notes:
Fedora GCCs were tested only without any -gdwarf-* parameter, Fedora GCCs
default to -gdwarf-3. Fedora GDB was not tested for this mail at all.
Thanks,
Jan
gdb/
2011-04-01 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2read.c: Include ctype.h.
(producer_is_gxx_lt_4_6, dwarf2_default_access_attribute): New
functions.
(dwarf2_add_field): Fix new_field->accessibility by calling
dwarf2_default_access_attribute. Restructure setting accessibility
vs. virtuality.
(dwarf2_add_member_fn): New variable accessibility. Fix fnp
is_private and is_protected by calling
dwarf2_default_access_attribute.
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -57,6 +57,7 @@
#include "vec.h"
#include "c-lang.h"
#include "valprint.h"
+#include <ctype.h>
#include <fcntl.h>
#include "gdb_string.h"
@@ -6209,6 +6210,81 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
}
}
+/* Check for GCC PR debug/45124 fix which is not present in any G++ version up
+ to 4.5.any while it is present already in G++ 4.6.0 - the PR has been fixed
+ during 4.6.0 experimental. */
+
+static int
+producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu)
+{
+ const char *cs;
+ int major, minor, release;
+
+ if (cu->producer == NULL)
+ {
+ /* For unknown compilers expect their behavior is DWARF version
+ compliant.
+
+ GCC started to support .debug_types sections by -gdwarf-4 since
+ gcc-4.5.x. As the .debug_types sections are missing DW_AT_producer
+ for their space efficiency GDB cannot workaround gcc-4.5.x -gdwarf-4
+ combination. gcc-4.5.x -gdwarf-4 binaries have DW_AT_accessibility
+ interpreted incorrectly by GDB now - GCC PR debug/48229. */
+
+ return 0;
+ }
+
+ /* Skip any identifier after "GNU " - such as "C++" or "Java". */
+
+ if (strncmp (cu->producer, "GNU ", strlen ("GNU ")) != 0)
+ {
+ /* For non-GCC compilers expect their behavior is DWARF version
+ compliant. */
+
+ return 0;
+ }
+ cs = &cu->producer[strlen ("GNU ")];
+ while (*cs && !isdigit (*cs))
+ cs++;
+ if (sscanf (cs, "%d.%d.%d", &major, &minor, &release) != 3)
+ {
+ /* Not recognized as GCC. */
+
+ return 0;
+ }
+
+ return major < 4 || (major == 4 && minor < 6);
+}
+
+/* Return the default accessibility type if it is not overriden by
+ DW_AT_accessibility. */
+
+static enum dwarf_access_attribute
+dwarf2_default_access_attribute (struct die_info *die, struct dwarf2_cu *cu)
+{
+ if (cu->header.version < 3 || producer_is_gxx_lt_4_6 (cu))
+ {
+ /* The default DWARF 2 accessibility for members is public, the default
+ accessibility for inheritance is private. */
+
+ if (die->tag != DW_TAG_inheritance)
+ return DW_ACCESS_public;
+ else
+ return DW_ACCESS_private;
+ }
+ else
+ {
+ /* DWARF 3+ defines the default accessibility a different way. The same
+ rules apply now for DW_TAG_inheritance as for the members and it only
+ depends on the container kind. */
+
+ if (die->parent->tag == DW_TAG_class_type)
+ return DW_ACCESS_private;
+ else
+ return DW_ACCESS_public;
+ }
+}
+
/* Add an aggregate field to the field list. */
static void
@@ -6239,23 +6315,19 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
}
fip->nfields++;
- /* Handle accessibility and virtuality of field.
- The default accessibility for members is public, the default
- accessibility for inheritance is private. */
- if (die->tag != DW_TAG_inheritance)
- new_field->accessibility = DW_ACCESS_public;
- else
- new_field->accessibility = DW_ACCESS_private;
- new_field->virtuality = DW_VIRTUALITY_none;
-
attr = dwarf2_attr (die, DW_AT_accessibility, cu);
if (attr)
new_field->accessibility = DW_UNSND (attr);
+ else
+ new_field->accessibility = dwarf2_default_access_attribute (die, cu);
if (new_field->accessibility != DW_ACCESS_public)
fip->non_public_fields = 1;
+
attr = dwarf2_attr (die, DW_AT_virtuality, cu);
if (attr)
new_field->virtuality = DW_UNSND (attr);
+ else
+ new_field->virtuality = DW_VIRTUALITY_none;
fp = &new_field->field;
@@ -6571,6 +6643,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
char *fieldname;
struct nextfnfield *new_fnfield;
struct type *this_type;
+ enum dwarf_access_attribute accessibility;
if (cu->language == language_ada)
error (_("unexpected member function in Ada type"));
@@ -6669,16 +6742,17 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
/* Get accessibility. */
attr = dwarf2_attr (die, DW_AT_accessibility, cu);
if (attr)
+ accessibility = DW_UNSND (attr);
+ else
+ accessibility = dwarf2_default_access_attribute (die, cu);
+ switch (accessibility)
{
- switch (DW_UNSND (attr))
- {
- case DW_ACCESS_private:
- fnp->is_private = 1;
- break;
- case DW_ACCESS_protected:
- fnp->is_protected = 1;
- break;
- }
+ case DW_ACCESS_private:
+ fnp->is_private = 1;
+ break;
+ case DW_ACCESS_protected:
+ fnp->is_protected = 1;
+ break;
}
/* Check for artificial methods. */
next prev parent reply other threads:[~2011-04-01 21:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-21 15:47 [patch] DWARF-3+ DW_AT_accessibility defaults #2 " Jan Kratochvil
2011-03-21 17:29 ` Tom Tromey
2011-03-21 20:15 ` Jan Kratochvil
2011-03-21 20:41 ` Tom Tromey
2011-03-22 10:06 ` revert+new [patch]: " Jan Kratochvil
2011-03-22 18:16 ` Tom Tromey
2011-03-22 18:32 ` Jan Kratochvil
2011-03-23 2:12 ` Dodji Seketeli
2011-03-28 12:35 ` Jan Kratochvil
2011-04-01 21:03 ` Jan Kratochvil [this message]
2011-04-03 16:28 ` [patch] DWARF-3+ DW_AT_accessibility defaults #3 " Jan Kratochvil
2011-04-09 11:21 ` [commit]+[brach 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=20110401210345.GA31785@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=dseketel@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