diff --git a/gdb-bz602314-ptype-class-typedef-1of3.patch b/gdb-bz602314-ptype-class-typedef-1of3.patch new file mode 100644 index 0000000..1d31bf2 --- /dev/null +++ b/gdb-bz602314-ptype-class-typedef-1of3.patch @@ -0,0 +1,274 @@ +commit f49f91e9c3eaba847f75f5c46e77e261a76d9a9b +Author: Jan Kratochvil +Date: Mon Jun 28 20:35:51 2010 +0000 + + gdb/ + * cp-namespace.c (cp_lookup_nested_type): New variable + concatenated_name. Turn the current return condition into a reverse + one. Call also lookup_static_symbol_aux on the constructed qualified + name. + * symtab.c (lookup_symbol_aux): Move variable objfile and searching in + other files into a called ... + (lookup_static_symbol_aux): ... new function here. + * symtab.h (lookup_static_symbol_aux): New prototype. + * valops.c (value_maybe_namespace_elt): Call also + lookup_static_symbol_aux if we failed otherwise. + + gdb/testsuite/ + * gdb.cp/namespace.exp (whatis C::cOtherFileType) + (whatis ::C::cOtherFileType, whatis C::cOtherFileVar) + (whatis ::C::cOtherFileVar, print C::cOtherFileVar) + (print ::C::cOtherFileVar) + (whatis C::OtherFileClass::cOtherFileClassType) + (whatis ::C::OtherFileClass::cOtherFileClassType) + (print C::OtherFileClass::cOtherFileClassVar) + (print ::cOtherFileClassVar) + (print ::C::OtherFileClass::cOtherFileClassVar): New tests. + (ptype OtherFileClass, ptype ::C::OtherFileClass): Permit arbitrary + trailing content. + * gdb.cp/namespace1.cc (C::OtherFileClass::cOtherFileClassType) + (C::OtherFileClass::cOtherFileClassVar) + (C::OtherFileClass::cOtherFileClassVar_use, C::cOtherFileType) + (C::cOtherFileVar, C::cOtherFileVar_use): New. + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,5 +1,18 @@ + 2010-06-28 Jan Kratochvil + ++ * cp-namespace.c (cp_lookup_nested_type): New variable ++ concatenated_name. Turn the current return condition into a reverse ++ one. Call also lookup_static_symbol_aux on the constructed qualified ++ name. ++ * symtab.c (lookup_symbol_aux): Move variable objfile and searching in ++ other files into a called ... ++ (lookup_static_symbol_aux): ... new function here. ++ * symtab.h (lookup_static_symbol_aux): New prototype. ++ * valops.c (value_maybe_namespace_elt): Call also ++ lookup_static_symbol_aux if we failed otherwise. ++ ++2010-06-28 Jan Kratochvil ++ + Fix PR c++/11703 and PR gdb/1448. + * c-exp.y (yylex) : Add + FIRST_ITER check. +Index: gdb-7.1/gdb/cp-namespace.c +=================================================================== +--- gdb-7.1.orig/gdb/cp-namespace.c 2010-06-29 17:54:17.000000000 +0200 ++++ gdb-7.1/gdb/cp-namespace.c 2010-06-29 17:59:32.000000000 +0200 +@@ -585,10 +585,24 @@ cp_lookup_nested_type (struct type *pare + nested_name, + block, + VAR_DOMAIN); +- if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF) +- return NULL; +- else ++ char *concatenated_name; ++ ++ if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF) ++ return SYMBOL_TYPE (sym); ++ ++ /* Now search all static file-level symbols. Not strictly correct, ++ but more useful than an error. We do not try to guess any imported ++ namespace as even the fully specified namespace seach is is already ++ not C++ compliant and more assumptions could make it too magic. */ ++ ++ concatenated_name = alloca (strlen (parent_name) + 2 ++ + strlen (nested_name) + 1); ++ sprintf (concatenated_name, "%s::%s", parent_name, nested_name); ++ sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN); ++ if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF) + return SYMBOL_TYPE (sym); ++ ++ return NULL; + } + default: + internal_error (__FILE__, __LINE__, +Index: gdb-7.1/gdb/symtab.h +=================================================================== +--- gdb-7.1.orig/gdb/symtab.h 2010-06-29 17:54:16.000000000 +0200 ++++ gdb-7.1/gdb/symtab.h 2010-06-29 18:00:37.000000000 +0200 +@@ -1036,6 +1036,12 @@ extern struct partial_symbol *lookup_par + const char *, int, + domain_enum); + ++/* Lookup a symbol only in the file static scope of all the objfiles. */ ++ ++struct symbol *lookup_static_symbol_aux (const char *name, ++ const domain_enum domain); ++ ++ + /* lookup a symbol by name, within a specified block */ + + extern struct symbol *lookup_block_symbol (const struct block *, const char *, +Index: gdb-7.1/gdb/testsuite/gdb.cp/namespace.exp +=================================================================== +--- gdb-7.1.orig/gdb/testsuite/gdb.cp/namespace.exp 2010-06-29 17:54:11.000000000 +0200 ++++ gdb-7.1/gdb/testsuite/gdb.cp/namespace.exp 2010-06-29 18:17:17.000000000 +0200 +@@ -217,6 +217,70 @@ gdb_expect { + gdb_test "break BBB::Class::xyzq" \ + "Breakpoint.*at $hex: file.*namespace.cc, line 68\\." + ++# Tests accessing static elements in namespace of other file. ++ ++gdb_test "whatis C::cOtherFileType" "type = short" ++gdb_test "whatis ::C::cOtherFileType" "type = short" ++gdb_test "whatis C::cOtherFileVar" "type = const C::cOtherFileType" ++gdb_test "whatis ::C::cOtherFileVar" "type = const C::cOtherFileType" ++gdb_test "print C::cOtherFileVar" "\\$\[0-9\].* = 319" ++gdb_test "print ::C::cOtherFileVar" "\\$\[0-9\].* = 319" ++ ++if {[test_compiler_info {gcc-[0-3]-*}] ++ || [test_compiler_info {gcc-4-[0-4]-*}]} { ++ # The type in class is missing in older GCCs. ++ setup_xfail *-*-* ++} ++gdb_test "whatis C::OtherFileClass::cOtherFileClassType" "type = short" ++if {[test_compiler_info {gcc-[0-3]-*}] ++ || [test_compiler_info {gcc-4-[0-4]-*}]} { ++ # The type in class is missing in older GCCs. ++ setup_xfail *-*-* ++} ++gdb_test "whatis ::C::OtherFileClass::cOtherFileClassType" "type = short" ++ ++set test "print C::OtherFileClass::cOtherFileClassVar" ++gdb_test_multiple $test $test { ++ -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" { ++ setup_kfail "c++/11702" "*-*-*" ++ fail $test ++ } ++} ++ ++# FSF GCC <=4.4 creates unqualified DIE "cOtherFileClassVar" ignoring the ++# namespace the same way older GDB did. ++set test "print ::cOtherFileClassVar" ++set test2 "print ::C::OtherFileClass::cOtherFileClassVar" ++gdb_test_multiple $test $test { ++ -re "No symbol \"cOtherFileClassVar\" in current context\\.\r\n$gdb_prompt $" { ++ pass $test ++ ++ gdb_test_multiple $test2 $test2 { ++ -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" { ++ pass $test2 ++ } ++ -re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" { ++ setup_kfail "c++/11702" "*-*-*" ++ fail $test2 ++ } ++ } ++ ++ } ++ -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" { ++ if {[test_compiler_info {gcc-[0-3]-*}] ++ || [test_compiler_info {gcc-4-[0-4]-*}]} { ++ # Do not permit to XFAIL on recent GCCs. ++ setup_xfail *-*-* ++ } ++ fail $test ++ ++ unresolved $test2 ++ } ++} ++ + # Test to see if the appropriate namespaces are in scope when trying + # to print out stuff from within a function defined within a + # namespace. +@@ -260,7 +324,7 @@ gdb_test "ptype C::NestedClass" "No symb + # Tests involving multiple files + + gdb_test "print cOtherFile" "\\$\[0-9\].* = 316" +-gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n\}" ++gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n.*\}" + cp_test_ptype_class \ + "ptype ::C::OtherFileClass" "" "class" "C::OtherFileClass" \ + { +Index: gdb-7.1/gdb/testsuite/gdb.cp/namespace1.cc +=================================================================== +--- gdb-7.1.orig/gdb/testsuite/gdb.cp/namespace1.cc 2010-01-01 08:32:01.000000000 +0100 ++++ gdb-7.1/gdb/testsuite/gdb.cp/namespace1.cc 2010-06-29 17:56:42.000000000 +0200 +@@ -21,7 +21,15 @@ namespace C + class OtherFileClass { + public: + int z; ++ ++ typedef short cOtherFileClassType; ++ static const cOtherFileClassType cOtherFileClassVar = 318; ++ cOtherFileClassType cOtherFileClassVar_use (); + }; ++ OtherFileClass::cOtherFileClassType OtherFileClass::cOtherFileClassVar_use () ++ { ++ return cOtherFileClassVar; ++ } + + namespace { + int cXOtherFile = 29; +@@ -35,6 +43,13 @@ namespace C + static OtherFileClass *c = new OtherFileClass(); + c->z = cOtherFile + cXOtherFile; + } ++ ++ typedef short cOtherFileType; ++ static const cOtherFileType cOtherFileVar = 319; ++ cOtherFileType cOtherFileVar_use () ++ { ++ return cOtherFileVar; ++ } + } + + namespace { +Index: gdb-7.1/gdb/valops.c +=================================================================== +--- gdb-7.1.orig/gdb/valops.c 2010-06-29 17:54:16.000000000 +0200 ++++ gdb-7.1/gdb/valops.c 2010-06-29 18:15:00.000000000 +0200 +@@ -3253,9 +3253,17 @@ value_maybe_namespace_elt (const struct + struct symbol *sym; + struct value *result; + +- sym = cp_lookup_symbol_namespace(namespace_name, name, +- get_selected_block (0), +- VAR_DOMAIN); ++ sym = cp_lookup_symbol_namespace (namespace_name, name, ++ get_selected_block (0), VAR_DOMAIN); ++ ++ if (sym == NULL) ++ { ++ char *concatenated_name = alloca (strlen (namespace_name) + 2 ++ + strlen (name) + 1); ++ ++ sprintf (concatenated_name, "%s::%s", namespace_name, name); ++ sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN); ++ } + + if (sym == NULL) + return NULL; +--- a/gdb/symtab.c ++++ b/gdb/symtab.c +@@ -1122,10 +1121,21 @@ lookup_symbol_aux (const char *name, const struct block *block, + return sym; + + /* Now search all static file-level symbols. Not strictly correct, +- but more useful than an error. Do the symtabs first, then check +- the psymtabs. If a psymtab indicates the existence of the +- desired name as a file-level static, then do psymtab-to-symtab +- conversion on the fly and return the found symbol. */ ++ but more useful than an error. */ ++ ++ return lookup_static_symbol_aux (name, domain); ++} ++ ++/* Search all static file-level symbols for NAME from DOMAIN. Do the symtabs ++ first, then check the psymtabs. If a psymtab indicates the existence of the ++ desired name as a file-level static, then do psymtab-to-symtab conversion on ++ the fly and return the found symbol. */ ++ ++struct symbol * ++lookup_static_symbol_aux (const char *name, const domain_enum domain) ++{ ++ struct objfile *objfile; ++ struct symbol *sym; + + sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain); + if (sym != NULL) diff --git a/gdb-bz602314-ptype-class-typedef-2of3.patch b/gdb-bz602314-ptype-class-typedef-2of3.patch new file mode 100644 index 0000000..3f01eb3 --- /dev/null +++ b/gdb-bz602314-ptype-class-typedef-2of3.patch @@ -0,0 +1,308 @@ +commit 758a1f7149cb7469c7e6bb30cb572715ee90a6e8 +Author: Jan Kratochvil +Date: Mon Jun 28 20:39:27 2010 +0000 + + gdb/ + * c-typeprint.c (c_type_print_base): For no fields check include also + TYPE_TYPEDEF_FIELD_COUNT. Print new typedefs section. + * dwarf2read.c (struct typedef_field_list) + (struct field_info) : New. + (dwarf2_add_typedef): New. + (read_structure_type): Call dwarf2_add_typedef for DW_TAG_typedef. + Copy also FI.TYPEDEF_FIELD_LIST. + * gdbtypes.h (struct typedef_field) + (struct cplus_struct_type) + (TYPE_TYPEDEF_FIELD_ARRAY, TYPE_TYPEDEF_FIELD, TYPE_TYPEDEF_FIELD_NAME) + (TYPE_TYPEDEF_FIELD_TYPE, TYPE_TYPEDEF_FIELD_COUNT): New. + + gdb/testsuite/ + * gdb.cp/namespace.exp (ptype OtherFileClass typedefs) + (ptype ::C::OtherFileClass typedefs): New. + * gdb.cp/namespace1.cc (C::OtherFileClass::cOtherFileClassType2) + (C::OtherFileClass::cOtherFileClassVar2): New. + (C::OtherFileClass::cOtherFileClassVar_use): Use also + cOtherFileClassVar2. + (C::cOtherFileType2, C::cOtherFileVar2): New. + (C::cOtherFileVar_use): use also cOtherFileVar2. + * gdb.cp/userdef.exp (ptype &*c): Permit arbitrary trailing text. + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,5 +1,19 @@ + 2010-06-28 Jan Kratochvil + ++ * c-typeprint.c (c_type_print_base): For no fields check include also ++ TYPE_TYPEDEF_FIELD_COUNT. Print new typedefs section. ++ * dwarf2read.c (struct typedef_field_list) ++ (struct field_info) : New. ++ (dwarf2_add_typedef): New. ++ (read_structure_type): Call dwarf2_add_typedef for DW_TAG_typedef. ++ Copy also FI.TYPEDEF_FIELD_LIST. ++ * gdbtypes.h (struct typedef_field) ++ (struct cplus_struct_type) ++ (TYPE_TYPEDEF_FIELD_ARRAY, TYPE_TYPEDEF_FIELD, TYPE_TYPEDEF_FIELD_NAME) ++ (TYPE_TYPEDEF_FIELD_TYPE, TYPE_TYPEDEF_FIELD_COUNT): New. ++ ++2010-06-28 Jan Kratochvil ++ + * cp-namespace.c (cp_lookup_nested_type): New variable + concatenated_name. Turn the current return condition into a reverse + one. Call also lookup_static_symbol_aux on the constructed qualified +Index: gdb-7.1/gdb/c-typeprint.c +=================================================================== +--- gdb-7.1.orig/gdb/c-typeprint.c 2010-06-29 17:54:09.000000000 +0200 ++++ gdb-7.1/gdb/c-typeprint.c 2010-06-29 18:17:48.000000000 +0200 +@@ -774,7 +774,8 @@ c_type_print_base (struct type *type, st + cp_type_print_derivation_info (stream, type); + + fprintf_filtered (stream, "{\n"); +- if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0)) ++ if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0 ++ && TYPE_TYPEDEF_FIELD_COUNT (type) == 0) + { + if (TYPE_STUB (type)) + fprintfi_filtered (level + 4, stream, _("\n")); +@@ -1060,6 +1061,29 @@ c_type_print_base (struct type *type, st + } + } + ++ /* Print typedefs defined in this class. */ ++ ++ if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0) ++ { ++ if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0) ++ fprintf_filtered (stream, "\n"); ++ ++ for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++) ++ { ++ struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i); ++ ++ /* Dereference the typedef declaration itself. */ ++ gdb_assert (TYPE_CODE (target) == TYPE_CODE_TYPEDEF); ++ target = TYPE_TARGET_TYPE (target); ++ ++ print_spaces_filtered (level + 4, stream); ++ fprintf_filtered (stream, "typedef "); ++ c_print_type (target, (char *) TYPE_TYPEDEF_FIELD_NAME (type, i), ++ stream, show - 1, level + 4); ++ fprintf_filtered (stream, ";\n"); ++ } ++ } ++ + fprintfi_filtered (level, stream, "}"); + + if (TYPE_LOCALTYPE_PTR (type) && show >= 0) +Index: gdb-7.1/gdb/dwarf2read.c +=================================================================== +--- gdb-7.1.orig/gdb/dwarf2read.c 2010-06-29 17:54:28.000000000 +0200 ++++ gdb-7.1/gdb/dwarf2read.c 2010-06-29 18:17:48.000000000 +0200 +@@ -722,6 +722,16 @@ struct field_info + + /* Number of entries in the fnfieldlists array. */ + int nfnfields; ++ ++ /* typedefs defined inside this class. TYPEDEF_FIELD_LIST contains head of ++ a NULL terminated list of TYPEDEF_FIELD_LIST_COUNT elements. */ ++ struct typedef_field_list ++ { ++ struct typedef_field field; ++ struct typedef_field_list *next; ++ } ++ *typedef_field_list; ++ unsigned typedef_field_list_count; + }; + + /* One item on the queue of compilation units to read in full symbols +@@ -5075,6 +5085,39 @@ dwarf2_add_field (struct field_info *fip + } + } + ++/* Add a typedef defined in the scope of the FIP's class. */ ++ ++static void ++dwarf2_add_typedef (struct field_info *fip, struct die_info *die, ++ struct dwarf2_cu *cu) ++{ ++ struct objfile *objfile = cu->objfile; ++ struct gdbarch *gdbarch = get_objfile_arch (objfile); ++ struct typedef_field_list *new_field; ++ struct attribute *attr; ++ struct typedef_field *fp; ++ char *fieldname = ""; ++ ++ /* Allocate a new field list entry and link it in. */ ++ new_field = xzalloc (sizeof (*new_field)); ++ make_cleanup (xfree, new_field); ++ ++ gdb_assert (die->tag == DW_TAG_typedef); ++ ++ fp = &new_field->field; ++ ++ /* Get name of field. */ ++ fp->name = dwarf2_name (die, cu); ++ if (fp->name == NULL) ++ return; ++ ++ fp->type = read_type_die (die, cu); ++ ++ new_field->next = fip->typedef_field_list; ++ fip->typedef_field_list = new_field; ++ fip->typedef_field_list_count++; ++} ++ + /* Create the vector of fields, and attach it to the type. */ + + static void +@@ -5600,6 +5643,8 @@ read_structure_type (struct die_info *di + /* C++ base class field. */ + dwarf2_add_field (&fi, child_die, cu); + } ++ else if (child_die->tag == DW_TAG_typedef) ++ dwarf2_add_typedef (&fi, child_die, cu); + child_die = sibling_die (child_die); + } + +@@ -5673,6 +5718,28 @@ read_structure_type (struct die_info *di + } + } + } ++ ++ /* Copy fi.typedef_field_list linked list elements content into the ++ allocated array TYPE_TYPEDEF_FIELD_ARRAY (type). */ ++ if (fi.typedef_field_list) ++ { ++ int i = fi.typedef_field_list_count; ++ ++ TYPE_TYPEDEF_FIELD_ARRAY (type) ++ = TYPE_ALLOC (type, sizeof (TYPE_TYPEDEF_FIELD (type, 0)) * i); ++ TYPE_TYPEDEF_FIELD_COUNT (type) = i; ++ ++ /* Reverse the list order to keep the debug info elements order. */ ++ while (--i >= 0) ++ { ++ struct typedef_field *dest, *src; ++ ++ dest = &TYPE_TYPEDEF_FIELD (type, i); ++ src = &fi.typedef_field_list->field; ++ fi.typedef_field_list = fi.typedef_field_list->next; ++ *dest = *src; ++ } ++ } + } + + quirk_gcc_member_function_pointer (type, cu->objfile); +Index: gdb-7.1/gdb/gdbtypes.h +=================================================================== +--- gdb-7.1.orig/gdb/gdbtypes.h 2010-06-29 17:54:17.000000000 +0200 ++++ gdb-7.1/gdb/gdbtypes.h 2010-06-29 18:18:29.000000000 +0200 +@@ -948,6 +948,19 @@ struct cplus_struct_type + member functions or virtual base classes. Minus one if not + dynamic. Zero if not yet computed. */ + int is_dynamic : 2; ++ ++ /* typedefs defined inside this class. TYPEDEF_FIELD points to an array of ++ TYPEDEF_FIELD_COUNT elements. */ ++ struct typedef_field ++ { ++ /* Unqualified name to be prefixed by owning class qualified name. */ ++ const char *name; ++ ++ /* Type this typedef named NAME represents. */ ++ struct type *type; ++ } ++ *typedef_field; ++ unsigned typedef_field_count; + }; + + /* Struct used for ranking a function for overload resolution */ +@@ -1182,6 +1195,17 @@ extern void allocate_gnat_aux_type (stru + #define TYPE_LOCALTYPE_FILE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->file) + #define TYPE_LOCALTYPE_LINE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->line) + ++#define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \ ++ TYPE_CPLUS_SPECIFIC (thistype)->typedef_field ++#define TYPE_TYPEDEF_FIELD(thistype, n) \ ++ TYPE_CPLUS_SPECIFIC (thistype)->typedef_field[n] ++#define TYPE_TYPEDEF_FIELD_NAME(thistype, n) \ ++ TYPE_TYPEDEF_FIELD (thistype, n).name ++#define TYPE_TYPEDEF_FIELD_TYPE(thistype, n) \ ++ TYPE_TYPEDEF_FIELD (thistype, n).type ++#define TYPE_TYPEDEF_FIELD_COUNT(thistype) \ ++ TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count ++ + #define TYPE_IS_OPAQUE(thistype) (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) || \ + (TYPE_CODE (thistype) == TYPE_CODE_UNION)) && \ + (TYPE_NFIELDS (thistype) == 0) && \ +Index: gdb-7.1/gdb/testsuite/gdb.cp/namespace.exp +=================================================================== +--- gdb-7.1.orig/gdb/testsuite/gdb.cp/namespace.exp 2010-06-29 18:17:17.000000000 +0200 ++++ gdb-7.1/gdb/testsuite/gdb.cp/namespace.exp 2010-06-29 18:18:58.000000000 +0200 +@@ -332,6 +332,21 @@ cp_test_ptype_class \ + } + gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"." + ++# Test class typedefs printing. ++set expect "type = class C::OtherFileClass \{\r\n.*\r\n *typedef short cOtherFileClassType;\r\n *typedef long cOtherFileClassType2;\r\n\}" ++if {[test_compiler_info {gcc-[0-3]-*}] ++ || [test_compiler_info {gcc-4-[0-4]-*}]} { ++ # The type in class is missing in older GCCs. ++ setup_xfail *-*-* ++} ++gdb_test "ptype OtherFileClass" $expect "ptype OtherFileClass typedefs" ++if {[test_compiler_info {gcc-[0-3]-*}] ++ || [test_compiler_info {gcc-4-[0-4]-*}]} { ++ # The type in class is missing in older GCCs. ++ setup_xfail *-*-* ++} ++gdb_test "ptype ::C::OtherFileClass" $expect "ptype ::C::OtherFileClass typedefs" ++ + # Some anonymous namespace tests. + + gdb_test "print cX" "\\$\[0-9\].* = 6" +Index: gdb-7.1/gdb/testsuite/gdb.cp/namespace1.cc +=================================================================== +--- gdb-7.1.orig/gdb/testsuite/gdb.cp/namespace1.cc 2010-06-29 17:56:42.000000000 +0200 ++++ gdb-7.1/gdb/testsuite/gdb.cp/namespace1.cc 2010-06-29 18:17:48.000000000 +0200 +@@ -23,12 +23,14 @@ namespace C + int z; + + typedef short cOtherFileClassType; ++ typedef long cOtherFileClassType2; + static const cOtherFileClassType cOtherFileClassVar = 318; ++ static const cOtherFileClassType2 cOtherFileClassVar2 = 320; + cOtherFileClassType cOtherFileClassVar_use (); + }; + OtherFileClass::cOtherFileClassType OtherFileClass::cOtherFileClassVar_use () + { +- return cOtherFileClassVar; ++ return cOtherFileClassVar + cOtherFileClassVar2; + } + + namespace { +@@ -45,10 +47,12 @@ namespace C + } + + typedef short cOtherFileType; ++ typedef long cOtherFileType2; + static const cOtherFileType cOtherFileVar = 319; ++ static const cOtherFileType2 cOtherFileVar2 = 321; + cOtherFileType cOtherFileVar_use () + { +- return cOtherFileVar; ++ return cOtherFileVar + cOtherFileVar2; + } + } + +Index: gdb-7.1/gdb/testsuite/gdb.cp/userdef.exp +=================================================================== +--- gdb-7.1.orig/gdb/testsuite/gdb.cp/userdef.exp 2010-06-29 17:54:11.000000000 +0200 ++++ gdb-7.1/gdb/testsuite/gdb.cp/userdef.exp 2010-06-29 18:17:48.000000000 +0200 +@@ -154,7 +154,7 @@ gdb_test "break A2::'operator +'" ".*Bre + gdb_test "print c" "\\\$\[0-9\]* = {m = {z = .*}}" + gdb_test "print *c" "\\\$\[0-9\]* = \\(Member &\\) @$hex: {z = .*}" + gdb_test "print &*c" "\\\$\[0-9\]* = \\(Member \\*\\) $hex" +-gdb_test "ptype &*c" "type = (struct|class) Member {(\[\r\n \]+public:)?\[\r\n \]+int z;\[\r\n\]+} &\\*" ++gdb_test "ptype &*c" "type = (struct|class) Member {(\[\r\n \]+public:)?\[\r\n \]+int z;\[\r\n\].*} &\\*" + + gdb_test "print operator== (mem1, mem2)" " = false" + gdb_test "print operator== (mem1, mem1)" " = true" diff --git a/gdb-bz602314-ptype-class-typedef-3of3.patch b/gdb-bz602314-ptype-class-typedef-3of3.patch new file mode 100644 index 0000000..f0ad50d --- /dev/null +++ b/gdb-bz602314-ptype-class-typedef-3of3.patch @@ -0,0 +1,38 @@ +commit 477c1359b217cdc052a7c9f83cae9c894396894c +Author: Jan Kratochvil +Date: Mon Jun 28 22:03:31 2010 +0000 + + gdb/ + * dwarf2read.c (read_structure_type) : Call + ALLOCATE_CPLUS_STRUCT_TYPE. + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,8 @@ ++2010-06-28 Jan Kratochvil ++ ++ * dwarf2read.c (read_structure_type) : Call ++ ALLOCATE_CPLUS_STRUCT_TYPE. ++ + 2010-06-28 Phil Muldoon + Tom Tromey + Thiago Jung Bauermann +## -27,8 +32,6 @@ + * python/py-inferior.c: New File. + * python/py-infthread.c: New File. + +- +- + 2010-06-28 Jan Kratochvil + + * c-typeprint.c (c_type_print_base): For no fields check include also +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -5327,6 +5327,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) + { + int i = fi.typedef_field_list_count; + ++ ALLOCATE_CPLUS_STRUCT_TYPE (type); + TYPE_TYPEDEF_FIELD_ARRAY (type) + = TYPE_ALLOC (type, sizeof (TYPE_TYPEDEF_FIELD (type, 0)) * i); + TYPE_TYPEDEF_FIELD_COUNT (type) = i; diff --git a/gdb-bz606185-obstack-1of5.patch b/gdb-bz606185-obstack-1of5.patch new file mode 100644 index 0000000..e2879bb --- /dev/null +++ b/gdb-bz606185-obstack-1of5.patch @@ -0,0 +1,214 @@ +commit 78c144e8c3ae7bb36d632f6bfaaaad9c97199ce6 +Author: cmoller +Date: Tue Apr 20 20:22:09 2010 +0000 + + PR 10867 + * cp-valprint.c (global): Adding new static array recursion + detection obstack. + (cp_print_value_fields, cp_print_static_field): Added new static + array recursion detection code. + * gdb.cp/Makefile.in (EXECUTABLES): Added pr10687 + * gdb.cp/pr10687.cc: New file. + * gdb.cp/pr10687.exp: New file + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,12 @@ ++2010-04-20 Chris Moller ++ ++ PR 10867 ++ ++ * cp-valprint.c (global): Adding new static array recursion ++ detection obstack. ++ (cp_print_value_fields, cp_print_static_field): Added new static ++ array recursion detection code. ++ + 2010-04-20 Mark Kettenis + + * i386-linux-tdep.c (i386_linux_regset_sections): Size of the +Index: gdb-7.1/gdb/cp-valprint.c +=================================================================== +--- gdb-7.1.orig/gdb/cp-valprint.c 2010-02-08 19:04:16.000000000 +0100 ++++ gdb-7.1/gdb/cp-valprint.c 2010-06-28 20:21:53.000000000 +0200 +@@ -71,6 +71,7 @@ show_static_field_print (struct ui_file + + static struct obstack dont_print_vb_obstack; + static struct obstack dont_print_statmem_obstack; ++static struct obstack dont_print_stat_array_obstack; + + extern void _initialize_cp_valprint (void); + +@@ -155,12 +156,17 @@ cp_print_value_fields (struct type *type + { + int i, len, n_baseclasses; + int fields_seen = 0; ++ static int last_set_recurse = -1; + + CHECK_TYPEDEF (type); + +- if (recurse == 0 +- && obstack_object_size (&dont_print_statmem_obstack) > 0) +- obstack_free (&dont_print_statmem_obstack, NULL); ++ if (recurse == 0) ++ { ++ if (obstack_object_size (&dont_print_statmem_obstack) > 0) ++ obstack_free (&dont_print_statmem_obstack, NULL); ++ if (obstack_object_size (&dont_print_stat_array_obstack) > 0) ++ obstack_free (&dont_print_stat_array_obstack, NULL); ++ } + + fprintf_filtered (stream, "{"); + len = TYPE_NFIELDS (type); +@@ -181,12 +187,20 @@ cp_print_value_fields (struct type *type + else + { + void *statmem_obstack_top = NULL; ++ void *stat_array_obstack_top = NULL; + + if (dont_print_statmem == 0) + { + /* Set the current printed-statics stack top. */ + statmem_obstack_top + = obstack_next_free (&dont_print_statmem_obstack); ++ ++ if (last_set_recurse != recurse) ++ { ++ stat_array_obstack_top ++ = obstack_next_free (&dont_print_stat_array_obstack); ++ last_set_recurse = recurse; ++ } + } + + for (i = n_baseclasses; i < len; i++) +@@ -307,9 +321,16 @@ cp_print_value_fields (struct type *type + + if (dont_print_statmem == 0) + { +- /* In effect, a pop of the printed-statics stack. */ + if (obstack_object_size (&dont_print_statmem_obstack) > 0) + obstack_free (&dont_print_statmem_obstack, statmem_obstack_top); ++ ++ if (last_set_recurse != recurse) ++ { ++ if (obstack_object_size (&dont_print_stat_array_obstack) > 0) ++ obstack_free (&dont_print_stat_array_obstack, ++ stat_array_obstack_top); ++ last_set_recurse = -1; ++ } + } + + if (options->pretty) +@@ -508,6 +529,7 @@ cp_print_static_field (struct type *type + const struct value_print_options *options) + { + struct value_print_options opts; ++ + if (TYPE_CODE (type) == TYPE_CODE_STRUCT) + { + CORE_ADDR *first_dont_print; +@@ -542,6 +564,32 @@ cp_print_static_field (struct type *type + return; + } + ++ if (TYPE_CODE (type) == TYPE_CODE_ARRAY) ++ { ++ struct type **first_dont_print; ++ int i; ++ struct type *target_type = TYPE_TARGET_TYPE (type); ++ ++ first_dont_print ++ = (struct type **) obstack_base (&dont_print_stat_array_obstack); ++ i = obstack_object_size (&dont_print_stat_array_obstack) ++ / sizeof (CORE_ADDR); ++ ++ while (--i >= 0) ++ { ++ if (target_type == first_dont_print[i]) ++ { ++ fputs_filtered ("", ++ stream); ++ return; ++ } ++ } ++ ++ obstack_grow (&dont_print_stat_array_obstack, (char *) &target_type, ++ sizeof (struct type *)); ++ } ++ + opts = *options; + opts.deref_ref = 0; + val_print (type, value_contents_all (val), +@@ -672,6 +720,7 @@ Show printing of object's derived type b + show_objectprint, + &setprintlist, &showprintlist); + ++ obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (CORE_ADDR)); + obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR)); + obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *)); + } +Index: gdb-7.1/gdb/testsuite/gdb.cp/pr10687.cc +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1/gdb/testsuite/gdb.cp/pr10687.cc 2010-06-28 20:21:53.000000000 +0200 +@@ -0,0 +1,24 @@ ++class vec2 ++{ ++ public: ++ vec2() { _v[0] = _v[1] = 0; } ++ vec2(int x, int y) { _v[0] = x; _v[1] = y; } ++ static vec2 axis[2]; ++ static vec2 axis6[6]; ++ private: ++ int _v[2]; ++}; ++ ++vec2 vec2::axis[2] = { vec2(1,0), vec2(0,1) }; ++vec2 vec2::axis6[6] = { ++ vec2(1,0), vec2(0,1), ++ vec2(2,0), vec2(0,2), ++ vec2(3,0), vec2(0,3) ++}; ++ ++int main(int argc, char*argv[]) ++{ ++ vec2 a; ++ ++ return 0; // marker ++} +Index: gdb-7.1/gdb/testsuite/gdb.cp/pr10687.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1/gdb/testsuite/gdb.cp/pr10687.exp 2010-06-28 20:21:53.000000000 +0200 +@@ -0,0 +1,31 @@ ++#Copyright 2010 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set testfile pr10687 ++set srcfile ${testfile}.cc ++if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] { ++ return -1 ++} ++ ++if ![runto_main] then { ++ fail "Can't run to main" ++ return ++} ++ ++gdb_breakpoint [gdb_get_line_number "marker"] ++gdb_continue_to_breakpoint "marker" ++ ++gdb_test "p a" "{static axis = {{static axis = +Date: Wed Apr 21 17:33:51 2010 +0000 + + PR 9167 + * cp-valprint.c (cp_print_value_fields): Replaced obstack_base() + method of popping recursion-detection stack with a method based on + obstack_object_size(). + * gdb.cp/Makefile.in (EXECUTABLES): Added pr9167. + * gdb.cp/pr9167.cc: New file. + * gdb.cp/pr9167.exp: New file. + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,10 @@ ++2010-04-21 Chris Moller ++ ++ PR 9167 ++ * cp-valprint.c (cp_print_value_fields): Replaced obstack_base() ++ method of popping recursion-detection stack with a method based on ++ obstack_object_size(). ++ + 2010-04-21 Pierre Muller + + PR pascal/11492. +## -3184,7 +3191,7 @@ + addr_bit. Adjust LOAD_ADDR sign for cross-arch inferiors. + + 2010-02-17 Tristan Gingold +- Petr Hluzín ++ Petr Hluz�n + + * avr-tdep.c (avr_scan_prologue): Convert an if statement to a + gdb_assert. Fix info->size for SIG prologue. +Index: gdb-7.1/gdb/cp-valprint.c +=================================================================== +--- gdb-7.1.orig/gdb/cp-valprint.c 2010-06-28 20:21:53.000000000 +0200 ++++ gdb-7.1/gdb/cp-valprint.c 2010-06-28 20:22:16.000000000 +0200 +@@ -186,14 +186,13 @@ cp_print_value_fields (struct type *type + fprintf_filtered (stream, ""); + else + { +- void *statmem_obstack_top = NULL; ++ int obstack_initial_size = 0; + void *stat_array_obstack_top = NULL; + + if (dont_print_statmem == 0) + { +- /* Set the current printed-statics stack top. */ +- statmem_obstack_top +- = obstack_next_free (&dont_print_statmem_obstack); ++ obstack_initial_size = ++ obstack_object_size (&dont_print_statmem_obstack); + + if (last_set_recurse != recurse) + { +@@ -321,8 +320,19 @@ cp_print_value_fields (struct type *type + + if (dont_print_statmem == 0) + { +- if (obstack_object_size (&dont_print_statmem_obstack) > 0) +- obstack_free (&dont_print_statmem_obstack, statmem_obstack_top); ++ int obstack_final_size = ++ obstack_object_size (&dont_print_statmem_obstack); ++ ++ if (obstack_final_size > obstack_initial_size) { ++ /* In effect, a pop of the printed-statics stack. */ ++ ++ void *free_to_ptr = ++ obstack_next_free (&dont_print_statmem_obstack) - ++ (obstack_final_size - obstack_initial_size); ++ ++ obstack_free (&dont_print_statmem_obstack, ++ free_to_ptr); ++ } + + if (last_set_recurse != recurse) + { +@@ -555,7 +565,6 @@ cp_print_static_field (struct type *type + addr = value_address (val); + obstack_grow (&dont_print_statmem_obstack, (char *) &addr, + sizeof (CORE_ADDR)); +- + CHECK_TYPEDEF (type); + cp_print_value_fields (type, value_enclosing_type (val), + value_contents_all (val), +Index: gdb-7.1/gdb/testsuite/gdb.cp/pr9167.cc +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1/gdb/testsuite/gdb.cp/pr9167.cc 2010-06-28 20:22:16.000000000 +0200 +@@ -0,0 +1,36 @@ ++#include ++ ++template ++struct ATB ++{ ++ int data; ++ ATB() : data(0) {} ++}; ++ ++ ++template ++class A : public ATB ++{ ++public: ++ static DerivedType const DEFAULT_INSTANCE; ++}; ++ ++template ++const DerivedType A::DEFAULT_INSTANCE; ++ ++class B : public A ++{ ++ ++}; ++ ++int main() ++{ ++ B b; ++ // If this if-block is removed then GDB shall ++ // not infinitely recurse when trying to print b. ++ ++ return 0; // marker ++} ++ ++ +Index: gdb-7.1/gdb/testsuite/gdb.cp/pr9167.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1/gdb/testsuite/gdb.cp/pr9167.exp 2010-06-28 20:22:16.000000000 +0200 +@@ -0,0 +1,31 @@ ++#Copyright 2010 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set testfile pr9167 ++set srcfile ${testfile}.cc ++if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] { ++ return -1 ++} ++ ++if ![runto_main] then { ++ fail "Can't run to main" ++ return ++} ++ ++gdb_breakpoint [gdb_get_line_number "marker"] ++gdb_continue_to_breakpoint "marker" ++ ++gdb_test "p b" "{> = {> = {data = 0}, static DEFAULT_INSTANCE = }, }" ++ diff --git a/gdb-bz606185-obstack-3of5.patch b/gdb-bz606185-obstack-3of5.patch new file mode 100644 index 0000000..4092c00 --- /dev/null +++ b/gdb-bz606185-obstack-3of5.patch @@ -0,0 +1,85 @@ +commit 407cb192dcac2602aebaa7e262419adb580ecca6 +Author: cmoller +Date: Thu Apr 22 20:12:06 2010 +0000 + + * cp-valprint.c (cp_print_value_fields): Replaced obstack_base() + method of popping recursion-detection stack with a method based on + obstack_object_size(). (Similar to the PR9167 patch below, but for + the static array obstack rather than the static member obstack.) + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,10 @@ ++2010-04-22 Chris Moller ++ ++ * cp-valprint.c (cp_print_value_fields): Replaced obstack_base() ++ method of popping recursion-detection stack with a method based on ++ obstack_object_size(). (Similar to the PR9167 patch below, but for ++ the static array obstack rather than the static member obstack.) ++ + 2010-04-22 H.J. Lu + + * amd64-linux-nat.c (amd64_linux_gregset64_reg_offset): Removed. +--- a/gdb/cp-valprint.c ++++ b/gdb/cp-valprint.c +@@ -186,18 +186,18 @@ cp_print_value_fields (struct type *type, struct type *real_type, + fprintf_filtered (stream, ""); + else + { +- int obstack_initial_size = 0; +- void *stat_array_obstack_top = NULL; ++ int statmem_obstack_initial_size = 0; ++ int stat_array_obstack_initial_size = 0; + + if (dont_print_statmem == 0) + { +- obstack_initial_size = ++ statmem_obstack_initial_size = + obstack_object_size (&dont_print_statmem_obstack); + + if (last_set_recurse != recurse) + { +- stat_array_obstack_top +- = obstack_next_free (&dont_print_stat_array_obstack); ++ stat_array_obstack_initial_size = ++ obstack_object_size (&dont_print_stat_array_obstack); + last_set_recurse = recurse; + } + } +@@ -323,12 +323,12 @@ cp_print_value_fields (struct type *type, struct type *real_type, + int obstack_final_size = + obstack_object_size (&dont_print_statmem_obstack); + +- if (obstack_final_size > obstack_initial_size) { ++ if (obstack_final_size > statmem_obstack_initial_size) { + /* In effect, a pop of the printed-statics stack. */ + + void *free_to_ptr = + obstack_next_free (&dont_print_statmem_obstack) - +- (obstack_final_size - obstack_initial_size); ++ (obstack_final_size - statmem_obstack_initial_size); + + obstack_free (&dont_print_statmem_obstack, + free_to_ptr); +@@ -336,9 +336,18 @@ cp_print_value_fields (struct type *type, struct type *real_type, + + if (last_set_recurse != recurse) + { +- if (obstack_object_size (&dont_print_stat_array_obstack) > 0) +- obstack_free (&dont_print_stat_array_obstack, +- stat_array_obstack_top); ++ int obstack_final_size = ++ obstack_object_size (&dont_print_stat_array_obstack); ++ ++ if (obstack_final_size > stat_array_obstack_initial_size) ++ { ++ void *free_to_ptr = ++ obstack_next_free (&dont_print_stat_array_obstack) - ++ (obstack_final_size - stat_array_obstack_initial_size); ++ ++ obstack_free (&dont_print_stat_array_obstack, ++ free_to_ptr); ++ } + last_set_recurse = -1; + } + } diff --git a/gdb-bz606185-obstack-4of5.patch b/gdb-bz606185-obstack-4of5.patch new file mode 100644 index 0000000..5153a2b --- /dev/null +++ b/gdb-bz606185-obstack-4of5.patch @@ -0,0 +1,42 @@ +commit 744735550d4a4fd6d4be40776069d799dca5ee39 +Author: Ulrich Weigand +Date: Mon Jun 14 16:09:55 2010 +0000 + + * cp-valprint.c (cp_print_static_field): Members of + dont_print_stat_array_obstack are of type "struct type *". + (_initialize_cp_valprint): Likewise. + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,5 +1,11 @@ + 2010-06-14 Ulrich Weigand + ++ * cp-valprint.c (cp_print_static_field): Members of ++ dont_print_stat_array_obstack are of type "struct type *". ++ (_initialize_cp_valprint): Likewise. ++ ++2010-06-14 Ulrich Weigand ++ + * frame.c (frame_register_unwind): Do not access contents + of "optimized out" unwound register value. + +--- a/gdb/cp-valprint.c ++++ b/gdb/cp-valprint.c +@@ -615,7 +615,7 @@ cp_print_static_field (struct type *type, + first_dont_print + = (struct type **) obstack_base (&dont_print_stat_array_obstack); + i = obstack_object_size (&dont_print_stat_array_obstack) +- / sizeof (CORE_ADDR); ++ / sizeof (struct type *); + + while (--i >= 0) + { +@@ -764,7 +764,7 @@ Show printing of object's derived type based on vtable info."), NULL, + show_objectprint, + &setprintlist, &showprintlist); + +- obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (CORE_ADDR)); ++ obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (struct type *)); + obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR)); + obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *)); + } diff --git a/gdb-bz606185-obstack-5of5.patch b/gdb-bz606185-obstack-5of5.patch new file mode 100644 index 0000000..4171e56 --- /dev/null +++ b/gdb-bz606185-obstack-5of5.patch @@ -0,0 +1,202 @@ +commit 47c8c764a9be6d023eca450336e6d9de16970fc0 +Author: Jan Kratochvil +Date: Mon Jun 28 16:59:43 2010 +0000 + + gdb/ + * cp-valprint.c (cp_print_value_fields) : Call + obstack_begin after each obstack_free. + + gdb/testsuite/ + * gdb.cp/static-print-quit.exp, gdb.cp/static-print-quit.cc: New. + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,8 @@ ++2010-06-28 Jan Kratochvil ++ ++ * cp-valprint.c (cp_print_value_fields) : Call ++ obstack_begin after each obstack_free. ++ + 2010-06-27 Doug Evans + + * value.c (value_static_field): Use `switch' instead of `if'. +## -12,27 +17,27 @@ + + 2010-06-25 Paul Hilfinger + +- * defs.h (make_command_stats_cleanup): Declare. +- (set_display_time): Declare. +- (set_display_space): Declare. +- * event-top.c (command_handler): Use make_command_stats_cleanup. +- * main.c (display_time, display_space): Move definitions to utils.c. +- (captured_main): Use make_command_stats_cleanup to get start-up +- statistics. +- Use set_display_time and set_display_space for processing OPT_STATISTICS +- case. +- * maint.c (maintenance_time_display): Use set_display_time. +- (maintenance_space_display): Use set_display_space. +- * top.c (execute_command): Remove obsolete 'maint time' code. +- (command_loop): Use make_command_stats_cleanup. +- * utils.c (struct cmd_stats): Structure for storing initial time +- and space usage. +- (display_time, display_space): Move definitions here from utils.c. +- (set_display_time): New function. +- (set_display_space): New function. +- (make_command_stats_cleanup): New function. +- (report_command_stats): New auxiliary function for +- make_command_stats_cleanup. ++ * defs.h (make_command_stats_cleanup): Declare. ++ (set_display_time): Declare. ++ (set_display_space): Declare. ++ * event-top.c (command_handler): Use make_command_stats_cleanup. ++ * main.c (display_time, display_space): Move definitions to utils.c. ++ (captured_main): Use make_command_stats_cleanup to get start-up ++ statistics. ++ Use set_display_time and set_display_space for processing OPT_STATISTICS ++ case. ++ * maint.c (maintenance_time_display): Use set_display_time. ++ (maintenance_space_display): Use set_display_space. ++ * top.c (execute_command): Remove obsolete 'maint time' code. ++ (command_loop): Use make_command_stats_cleanup. ++ * utils.c (struct cmd_stats): Structure for storing initial time ++ and space usage. ++ (display_time, display_space): Move definitions here from utils.c. ++ (set_display_time): New function. ++ (set_display_space): New function. ++ (make_command_stats_cleanup): New function. ++ (report_command_stats): New auxiliary function for ++ make_command_stats_cleanup. + + 2010-06-25 Ulrich Weigand + +## -6103,7 +6108,7 @@ + + PR gdb/9067 + * cp-valprint.c (cp_print_value_fields) Fix use of obstacks. +- cp_print_static_field) Fix use of obstacks. ++ (cp_print_static_field) Fix use of obstacks. + + 2010-02-08 Pedro Alves + +--- a/gdb/cp-valprint.c ++++ b/gdb/cp-valprint.c +@@ -164,10 +164,19 @@ cp_print_value_fields (struct type *type, struct type *real_type, + + if (recurse == 0) + { ++ /* Any object can be left on obstacks only during an unexpected error. */ ++ + if (obstack_object_size (&dont_print_statmem_obstack) > 0) +- obstack_free (&dont_print_statmem_obstack, NULL); ++ { ++ obstack_free (&dont_print_statmem_obstack, NULL); ++ obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR)); ++ } + if (obstack_object_size (&dont_print_stat_array_obstack) > 0) +- obstack_free (&dont_print_stat_array_obstack, NULL); ++ { ++ obstack_free (&dont_print_stat_array_obstack, NULL); ++ obstack_begin (&dont_print_stat_array_obstack, ++ 32 * sizeof (struct type *)); ++ } + } + + fprintf_filtered (stream, "{"); +### a/gdb/testsuite/ChangeLog +### b/gdb/testsuite/ChangeLog +## -1,3 +1,7 @@ ++2010-06-28 Jan Kratochvil ++ ++ * gdb.cp/static-print-quit.exp, gdb.cp/static-print-quit.cc: New. ++ + 2010-06-28 Doug Evans + + * gdb.base/break-interp.exp (reach): Relax expected output a bit. +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/static-print-quit.cc +@@ -0,0 +1,32 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2010 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++class D ++ { ++ public: ++ int loooooooooooooooooooooooooooooooooooooooooooooong; ++ }; ++ ++class C ++ { ++ public: ++ int loooooooooooooooooooooooooooooooooooooooooooooong; ++ static D field; ++ }; ++ ++D C::field; ++C c; +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/static-print-quit.exp +@@ -0,0 +1,50 @@ ++# Copyright 2010 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if { [skip_cplus_tests] } { continue } ++ ++set testfile static-print-quit ++set srcfile ${testfile}.cc ++set executable $testfile.o ++set objfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile $srcdir/$subdir/$srcfile $objfile object {debug c++}] != ""} { ++ untested ${testfile}.exp ++ return -1 ++} ++ ++clean_restart $executable ++ ++gdb_test "set width 80" ++gdb_test "set height 2" ++ ++set test "print c" ++gdb_test_multiple $test $test { ++ -re " = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n---Type to continue, or q to quit---$" { ++ pass $test ++ } ++ -re " to quit---$" { ++ fail $test ++ return -1 ++ } ++} ++ ++gdb_test "q" ".*" ++ ++# Now the obstack is uninitialized. Excercise it. ++ ++gdb_test "set pagination off" ++gdb_test "print c" ".*" "first print" ++gdb_test "print c" ".*" "second print" diff --git a/gdb-bz606660-print-object-nonvirtual.patch b/gdb-bz606660-print-object-nonvirtual.patch new file mode 100644 index 0000000..9b52038 --- /dev/null +++ b/gdb-bz606660-print-object-nonvirtual.patch @@ -0,0 +1,106 @@ +commit bb604f9e70de515b13e2a935d8ad9d2fb0290849 +Author: Jan Kratochvil +Date: Mon Jun 28 20:12:52 2010 +0000 + + gdb/ + Fix modification of cplus_struct_default. + * dwarf2read.c (dwarf2_add_member_fn) : + Call ALLOCATE_CPLUS_STRUCT_TYPE. + + * gdbtypes.c (cplus_struct_default): New empty initializer, comment it. + + + gdb/testsuite/ + * gdb.cp/virtbase.cc (class RTTI_base, class RTTI_data) + (main) : New. + * gdb.cp/virtbase.exp (print rtti_data): New. + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,10 @@ ++2010-06-28 Jan Kratochvil ++ ++ Fix modification of cplus_struct_default. ++ * dwarf2read.c (dwarf2_add_member_fn) : ++ Call ALLOCATE_CPLUS_STRUCT_TYPE. ++ * gdbtypes.c (cplus_struct_default): New empty initializer, comment it. ++ +### a/gdb/testsuite/ChangeLog +### b/gdb/testsuite/ChangeLog +## -1,4 +1,10 @@ ++2010-06-28 Jan Kratochvil ++ ++ * gdb.cp/virtbase.cc (class RTTI_base, class RTTI_data) ++ (main) : New. ++ * gdb.cp/virtbase.exp (print rtti_data): New. ++ +###--- a/gdb/gdbtypes.c +###+++ b/gdb/gdbtypes.c +###@@ -1733,7 +1733,8 @@ check_stub_method_group (struct type *type, int method_id) +### } +### } +### +###-const struct cplus_struct_type cplus_struct_default; +###+/* Ensure it is in .rodata (if available) by workarounding GCC PR 44690. */ +###+const struct cplus_struct_type cplus_struct_default = { }; +### +### void +### allocate_cplus_struct_type (struct type *type) +Index: gdb-7.1/gdb/dwarf2read.c +=================================================================== +--- gdb-7.1.orig/gdb/dwarf2read.c 2010-06-29 18:26:47.000000000 +0200 ++++ gdb-7.1/gdb/dwarf2read.c 2010-06-29 18:39:43.000000000 +0200 +@@ -5404,6 +5404,7 @@ dwarf2_add_member_fn (struct field_info + complaint (&symfile_complaints, + _("Member function \"%s\" (offset %d) is virtual but the vtable offset is not specified"), + fieldname, die->offset); ++ ALLOCATE_CPLUS_STRUCT_TYPE (type); + TYPE_CPLUS_DYNAMIC (type) = 1; + } + } +Index: gdb-7.1/gdb/testsuite/gdb.cp/virtbase.cc +=================================================================== +--- gdb-7.1.orig/gdb/testsuite/gdb.cp/virtbase.cc 2010-02-03 00:40:28.000000000 +0100 ++++ gdb-7.1/gdb/testsuite/gdb.cp/virtbase.cc 2010-06-29 18:39:43.000000000 +0200 +@@ -74,8 +74,19 @@ public: + virtual void b() {} + }; + ++class RTTI_base ++{ ++public: ++ virtual ~RTTI_base() {} ++}; + +- ++class RTTI_data ++{ ++public: ++ RTTI_base base; ++ int data; ++ RTTI_data() : data(1) {} ++}; + + int main() { + ph::Derived tst; +@@ -84,6 +95,7 @@ int main() { + + E *e = new E; + RHB *b = new RHC(); ++ RTTI_data rtti_data; + + return 0; // breakpoint 3 + } +Index: gdb-7.1/gdb/testsuite/gdb.cp/virtbase.exp +=================================================================== +--- gdb-7.1.orig/gdb/testsuite/gdb.cp/virtbase.exp 2010-02-04 22:04:30.000000000 +0100 ++++ gdb-7.1/gdb/testsuite/gdb.cp/virtbase.exp 2010-06-29 18:39:56.000000000 +0200 +@@ -60,3 +60,8 @@ gdb_test "print *(D *) e" " = { = {v + # https://bugzilla.redhat.com/show_bug.cgi?id=560741 + gdb_test "set print object on" "" + gdb_test "print/x b->mA" " = 0xaaaaaaaa" ++ ++# A regression test reported to Red Hat bugzilla, see: ++# https://bugzilla.redhat.com/show_bug.cgi?id=606660 ++# `set print object on' is expected. ++gdb_test "print rtti_data" " = .*, data = 1\}" diff --git a/gdb.spec b/gdb.spec index 066f1d0..182d326 100644 --- a/gdb.spec +++ b/gdb.spec @@ -36,7 +36,7 @@ Version: 7.1 # The release always contains a leading reserved number, start it at 1. # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing. -Release: 26%{?_with_upstream:.upstream}%{dist} +Release: 27%{?_with_upstream:.upstream}%{dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain Group: Development/Debuggers @@ -507,6 +507,21 @@ Patch473: gdb-bz601887-dwarf4-1of2.patch Patch474: gdb-bz601887-dwarf4-2of2.patch Patch475: gdb-bz601887-dwarf4-rh-test.patch +# Fix obstack corruptions on C++ (BZ 606185, Chris Moller, Jan Kratochvil). +Patch476: gdb-bz606185-obstack-1of5.patch +Patch477: gdb-bz606185-obstack-2of5.patch +Patch478: gdb-bz606185-obstack-3of5.patch +Patch479: gdb-bz606185-obstack-4of5.patch +Patch480: gdb-bz606185-obstack-5of5.patch + +# Improve support for typedefs in classes (BZ 602314). +Patch481: gdb-bz602314-ptype-class-typedef-1of3.patch +Patch482: gdb-bz602314-ptype-class-typedef-2of3.patch +Patch483: gdb-bz602314-ptype-class-typedef-3of3.patch + +# Fix `set print object on' for some non-dynamic classes (BZ 606660). +Patch484: gdb-bz606660-print-object-nonvirtual.patch + BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa} Requires: readline%{?_isa} BuildRequires: readline-devel%{?_isa} @@ -797,6 +812,15 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch473 -p1 %patch474 -p1 %patch475 -p1 +%patch476 -p1 +%patch477 -p1 +%patch478 -p1 +%patch479 -p1 +%patch480 -p1 +%patch481 -p1 +%patch482 -p1 +%patch483 -p1 +%patch484 -p1 %patch415 -p1 %patch393 -p1 @@ -1129,6 +1153,11 @@ fi %endif %changelog +* Wed Jun 30 2010 Jan Kratochvil - 7.1-27.fc13 +- Fix obstack corruptions on C++ (BZ 606185, Chris Moller, Jan Kratochvil). +- Improve support for typedefs in classes (BZ 602314). +- Fix `set print object on' for some non-dynamic classes (BZ 606660). + * Wed Jun 9 2010 Jan Kratochvil - 7.1-26.fc13 - Backport DWARF-4 support (BZ 601887, Tom Tromey).