aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2010-09-08 19:09:43 +0000
committerDaniel Jacobowitz <drow@false.org>2010-09-08 19:09:43 +0000
commitc767944bf25ae52241366d9bdc7ba14b493f17eb (patch)
tree322a298962eafe7852fad3d99848edcf3fd8cbc4
parent561d38252c8b1c7a006eb58f079d3d650bee5743 (diff)
downloadgdb-c767944bf25ae52241366d9bdc7ba14b493f17eb.zip
gdb-c767944bf25ae52241366d9bdc7ba14b493f17eb.tar.gz
gdb-c767944bf25ae52241366d9bdc7ba14b493f17eb.tar.bz2
gdb/
* dwarf2read.c (read_structure_type): Move processing of fields and member functions from here... (process_structure_scope): ... to here. gdb/testsuite/ * gdb.cp/templates.cc (Empty, FunctionArg): New classes. (FunctionArg::method): New function. (empty, arg): New variables. (main): Call arg.method. * gdb.cp/templates.exp (test_template_args): New function. (do_tests): Call it.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/dwarf2read.c48
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.cp/templates.cc32
-rw-r--r--gdb/testsuite/gdb.cp/templates.exp11
5 files changed, 71 insertions, 35 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a31bfd5..45eb3e7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2010-09-08 Daniel Jacobowitz <dan@codesourcery.com>
+ * dwarf2read.c (read_structure_type): Move processing of
+ fields and member functions from here...
+ (process_structure_scope): ... to here.
+
+2010-09-08 Daniel Jacobowitz <dan@codesourcery.com>
+
* gnu-v3-abi.c (gnuv3_print_method_ptr): Do not use
the domain type.
(gnuv3_make_method_ptr): Likewise.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 3720891..b7d3b21 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6643,11 +6643,12 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile)
}
/* Called when we find the DIE that starts a structure or union scope
- (definition) to process all dies that define the members of the
- structure or union.
+ (definition) to create a type for the structure or union. Fill in
+ the type's name and general properties; the members will not be
+ processed until process_structure_type.
- NOTE: we need to call struct_type regardless of whether or not the
- DIE has an at_name attribute, since it might be an anonymous
+ NOTE: we need to call these functions regardless of whether or not the
+ DIE has a DW_AT_name attribute, since it might be an anonymous
structure or union. This gets the type entered into our set of
user defined types.
@@ -6665,7 +6666,6 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
struct type *type;
struct attribute *attr;
char *name;
- struct cleanup *back_to;
/* If the definition of this type lives in .debug_types, read that type.
Don't follow DW_AT_specification though, that will take us back up
@@ -6687,8 +6687,6 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
return set_die_type (die, type, cu);
}
- back_to = make_cleanup (null_cleanup, 0);
-
type = alloc_type (objfile);
INIT_CPLUS_SPECIFIC (type);
@@ -6763,11 +6761,29 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
/* set_die_type should be already done. */
set_descriptive_type (type, die, cu);
+ return type;
+}
+
+/* Finish creating a structure or union type, including filling in
+ its members and creating a symbol for it. */
+
+static void
+process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
+{
+ struct objfile *objfile = cu->objfile;
+ struct die_info *child_die = die->child;
+ struct type *type;
+
+ type = get_die_type (die, cu);
+ if (type == NULL)
+ type = read_structure_type (die, cu);
+
if (die->child != NULL && ! die_is_declaration (die, cu))
{
struct field_info fi;
struct die_info *child_die;
VEC (symbolp) *template_args = NULL;
+ struct cleanup *back_to = make_cleanup (null_cleanup, 0);
memset (&fi, 0, sizeof (struct field_info));
@@ -6918,24 +6934,12 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
*dest = *src;
}
}
+
+ do_cleanups (back_to);
}
quirk_gcc_member_function_pointer (type, cu->objfile);
- do_cleanups (back_to);
- return type;
-}
-
-static void
-process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
-{
- struct die_info *child_die = die->child;
- struct type *this_type;
-
- this_type = get_die_type (die, cu);
- if (this_type == NULL)
- this_type = read_structure_type (die, cu);
-
/* NOTE: carlton/2004-03-16: GCC 3.4 (or at least one of its
snapshots) has been known to create a die giving a declaration
for a class that has, as a child, a die giving a definition for a
@@ -6964,7 +6968,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
attribute, and a declaration attribute. */
if (dwarf2_attr (die, DW_AT_byte_size, cu) != NULL
|| !die_is_declaration (die, cu))
- new_symbol (die, this_type, cu);
+ new_symbol (die, type, cu);
}
/* Given a DW_AT_enumeration_type die, set its type. We do not
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 516efae..3868b97 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-08 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * gdb.cp/templates.cc (Empty, FunctionArg): New classes.
+ (FunctionArg::method): New function.
+ (empty, arg): New variables.
+ (main): Call arg.method.
+ * gdb.cp/templates.exp (test_template_args): New function.
+ (do_tests): Call it.
+
2010-09-08 Ulrich Weigand <uweigand@de.ibm.com>
* gdb.threads/threxit-hop-specific.exp: Use "continue" instead
diff --git a/gdb/testsuite/gdb.cp/templates.cc b/gdb/testsuite/gdb.cp/templates.cc
index 783bc2c..b5e0643 100644
--- a/gdb/testsuite/gdb.cp/templates.cc
+++ b/gdb/testsuite/gdb.cp/templates.cc
@@ -712,6 +712,23 @@ template<class T> T Garply<T>::garply (int i, T tt)
}
}
+template<class C> class Empty
+{
+};
+
+template<class C> class FunctionArg
+{
+public:
+ int method(Empty<void (FunctionArg<C>)> &);
+};
+
+template<class C> int FunctionArg<C>::method(Empty<void (FunctionArg<C>)> &arg)
+{
+ return 75;
+}
+
+Empty<void(FunctionArg<int>)> empty;
+FunctionArg<int> arg;
int main()
{
@@ -785,18 +802,7 @@ int main()
t5i.value();
+ arg.method(empty);
+
return 0;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp
index 33cccc1..c531307 100644
--- a/gdb/testsuite/gdb.cp/templates.exp
+++ b/gdb/testsuite/gdb.cp/templates.exp
@@ -196,6 +196,16 @@ proc test_template_typedef {} {
"print destructor of template typedef"
}
+proc test_template_args {} {
+
+ set empty_re "Empty *<void *\\(FunctionArg *<int>\\)>"
+ gdb_test "ptype empty" \
+ "type = class $empty_re {.*<no data fields>.*}"
+
+ gdb_test "ptype arg" \
+ "type = class FunctionArg<int> {.*int method\\($empty_re \\&\\);.*}"
+}
+
proc do_tests {} {
global subdir
global objdir
@@ -220,6 +230,7 @@ proc do_tests {} {
test_ptype_of_templates
test_template_breakpoints
test_template_typedef
+ test_template_args
if [ runto_main] {
test_template_calls