From 418835cceca7eb0a5193eb476fe1733ab290adcc Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Thu, 25 Mar 2010 22:13:15 +0000 Subject: [PATCH] * dwarf2read.c (read_subroutine_type): If the compilation unit language is Java, mark any formal parameter named "this" as artificial (GCC/43521). (dwarf2_name): Add special handling for Java constructors. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2read.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d2c44c0df8..3bf6836230 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2010-03-25 Keith Seitz + + * dwarf2read.c (read_subroutine_type): If the compilation unit + language is Java, mark any formal parameter named "this" as + artificial (GCC/43521). + (dwarf2_name): Add special handling for Java constructors. + 2010-03-25 Tom Tromey PR gdb/11327, PR gdb/11328, PR breakpoints/11368: diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 40f8cdeb2c..4de07976f7 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -5949,7 +5949,18 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) if (attr) TYPE_FIELD_ARTIFICIAL (ftype, iparams) = DW_UNSND (attr); else - TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0; + { + TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0; + + /* GCC/43521: In java, the formal parameter + "this" is sometimes not marked with DW_AT_artificial. */ + if (cu->language == language_java) + { + const char *name = dwarf2_name (child_die, cu); + if (name && !strcmp (name, "this")) + TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 1; + } + } TYPE_FIELD_TYPE (ftype, iparams) = die_type (child_die, cu); iparams++; } @@ -9176,6 +9187,34 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) /* These tags always have simple identifiers already; no need to canonicalize them. */ return DW_STRING (attr); + case DW_TAG_subprogram: + /* Java constructors will all be named "", so return + the class name when we see this special case. */ + if (cu->language == language_java + && DW_STRING (attr) != NULL + && strcmp (DW_STRING (attr), "") == 0) + { + struct dwarf2_cu *spec_cu = cu; + struct die_info *spec_die; + + /* GCJ will output '' for Java constructor names. + For this special case, return the name of the parent class. */ + + /* GCJ may output suprogram DIEs with AT_specification set. + If so, use the name of the specified DIE. */ + spec_die = die_specification (die, &spec_cu); + if (spec_die != NULL) + return dwarf2_name (spec_die, spec_cu); + + do + { + die = die->parent; + if (die->tag == DW_TAG_class_type) + return dwarf2_name (die, cu); + } + while (die->tag != DW_TAG_compile_unit); + } + /* fall through */ default: if (!DW_STRING_IS_CANONICAL (attr)) { -- 2.34.1