diff options
author | Pedro Alves <palves@redhat.com> | 2010-07-28 19:04:08 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2010-07-28 19:04:08 +0000 |
commit | 3ce3b1ba3153a2fc9265ba78cc25acaa7db127ba (patch) | |
tree | cd0924e857600e96284efa3193a9c1ead08599b6 /gdb/dwarf2read.c | |
parent | 2bb4f988e5ec9ab6c7adc9c9eb8cc6b8f56491a4 (diff) | |
download | gdb-3ce3b1ba3153a2fc9265ba78cc25acaa7db127ba.zip gdb-3ce3b1ba3153a2fc9265ba78cc25acaa7db127ba.tar.gz gdb-3ce3b1ba3153a2fc9265ba78cc25acaa7db127ba.tar.bz2 |
2010-07-28 Daniel Jacobowitz <dan@codesourcery.com>
gdb/
* dwarf2read.c (read_subroutine_type): Improve THIS detection,
handling DW_AT_object_pointer, and workaround GCC PR 43053.
gdb/testsuite/
* gdb.cp/member-ptr.exp, gdb.cp/printmethod.exp,
gdb.dwarf2/member-ptr-forwardref.exp: Adjust.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 4c92c61..7a0da0e 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -7395,11 +7395,17 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) { if (child_die->tag == DW_TAG_formal_parameter) { - /* Dwarf2 has no clean way to discern C++ static and non-static - member functions. G++ helps GDB by marking the first - parameter for non-static member functions (which is the - this pointer) as artificial. We pass this information - to dwarf2_add_member_fn via TYPE_FIELD_ARTIFICIAL. */ + struct type *arg_type; + + /* DWARF version 2 has no clean way to discern C++ + static and non-static member functions. G++ helps + GDB by marking the first parameter for non-static + member functions (which is the this pointer) as + artificial. We pass this information to + dwarf2_add_member_fn via TYPE_FIELD_ARTIFICIAL. + + DWARF version 3 added DW_AT_object_pointer, which GCC + 4.5 does not yet generate. */ attr = dwarf2_attr (child_die, DW_AT_artificial, cu); if (attr) TYPE_FIELD_ARTIFICIAL (ftype, iparams) = DW_UNSND (attr); @@ -7417,7 +7423,40 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 1; } } - TYPE_FIELD_TYPE (ftype, iparams) = die_type (child_die, cu); + arg_type = die_type (child_die, cu); + + /* RealView does not mark THIS as const, which the testsuite + expects. GCC marks THIS as const in method definitions, + but not in the class specifications (GCC PR 43053). */ + if (cu->language == language_cplus && !TYPE_CONST (arg_type) + && TYPE_FIELD_ARTIFICIAL (ftype, iparams)) + { + int is_this = 0; + struct dwarf2_cu *arg_cu = cu; + const char *name = dwarf2_name (child_die, cu); + + attr = dwarf2_attr (die, DW_AT_object_pointer, cu); + if (attr) + { + /* If the compiler emits this, use it. */ + if (follow_die_ref (die, attr, &arg_cu) == child_die) + is_this = 1; + } + else if (name && strcmp (name, "this") == 0) + /* Function definitions will have the argument names. */ + is_this = 1; + else if (name == NULL && iparams == 0) + /* Declarations may not have the names, so like + elsewhere in GDB, assume an artificial first + argument is "this". */ + is_this = 1; + + if (is_this) + arg_type = make_cv_type (1, TYPE_VOLATILE (arg_type), + arg_type, 0); + } + + TYPE_FIELD_TYPE (ftype, iparams) = arg_type; iparams++; } child_die = sibling_die (child_die); |