From 8ed182f504340b132ae3da8dfdd56aafea2429944588d5c64b13fce4637e0f40 Mon Sep 17 00:00:00 2001 From: OBS User autobuild Date: Tue, 25 May 2010 12:02:22 +0000 Subject: [PATCH] Accepting request 40473 from devel:gcc Copy from devel:gcc/gdb based on submit request 40473 from user rguenther OBS-URL: https://build.opensuse.org/request/show/40473 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/gdb?expand=0&rev=74 --- gdb-archer-vla-ref-optimizedout.patch | 105 +++ gdb-archer-vla-test-oom.patch | 21 + gdb-archer.patch | 974 ++++++++++++++++---- gdb-bz539590-gnu-ifunc-fix-cond.patch | 14 + gdb-bz570635-prettyprint-doc1.patch | 40 + gdb-bz570635-prettyprint-doc2.patch | 182 ++++ gdb-bz575292-delayed-physname.patch | 624 +++++++++++++ gdb-bz575292-void-workaround.patch | 187 ++++ gdb-moribund-utrace-workaround.patch | 16 + gdb-unwind-debughook-safe-fail.patch | 46 + gdb-unwind-debughook-step-independent.patch | 235 +++++ gdb-upstream.patch | 21 + gdb.changes | 5 + gdb.spec | 43 +- 14 files changed, 2307 insertions(+), 206 deletions(-) create mode 100644 gdb-archer-vla-ref-optimizedout.patch create mode 100644 gdb-archer-vla-test-oom.patch create mode 100644 gdb-bz539590-gnu-ifunc-fix-cond.patch create mode 100644 gdb-bz570635-prettyprint-doc1.patch create mode 100644 gdb-bz570635-prettyprint-doc2.patch create mode 100644 gdb-bz575292-delayed-physname.patch create mode 100644 gdb-bz575292-void-workaround.patch create mode 100644 gdb-moribund-utrace-workaround.patch create mode 100644 gdb-unwind-debughook-safe-fail.patch create mode 100644 gdb-unwind-debughook-step-independent.patch diff --git a/gdb-archer-vla-ref-optimizedout.patch b/gdb-archer-vla-ref-optimizedout.patch new file mode 100644 index 0000000..78dc309 --- /dev/null +++ b/gdb-archer-vla-ref-optimizedout.patch @@ -0,0 +1,105 @@ +commit a683bac73af74a757591672d89d720169c0b5ec9 +Author: Jan Kratochvil +Date: Thu May 13 18:08:30 2010 +0200 + + Support DW_AT_upper_bound is referencing an optimized-out variable. + https://bugzilla.redhat.com/show_bug.cgi?id=591879 + +--- a/gdb/dwarf2loc.c ++++ b/gdb/dwarf2loc.c +@@ -383,6 +383,9 @@ dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton, + size_t size; + struct value *val; + ++ if (!dllbaton) ++ return 0; ++ + data = find_location_expression (dllbaton, &size, + get_frame_address_in_block (frame)); + if (data == NULL) +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -11693,6 +11693,11 @@ dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu) + { + struct dwarf2_loclist_baton *baton; + ++ /* DW_AT_location of the referenced DIE may be missing if the referenced ++ variable has been optimized out. */ ++ if (!attr) ++ return NULL; ++ + if (!(attr_form_is_section_offset (attr) + /* ".debug_loc" may not exist at all, or the offset may be outside + the section. If so, fall through to the complaint in the +--- a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S +@@ -51,6 +51,17 @@ vardata: + .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */ + .byte 0 /* End of children of die */ + ++ /* DW_AT_upper_bound is referencing an optimized-out variable. */ ++.Larrayb_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */ ++ .byte 0 /* End of children of die */ ++ + .Luint_type: + .uleb128 4 /* Abbrev: DW_TAG_base_type */ + .4byte .Luint_str /* DW_AT_name */ +@@ -69,9 +80,24 @@ vardata: + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ + .4byte .Llen_loclist-.Lloclist /* DW_AT_location */ + ++ /* optimized-out variable for b_string. */ ++.Llenb_var: ++ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */ ++ .byte 1 /* DW_AT_artificial */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ + .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ + .string "a_string" /* DW_AT_name */ +- .4byte .Larray_type-.Lcu1_begin/* DW_AT_type */ ++ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ /* DW_AT_upper_bound is referencing an optimized-out variable. */ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "b_string" /* DW_AT_name */ ++ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */ + .byte 2f - 1f /* DW_AT_location */ + 1: .byte 3 /* DW_OP_addr */ + .4byte vardata /* */ +@@ -164,6 +190,16 @@ vardata: + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + ++ .uleb128 7 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0x0c /* DW_FORM_flag */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ + .byte 0x0 /* Terminator */ + + /* String table */ +--- a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp +@@ -46,3 +46,6 @@ if ![runto "*main"] { + + gdb_test "p a_string" { = "seen"} + gdb_test "ptype a_string" {type = char \[4\]} ++ ++gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"} ++gdb_test "ptype b_string" {type = char \[\]} diff --git a/gdb-archer-vla-test-oom.patch b/gdb-archer-vla-test-oom.patch new file mode 100644 index 0000000..7f27dcd --- /dev/null +++ b/gdb-archer-vla-test-oom.patch @@ -0,0 +1,21 @@ +commit ec5a7769d5c05542d12fc21afa25f32360db7de4 +Author: Jan Kratochvil +Date: Wed May 12 22:00:46 2010 +0200 + + Fix mb_reserve: + https://bugzilla.redhat.com/show_bug.cgi?id=590635 + +diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp +index 7203a48..24a608f 100644 +--- a/gdb/testsuite/gdb.base/vla-overflow.exp ++++ b/gdb/testsuite/gdb.base/vla-overflow.exp +@@ -66,7 +66,8 @@ proc memory_v_pages_get {} { + + set pages_found [memory_v_pages_get] + +-set mb_reserve 10 ++# s390x with glibc-debuginfo.s390x installed used approx. 16MB. ++set mb_reserve 40 + verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve" + set kb_found [expr $pages_found * $pagesize / 1024] + set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024] diff --git a/gdb-archer.patch b/gdb-archer.patch index 93568da..8d847c7 100644 --- a/gdb-archer.patch +++ b/gdb-archer.patch @@ -2,7 +2,7 @@ http://sourceware.org/gdb/wiki/ProjectArcher http://sourceware.org/gdb/wiki/ArcherBranchManagement GIT snapshot: -commit cb854301ce799ed6c96a80a03d829f3d186e4811 +commit 39998c496988faaa1509cc6ab76b5c4777659bf4 branch `archer' - the merge of branches: archer-tromey-delayed-symfile2 @@ -1275,7 +1275,7 @@ index d620881..34cb34a 100644 dump_subexp_body_standard, evaluate_subexp_c diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c -index ed98381..a405826 100644 +index ed98381..3061ab7 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -32,6 +32,7 @@ @@ -1358,12 +1358,13 @@ index ed98381..a405826 100644 printed_any = 1; } -@@ -558,7 +584,12 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, +@@ -558,7 +584,13 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, fprintf_filtered (stream, ")"); fprintf_filtered (stream, "["); - if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0 -+ if (TYPE_ARRAY_UPPER_BOUND_IS_DWARF_BLOCK (type)) ++ if (TYPE_RANGE_DATA (TYPE_INDEX_TYPE (type))->high.kind ++ != RANGE_BOUND_KIND_CONSTANT) + { + /* No _() - printed sources should not be locale dependent. */ + fprintf_filtered (stream, "variable"); @@ -1372,7 +1373,7 @@ index ed98381..a405826 100644 && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type)) fprintf_filtered (stream, "%d", (TYPE_LENGTH (type) -@@ -591,7 +622,7 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, +@@ -591,7 +623,7 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, if (passed_a_ptr) fprintf_filtered (stream, ")"); if (!demangled_args) @@ -3284,10 +3285,23 @@ index 437ca39..f7fce92 100644 /* The current depth of dwarf expression recursion, via DW_OP_call*, DW_OP_fbreg, DW_OP_push_object_address, etc., and the maximum diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c -index 1c4d057..ac67f22 100644 +index 1c4d057..20dcacd 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c -@@ -121,6 +121,9 @@ struct dwarf_expr_baton +@@ -46,6 +46,12 @@ static void + dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, + gdb_byte **start, size_t *length); + ++static struct value *dwarf2_evaluate_loc_desc (struct type *type, ++ struct frame_info *frame, ++ gdb_byte *data, ++ unsigned short size, ++ struct dwarf2_per_cu_data *per_cu); ++ + /* A helper function for dealing with location lists. Given a + symbol baton (BATON) and a pc value (PC), find the appropriate + location expression, set *LOCEXPR_LENGTH, and return a pointer +@@ -121,6 +127,9 @@ struct dwarf_expr_baton { struct frame_info *frame; struct objfile *objfile; @@ -3297,7 +3311,7 @@ index 1c4d057..ac67f22 100644 }; /* Helper functions for dwarf2_evaluate_loc_desc. */ -@@ -189,22 +192,33 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, +@@ -189,22 +198,33 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, symbaton = SYMBOL_LOCATION_BATON (framefunc); *start = find_location_expression (symbaton, length, pc); } @@ -3340,7 +3354,7 @@ index 1c4d057..ac67f22 100644 } /* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for -@@ -227,6 +241,129 @@ dwarf_expr_tls_address (void *baton, CORE_ADDR offset) +@@ -227,6 +247,155 @@ dwarf_expr_tls_address (void *baton, CORE_ADDR offset) return target_translate_tls_address (debaton->objfile, offset); } @@ -3466,11 +3480,43 @@ index 1c4d057..ac67f22 100644 + + return retval; +} ++ ++/* Evaluate DWARF location list at DLLBATON expecting it produces exactly one ++ CORE_ADDR result stored to *ADDRP on the DWARF stack stack. If the result ++ could not be found return zero and keep *ADDRP unchanged. */ ++ ++int ++dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton, ++ struct type *type, CORE_ADDR *addrp) ++{ ++ struct frame_info *frame = get_selected_frame (NULL); ++ gdb_byte *data; ++ size_t size; ++ struct value *val; ++ ++ data = find_location_expression (dllbaton, &size, ++ get_frame_address_in_block (frame)); ++ if (data == NULL) ++ return 0; ++ ++ val = dwarf2_evaluate_loc_desc (type, frame, data, size, dllbaton->per_cu); ++ if (value_optimized_out (val)) ++ return 0; ++ ++ *addrp = value_as_address (val); ++ return 1; ++} + struct piece_closure { /* The number of pieces used to describe this variable. */ -@@ -406,9 +543,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, +@@ -401,48 +570,31 @@ static struct lval_funcs pieced_value_funcs = { + SIZE, to find the current location of variable VAR in the context + of FRAME. */ + static struct value * +-dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, ++dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, + gdb_byte *data, unsigned short size, struct dwarf2_per_cu_data *per_cu) { struct value *retval; @@ -3481,7 +3527,10 @@ index 1c4d057..ac67f22 100644 if (size == 0) { -@@ -418,22 +554,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, +- retval = allocate_value (SYMBOL_TYPE (var)); ++ retval = allocate_value (type); + VALUE_LVAL (retval) = not_lval; + set_value_optimized_out (retval, 1); return retval; } @@ -3505,19 +3554,88 @@ index 1c4d057..ac67f22 100644 if (ctx->num_pieces > 0) { struct piece_closure *c; -@@ -463,6 +585,11 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, + struct frame_id frame_id = get_frame_id (frame); + + c = allocate_piece_closure (ctx->num_pieces, ctx->pieces, ctx->gdbarch); +- retval = allocate_computed_value (SYMBOL_TYPE (var), +- &pieced_value_funcs, +- c); ++ retval = allocate_computed_value (type, &pieced_value_funcs, c); + VALUE_FRAME_ID (retval) = frame_id; + } + else +@@ -454,7 +606,7 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, + struct gdbarch *arch = get_frame_arch (frame); + CORE_ADDR dwarf_regnum = dwarf_expr_fetch (ctx, 0); + int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, dwarf_regnum); +- retval = value_from_register (SYMBOL_TYPE (var), gdb_regnum, frame); ++ retval = value_from_register (type, gdb_regnum, frame); + } + break; + +@@ -463,7 +615,12 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, CORE_ADDR address = dwarf_expr_fetch (ctx, 0); int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0); +- retval = allocate_value (SYMBOL_TYPE (var)); + /* object_address_set called here is required in ALLOCATE_VALUE's + CHECK_TYPEDEF for the object's possible + DW_OP_push_object_address. */ + object_address_set (address); + - retval = allocate_value (SYMBOL_TYPE (var)); ++ retval = allocate_value (type); VALUE_LVAL (retval) = lval_memory; set_value_lazy (retval, 1); -@@ -868,7 +995,7 @@ static int + if (in_stack_memory) +@@ -478,10 +635,10 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, + bfd_byte *contents; + size_t n = ctx->addr_size; + +- retval = allocate_value (SYMBOL_TYPE (var)); ++ retval = allocate_value (type); + contents = value_contents_raw (retval); +- if (n > TYPE_LENGTH (SYMBOL_TYPE (var))) +- n = TYPE_LENGTH (SYMBOL_TYPE (var)); ++ if (n > TYPE_LENGTH (type)) ++ n = TYPE_LENGTH (type); + store_unsigned_integer (contents, n, + gdbarch_byte_order (ctx->gdbarch), + value); +@@ -493,10 +650,10 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, + bfd_byte *contents; + size_t n = ctx->len; + +- retval = allocate_value (SYMBOL_TYPE (var)); ++ retval = allocate_value (type); + contents = value_contents_raw (retval); +- if (n > TYPE_LENGTH (SYMBOL_TYPE (var))) +- n = TYPE_LENGTH (SYMBOL_TYPE (var)); ++ if (n > TYPE_LENGTH (type)) ++ n = TYPE_LENGTH (type); + memcpy (contents, ctx->data, n); + } + break; +@@ -720,8 +877,8 @@ locexpr_read_variable (struct symbol *symbol, struct frame_info *frame) + { + struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol); + struct value *val; +- val = dwarf2_evaluate_loc_desc (symbol, frame, dlbaton->data, dlbaton->size, +- dlbaton->per_cu); ++ val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, dlbaton->data, ++ dlbaton->size, dlbaton->per_cu); + + return val; + } +@@ -844,7 +1001,7 @@ loclist_read_variable (struct symbol *symbol, struct frame_info *frame) + set_value_optimized_out (val, 1); + } + else +- val = dwarf2_evaluate_loc_desc (symbol, frame, data, size, ++ val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, data, size, + dlbaton->per_cu); + + return val; +@@ -868,7 +1025,7 @@ static int loclist_describe_location (struct symbol *symbol, struct ui_file *stream) { /* FIXME: Could print the entire list of locations. */ @@ -3526,7 +3644,7 @@ index 1c4d057..ac67f22 100644 return 1; } -@@ -884,16 +1011,56 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, +@@ -884,16 +1041,56 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, data = find_location_expression (dlbaton, &size, ax->scope); if (data == NULL) @@ -3587,10 +3705,10 @@ index 1c4d057..ac67f22 100644 + missing_tracepoint_var_ref +}; diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h -index fa0bd11..fdea2b4 100644 +index fa0bd11..3535c1f 100644 --- a/gdb/dwarf2loc.h +++ b/gdb/dwarf2loc.h -@@ -72,5 +72,11 @@ struct dwarf2_loclist_baton +@@ -72,5 +72,14 @@ struct dwarf2_loclist_baton extern const struct symbol_computed_ops dwarf2_locexpr_funcs; extern const struct symbol_computed_ops dwarf2_loclist_funcs; @@ -3600,10 +3718,13 @@ index fa0bd11..fdea2b4 100644 + +extern CORE_ADDR dwarf_locexpr_baton_eval + (struct dwarf2_locexpr_baton *dlbaton); ++ ++extern int dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton, ++ struct type *type, CORE_ADDR *addrp); #endif /* dwarf2loc.h */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c -index a05c946..285c58e 100644 +index a05c946..9452844 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -48,6 +48,10 @@ @@ -3728,7 +3849,17 @@ index a05c946..285c58e 100644 static char *dwarf2_canonicalize_name (char *, struct dwarf2_cu *, struct obstack *); -@@ -1144,6 +1177,9 @@ static void age_cached_comp_units (void); +@@ -1114,6 +1147,9 @@ static int attr_form_is_section_offset (struct attribute *); + + static int attr_form_is_constant (struct attribute *); + ++static struct dwarf2_loclist_baton *dwarf2_attr_to_loclist_baton ++ (struct attribute *attr, struct dwarf2_cu *cu); ++ + static void dwarf2_symbol_mark_computed (struct attribute *attr, + struct symbol *sym, + struct dwarf2_cu *cu); +@@ -1144,6 +1180,9 @@ static void age_cached_comp_units (void); static void free_one_cached_comp_unit (void *); @@ -3738,7 +3869,7 @@ index a05c946..285c58e 100644 static struct type *set_die_type (struct die_info *, struct type *, struct dwarf2_cu *); -@@ -1163,22 +1199,31 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *); +@@ -1163,22 +1202,31 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *); static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu); @@ -3779,7 +3910,7 @@ index a05c946..285c58e 100644 } /* When loading sections, we can either look for ".", or for -@@ -1271,10 +1316,13 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr) +@@ -1271,10 +1319,13 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr) } /* Decompress a section that was compressed using zlib. Store the @@ -3795,7 +3926,7 @@ index a05c946..285c58e 100644 gdb_byte **outbuf, bfd_size_type *outsize) { bfd *abfd = objfile->obfd; -@@ -1291,6 +1339,7 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, +@@ -1291,6 +1342,7 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, z_stream strm; int rc; int header_size = 12; @@ -3803,7 +3934,7 @@ index a05c946..285c58e 100644 if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 || bfd_bread (compressed_buffer, compressed_size, abfd) != compressed_size) -@@ -1320,8 +1369,13 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, +@@ -1320,8 +1372,13 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, strm.avail_in = compressed_size - header_size; strm.next_in = (Bytef*) compressed_buffer + header_size; strm.avail_out = uncompressed_size; @@ -3819,7 +3950,7 @@ index a05c946..285c58e 100644 rc = inflateInit (&strm); while (strm.avail_in > 0) { -@@ -1342,26 +1396,176 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, +@@ -1342,26 +1399,176 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, error (_("Dwarf Error: concluding DWARF uncompression in '%s': %d"), bfd_get_filename (abfd), rc); @@ -4001,7 +4132,7 @@ index a05c946..285c58e 100644 if (info->asection == NULL || info->size == 0) return; -@@ -1374,7 +1578,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1374,7 +1581,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) /* Upon decompression, update the buffer and its size. */ if (strncmp (header, "ZLIB", sizeof (header)) == 0) { @@ -4010,7 +4141,7 @@ index a05c946..285c58e 100644 &info->size); return; } -@@ -1397,7 +1601,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1397,7 +1604,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) if (retbuf != MAP_FAILED) { @@ -4019,7 +4150,7 @@ index a05c946..285c58e 100644 info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ; return; } -@@ -1405,8 +1609,15 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1405,8 +1612,15 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) #endif /* If we get here, we are a normal, not-compressed section. */ @@ -4037,7 +4168,7 @@ index a05c946..285c58e 100644 /* When debugging .o files, we may need to apply relocations; see http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html . -@@ -1415,6 +1626,8 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1415,6 +1629,8 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) retbuf = symfile_relocate_debug_section (objfile, sectp, buf); if (retbuf != NULL) { @@ -4046,7 +4177,7 @@ index a05c946..285c58e 100644 info->buffer = retbuf; return; } -@@ -1423,6 +1636,19 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1423,6 +1639,19 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) || bfd_bread (buf, info->size, abfd) != info->size) error (_("Dwarf Error: Can't read DWARF data from '%s'"), bfd_get_filename (abfd)); @@ -4066,7 +4197,7 @@ index a05c946..285c58e 100644 } /* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and -@@ -2070,6 +2296,29 @@ build_type_psymtabs (struct objfile *objfile) +@@ -2070,6 +2299,29 @@ build_type_psymtabs (struct objfile *objfile) process_type_comp_unit, objfile); } @@ -4096,7 +4227,7 @@ index a05c946..285c58e 100644 /* Build the partial symbol table by doing a quick pass through the .debug_info and .debug_abbrev sections. */ -@@ -2080,7 +2329,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile) +@@ -2080,7 +2332,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile) mmap() on architectures that support it. (FIXME) */ bfd *abfd = objfile->obfd; gdb_byte *info_ptr; @@ -4105,7 +4236,7 @@ index a05c946..285c58e 100644 info_ptr = dwarf2_per_objfile->info.buffer; -@@ -2094,6 +2343,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile) +@@ -2094,6 +2346,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile) objfile->psymtabs_addrmap = addrmap_create_mutable (&objfile->objfile_obstack); @@ -4113,7 +4244,7 @@ index a05c946..285c58e 100644 /* Since the objects we're extracting from .debug_info vary in length, only the individual functions to extract them (like -@@ -2123,6 +2373,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile) +@@ -2123,6 +2376,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile) dwarf2_per_objfile->info.size); } @@ -4121,7 +4252,7 @@ index a05c946..285c58e 100644 objfile->psymtabs_addrmap = addrmap_create_fixed (objfile->psymtabs_addrmap, &objfile->objfile_obstack); -@@ -2389,11 +2640,18 @@ partial_die_parent_scope (struct partial_die_info *pdi, +@@ -2389,11 +2643,18 @@ partial_die_parent_scope (struct partial_die_info *pdi, || parent->tag == DW_TAG_union_type || parent->tag == DW_TAG_enumeration_type) { @@ -4142,7 +4273,7 @@ index a05c946..285c58e 100644 } else if (parent->tag == DW_TAG_enumerator) /* Enumerators should not get the name of the enumeration as a prefix. */ -@@ -2405,7 +2663,7 @@ partial_die_parent_scope (struct partial_die_info *pdi, +@@ -2405,7 +2666,7 @@ partial_die_parent_scope (struct partial_die_info *pdi, ignoring them. */ complaint (&symfile_complaints, _("unhandled containing DIE tag %d for DIE at %d"), @@ -4151,7 +4282,7 @@ index a05c946..285c58e 100644 parent->scope = grandparent_scope; } -@@ -2420,12 +2678,22 @@ partial_die_full_name (struct partial_die_info *pdi, +@@ -2420,12 +2681,22 @@ partial_die_full_name (struct partial_die_info *pdi, struct dwarf2_cu *cu) { char *parent_scope; @@ -4178,7 +4309,7 @@ index a05c946..285c58e 100644 } static void -@@ -2441,12 +2709,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) +@@ -2441,12 +2712,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); @@ -4194,7 +4325,7 @@ index a05c946..285c58e 100644 if (actual_name == NULL) actual_name = pdi->name; -@@ -2543,6 +2808,13 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) +@@ -2543,6 +2811,13 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) &objfile->global_psymbols, 0, (CORE_ADDR) 0, cu->language, objfile); break; @@ -4208,7 +4339,7 @@ index a05c946..285c58e 100644 case DW_TAG_class_type: case DW_TAG_interface_type: case DW_TAG_structure_type: -@@ -2586,49 +2858,10 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) +@@ -2586,49 +2861,10 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) break; } @@ -4258,7 +4389,7 @@ index a05c946..285c58e 100644 /* Read a partial die corresponding to a namespace; also, add a symbol corresponding to that namespace to the symbol table. NAMESPACE is the name of the enclosing namespace. */ -@@ -2656,12 +2889,12 @@ static void +@@ -2656,12 +2892,12 @@ static void add_partial_module (struct partial_die_info *pdi, CORE_ADDR *lowpc, CORE_ADDR *highpc, int need_pc, struct dwarf2_cu *cu) { @@ -4275,7 +4406,7 @@ index a05c946..285c58e 100644 } /* Read a partial die corresponding to a subprogram and create a partial -@@ -2739,7 +2972,6 @@ guess_structure_name (struct partial_die_info *struct_pdi, +@@ -2739,7 +2975,6 @@ guess_structure_name (struct partial_die_info *struct_pdi, could fix this by only using the demangled name to get the prefix (but see comment in read_structure_type). */ @@ -4283,7 +4414,7 @@ index a05c946..285c58e 100644 struct partial_die_info *real_pdi; /* If this DIE (this DIE's specification, if any) has a parent, then -@@ -2752,27 +2984,6 @@ guess_structure_name (struct partial_die_info *struct_pdi, +@@ -2752,27 +2987,6 @@ guess_structure_name (struct partial_die_info *struct_pdi, if (real_pdi->die_parent != NULL) return; @@ -4311,7 +4442,7 @@ index a05c946..285c58e 100644 } } -@@ -3325,6 +3536,14 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) +@@ -3325,6 +3539,14 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) case DW_TAG_imported_declaration: case DW_TAG_imported_module: processing_has_namespace_info = 1; @@ -4326,7 +4457,7 @@ index a05c946..285c58e 100644 if (die->child != NULL && (die->tag == DW_TAG_imported_declaration || cu->language != language_fortran)) complaint (&symfile_complaints, _("Tag '%s' has unexpected children"), -@@ -3337,42 +3556,183 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) +@@ -3337,42 +3559,183 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) } } @@ -4537,7 +4668,7 @@ index a05c946..285c58e 100644 } /* Read the import statement specified by the given die and record it. */ -@@ -3385,11 +3745,15 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) +@@ -3385,11 +3748,15 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) struct dwarf2_cu *imported_cu; const char *imported_name; const char *imported_name_prefix; @@ -4557,7 +4688,7 @@ index a05c946..285c58e 100644 import_attr = dwarf2_attr (die, DW_AT_import, cu); if (import_attr == NULL) { -@@ -3439,19 +3803,25 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) +@@ -3439,19 +3806,25 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) } /* Figure out the local name after import. */ @@ -4590,7 +4721,7 @@ index a05c946..285c58e 100644 strcpy (canonical_name, imported_name_prefix); strcat (canonical_name, "::"); strcat (canonical_name, imported_name); -@@ -3461,10 +3831,13 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) +@@ -3461,10 +3834,13 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) canonical_name = alloca (strlen (imported_name) + 1); strcpy (canonical_name, imported_name); } @@ -4605,7 +4736,7 @@ index a05c946..285c58e 100644 using_directives); } -@@ -3734,6 +4107,14 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) +@@ -3734,6 +4110,14 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) struct attribute *attr; attr = dwarf2_attr (die, DW_AT_abstract_origin, cu); @@ -4620,7 +4751,7 @@ index a05c946..285c58e 100644 if (!attr) return; -@@ -3832,6 +4213,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3832,6 +4216,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) char *name; CORE_ADDR baseaddr; struct block *block; @@ -4628,7 +4759,7 @@ index a05c946..285c58e 100644 int inlined_func = (die->tag == DW_TAG_inlined_subroutine); if (inlined_func) -@@ -3850,13 +4232,23 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3850,13 +4235,23 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); @@ -4655,7 +4786,7 @@ index a05c946..285c58e 100644 lowpc += baseaddr; highpc += baseaddr; -@@ -3883,14 +4275,19 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3883,14 +4278,19 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) cu->list_in_scope = &local_symbols; @@ -4682,7 +4813,7 @@ index a05c946..285c58e 100644 } inherit_abstract_dies (die, cu); -@@ -3906,6 +4303,13 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3906,6 +4306,13 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) determine_prefix (die, cu), processing_has_namespace_info); @@ -4696,7 +4827,7 @@ index a05c946..285c58e 100644 /* If we have address ranges, record them. */ dwarf2_record_block_ranges (die, block, baseaddr, cu); -@@ -4524,7 +4928,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, +@@ -4524,7 +4931,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, return; /* Get physical name. */ @@ -4705,7 +4836,7 @@ index a05c946..285c58e 100644 /* The name is already allocated along with this objfile, so we don't need to duplicate it for the type. */ -@@ -4686,7 +5090,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, +@@ -4686,7 +5093,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, return; /* Get the mangled name. */ @@ -4714,7 +4845,7 @@ index a05c946..285c58e 100644 /* Look up member function name in fieldlist. */ for (i = 0; i < fip->nfnfields; i++) -@@ -4993,14 +5397,18 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -4993,14 +5400,18 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) if (cu->language == language_cplus || cu->language == language_java) { @@ -4736,7 +4867,7 @@ index a05c946..285c58e 100644 } } -@@ -5219,7 +5627,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5219,7 +5630,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) type = alloc_type (objfile); TYPE_CODE (type) = TYPE_CODE_ENUM; @@ -4745,7 +4876,7 @@ index a05c946..285c58e 100644 if (name != NULL) TYPE_TAG_NAME (type) = (char *) name; -@@ -5244,51 +5652,6 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5244,51 +5655,6 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) return set_die_type (die, type, cu); } @@ -4797,7 +4928,7 @@ index a05c946..285c58e 100644 /* Given a pointer to a die which begins an enumeration, process all the dies that define the members of the enumeration, and create the symbol for the enumeration type. -@@ -5366,6 +5729,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -5366,6 +5732,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) new_symbol (die, this_type, cu); } @@ -4827,7 +4958,7 @@ index a05c946..285c58e 100644 /* Extract all information from a DW_TAG_array_type DIE and put it in the DIE's type field. For now, this only handles one dimensional arrays. */ -@@ -5379,7 +5765,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5379,7 +5768,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) struct type *element_type, *range_type, *index_type; struct type **range_types = NULL; struct attribute *attr; @@ -4836,7 +4967,7 @@ index a05c946..285c58e 100644 struct cleanup *back_to; char *name; -@@ -5426,16 +5812,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5426,16 +5815,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) type = element_type; if (read_array_order (die, cu) == DW_ORD_col_major) @@ -4858,7 +4989,7 @@ index a05c946..285c58e 100644 /* Understand Dwarf2 support for vector types (like they occur on the PowerPC w/ AltiVec). Gcc just adds another attribute to the -@@ -5624,7 +6005,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) +@@ -5624,7 +6008,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) if (is_anonymous) { const char *previous_prefix = determine_prefix (die, cu); @@ -4867,7 +4998,7 @@ index a05c946..285c58e 100644 } } -@@ -5640,20 +6021,155 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) +@@ -5640,20 +6024,155 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) } } @@ -4888,12 +5019,11 @@ index a05c946..285c58e 100644 +} + +/* Read a Fortran module as type. - -- /* FIXME: Support the separate Fortran module namespaces. */ ++ + Modules present only as declarations - being used only for DW_AT_import of + DW_TAG_imported_module - are ignored here. They are read in only in form of + the module name by read_fortran_imported_module. */ - ++ +static struct type * +read_module_type (struct die_info *die, struct dwarf2_cu *cu) +{ @@ -4924,9 +5054,10 @@ index a05c946..285c58e 100644 + save_global_symbols = global_symbols; + global_symbols = NULL; + save_list_in_scope = cu->list_in_scope; -+ + +- /* FIXME: Support the separate Fortran module namespaces. */ + /* Process the child DIEs. */ -+ + + child_die = die->child; while (child_die && child_die->tag) { @@ -5026,7 +5157,7 @@ index a05c946..285c58e 100644 } /* Return the name of the namespace represented by DIE. Set -@@ -5818,29 +6334,113 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5818,29 +6337,115 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) struct gdbarch *gdbarch = get_objfile_arch (objfile); struct type *type, *range_type, *index_type, *char_type; struct attribute *attr; @@ -5111,7 +5242,8 @@ index a05c946..285c58e 100644 + } + } + -+ TYPE_HIGH_BOUND_IS_DWARF_BLOCK (range_type) = 1; ++ TYPE_RANGE_DATA (range_type)->high.kind ++ = RANGE_BOUND_KIND_DWARF_BLOCK; + TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = length_baton; + TYPE_DYNAMIC (range_type) = 1; + } @@ -5135,7 +5267,8 @@ index a05c946..285c58e 100644 - } + if (attr && attr_form_is_block (attr)) + { -+ TYPE_HIGH_BOUND_IS_DWARF_BLOCK (range_type) = 1; ++ TYPE_RANGE_DATA (range_type)->high.kind ++ = RANGE_BOUND_KIND_DWARF_BLOCK; + TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = + dwarf2_attr_to_locexpr_baton (attr, cu); + TYPE_DYNAMIC (range_type) = 1; @@ -5154,7 +5287,7 @@ index a05c946..285c58e 100644 char_type = language_string_char_type (cu->language_defn, gdbarch); type = create_string_type (NULL, char_type, range_type); -@@ -5940,11 +6540,10 @@ static struct type * +@@ -5940,11 +6545,10 @@ static struct type * read_typedef (struct die_info *die, struct dwarf2_cu *cu) { struct objfile *objfile = cu->objfile; @@ -5167,7 +5300,7 @@ index a05c946..285c58e 100644 this_type = init_type (TYPE_CODE_TYPEDEF, 0, TYPE_FLAG_TARGET_STUB, NULL, objfile); TYPE_NAME (this_type) = (char *) name; -@@ -6048,8 +6647,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -6048,8 +6652,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) struct type *base_type; struct type *range_type; struct attribute *attr; @@ -5177,7 +5310,7 @@ index a05c946..285c58e 100644 char *name; LONGEST negative_mask; -@@ -6063,49 +6661,101 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -6063,49 +6666,157 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) 0, NULL, cu->objfile); } @@ -5200,13 +5333,32 @@ index a05c946..285c58e 100644 - low = dwarf2_get_attr_constant_value (attr, 0); + if (attr && attr_form_is_block (attr)) + { -+ TYPE_LOW_BOUND_IS_DWARF_BLOCK (range_type) = 1; ++ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_BLOCK; + TYPE_RANGE_DATA (range_type)->low.u.dwarf_block = + dwarf2_attr_to_locexpr_baton (attr, cu); + TYPE_DYNAMIC (range_type) = 1; + /* For setting a default if DW_AT_UPPER_BOUND would be missing. */ + low = 0; + } ++ else if (attr && is_ref_attr (attr)) ++ { ++ struct die_info *target_die; ++ struct dwarf2_cu *target_cu = cu; ++ struct attribute *target_loc_attr; ++ ++ target_die = follow_die_ref_or_sig (die, attr, &target_cu); ++ gdb_assert (target_cu->objfile == cu->objfile); ++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); ++ ++ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_LOCLIST; ++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.loclist ++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu); ++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.type ++ = die_type (target_die, target_cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ /* For setting a default if DW_AT_UPPER_BOUND would be missing. */ ++ low = 0; ++ } + else + { + if (attr && attr_form_is_constant (attr)) @@ -5250,9 +5402,8 @@ index a05c946..285c58e 100644 - the lower bound we've computed above. */ - high = low - 1; - } -- else -- high = dwarf2_get_attr_constant_value (attr, 1); -+ if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr))) ++ if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr) ++ && !is_ref_attr (attr))) + { + attr = dwarf2_attr (die, DW_AT_count, cu); + /* It does not hurt but it is needlessly ineffective in check_typedef. */ @@ -5262,6 +5413,49 @@ index a05c946..285c58e 100644 + TYPE_DYNAMIC (range_type) = 1; + } + /* Pass it now as the regular DW_AT_upper_bound. */ ++ } ++ ++ if (attr && attr_form_is_block (attr)) ++ { ++ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = ++ dwarf2_attr_to_locexpr_baton (attr, cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ } ++ else if (attr && is_ref_attr (attr)) ++ { ++ struct die_info *target_die; ++ struct dwarf2_cu *target_cu = cu; ++ struct attribute *target_loc_attr; ++ ++ target_die = follow_die_ref_or_sig (die, attr, &target_cu); ++ gdb_assert (target_cu->objfile == cu->objfile); ++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); ++ ++ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_LOCLIST; ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.loclist ++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu); ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.type ++ = die_type (target_die, target_cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ } ++ else ++ { ++ if (attr && attr_form_is_constant (attr)) ++ { ++ LONGEST high; ++ ++ high = dwarf2_get_attr_constant_value (attr, 0); ++ if (!TYPE_UNSIGNED (base_type) && (high & negative_mask)) ++ high |= negative_mask; ++ TYPE_HIGH_BOUND (range_type) = high; ++ } + else +- high = dwarf2_get_attr_constant_value (attr, 1); ++ { ++ TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; ++ TYPE_HIGH_BOUND (range_type) = low - 1; ++ } } - negative_mask = @@ -5270,41 +5464,35 @@ index a05c946..285c58e 100644 - low |= negative_mask; - if (!TYPE_UNSIGNED (base_type) && (high & negative_mask)) - high |= negative_mask; -+ if (attr && attr_form_is_block (attr)) -+ { -+ TYPE_HIGH_BOUND_IS_DWARF_BLOCK (range_type) = 1; -+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = -+ dwarf2_attr_to_locexpr_baton (attr, cu); -+ TYPE_DYNAMIC (range_type) = 1; -+ } -+ else -+ { -+ if (attr && attr_form_is_constant (attr)) -+ { -+ LONGEST high; - -- range_type = create_range_type (NULL, base_type, low, high); -+ high = dwarf2_get_attr_constant_value (attr, 0); -+ if (!TYPE_UNSIGNED (base_type) && (high & negative_mask)) -+ high |= negative_mask; -+ TYPE_HIGH_BOUND (range_type) = high; -+ } -+ else -+ { -+ TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; -+ TYPE_HIGH_BOUND (range_type) = low - 1; -+ } -+ } -+ + /* DW_AT_bit_stride is currently unsupported as we count in bytes. */ + attr = dwarf2_attr (die, DW_AT_byte_stride, cu); + if (attr && attr_form_is_block (attr)) + { -+ TYPE_BYTE_STRIDE_IS_DWARF_BLOCK (range_type) = 1; ++ TYPE_RANGE_DATA (range_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_DWARF_BLOCK; + TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_block = + dwarf2_attr_to_locexpr_baton (attr, cu); + TYPE_DYNAMIC (range_type) = 1; + } ++ else if (attr && is_ref_attr (attr)) ++ { ++ struct die_info *target_die; ++ struct dwarf2_cu *target_cu = cu; ++ struct attribute *target_loc_attr; + +- range_type = create_range_type (NULL, base_type, low, high); ++ target_die = follow_die_ref_or_sig (die, attr, &target_cu); ++ gdb_assert (target_cu->objfile == cu->objfile); ++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); ++ ++ TYPE_RANGE_DATA (range_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_DWARF_LOCLIST; ++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.loclist ++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu); ++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.type ++ = die_type (target_die, target_cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ } + else if (attr && attr_form_is_constant (attr)) + { + TYPE_BYTE_STRIDE (range_type) = dwarf2_get_attr_constant_value (attr, 0); @@ -5315,7 +5503,7 @@ index a05c946..285c58e 100644 name = dwarf2_name (die, cu); if (name) -@@ -6564,6 +7214,7 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr, +@@ -6564,6 +7275,7 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr, && abbrev->tag != DW_TAG_lexical_block && abbrev->tag != DW_TAG_variable && abbrev->tag != DW_TAG_namespace @@ -5323,7 +5511,7 @@ index a05c946..285c58e 100644 && abbrev->tag != DW_TAG_member) { /* Otherwise we skip to the next sibling, if any. */ -@@ -6772,7 +7423,8 @@ read_partial_die (struct partial_die_info *part_die, +@@ -6772,7 +7484,8 @@ read_partial_die (struct partial_die_info *part_die, } break; case DW_AT_MIPS_linkage_name: @@ -5333,7 +5521,7 @@ index a05c946..285c58e 100644 break; case DW_AT_low_pc: has_low_pc_attr = 1; -@@ -6970,7 +7622,8 @@ fixup_partial_die (struct partial_die_info *part_die, +@@ -6970,7 +7683,8 @@ fixup_partial_die (struct partial_die_info *part_die, /* If we found a reference attribute and the DIE has no name, try to find a name in the referred to DIE. */ @@ -5343,7 +5531,7 @@ index a05c946..285c58e 100644 { struct partial_die_info *spec_die; -@@ -8312,10 +8965,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym, +@@ -8312,10 +9026,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym, (i.e. when the value of a register or memory location is referenced, or a thread-local block, etc.). Then again, it might not be worthwhile. I'm assuming that it isn't unless performance @@ -5358,7 +5546,7 @@ index a05c946..285c58e 100644 } /* Given a pointer to a DWARF information entry, figure out if we need -@@ -8337,21 +8992,27 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8337,21 +9053,27 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); @@ -5392,7 +5580,7 @@ index a05c946..285c58e 100644 /* Default assumptions. Use the passed type or decode it from the die. */ -@@ -8451,7 +9112,24 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8451,7 +9173,24 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) var_decode_location (attr, sym, cu); attr2 = dwarf2_attr (die, DW_AT_external, cu); if (attr2 && (DW_UNSND (attr2) != 0)) @@ -5418,7 +5606,7 @@ index a05c946..285c58e 100644 else add_symbol_to_list (sym, cu->list_in_scope); } -@@ -8576,7 +9254,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8576,7 +9315,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) } break; case DW_TAG_typedef: @@ -5428,7 +5616,7 @@ index a05c946..285c58e 100644 SYMBOL_CLASS (sym) = LOC_TYPEDEF; SYMBOL_DOMAIN (sym) = VAR_DOMAIN; add_symbol_to_list (sym, cu->list_in_scope); -@@ -8588,7 +9267,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8588,7 +9328,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) add_symbol_to_list (sym, cu->list_in_scope); break; case DW_TAG_enumerator: @@ -5438,7 +5626,7 @@ index a05c946..285c58e 100644 attr = dwarf2_attr (die, DW_AT_const_value, cu); if (attr) { -@@ -8612,6 +9292,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8612,6 +9353,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) SYMBOL_CLASS (sym) = LOC_TYPEDEF; add_symbol_to_list (sym, &global_symbols); break; @@ -5450,7 +5638,7 @@ index a05c946..285c58e 100644 default: /* Not a tag we recognize. Hopefully we aren't processing trash data, but since we must specifically ignore things -@@ -8625,8 +9310,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8625,8 +9371,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) /* For the benefit of old versions of GCC, check for anonymous namespaces based on the demangled name. */ if (!processing_has_namespace_info @@ -5460,7 +5648,7 @@ index a05c946..285c58e 100644 cp_scan_for_anonymous_namespaces (sym); } return (sym); -@@ -8938,12 +9622,18 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu) +@@ -8938,12 +9683,18 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu) case DW_TAG_namespace: this_type = read_namespace_type (die, cu); break; @@ -5479,7 +5667,7 @@ index a05c946..285c58e 100644 return this_type; } -@@ -9011,6 +9701,10 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) +@@ -9011,6 +9762,10 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) case DW_TAG_namespace: parent_type = read_type_die (parent, cu); /* We give a name to even anonymous namespaces. */ @@ -5490,7 +5678,7 @@ index a05c946..285c58e 100644 return TYPE_TAG_NAME (parent_type); case DW_TAG_class_type: case DW_TAG_interface_type: -@@ -9025,7 +9719,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) +@@ -9025,7 +9780,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) So it does not need a prefix. */ return ""; default: @@ -5499,7 +5687,7 @@ index a05c946..285c58e 100644 } } -@@ -9078,17 +9772,37 @@ sibling_die (struct die_info *die) +@@ -9078,17 +9833,37 @@ sibling_die (struct die_info *die) return die->sibling; } @@ -5525,7 +5713,11 @@ index a05c946..285c58e 100644 + if (module_name) + { + char *retval; -+ + +- attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu); +- if (attr && DW_STRING (attr)) +- return DW_STRING (attr); +- return dwarf2_name (die, cu); + /* `__modulename_MOD_variablename0'. */ + retval = obstack_alloc (&cu->objfile->objfile_obstack, + 2 + strlen (module_name) + 5 + strlen (name) @@ -5535,16 +5727,12 @@ index a05c946..285c58e 100644 + return retval; + } + } - -- attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu); -- if (attr && DW_STRING (attr)) -- return DW_STRING (attr); -- return dwarf2_name (die, cu); ++ + return name; } /* Get name of a die, return NULL if not found. */ -@@ -11436,6 +12150,34 @@ attr_form_is_constant (struct attribute *attr) +@@ -11436,64 +12211,94 @@ attr_form_is_constant (struct attribute *attr) } } @@ -5574,20 +5762,76 @@ index a05c946..285c58e 100644 + return baton; +} + ++static struct dwarf2_loclist_baton * ++dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu) ++{ ++ struct dwarf2_loclist_baton *baton; ++ ++ if (!(attr_form_is_section_offset (attr) ++ /* ".debug_loc" may not exist at all, or the offset may be outside ++ the section. If so, fall through to the complaint in the ++ other branch. */ ++ && DW_UNSND (attr) < dwarf2_per_objfile->loc.size)) ++ return NULL; ++ ++ baton = obstack_alloc (&cu->objfile->objfile_obstack, ++ sizeof (struct dwarf2_loclist_baton)); ++ baton->per_cu = cu->per_cu; ++ gdb_assert (baton->per_cu); ++ ++ /* We don't know how long the location list is, but make sure we ++ don't run off the edge of the section. */ ++ baton->size = dwarf2_per_objfile->loc.size - DW_UNSND (attr); ++ baton->data = dwarf2_per_objfile->loc.buffer + DW_UNSND (attr); ++ baton->base_address = cu->base_address; ++ if (cu->base_known == 0) ++ complaint (&symfile_complaints, ++ _("Location list used without specifying the CU base address.")); ++ ++ return baton; ++} ++ +/* SYM may get its SYMBOL_CLASS overriden on invalid ATTR content. */ + static void dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, struct dwarf2_cu *cu) -@@ -11465,35 +12207,25 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, + { +- if (attr_form_is_section_offset (attr) +- /* ".debug_loc" may not exist at all, or the offset may be outside +- the section. If so, fall through to the complaint in the +- other branch. */ +- && DW_UNSND (attr) < dwarf2_per_objfile->loc.size) +- { +- struct dwarf2_loclist_baton *baton; +- +- baton = obstack_alloc (&cu->objfile->objfile_obstack, +- sizeof (struct dwarf2_loclist_baton)); +- baton->per_cu = cu->per_cu; +- gdb_assert (baton->per_cu); +- +- /* We don't know how long the location list is, but make sure we +- don't run off the edge of the section. */ +- baton->size = dwarf2_per_objfile->loc.size - DW_UNSND (attr); +- baton->data = dwarf2_per_objfile->loc.buffer + DW_UNSND (attr); +- baton->base_address = cu->base_address; +- if (cu->base_known == 0) +- complaint (&symfile_complaints, +- _("Location list used without specifying the CU base address.")); ++ struct dwarf2_loclist_baton *loclist_baton; + ++ loclist_baton = dwarf2_attr_to_loclist_baton (attr, cu); ++ if (loclist_baton) ++ { SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs; - SYMBOL_LOCATION_BATON (sym) = baton; - } +- SYMBOL_LOCATION_BATON (sym) = baton; ++ SYMBOL_LOCATION_BATON (sym) = loclist_baton; ++ } + else if (attr_form_is_block (attr)) + { + SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs; + SYMBOL_LOCATION_BATON (sym) = dwarf2_attr_to_locexpr_baton (attr, cu); -+ } + } else { - struct dwarf2_locexpr_baton *baton; @@ -5630,7 +5874,7 @@ index a05c946..285c58e 100644 } } -@@ -11781,6 +12513,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) +@@ -11781,6 +12586,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) return ofs_lhs->offset == ofs_rhs->offset; } @@ -5662,7 +5906,7 @@ index a05c946..285c58e 100644 /* Set the type associated with DIE to TYPE. Save it in CU's hash table if necessary. For convenience, return TYPE. */ -@@ -11789,6 +12546,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -11789,6 +12619,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) { struct dwarf2_offset_and_type **slot, ofs; @@ -5671,7 +5915,7 @@ index a05c946..285c58e 100644 /* For Ada types, make sure that the gnat-specific data is always initialized (if not already set). There are a few types where we should not be doing so, because the type-specific area is -@@ -11944,23 +12703,13 @@ show_dwarf2_cmd (char *args, int from_tty) +@@ -11944,23 +12776,13 @@ show_dwarf2_cmd (char *args, int from_tty) cmd_show_list (show_dwarf2_cmdlist, from_tty, ""); } @@ -5699,7 +5943,7 @@ index a05c946..285c58e 100644 } /* munmap debug sections for OBJFILE, if necessary. */ -@@ -11969,15 +12718,15 @@ static void +@@ -11969,15 +12791,15 @@ static void dwarf2_per_objfile_free (struct objfile *objfile, void *d) { struct dwarf2_per_objfile *data = d; @@ -7033,7 +7277,7 @@ index cd24eaf..119af7d 100644 once for each known thread. */ typedef int (*thread_callback_func) (struct thread_info *, void *); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c -index 46846c4..bf6e891 100644 +index 46846c4..95bcca4 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -39,6 +39,9 @@ @@ -7162,8 +7406,8 @@ index 46846c4..bf6e891 100644 + /* DWARF blocks may depend on runtime information like + DW_OP_PUSH_OBJECT_ADDRESS not being available during the + CREATE_ARRAY_TYPE time. */ -+ if (TYPE_LOW_BOUND_IS_DWARF_BLOCK (range_type) -+ || TYPE_HIGH_BOUND_IS_DWARF_BLOCK (range_type) ++ if (TYPE_RANGE_DATA (range_type)->low.kind != RANGE_BOUND_KIND_CONSTANT ++ || TYPE_RANGE_DATA (range_type)->high.kind != RANGE_BOUND_KIND_CONSTANT + || TYPE_LOW_BOUND_UNDEFINED (range_type) + || TYPE_HIGH_BOUND_UNDEFINED (range_type) + || get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) @@ -7495,7 +7739,7 @@ index 46846c4..bf6e891 100644 if (TYPE_NAME (type)) TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type)); if (TYPE_TAG_NAME (type)) -@@ -3053,12 +3241,45 @@ copy_type_recursive (struct objfile *objfile, +@@ -3053,12 +3241,48 @@ copy_type_recursive (struct objfile *objfile, TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type); TYPE_LENGTH (new_type) = TYPE_LENGTH (type); @@ -7536,12 +7780,15 @@ index 46846c4..bf6e891 100644 { int i, nfields; ++ /* TYPE_CODE_RANGE uses TYPE_RANGE_DATA of the union with TYPE_FIELDS. */ ++ gdb_assert (TYPE_CODE (type) != TYPE_CODE_RANGE); ++ nfields = TYPE_NFIELDS (type); + TYPE_NFIELDS (new_type) = nfields; TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field); for (i = 0; i < nfields; i++) { -@@ -3067,8 +3288,8 @@ copy_type_recursive (struct objfile *objfile, +@@ -3067,8 +3291,8 @@ copy_type_recursive (struct objfile *objfile, TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i); if (TYPE_FIELD_TYPE (type, i)) TYPE_FIELD_TYPE (new_type, i) @@ -7552,7 +7799,7 @@ index 46846c4..bf6e891 100644 if (TYPE_FIELD_NAME (type, i)) TYPE_FIELD_NAME (new_type, i) = xstrdup (TYPE_FIELD_NAME (type, i)); -@@ -3095,24 +3316,75 @@ copy_type_recursive (struct objfile *objfile, +@@ -3095,24 +3319,166 @@ copy_type_recursive (struct objfile *objfile, } } @@ -7561,55 +7808,147 @@ index 46846c4..bf6e891 100644 + TYPE_DYNAMIC (new_type) = 0; + /* For range types, copy the bounds information. */ - if (TYPE_CODE (type) == TYPE_CODE_RANGE) +- if (TYPE_CODE (type) == TYPE_CODE_RANGE) ++ if (TYPE_CODE (new_type) == TYPE_CODE_RANGE) { TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds)); *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type); + -+ if (TYPE_LOW_BOUND_IS_DWARF_BLOCK (type)) ++ switch (TYPE_RANGE_DATA (new_type)->low.kind) + { ++ case RANGE_BOUND_KIND_CONSTANT: ++ break; ++ case RANGE_BOUND_KIND_DWARF_BLOCK: + /* `struct dwarf2_locexpr_baton' is too bound to its objfile so -+ it is expected to be made constant by CHECK_TYPEDEF. */ -+ if (TYPE_NOT_ALLOCATED (type) -+ || TYPE_NOT_ASSOCIATED (type)) -+ TYPE_RANGE_DATA (new_type)->low.u.dwarf_block = NULL; ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type) ++ || ! has_stack_frames ()) ++ { ++ /* We should set 1 for Fortran but how to find the language? */ ++ TYPE_LOW_BOUND (new_type) = 0; ++ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1; ++ } + else + TYPE_LOW_BOUND (new_type) = dwarf_locexpr_baton_eval + (TYPE_RANGE_DATA (new_type)->low.u.dwarf_block); -+ TYPE_LOW_BOUND_IS_DWARF_BLOCK (new_type) = 0; ++ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT; ++ break; ++ case RANGE_BOUND_KIND_DWARF_LOCLIST: ++ { ++ CORE_ADDR addr; ++ ++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (! TYPE_NOT_ALLOCATED (new_type) ++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames () ++ && dwarf_loclist_baton_eval ++ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.loclist, ++ TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.type, &addr)) ++ TYPE_LOW_BOUND (new_type) = addr; ++ else ++ { ++ /* We should set 1 for Fortran but how to find the language? */ ++ TYPE_LOW_BOUND (new_type) = 0; ++ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1; ++ } ++ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT; ++ } ++ break; + } + -+ if (TYPE_HIGH_BOUND_IS_DWARF_BLOCK (type)) ++ switch (TYPE_RANGE_DATA (new_type)->high.kind) + { ++ case RANGE_BOUND_KIND_CONSTANT: ++ break; ++ case RANGE_BOUND_KIND_DWARF_BLOCK: + /* `struct dwarf2_locexpr_baton' is too bound to its objfile so -+ it is expected to be made constant by CHECK_TYPEDEF. */ -+ if (TYPE_NOT_ALLOCATED (type) -+ || TYPE_NOT_ASSOCIATED (type)) -+ TYPE_RANGE_DATA (new_type)->high.u.dwarf_block = NULL; ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type) ++ || ! has_stack_frames ()) ++ { ++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1; ++ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1; ++ } + else + TYPE_HIGH_BOUND (new_type) = dwarf_locexpr_baton_eval + (TYPE_RANGE_DATA (new_type)->high.u.dwarf_block); -+ TYPE_HIGH_BOUND_IS_DWARF_BLOCK (new_type) = 0; ++ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT; ++ break; ++ case RANGE_BOUND_KIND_DWARF_LOCLIST: ++ { ++ CORE_ADDR addr; ++ ++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (! TYPE_NOT_ALLOCATED (new_type) ++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames () ++ && dwarf_loclist_baton_eval ++ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.loclist, ++ TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.type, ++ &addr)) ++ TYPE_HIGH_BOUND (new_type) = addr; ++ else ++ { ++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1; ++ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1; ++ } ++ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT; ++ } ++ break; + } + -+ if (TYPE_BYTE_STRIDE_IS_DWARF_BLOCK (type)) ++ switch (TYPE_RANGE_DATA (new_type)->byte_stride.kind) + { ++ case RANGE_BOUND_KIND_CONSTANT: ++ break; ++ case RANGE_BOUND_KIND_DWARF_BLOCK: + /* `struct dwarf2_locexpr_baton' is too bound to its objfile so -+ it is expected to be made constant by CHECK_TYPEDEF. */ -+ if (TYPE_NOT_ALLOCATED (type) -+ || TYPE_NOT_ASSOCIATED (type)) -+ TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_block = NULL; ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type) ++ || ! has_stack_frames ()) ++ TYPE_BYTE_STRIDE (new_type) = 0; + else + TYPE_BYTE_STRIDE (new_type) = dwarf_locexpr_baton_eval + (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_block); -+ TYPE_BYTE_STRIDE_IS_DWARF_BLOCK (new_type) = 0; ++ TYPE_RANGE_DATA (new_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_CONSTANT; ++ break; ++ case RANGE_BOUND_KIND_DWARF_LOCLIST: ++ { ++ CORE_ADDR addr = 0; ++ ++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (! TYPE_NOT_ALLOCATED (new_type) ++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()) ++ dwarf_loclist_baton_eval ++ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.loclist, ++ TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.type, ++ &addr); ++ TYPE_BYTE_STRIDE (new_type) = addr; ++ TYPE_RANGE_DATA (new_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_CONSTANT; ++ } ++ break; + } + + /* Convert TYPE_RANGE_HIGH_BOUND_IS_COUNT into a regular bound. */ -+ if (TYPE_RANGE_HIGH_BOUND_IS_COUNT (type)) ++ if (TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type)) + { -+ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (type) -+ + TYPE_HIGH_BOUND (type) - 1; ++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) ++ + TYPE_HIGH_BOUND (new_type) - 1; + TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type) = 0; + } } @@ -7634,7 +7973,7 @@ index 46846c4..bf6e891 100644 /* Maybe copy the type_specific bits. NOTE drow/2005-12-09: We do not copy the C++-specific bits like -@@ -3130,6 +3402,17 @@ copy_type_recursive (struct objfile *objfile, +@@ -3130,6 +3496,17 @@ copy_type_recursive (struct objfile *objfile, return new_type; } @@ -7652,7 +7991,7 @@ index 46846c4..bf6e891 100644 /* Make a copy of the given TYPE, except that the pointer & reference types are not preserved. -@@ -3152,6 +3435,211 @@ copy_type (const struct type *type) +@@ -3152,6 +3529,211 @@ copy_type (const struct type *type) return new_type; } @@ -7864,7 +8203,7 @@ index 46846c4..bf6e891 100644 /* Helper functions to initialize architecture-specific types. */ -@@ -3475,6 +3963,8 @@ gdbtypes_post_init (struct gdbarch *gdbarch) +@@ -3475,6 +4057,8 @@ gdbtypes_post_init (struct gdbarch *gdbarch) = lookup_pointer_type (builtin_type->builtin_void); builtin_type->builtin_func_ptr = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void)); @@ -7873,7 +8212,7 @@ index 46846c4..bf6e891 100644 /* This type represents a GDB internal function. */ builtin_type->internal_fn -@@ -3588,6 +4078,11 @@ objfile_type (struct objfile *objfile) +@@ -3588,6 +4172,11 @@ objfile_type (struct objfile *objfile) "", objfile); TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol) = objfile_type->builtin_int; @@ -7885,7 +8224,7 @@ index 46846c4..bf6e891 100644 objfile_type->nodebug_data_symbol = init_type (TYPE_CODE_INT, gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0, -@@ -3642,6 +4137,11 @@ void +@@ -3642,6 +4231,11 @@ void _initialize_gdbtypes (void) { gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init); @@ -7898,7 +8237,7 @@ index 46846c4..bf6e891 100644 add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h -index 643fa03..6381dcf 100644 +index 643fa03..efe5512 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -138,6 +138,8 @@ enum type_code @@ -8056,7 +8395,7 @@ index 643fa03..6381dcf 100644 } loc; -@@ -544,13 +615,22 @@ struct main_type +@@ -544,13 +615,34 @@ struct main_type struct range_bounds { @@ -8064,11 +8403,23 @@ index 643fa03..6381dcf 100644 + { + union + { -+ struct dwarf2_locexpr_baton *dwarf_block; + LONGEST constant; ++ struct dwarf2_locexpr_baton *dwarf_block; ++ struct ++ { ++ struct dwarf2_loclist_baton *loclist; ++ struct type *type; ++ } ++ dwarf_loclist; + } + u; -+ unsigned is_dwarf_block : 1; ++ enum range_bound_kind ++ { ++ RANGE_BOUND_KIND_CONSTANT, ++ RANGE_BOUND_KIND_DWARF_BLOCK, ++ RANGE_BOUND_KIND_DWARF_LOCLIST ++ } ++ kind; + } /* Low bound of range. */ - @@ -8084,7 +8435,7 @@ index 643fa03..6381dcf 100644 /* Flags indicating whether the values of low and high are valid. When true, the respective range value is -@@ -602,6 +682,9 @@ struct main_type +@@ -602,6 +694,9 @@ struct main_type supporting multiple ABIs. Right now this is only fetched from the Dwarf-2 DW_AT_calling_convention attribute. */ unsigned calling_convention; @@ -8094,7 +8445,7 @@ index 643fa03..6381dcf 100644 } type_specific; }; -@@ -838,13 +921,6 @@ struct cplus_struct_type +@@ -838,13 +933,6 @@ struct cplus_struct_type int is_dynamic : 2; }; @@ -8108,7 +8459,7 @@ index 643fa03..6381dcf 100644 /* Struct used for ranking a function for overload resolution */ struct badness_vector { -@@ -899,9 +975,9 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -899,9 +987,9 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type #define TYPE_CHAIN(thistype) (thistype)->chain @@ -8121,7 +8472,7 @@ index 643fa03..6381dcf 100644 calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */ #define TYPE_LENGTH(thistype) (thistype)->length /* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real -@@ -910,15 +986,26 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -910,11 +998,16 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields #define TYPE_TEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->template_args @@ -8140,26 +8491,7 @@ index 643fa03..6381dcf 100644 #define TYPE_LOW_BOUND_UNDEFINED(range_type) \ TYPE_RANGE_DATA(range_type)->low_undefined #define TYPE_HIGH_BOUND_UNDEFINED(range_type) \ - TYPE_RANGE_DATA(range_type)->high_undefined -+#define TYPE_LOW_BOUND_IS_DWARF_BLOCK(range_type) \ -+ TYPE_RANGE_DATA(range_type)->low.is_dwarf_block -+#define TYPE_HIGH_BOUND_IS_DWARF_BLOCK(range_type) \ -+ TYPE_RANGE_DATA(range_type)->high.is_dwarf_block -+#define TYPE_BYTE_STRIDE_IS_DWARF_BLOCK(range_type) \ -+ TYPE_RANGE_DATA(range_type)->byte_stride.is_dwarf_block - - /* Moto-specific stuff for FORTRAN arrays */ - -@@ -927,11 +1014,23 @@ extern void allocate_gnat_aux_type (struct type *); - #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \ - TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype)) - -+#define TYPE_ARRAY_UPPER_BOUND_IS_DWARF_BLOCK(arraytype) \ -+ TYPE_HIGH_BOUND_IS_DWARF_BLOCK(TYPE_INDEX_TYPE(arraytype)) -+#define TYPE_ARRAY_LOWER_BOUND_IS_DWARF_BLOCK(arraytype) \ -+ TYPE_LOW_BOUND_IS_DWARF_BLOCK(TYPE_INDEX_TYPE(arraytype)) -+ - #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \ +@@ -931,7 +1024,14 @@ extern void allocate_gnat_aux_type (struct type *); (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype)))) #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \ @@ -8175,7 +8507,7 @@ index 643fa03..6381dcf 100644 /* C++ */ -@@ -959,6 +1058,7 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -959,6 +1059,7 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff #define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.calling_convention @@ -8183,7 +8515,7 @@ index 643fa03..6381dcf 100644 #define TYPE_BASECLASS(thistype,index) TYPE_FIELD_TYPE(thistype, index) #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses #define TYPE_BASECLASS_NAME(thistype,index) TYPE_FIELD_NAME(thistype, index) -@@ -977,7 +1077,6 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -977,7 +1078,6 @@ extern void allocate_gnat_aux_type (struct type *); #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos) #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname) #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr) @@ -8191,7 +8523,7 @@ index 643fa03..6381dcf 100644 #define SET_FIELD_BITPOS(thisfld, bitpos) \ (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_BITPOS, \ FIELD_BITPOS (thisfld) = (bitpos)) -@@ -987,9 +1086,6 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -987,9 +1087,6 @@ extern void allocate_gnat_aux_type (struct type *); #define SET_FIELD_PHYSADDR(thisfld, addr) \ (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \ FIELD_STATIC_PHYSADDR (thisfld) = (addr)) @@ -8201,7 +8533,7 @@ index 643fa03..6381dcf 100644 #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial) #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize) -@@ -1000,7 +1096,6 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -1000,7 +1097,6 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n)) #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n)) #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n)) @@ -8209,7 +8541,7 @@ index 643fa03..6381dcf 100644 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n)) #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n)) #define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE(TYPE_FIELD(thistype,n))!=0) -@@ -1139,6 +1234,10 @@ struct builtin_type +@@ -1139,6 +1235,10 @@ struct builtin_type (*) () can server as a generic function pointer. */ struct type *builtin_func_ptr; @@ -8220,7 +8552,7 @@ index 643fa03..6381dcf 100644 /* Special-purpose types. */ -@@ -1179,6 +1278,7 @@ struct objfile_type +@@ -1179,6 +1279,7 @@ struct objfile_type /* Types used for symbols with no debug information. */ struct type *nodebug_text_symbol; @@ -8228,7 +8560,7 @@ index 643fa03..6381dcf 100644 struct type *nodebug_data_symbol; struct type *nodebug_unknown_symbol; struct type *nodebug_tls_symbol; -@@ -1333,6 +1433,18 @@ extern struct type *create_array_type (struct type *, struct type *, +@@ -1333,6 +1434,18 @@ extern struct type *create_array_type (struct type *, struct type *, struct type *); extern struct type *lookup_array_range_type (struct type *, int, int); @@ -8247,7 +8579,7 @@ index 643fa03..6381dcf 100644 extern struct type *create_string_type (struct type *, struct type *, struct type *); extern struct type *lookup_string_range_type (struct type *, int, int); -@@ -1375,6 +1487,8 @@ extern int is_public_ancestor (struct type *, struct type *); +@@ -1375,6 +1488,8 @@ extern int is_public_ancestor (struct type *, struct type *); extern int is_unique_ancestor (struct type *, struct value *); @@ -8256,7 +8588,7 @@ index 643fa03..6381dcf 100644 /* Overload resolution */ #define LENGTH_MATCH(bv) ((bv)->rank[0]) -@@ -1437,10 +1551,11 @@ extern void maintenance_print_type (char *, int); +@@ -1437,10 +1552,11 @@ extern void maintenance_print_type (char *, int); extern htab_t create_copied_types_hash (struct objfile *objfile); @@ -24773,6 +25105,242 @@ index 0000000..39632d5 + +# Failed gdb_load would abort the testcase execution earlier. +pass "file loaded" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S +new file mode 100644 +index 0000000..9353698 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S +@@ -0,0 +1,176 @@ ++/* 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 . */ ++ ++/* Debug information */ ++ ++/* We will `break *main' at the very first instruction. */ ++#define main_length 1 ++ ++ .section .data ++vardata: ++ /* See DW_OP_lit3 + 1 (0-based). */ ++ .string "seennotseen" ++ ++ .section .debug_info ++.Lcu1_begin: ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF version number */ ++ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte 4 /* Pointer Size (in bytes) */ ++ ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .4byte .Lproducer /* DW_AT_producer */ ++ /* Use C++ to exploit a bug in parsing DW_AT_name "". */ ++ .byte 4 /* DW_AT_language (C++) - */ ++ .4byte main /* DW_AT_low_pc */ ++ .byte main_length /* DW_AT_high_pc */ ++ ++.Larray_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */ ++ .byte 0 /* End of children of die */ ++ ++.Luint_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .4byte .Luint_str /* DW_AT_name */ ++ .byte 4 /* DW_AT_byte_size */ ++ .byte 7 /* DW_AT_encoding */ ++ ++.Lchar_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .4byte .Lchar_str /* DW_AT_name */ ++ .byte 1 /* DW_AT_byte_size */ ++ .byte 6 /* DW_AT_encoding */ ++ ++.Llen_var: ++ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */ ++ .byte 1 /* DW_AT_artificial */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */ ++ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "a_string" /* DW_AT_name */ ++ .4byte .Larray_type-.Lcu1_begin/* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ .byte 0 /* End of children of CU */ ++.Lcu1_end: ++ ++ .section .debug_loc ++.Lloclist: ++.Llen_loclist: ++ .4byte 0 # Location list begin address ++ .4byte main_length # Location list end address ++ .value 2f-1f # Location expression size ++1: .byte 0x33 # DW_OP_lit3 ++ .byte 0x9f # DW_OP_stack_value ++2: ++ .quad 0x0 # Location list terminator begin (*.LLST2) ++ .quad 0x0 # Location list terminator end (*.LLST2) ++ ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 0x1 /* has_children */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x1 /* TAG: DW_TAG_array_type */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x21 /* DW_TAG_subrange_type */ ++ .byte 0x0 /* no children */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x22 /* DW_AT_lower_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x2f /* DW_AT_upper_bound */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 4 /* Abbrev code */ ++ .uleb128 0x24 /* DW_TAG_base_type */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3e /* DW_AT_encoding */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 5 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0x0c /* DW_FORM_flag */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x02 /* DW_AT_location */ ++ .uleb128 0x06 /* DW_FORM_data4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 6 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ ++ ++/* String table */ ++ .section .debug_str ++.Lproducer: ++ .string "GNU C 3.3.3" ++.Lchar_str: ++ .string "char" ++.Luint_str: ++ .string "unsigned int" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp +new file mode 100644 +index 0000000..28db005 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp +@@ -0,0 +1,48 @@ ++# 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 . ++ ++# Test printing variable with dynamic bounds which reference a different ++# (artificial in the GCC case) variable containing loclist as its location. ++# This testcase uses value (not address) of the referenced variable: ++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762 ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile dw2-bound-loclist ++if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } { ++ return -1 ++} ++ ++# Verify it behaves at least as an unbound array without inferior. ++ ++gdb_test "p a_string" { = 0x[0-9a-f]+ "seennotseen"} ++gdb_test "ptype a_string" {type = char \[\]} ++ ++# Not runto_main as dw2-bound-loclist.S handles only the first byte of main. ++if ![runto "*main"] { ++ return -1 ++} ++ ++gdb_test "p a_string" { = "seen"} ++gdb_test "ptype a_string" {type = char \[4\]} diff --git a/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.S b/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.S new file mode 100644 index 0000000..7b03ff1 diff --git a/gdb-bz539590-gnu-ifunc-fix-cond.patch b/gdb-bz539590-gnu-ifunc-fix-cond.patch new file mode 100644 index 0000000..f6146c4 --- /dev/null +++ b/gdb-bz539590-gnu-ifunc-fix-cond.patch @@ -0,0 +1,14 @@ +--- ./gdb/breakpoint.c 2010-04-26 02:35:53.000000000 +0200 ++++ ./gdb/breakpoint.c 2010-04-26 02:33:26.000000000 +0200 +@@ -8499,6 +8499,11 @@ update_breakpoint_locations (struct brea + { + struct gdb_exception e; + ++ /* Temporary workaround before the non-intrusive ifunc patch gets in. ++ exp parsing can now call inferior function invalidating ++ EXISTING_LOCATIONS. */ ++ existing_locations = NULL; ++ + s = b->cond_string; + TRY_CATCH (e, RETURN_MASK_ERROR) + { diff --git a/gdb-bz570635-prettyprint-doc1.patch b/gdb-bz570635-prettyprint-doc1.patch new file mode 100644 index 0000000..ef63291 --- /dev/null +++ b/gdb-bz570635-prettyprint-doc1.patch @@ -0,0 +1,40 @@ +RFA: update `print' docs +http://sourceware.org/ml/gdb-patches/2010-03/msg00236.html +http://sourceware.org/ml/gdb-cvs/2010-03/msg00048.html + +### src/gdb/doc/ChangeLog 2010/03/01 17:19:22 1.1017 +### src/gdb/doc/ChangeLog 2010/03/05 20:01:21 1.1018 +## -1,3 +1,8 @@ ++2010-03-05 Tom Tromey ++ ++ * gdb.texinfo (Data): Link to pretty-printing. ++ (Output Formats): Likewise. Correct text. ++ + 2010-03-01 Daniel Jacobowitz + + * gdb.texinfo (Types): Describe and . +--- src/gdb/doc/gdb.texinfo 2010/03/01 17:19:22 1.676 ++++ src/gdb/doc/gdb.texinfo 2010/03/05 20:01:21 1.677 +@@ -6661,7 +6661,8 @@ + command (abbreviated @code{p}), or its synonym @code{inspect}. It + evaluates and prints the value of an expression of the language your + program is written in (@pxref{Languages, ,Using @value{GDBN} with +-Different Languages}). ++Different Languages}). It may also print the expression using a ++Python-based pretty-printer (@pxref{Pretty Printing}). + + @table @code + @item print @var{expr} +@@ -7159,8 +7160,10 @@ + @item r + @cindex raw printing + Print using the @samp{raw} formatting. By default, @value{GDBN} will +-use a type-specific pretty-printer. The @samp{r} format bypasses any +-pretty-printer which might exist for the value's type. ++use a Python-based pretty-printer, if one is available (@pxref{Pretty ++Printing}). This typically results in a higher-level display of the ++value's contents. The @samp{r} format bypasses any Python ++pretty-printer which might exist. + @end table + + For example, to print the program counter in hex (@pxref{Registers}), type diff --git a/gdb-bz570635-prettyprint-doc2.patch b/gdb-bz570635-prettyprint-doc2.patch new file mode 100644 index 0000000..41f7efc --- /dev/null +++ b/gdb-bz570635-prettyprint-doc2.patch @@ -0,0 +1,182 @@ +Re: [patch] doc-python: Pretty Printing split user / developer +http://sourceware.org/ml/gdb-patches/2010-04/msg00757.html +http://sourceware.org/ml/gdb-cvs/2010-04/msg00221.html + +[ Backported for Fedora. ] + +### src/gdb/doc/ChangeLog 2010/04/22 04:09:25 1.1053 +### src/gdb/doc/ChangeLog 2010/04/22 16:32:43 1.1054 +## -1,3 +1,14 @@ ++2010-04-22 Jan Kratochvil ++ ++ * gdb.texinfo (Data): New @menu reference to Pretty Printing. ++ (Python API): Change the reference to Pretty Printing API. ++ (Pretty Printing): Move the user part under the Data node. Reformat ++ the sample output to 72 columns. Create a new reference to Pretty ++ Printing API. Rename the API part ... ++ (Pretty Printing API): To a new node name. ++ (Selecting Pretty-Printers, Progspaces In Python, Objfiles In Python) ++ (GDB/MI Variable Objects): Change references to Pretty Printing API. ++ + 2010-04-21 Stan Shebs + + * gdb.texinfo (Tracepoint Actions): Mention synonymy of actions +--- gdb-7.1/gdb/doc/gdb.texinfo.orig 2010-04-22 19:08:30.000000000 +0200 ++++ gdb-7.1/gdb/doc/gdb.texinfo 2010-04-22 19:10:41.000000000 +0200 +@@ -6727,6 +6727,7 @@ Table}. + * Memory:: Examining memory + * Auto Display:: Automatic display + * Print Settings:: Print settings ++* Pretty Printing:: Python pretty printing + * Value History:: Value history + * Convenience Vars:: Convenience variables + * Registers:: Registers +@@ -7897,6 +7898,42 @@ Do not pretty print C@t{++} virtual func + Show whether C@t{++} virtual function tables are pretty printed, or not. + @end table + ++@node Pretty Printing ++@section Pretty Printing ++ ++@value{GDBN} provides a mechanism to allow pretty-printing of values using ++Python code. It greatly simplifies the display of complex objects. This ++mechanism works for both MI and the CLI. ++ ++For example, here is how a C@t{++} @code{std::string} looks without a ++pretty-printer: ++ ++@smallexample ++(@value{GDBP}) print s ++$1 = @{ ++ static npos = 4294967295, ++ _M_dataplus = @{ ++ > = @{ ++ <__gnu_cxx::new_allocator> = @{ ++ @}, ++ @}, ++ members of std::basic_string, ++ std::allocator >::_Alloc_hider: ++ _M_p = 0x804a014 "abcd" ++ @} ++@} ++@end smallexample ++ ++With a pretty-printer for @code{std::string} only the contents are printed: ++ ++@smallexample ++(@value{GDBP}) print s ++$2 = "abcd" ++@end smallexample ++ ++For implementing pretty printers for new types you should read the Python API ++details (@pxref{Pretty Printing API}). ++ + @node Value History + @section Value History + +@@ -19608,8 +19645,8 @@ situation, a Python @code{KeyboardInterr + * Exception Handling:: + * Auto-loading:: Automatically loading Python code. + * Values From Inferior:: Python representation of values. +-* Types In Python:: Python representation of types. +-* Pretty Printing:: Pretty-printing values. ++* Types In Python:: Python representation of types. ++* Pretty Printing API:: Pretty-printing values. + * Selecting Pretty-Printers:: How GDB chooses a pretty-printer. + * Inferiors In Python:: Python representation of inferiors (processes) + * Threads In Python:: Accessing inferior threads from Python. +@@ -20241,37 +20278,10 @@ A function internal to @value{GDBN}. Th + convenience functions. + @end table + +-@node Pretty Printing +-@subsubsection Pretty Printing +- +-@value{GDBN} provides a mechanism to allow pretty-printing of values +-using Python code. The pretty-printer API allows application-specific +-code to greatly simplify the display of complex objects. This +-mechanism works for both MI and the CLI. +- +-For example, here is how a C@t{++} @code{std::string} looks without a +-pretty-printer: ++@node Pretty Printing API ++@subsubsection Pretty Printing API + +-@smallexample +-(@value{GDBP}) print s +-$1 = @{ +- static npos = 4294967295, +- _M_dataplus = @{ +- > = @{ +- <__gnu_cxx::new_allocator> = @{@}, @}, +- members of std::basic_string, std::allocator >::_Alloc_hider: +- _M_p = 0x804a014 "abcd" +- @} +-@} +-@end smallexample +- +-After a pretty-printer for @code{std::string} has been installed, only +-the contents are printed: +- +-@smallexample +-(@value{GDBP}) print s +-$2 = "abcd" +-@end smallexample ++An example output is provided (@pxref{Pretty Printing}). + + A pretty-printer is just an object that holds a value and implements a + specific interface, defined here. +@@ -20359,7 +20369,7 @@ attribute. + + A function on one of these lists is passed a single @code{gdb.Value} + argument and should return a pretty-printer object conforming to the +-interface definition above (@pxref{Pretty Printing}). If a function ++interface definition above (@pxref{Pretty Printing API}). If a function + cannot create a pretty-printer for the value, it should return + @code{None}. + +@@ -20436,7 +20446,7 @@ printers with a specific objfile, @value + printers for the specific version of the library used by each + inferior. + +-To continue the @code{std::string} example (@pxref{Pretty Printing}), ++To continue the @code{std::string} example (@pxref{Pretty Printing API}), + this code might appear in @code{gdb.libstdcxx.v6}: + + @smallexample +@@ -21048,7 +21058,7 @@ The @code{pretty_printers} attribute is + used to look up pretty-printers. A @code{Value} is passed to each + function in order; if the function returns @code{None}, then the + search continues. Otherwise, the return value should be an object +-which is used to format the value. @xref{Pretty Printing}, for more ++which is used to format the value. @xref{Pretty Printing API}, for more + information. + @end defivar + +@@ -24875,7 +24885,7 @@ then this attribute will not be present. + @item displayhint + A dynamic varobj can supply a display hint to the front end. The + value comes directly from the Python pretty-printer object's +-@code{display_hint} method. @xref{Pretty Printing}. ++@code{display_hint} method. @xref{Pretty Printing API}. + @end table + + Typical output will look like this: +@@ -25047,7 +25057,7 @@ The result may have its own attributes: + @item displayhint + A dynamic varobj can supply a display hint to the front end. The + value comes directly from the Python pretty-printer object's +-@code{display_hint} method. @xref{Pretty Printing}. ++@code{display_hint} method. @xref{Pretty Printing API}. + + @item has_more + This is an integer attribute which is nonzero if there are children +@@ -25411,7 +25421,7 @@ single argument. @value{GDBN} will call + the varobj @var{name} as an argument (this is done so that the same + Python pretty-printing code can be used for both the CLI and MI). + When called, this object must return an object which conforms to the +-pretty-printing interface (@pxref{Pretty Printing}). ++pretty-printing interface (@pxref{Pretty Printing API}). + + The pre-defined function @code{gdb.default_visualizer} may be used to + select a visualizer by following the built-in process diff --git a/gdb-bz575292-delayed-physname.patch b/gdb-bz575292-delayed-physname.patch new file mode 100644 index 0000000..605bd3b --- /dev/null +++ b/gdb-bz575292-delayed-physname.patch @@ -0,0 +1,624 @@ +Made more safe (but less effective) by using a linked list. + +Based on: + Re: [RFA] Delayed physname computation + http://sourceware.org/ml/gdb-patches/2010-05/msg00248.html + +Neither its obstack-leak.patch nor + [patch] Fix duplicate types for single DIE + http://sourceware.org/ml/gdb-patches/2010-05/msg00271.html +is needed as the linked list is used instead. + +--- ./gdb/dwarf2read.c 2010-05-13 18:26:22.000000000 +0200 ++++ ./gdb/dwarf2read.c 2010-05-13 18:45:04.000000000 +0200 +@@ -251,6 +251,28 @@ struct comp_unit_head + unsigned int first_die_offset; + }; + ++/* Type used for delaying computation of method physnames. ++ See comments for compute_delayed_physnames. */ ++struct delayed_method_info ++{ ++ struct delayed_method_info *next; ++ ++ /* The type to which the method is attached, i.e., its parent class. */ ++ struct type *type; ++ ++ /* The index of the method in the type's function fieldlists. */ ++ int fnfield_index; ++ ++ /* The index of the method in the fieldlist. */ ++ int index; ++ ++ /* The name of the DIE. */ ++ const char *name; ++ ++ /* The DIE associated with this method. */ ++ struct die_info *die; ++}; ++ + /* Internal state when decoding a particular compilation unit. */ + struct dwarf2_cu + { +@@ -329,6 +351,10 @@ struct dwarf2_cu + /* Header data from the line table, during full symbol processing. */ + struct line_header *line_header; + ++ /* A list of methods which need to have physnames computed ++ after all type information has been read. */ ++ struct delayed_method_info *method_list; ++ + /* Mark used when releasing cached dies. */ + unsigned int mark : 1; + +@@ -1208,6 +1234,9 @@ static void destroy_section (struct dwar + static struct dwarf2_locexpr_baton *dwarf2_attr_to_locexpr_baton + (struct attribute *attr, struct dwarf2_cu *cu); + ++static const char *dwarf2_physname (char *name, struct die_info *die, ++ struct dwarf2_cu *cu); ++ + /* Try to locate the sections we need for DWARF 2 debugging + information and return true if we have enough to do something. */ + +@@ -3435,6 +3464,58 @@ load_full_comp_unit (struct dwarf2_per_c + discard_cleanups (free_cu_cleanup); + } + ++/* Add a DIE to the delayed physname list. */ ++static void ++add_to_method_list (struct type *type, int fnfield_index, int index, ++ const char *name, struct die_info *die, ++ struct dwarf2_cu *cu) ++{ ++ struct delayed_method_info *mi; ++ ++ mi = xmalloc (sizeof (*mi)); ++ mi->next = cu->method_list; ++ cu->method_list = mi; ++ mi->type = type; ++ mi->fnfield_index = fnfield_index; ++ mi->index = index; ++ mi->name = name; ++ mi->die = die; ++} ++ ++/* Compute the physnames of any methods on the CU's method list. ++ ++ The computation of method physnames is delayed in order to avoid the ++ (bad) condition that one of the method's formal parameters is of an as yet ++ incomplete type. */ ++static void ++compute_delayed_physnames (struct dwarf2_cu *cu) ++{ ++ struct delayed_method_info *mi; ++ ++ for (mi = cu->method_list; mi; mi = mi->next) ++ { ++ char *physname; ++ struct fn_fieldlist *fn_flp ++ = &TYPE_FN_FIELDLIST (mi->type, mi->fnfield_index); ++ physname = (char *) dwarf2_physname ((char *) mi->name, mi->die, cu); ++ fn_flp->fn_fields[mi->index].physname = physname ? physname : ""; ++ } ++} ++ ++static void ++method_list_cleanup (void *arg) ++{ ++ struct delayed_method_info **method_list_pointer = arg; ++ ++ while (*method_list_pointer) ++ { ++ struct delayed_method_info *mi = *method_list_pointer; ++ ++ *method_list_pointer = mi->next; ++ xfree (mi); ++ } ++} ++ + /* Generate full symbol information for PST and CU, whose DIEs have + already been loaded into memory. */ + +@@ -3447,7 +3528,7 @@ process_full_comp_unit (struct dwarf2_pe + bfd *abfd = objfile->obfd; + CORE_ADDR lowpc, highpc; + struct symtab *symtab; +- struct cleanup *back_to; ++ struct cleanup *back_to, *delayed_list_cleanup; + CORE_ADDR baseaddr; + + baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); +@@ -3457,11 +3538,22 @@ process_full_comp_unit (struct dwarf2_pe + + cu->list_in_scope = &file_symbols; + ++ /* If methods were found in the partial symbol table, we allocate one ++ big buffer to hold the entire delayed list for the CU. */ ++ delayed_list_cleanup = make_cleanup (method_list_cleanup, ++ &cu->method_list); ++ + dwarf2_find_base_address (cu->dies, cu); + + /* Do line number decoding in read_file_scope () */ + process_die (cu->dies, cu); + ++ /* Now that we have processed all the DIEs in the CU, all the types ++ should be complete, and it should now be safe to compute all of the ++ physnames. */ ++ compute_delayed_physnames (cu); ++ do_cleanups (delayed_list_cleanup); ++ + /* Some compilers don't define a DW_AT_high_pc attribute for the + compilation unit. If the DW_AT_high_pc is missing, synthesize + it, by scanning the DIE's below the compilation unit. */ +@@ -5093,7 +5185,6 @@ dwarf2_add_member_fn (struct field_info + int i; + struct fn_field *fnp; + char *fieldname; +- char *physname; + struct nextfnfield *new_fnfield; + struct type *this_type; + +@@ -5105,9 +5196,6 @@ dwarf2_add_member_fn (struct field_info + if (fieldname == NULL) + return; + +- /* Get the mangled name. */ +- physname = (char *) dwarf2_physname (fieldname, die, cu); +- + /* Look up member function name in fieldlist. */ + for (i = 0; i < fip->nfnfields; i++) + { +@@ -5133,7 +5221,7 @@ dwarf2_add_member_fn (struct field_info + flp->name = fieldname; + flp->length = 0; + flp->head = NULL; +- fip->nfnfields++; ++ i = fip->nfnfields++; + } + + /* Create a new member function field and chain it to the field list +@@ -5147,9 +5235,19 @@ dwarf2_add_member_fn (struct field_info + + /* Fill in the member function field info. */ + fnp = &new_fnfield->fnfield; +- /* The name is already allocated along with this objfile, so we don't +- need to duplicate it for the type. */ +- fnp->physname = physname ? physname : ""; ++ ++ /* Delay processing of the physname until later. */ ++ if (cu->language == language_cplus || cu->language == language_java) ++ { ++ add_to_method_list (type, i, flp->length - 1, fieldname, ++ die, cu); ++ } ++ else ++ { ++ char *physname = (char *) dwarf2_physname (fieldname, die, cu); ++ fnp->physname = physname ? physname : ""; ++ } ++ + fnp->type = alloc_type (objfile); + this_type = read_type_die (die, cu); + if (this_type && TYPE_CODE (this_type) == TYPE_CODE_FUNC) +@@ -5175,7 +5273,7 @@ dwarf2_add_member_fn (struct field_info + } + else + complaint (&symfile_complaints, _("member function type missing for '%s'"), +- physname); ++ dwarf2_full_name (fieldname, die, cu)); + + /* Get fcontext from DW_AT_containing_type if present. */ + if (dwarf2_attr (die, DW_AT_containing_type, cu) != NULL) +@@ -7500,7 +7598,9 @@ load_partial_dies (bfd *abfd, gdb_byte * + || last_die->tag == DW_TAG_interface_type + || last_die->tag == DW_TAG_structure_type + || last_die->tag == DW_TAG_union_type)) +- || (cu->language == language_ada ++ || ((cu->language == language_ada ++ || cu->language == language_cplus ++ || cu->language == language_java) + && (last_die->tag == DW_TAG_subprogram + || last_die->tag == DW_TAG_lexical_block)))) + { +--- ./gdb/testsuite/gdb.dwarf2/pr11465.S 1970-01-01 01:00:00.000000000 +0100 ++++ ./gdb/testsuite/gdb.dwarf2/pr11465.S 2010-05-13 18:39:00.000000000 +0200 +@@ -0,0 +1,355 @@ ++/* 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 . */ ++ ++/* Compiled from: ++ ++ namespace N ++ { ++ class C ++ { ++ public: ++ typedef void (*t) (C); ++ C (t) {} ++ }; ++ typedef C::t u; ++ u f; ++ C c (f); ++ }; ++ ++ int ++ main () ++ { ++ return 0; ++ } ++*/ ++ ++ .text ++_ZN1N1cE: ++ .section .debug_info ++d: ++ .long .Ldebug_info_end - 1f /* Length of CU info */ ++1: ++ .2byte 0x2 /* DWARF version number */ ++ .long .Ldebug_abbrev0 /* Abbrev offset */ ++ .byte 0x4 /* Pointer size */ ++dieb: .uleb128 0x1 /* DW_TAG_compile_unit */ ++ .long .LASF4 /* DW_AT_producer */ ++ .byte 0x4 /* DW_AT_language */ ++ .long .LASF5 /* DW_AT_name */ ++ .long .LASF6 /* DW_AT_comp_dir */ ++ .long 0x0 /* DW_AT_low_pc */ ++ .long 0x0 /* DW_AT_high_pc */ ++ .long 0x0 /* DW_AT_entry_pc */ ++die29: .uleb128 0x2 /* DW_TAG_namespace */ ++ .string "N" /* DW_AT_name */ ++die32: .uleb128 0x3 /* DW_TAG_class_type */ ++ .string "C" /* DW_AT_name */ ++ .byte 0x1 /* DW_AT_declaration */ ++die36: .uleb128 0x4 /* DW_TAG_typedef */ ++ .string "u" /* DW_AT_name */ ++ .long die7e-d /* DW_AT_type */ ++die3f: .uleb128 0x5 /* DW_TAG_variable */ ++ .string "f" /* DW_AT_name */ ++ .long .LASF0 /* DW_AT_MIPS_linkage_name */ ++ .long die36-d /* DW_AT_type */ ++ .byte 0x1 /* DW_AT_external */ ++ .byte 0x1 /* DW_AT_declaration */ ++die4e: .uleb128 0x5 /* DW_TAG_variable */ ++ .string "c" /* DW_AT_name */ ++ .long .LASF1 /* DW_AT_MIPS_linkage_name */ ++ .long die5e-d /* DW_AT_type */ ++ .byte 0x1 /* DW_AT_external */ ++ .byte 0x1 /* DW_AT_declaration */ ++ .byte 0x0 ++die5e: .uleb128 0x6 /* DW_TAG_class_type */ ++ .long die32-d /* DW_AT_specification */ ++ .byte 0x1 /* DW_AT_byte_size */ ++die6a: .uleb128 0x7 /* DW_TAG_subprogram */ ++ .byte 0x1 /* DW_AT_external */ ++ .string "C" /* DW_AT_name */ ++ .byte 0x1 /* DW_AT_declaration */ ++die71: .uleb128 0x8 /* DW_TAG_formal_parameter */ ++ .long die8f-d /* DW_AT_type */ ++ .byte 0x1 /* DW_AT_artificial */ ++die77: .uleb128 0x9 /* DW_TAG_formal_parameter */ ++ .long die7e-d /* DW_AT_type */ ++ .byte 0x0 ++ .byte 0x0 ++die7e: .uleb128 0xa /* DW_TAG_pointer_type */ ++ .byte 0x4 /* DW_AT_byte_size */ ++ .long die84-d /* DW_AT_type */ ++die84: .uleb128 0xb /* DW_TAG_subroutine_type */ ++die89: .uleb128 0x9 /* DW_TAG_formal_parameter */ ++ .long die5e-d /* DW_AT_type */ ++ .byte 0x0 ++die8f: .uleb128 0xa /* DW_TAG_pointer_type */ ++ .byte 0x4 /* DW_AT_byte_size */ ++ .long die5e-d /* DW_AT_type */ ++die95: .uleb128 0xc /* DW_TAG_subprogram */ ++ .long die6a-d /* DW_AT_specification */ ++ .byte 0x2 /* DW_AT_inline */ ++die9f: .uleb128 0xd /* DW_TAG_formal_parameter */ ++ .long .LASF7 /* DW_AT_name */ ++ .long dieaf-d /* DW_AT_type */ ++ .byte 0x1 /* DW_AT_artificial */ ++diea9: .uleb128 0x9 /* DW_TAG_formal_parameter */ ++ .long die7e-d /* DW_AT_type */ ++ .byte 0x0 ++dieaf: .uleb128 0xe /* DW_TAG_const_type */ ++ .long die8f-d /* DW_AT_type */ ++dieb4: .uleb128 0xf /* DW_TAG_subprogram */ ++ .long die95-d /* DW_AT_abstract_origin */ ++ .long _ZN1N1cE /* DW_AT_low_pc */ ++ .long _ZN1N1cE /* DW_AT_high_pc */ ++diec9: .uleb128 0x10 /* DW_TAG_subprogram */ ++ .long die9f-d /* DW_AT_abstract_origin */ ++ .byte 2f-1f /* DW_AT_location */ ++1: ++ .byte 0x50 /* DW_OP_reg0 */ ++2: ++died1: .uleb128 0x10 /* DW_TAG_formal_parameter */ ++ .long diea9-d /* DW_AT_abstract_origin */ ++ .byte 2f-1f /* DW_AT_location */ ++1: ++ .byte 0x51 /* DW_OP_reg1 */ ++2: ++ .byte 0x0 ++dieda: .uleb128 0x11 /* DW_TAG_subprogram */ ++ .byte 0x1 /* DW_AT_external */ ++ .long .LASF8 /* DW_AT_name */ ++ .long dief2-d /* DW_AT_type */ ++ .long _ZN1N1cE /* DW_AT_low_pc */ ++ .long _ZN1N1cE /* DW_AT_high_pc */ ++dief2: .uleb128 0x12 /* DW_TAG_base_type */ ++ .byte 0x4 /* DW_AT_byte_size */ ++ .byte 0x5 /* DW_AT_encoding */ ++ .string "int" /* DW_AT_name */ ++die149: .uleb128 0x16 /* DW_TAG_variable */ ++ .long die4e-d /* DW_AT_specification */ ++ .byte 0x5 /* DW_AT_location */ ++ .byte 0x3 ++ .long _ZN1N1cE ++ .byte 0x0 ++.Ldebug_info_end: ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ .uleb128 0x1 /* abbrev code*/ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x25 /* DW_AT_producer*/ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x1b /* DW_AT_comp_dir */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x52 /* DW_AT_entry_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 /* abbrev code */ ++ .uleb128 0x39 /* DW_TAG_namespace */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 /* abbrev code */ ++ .uleb128 0x2 /* DW_TAG_class_type */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x3c /* DW_AT_declaration */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 /* abbrev code */ ++ .uleb128 0x16 /* DW_TAG_typedef */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 /* abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x2007 /* DW_AT_MIPS_linkage_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x49 /* DW_AT_TYPE */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x3f /* DW_AT_external */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .uleb128 0x3c /* DW_AT_declaration */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 /* abbrev code */ ++ .uleb128 0x2 /* DW_TAG_class_type */ ++ .byte 0x1 /* DW_has_children_yes */ ++ .uleb128 0x47 /* DW_AT_specification */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 /* abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogra */ ++ .byte 0x1 /* DW_has_children_yes */ ++ .uleb128 0x3f /* DW_AT_external */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x3c /* DW_AT_declaration */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x8 /* abbrev code */ ++ .uleb128 0x5 /* DW_TAG_formal_parameter */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 /* abbrev code */ ++ .uleb128 0x5 /* DW_TAG_formal_parameter */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xa /* abbrev code */ ++ .uleb128 0xf /* DW_TAG_pointer_type */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xb /* abbrev code */ ++ .uleb128 0x15 /* DW_TAG_subroutine_type */ ++ .byte 0x1 /* DW_has_children_yes */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xc /* abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogram */ ++ .byte 0x1 /* DW_has_children_yes */ ++ .uleb128 0x47 /* DW_AT_specification */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x20 /* DW_AT_inline */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xd /* abbrev code */ ++ .uleb128 0x5 /* DW_TAG_formal_parameter */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xe /* abbrev code */ ++ .uleb128 0x26 /* DW_TAG_const_type */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xf /* abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogram */ ++ .byte 0x1 /* DW_has_children_yes */ ++ .uleb128 0x31 /* DW_AT_abstract_origin */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x10 /* abbrev code */ ++ .uleb128 0x5 /* DW_TAG_formal_parameter */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x31 /* DW_AT_abstract_origin */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x11 /* abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogram */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x3f /* DW_AT_external */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x12 /* abbrev code */ ++ .uleb128 0x24 /* DW_TAG_base_type */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3e /* DW_AT_encoding */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x16 /* abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x47 /* DW_AT_specification */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_str ++.LASF0: ++ .string "_ZN1N1fE" ++.LASF7: ++ .string "this" ++.LASF6: ++ .string "" ++.LASF8: ++ .string "main" ++.LASF1: ++ .string "_ZN1N1cE" ++.LASF5: ++ .string "pr11465.cc" ++.LASF4: ++ .string "GNU C++ 4.4.2" ++ .ident "GCC: (GNU) 4.4.2" +--- ./gdb/testsuite/gdb.dwarf2/pr11465.exp 1970-01-01 01:00:00.000000000 +0100 ++++ ./gdb/testsuite/gdb.dwarf2/pr11465.exp 2010-05-13 18:39:00.000000000 +0200 +@@ -0,0 +1,39 @@ ++# 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 . ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile "pr11465" ++set srcfile ${testfile}.S ++set executable ${testfile}.x ++set binfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { ++ return -1 ++} ++ ++clean_restart $executable ++ ++# Test delayed physname computations ++gdb_test "p N::c.C" { = {void \(N::C \*, void \(\*\)\(N::C\)\)}.*} diff --git a/gdb-bz575292-void-workaround.patch b/gdb-bz575292-void-workaround.patch new file mode 100644 index 0000000..0e6f2e8 --- /dev/null +++ b/gdb-bz575292-void-workaround.patch @@ -0,0 +1,187 @@ +http://sourceware.org/ml/gdb-patches/2010-03/msg01039.html +Subject: [patch] Fix crash on NULL function's TYPE_FIELD_TYPE + +Hi, + +seen one possibility of a crash. + +#0 c_print_type (type=0x0, ...) +#1 in c_type_print_args (type=0xfceb890, + +(The real reason of a reported GDB crash was different, though.) + + +Thanks, +Jan + + +gdb/ +2010-03-30 Jan Kratochvil + + Fix crash on reading wrong function declaration DWARF. + * dwarf2read.c (read_subroutine_type): New variable void_type. + Pre-fill all TYPE_FIELD_TYPEs. Move nparams and iparams initialization + more close to their use. + +gdb/testsuite/ +2010-03-30 Jan Kratochvil + + * gdb.dwarf2/dw2-bad-parameter-type.exp, + gdb.dwarf2/dw2-bad-parameter-type.S: New. + +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -5938,13 +5938,14 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) + + if (die->child != NULL) + { ++ struct type *void_type = objfile_type (cu->objfile)->builtin_void; + struct die_info *child_die; +- int nparams = 0; +- int iparams = 0; ++ int nparams, iparams; + + /* Count the number of parameters. + FIXME: GDB currently ignores vararg functions, but knows about + vararg member functions. */ ++ nparams = 0; + child_die = die->child; + while (child_die && child_die->tag) + { +@@ -5960,6 +5961,12 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) + TYPE_FIELDS (ftype) = (struct field *) + TYPE_ZALLOC (ftype, nparams * sizeof (struct field)); + ++ /* TYPE_FIELD_TYPE must never be NULL. Pre-fill the array to ensure it ++ even if we error out during the parameters reading below. */ ++ for (iparams = 0; iparams < nparams; iparams++) ++ TYPE_FIELD_TYPE (ftype, iparams) = void_type; ++ ++ iparams = 0; + child_die = die->child; + while (child_die && child_die->tag) + { +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-parameter-type.S +@@ -0,0 +1,73 @@ ++/* 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 . */ ++ ++ .section .debug_info ++debug_start: ++ .long debug_end - 1f /* Length of Compilation Unit Info */ ++1: ++ .2byte 0x3 /* DWARF version number */ ++ .long .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte 0x4 /* Pointer Size (in bytes) */ ++ .uleb128 0x1 /* (DIE (0xb) DW_TAG_compile_unit) */ ++ .ascii "GNU C 4.4.3\0" /* DW_AT_producer */ ++ .byte 0x1 /* DW_AT_language */ ++ .ascii "1.c\0" /* DW_AT_name */ ++ .uleb128 0x4 /* (DIE (0x3c) DW_TAG_subprogram) */ ++ .ascii "f\0" /* DW_AT_name */ ++/* Value 0 would require has_section_at_zero != 0 (which is true, though). */ ++ .long 1 /* DW_AT_low_pc */ ++ .long 2 /* DW_AT_high_pc */ ++ .byte 0x1 /* DW_AT_prototyped */ ++ .uleb128 0x5 /* (DIE (0x42) DW_TAG_formal_parameter) */ ++/* Invalid value. */ ++ .long 0x0 /* DW_AT_type */ ++ .byte 0x0 /* end of children of DIE 0x3c */ ++ .byte 0x0 /* end of children of DIE 0xb */ ++debug_end: ++ ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ .uleb128 0x1 /* (abbrev code) */ ++ .uleb128 0x11 /* (TAG: DW_TAG_compile_unit) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x25 /* (DW_AT_producer) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x13 /* (DW_AT_language) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 /* (abbrev code) */ ++ .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x11 /* (DW_AT_low_pc) */ ++ .uleb128 0x1 /* (DW_FORM_addr) */ ++ .uleb128 0x12 /* (DW_AT_high_pc) */ ++ .uleb128 0x1 /* (DW_FORM_addr) */ ++ .uleb128 0x27 /* (DW_AT_prototyped) */ ++ .uleb128 0xc /* (DW_FORM_flag) */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 /* (abbrev code) */ ++ .uleb128 0x5 /* (TAG: DW_TAG_formal_parameter) */ ++ .byte 0x0 /* DW_children_no */ ++ .uleb128 0x49 /* (DW_AT_type) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-parameter-type.exp +@@ -0,0 +1,44 @@ ++# 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 . ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile "dw2-bad-parameter-type" ++set srcfile ${testfile}.S ++set executable ${testfile}.x ++set binfile ${objdir}/${subdir}/${executable} ++ ++# First try referencing DW_AT_frame_base which is not defined. ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { ++ return -1 ++} ++ ++clean_restart $executable ++ ++# The first access (as we do not use -readnow) prints some: ++# Dwarf Error: Cannot find DIE at 0x0 referenced from DIE at 0x29 [in module ...] ++gdb_test "ptype f" ++ ++gdb_test "ptype f" ++gdb_test "p 5" " = 5" "is alive" + diff --git a/gdb-moribund-utrace-workaround.patch b/gdb-moribund-utrace-workaround.patch new file mode 100644 index 0000000..f5a38dc --- /dev/null +++ b/gdb-moribund-utrace-workaround.patch @@ -0,0 +1,16 @@ +https://bugzilla.redhat.com/show_bug.cgi?id=590623 +http://sources.redhat.com/bugzilla/show_bug.cgi?id=11593 + +Bug in FSF GDB exploited by the ptrace-on-utrace interaction. + +--- a/gdb/breakpoint.c ++++ b/gdb/breakpoint.c +@@ -9084,6 +9084,8 @@ update_global_location_list (int should_insert) + traps we can no longer explain. */ + + old_loc->events_till_retirement = 3 * (thread_count () + 1); ++ /* Red Hat Bug 590623. */ ++ old_loc->events_till_retirement *= 10; + old_loc->owner = NULL; + + VEC_safe_push (bp_location_p, moribund_locations, old_loc); diff --git a/gdb-unwind-debughook-safe-fail.patch b/gdb-unwind-debughook-safe-fail.patch new file mode 100644 index 0000000..aa2af19 --- /dev/null +++ b/gdb-unwind-debughook-safe-fail.patch @@ -0,0 +1,46 @@ +commit 802214c97d1661ad337aad0d011dded44f0b5ddd +Author: Tom Tromey +Date: Mon Apr 26 15:15:55 2010 -0600 + + Fail gracefully if the _Unwind_DebugHook argument is optimized out + +diff --git a/gdb/infrun.c b/gdb/infrun.c +index 2eea550..9a5b534 100644 +--- a/gdb/infrun.c ++++ b/gdb/infrun.c +@@ -4925,20 +4925,24 @@ insert_exception_resume_breakpoint (struct thread_info *tp, + + vsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), b, VAR_DOMAIN, NULL); + value = read_var_value (vsym, frame); +- handler = value_as_address (value); ++ /* If the value was optimized out, revert to the old behavior. */ ++ if (! value_optimized_out (value)) ++ { ++ handler = value_as_address (value); + +- /* We're going to replace the current step-resume breakpoint +- with an exception-resume breakpoint. */ +- delete_step_resume_breakpoint (tp); ++ /* We're going to replace the current step-resume breakpoint ++ with an exception-resume breakpoint. */ ++ delete_step_resume_breakpoint (tp); + +- if (debug_infrun) +- fprintf_unfiltered (gdb_stdlog, +- "infrun: exception resume at %lx\n", +- (unsigned long) handler); ++ if (debug_infrun) ++ fprintf_unfiltered (gdb_stdlog, ++ "infrun: exception resume at %lx\n", ++ (unsigned long) handler); + +- bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame), +- handler, bp_exception_resume); +- inferior_thread ()->step_resume_breakpoint = bp; ++ bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame), ++ handler, bp_exception_resume); ++ inferior_thread ()->step_resume_breakpoint = bp; ++ } + } + } + diff --git a/gdb-unwind-debughook-step-independent.patch b/gdb-unwind-debughook-step-independent.patch new file mode 100644 index 0000000..46d6c7c --- /dev/null +++ b/gdb-unwind-debughook-step-independent.patch @@ -0,0 +1,235 @@ +commit f8ca03e0097ae49c66cf33a50e3247bccd3a4a33 +Author: Tom Tromey +Date: Wed Apr 28 14:17:38 2010 -0600 + + Reimplement infrun parts of next-over-throw. + Previously, we reset the step-resume breakpoint. + However, this can do the wrong thing if an exception + is thrown and caught beneath the nexting frame. + The new approach is to have a separate exception-resume + breakpoint. + +diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h +index 611dcbb..9638368 100644 +--- a/gdb/gdbthread.h ++++ b/gdb/gdbthread.h +@@ -66,6 +66,9 @@ struct thread_info + /* Step-resume or longjmp-resume breakpoint. */ + struct breakpoint *step_resume_breakpoint; + ++ /* Exception-resume breakpoint. */ ++ struct breakpoint *exception_resume_breakpoint; ++ + /* Range to single step within. + + If this is nonzero, respond to a single-step signal by continuing +@@ -225,6 +228,9 @@ extern void delete_thread_silent (ptid_t); + /* Delete a step_resume_breakpoint from the thread database. */ + extern void delete_step_resume_breakpoint (struct thread_info *); + ++/* Delete an exception_resume_breakpoint from the thread database. */ ++extern void delete_exception_resume_breakpoint (struct thread_info *); ++ + /* Translate the integer thread id (GDB's homegrown id, not the system's) + into a "pid" (which may be overloaded with extra thread information). */ + extern ptid_t thread_id_to_pid (int); +diff --git a/gdb/infrun.c b/gdb/infrun.c +index 9a5b534..3546cf1 100644 +--- a/gdb/infrun.c ++++ b/gdb/infrun.c +@@ -300,6 +300,7 @@ follow_fork (void) + parent thread structure's run control related fields, not just these. + Initialized to avoid "may be used uninitialized" warnings from gcc. */ + struct breakpoint *step_resume_breakpoint = NULL; ++ struct breakpoint *exception_resume_breakpoint = NULL; + CORE_ADDR step_range_start = 0; + CORE_ADDR step_range_end = 0; + struct frame_id step_frame_id = { 0 }; +@@ -352,6 +353,8 @@ follow_fork (void) + step_range_start = tp->step_range_start; + step_range_end = tp->step_range_end; + step_frame_id = tp->step_frame_id; ++ exception_resume_breakpoint ++ = clone_momentary_breakpoint (tp->exception_resume_breakpoint); + + /* For now, delete the parent's sr breakpoint, otherwise, + parent/child sr breakpoints are considered duplicates, +@@ -362,6 +365,7 @@ follow_fork (void) + tp->step_range_start = 0; + tp->step_range_end = 0; + tp->step_frame_id = null_frame_id; ++ delete_exception_resume_breakpoint (tp); + } + + parent = inferior_ptid; +@@ -403,6 +407,8 @@ follow_fork (void) + tp->step_range_start = step_range_start; + tp->step_range_end = step_range_end; + tp->step_frame_id = step_frame_id; ++ tp->exception_resume_breakpoint ++ = exception_resume_breakpoint; + } + else + { +@@ -456,6 +462,9 @@ follow_inferior_reset_breakpoints (void) + if (tp->step_resume_breakpoint) + breakpoint_re_set_thread (tp->step_resume_breakpoint); + ++ if (tp->exception_resume_breakpoint) ++ breakpoint_re_set_thread (tp->exception_resume_breakpoint); ++ + /* Reinsert all breakpoints in the child. The user may have set + breakpoints after catching the fork, in which case those + were never set in the child, but only in the parent. This makes +@@ -694,6 +703,7 @@ follow_exec (ptid_t pid, char *execd_pathname) + /* If there was one, it's gone now. We cannot truly step-to-next + statement through an exec(). */ + th->step_resume_breakpoint = NULL; ++ th->exception_resume_breakpoint = NULL; + th->step_range_start = 0; + th->step_range_end = 0; + +@@ -2145,6 +2155,7 @@ delete_step_resume_breakpoint_callback (struct thread_info *info, void *data) + return 0; + + delete_step_resume_breakpoint (info); ++ delete_exception_resume_breakpoint (info); + return 0; + } + +@@ -2168,6 +2179,7 @@ delete_step_thread_step_resume_breakpoint (void) + stepping. */ + struct thread_info *tp = inferior_thread (); + delete_step_resume_breakpoint (tp); ++ delete_exception_resume_breakpoint (tp); + } + else + /* In all-stop mode, delete all step-resume and longjmp-resume +@@ -3832,30 +3844,31 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); + fprintf_unfiltered (gdb_stdlog, + "infrun: BPSTAT_WHAT_CLEAR_LONGJMP_RESUME\n"); + +- gdb_assert (ecs->event_thread->step_resume_breakpoint != NULL); +- delete_step_resume_breakpoint (ecs->event_thread); +- +- if (!what.is_longjmp) ++ if (what.is_longjmp) ++ { ++ gdb_assert (ecs->event_thread->step_resume_breakpoint != NULL); ++ delete_step_resume_breakpoint (ecs->event_thread); ++ } ++ else + { + /* There are several cases to consider. +- ++ + 1. The initiating frame no longer exists. In this case + we must stop, because the exception has gone too far. +- ++ + 2. The initiating frame exists, and is the same as the +- current frame. +- +- 2.1. If we are stepping, defer to the stepping logic. +- +- 2.2. Otherwise, we are not stepping, so we are doing a +- "finish" and we have reached the calling frame. So, +- stop. +- ++ current frame. We stop, because the exception has been ++ caught. ++ + 3. The initiating frame exists and is different from + the current frame. This means the exception has been + caught beneath the initiating frame, so keep going. */ + struct frame_info *init_frame + = frame_find_by_id (ecs->event_thread->initiating_frame); ++ ++ gdb_assert (ecs->event_thread->exception_resume_breakpoint != NULL); ++ delete_exception_resume_breakpoint (ecs->event_thread); ++ + if (init_frame) + { + struct frame_id current_id +@@ -3863,15 +3876,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); + if (frame_id_eq (current_id, + ecs->event_thread->initiating_frame)) + { +- if (ecs->event_thread->step_range_start) +- { +- /* Case 2.1. */ +- break; +- } +- else +- { +- /* Case 2.2: fall through. */ +- } ++ /* Case 2. Fall through. */ + } + else + { +@@ -3880,6 +3885,10 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); + return; + } + } ++ ++ /* For Cases 1 and 2, remove the step-resume breakpoint, ++ if it exists. */ ++ delete_step_resume_breakpoint (ecs->event_thread); + } + + ecs->event_thread->stop_step = 1; +@@ -4930,10 +4939,6 @@ insert_exception_resume_breakpoint (struct thread_info *tp, + { + handler = value_as_address (value); + +- /* We're going to replace the current step-resume breakpoint +- with an exception-resume breakpoint. */ +- delete_step_resume_breakpoint (tp); +- + if (debug_infrun) + fprintf_unfiltered (gdb_stdlog, + "infrun: exception resume at %lx\n", +@@ -4941,7 +4946,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp, + + bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame), + handler, bp_exception_resume); +- inferior_thread ()->step_resume_breakpoint = bp; ++ inferior_thread ()->exception_resume_breakpoint = bp; + } + } + } +diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp +index ee9aeff..c77dbd8 100644 +--- a/gdb/testsuite/gdb.cp/gdb9593.exp ++++ b/gdb/testsuite/gdb.cp/gdb9593.exp +@@ -145,7 +145,7 @@ gdb_test "step" \ + "step into finish, for until" + + gdb_test "until" \ +- ".*catch .int x.*" \ ++ ".*function1 ().*" \ + "until with no argument 1" + + set line [gdb_get_line_number "marker for until" $testfile.cc] +diff --git a/gdb/thread.c b/gdb/thread.c +index 16a207c..3c52ae4 100644 +--- a/gdb/thread.c ++++ b/gdb/thread.c +@@ -90,6 +90,16 @@ delete_step_resume_breakpoint (struct thread_info *tp) + } + } + ++void ++delete_exception_resume_breakpoint (struct thread_info *tp) ++{ ++ if (tp && tp->exception_resume_breakpoint) ++ { ++ delete_breakpoint (tp->exception_resume_breakpoint); ++ tp->exception_resume_breakpoint = NULL; ++ } ++} ++ + static void + clear_thread_inferior_resources (struct thread_info *tp) + { diff --git a/gdb-upstream.patch b/gdb-upstream.patch index b51b8a4..5d3dc67 100644 --- a/gdb-upstream.patch +++ b/gdb-upstream.patch @@ -801,3 +801,24 @@ http://sourceware.org/ml/gdb-cvs/2010-04/msg00029.html + +gdb_breakpoint "main" +gdb_continue_to_breakpoint "main" "main.*" + + + +https://bugzilla.redhat.com/show_bug.cgi?id=590648 +Re: [rfc] Work around invalid G++ DWARF for unnamed aggregates +http://sourceware.org/ml/gdb-patches/2010-03/msg00909.html +commit 5e40af195bd74a66d300d8f481cab1f2ba533f3a + +[ cut only a part of it ] + +--- a/gdb/completer.c ++++ b/gdb/completer.c +@@ -401,7 +401,7 @@ add_struct_fields (struct type *type, int *nextp, char **output, + computed_type_name = 1; + } + /* Omit constructors from the completion list. */ +- if (type_name && strcmp (type_name, name)) ++ if (!type_name || strcmp (type_name, name)) + { + output[*nextp] = xstrdup (name); + ++*nextp; diff --git a/gdb.changes b/gdb.changes index 80d425b..656b50b 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri May 21 12:17:19 UTC 2010 - rguenther@novell.com + +- Merge from gdb-7.1-20.fc13.src.rpm. + ------------------------------------------------------------------- Thu Apr 22 19:13:48 UTC 2010 - aj@suse.de diff --git a/gdb.spec b/gdb.spec index 5115bf3..3531dbf 100644 --- a/gdb.spec +++ b/gdb.spec @@ -24,7 +24,7 @@ Name: gdb # NOTE: the FSF gdb versions are numbered N.M for official releases, like 6.3 # and, since January 2005, X.Y.Z.date for daily snapshots, like 6.3.50.20050112 # (daily snapshot from mailine), or 6.3.0.20040112 (head of the release branch). Version: 7.1 -Release: 2 +Release: 3 # 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. @@ -433,8 +433,35 @@ Patch447: gdb-bz578250-avx-09of10.patch Patch448: gdb-bz578250-avx-10of10.patch Patch449: gdb-bz578250-avx-10of10-ppc.patch +# Fix crash on C++ types in some debug info files (BZ 575292, Keith Seitz). +# Temporarily workaround the crash of BZ 575292 as there was now BZ 585445. +# Re-enable the BZ 575292 and BZ 585445 C++ fix using an updated patch. +Patch451: gdb-bz575292-delayed-physname.patch +Patch455: gdb-bz575292-void-workaround.patch + +# Pretty printers not well documented (BZ 570635, Tom Tromey, Jan Kratochvil). +Patch452: gdb-bz570635-prettyprint-doc1.patch +Patch453: gdb-bz570635-prettyprint-doc2.patch + +# Fix crash when using GNU IFUNC call from breakpoint condition. +Patch454: gdb-bz539590-gnu-ifunc-fix-cond.patch + +# Fail gracefully if the _Unwind_DebugHook arg. is optimized out (Tom Tromey). +# Make _Unwind_DebugHook independent from step-resume breakpoint (Tom Tromey). +Patch456: gdb-unwind-debughook-safe-fail.patch +Patch457: gdb-unwind-debughook-step-independent.patch + +# testsuite: Fix gdb.base/vla-overflow.exp FAILing on s390x (BZ 590635). +Patch458: gdb-archer-vla-test-oom.patch + +# Workaround non-stop moribund locations exploited by kernel utrace (BZ 590623). +Patch459: gdb-moribund-utrace-workaround.patch + +# Fix crash on VLA bound referencing an optimized-out variable (BZ 591879). +Patch460: gdb-archer-vla-ref-optimizedout.patch + # Upstream patch to fix gcc -Werror -Patch500: gdb-7.1-werror.patch +Patch1001: gdb-7.1-werror.patch # Fix readline 5.1 warnings Patch1000: readline-5.1-random.patch @@ -664,9 +691,19 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch447 -p1 %patch448 -p1 %patch449 -p1 -%patch500 -p0 +%patch451 -p1 +%patch452 -p1 +%patch453 -p1 +%patch454 -p1 +%patch455 -p1 +%patch456 -p1 +%patch457 -p1 +%patch458 -p1 +%patch459 -p1 +%patch460 -p1 %patch1000 +%patch1001 -p0 %patch1002 -p1 find -name "*.orig" | xargs rm -f