binutils-gdb.git
9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 24 Dec 2014 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoClarify strip docs.
Andrew Stubbs [Tue, 23 Dec 2014 20:28:16 +0000 (20:28 +0000)]
Clarify strip docs.

binutils/
* objcopy.c (strip_usage): Reword --remove-section description.
* doc/binutils.texi (strip): Likewise.

9 years agoLook up primitive types as symbols.
Doug Evans [Tue, 23 Dec 2014 15:55:39 +0000 (07:55 -0800)]
Look up primitive types as symbols.

gdb/ChangeLog:

* ada-lang.c (user_select_syms): Only fetch symtab if symbol is
objfile-owned.
(cache_symbol): Ignore symbols that are not objfile-owned.
* block.c (block_objfile): New function.
(block_gdbarch): New function.
* block.h (block_objfile): Declare.
(block_gdbarch): Declare.
* c-exp.y (classify_name): Remove call to
language_lookup_primitive_type.  No longer necessary.
* gdbtypes.c (lookup_typename): Call lookup_symbol_in_language.
Remove call to language_lookup_primitive_type.  No longer necessary.
* guile/scm-symbol.c (syscm_gdbarch_data_key): New static global.
(syscm_gdbarch_data): New struct.
(syscm_init_arch_symbols): New function.
(syscm_get_symbol_map): Renamed from syscm_objfile_symbol_map.
All callers updated.  Handle symbols owned by arches.
(gdbscm_symbol_symtab): Handle symbols owned by arches.
(gdbscm_initialize_symbols): Initialize syscm_gdbarch_data_key.
* language.c (language_lookup_primitive_type_1): New function.
(language_lookup_primitive_type): Call it.
(language_alloc_type_symbol): New function.
(language_init_primitive_type_symbols): New function.
(language_lookup_primitive_type_as_symbol): New function.
* language.h (struct language_arch_info) <primitive_type_symbols>:
New member.
(language_lookup_primitive_type): Add function comment.
(language_lookup_primitive_type_as_symbol): Declare.
* printcmd.c (address_info): Handle arch-owned symbols.
* python/py-symbol.c (sympy_get_symtab): Ditto.
(set_symbol): Ditto.
(sympy_dealloc): Ditto.
* symmisc.c (print_symbol): Ditto.
* symtab.c (fixup_symbol_section): Ditto.
(lookup_symbol_aux): Initialize block_found.
(basic_lookup_symbol_nonlocal): Try looking up the symbol as a
primitive type.
(initialize_objfile_symbol_1): New function.
(initialize_objfile_symbol): Call it.
(allocate_symbol): Call it.
(allocate_template_symbol): Call it.
(symbol_objfile): Assert symbol is objfile-owned.
(symbol_arch, symbol_symtab, symbol_set_symtab): Ditto.
* symtab.h (struct symbol) <owner>: Replaces member "symtab".
(struct symbol) <is_objfile_owned>: New member.
(SYMBOL_OBJFILE_OWNED): New macro.
* cp-namespace.c (cp_lookup_bare_symbol): New arg langdef.
All callers updated.  Try to find the symbol as a primitive type.
(lookup_namespace_scope): New arg langdef.  All callers updated.
Call cp_lookup_bare_symbol directly for simple bare symbols.

9 years agoAVR/ld: Propagate link-relax elf header flag correctly.
Andrew Burgess [Sat, 22 Nov 2014 23:25:17 +0000 (23:25 +0000)]
AVR/ld: Propagate link-relax elf header flag correctly.

The AVR target has an elf header flag to indicate if an object was
assembler ready for linker relaxation.  If a partial link is performed
then it is important that the link-relax flag in the output object is
set correctly, otherwise, during the final link, we might try to perform
linker relaxation on code that was not assembled suitably.

As the link-relax elf header covers the entire object file we must be
conservative when setting the flag in the output object, so, for a
partial link, any input object that does not have the link-relax flag
set will cause the output object to also not have the link-relax flag
set.

This conservative approach could be softened in future, we only need to
disable the link relax flag if an input file is not marked link-relax
ready, and the input file contains a relaxable section.  However, I've
left this optimisation for a later day.

For the final link I've overloaded the use of the link-relax elf header
flag, in a final executable, the flag now indicates if the executable
was built with linker relaxation on or not.

ld/ChangeLog:

* emultempl/avrelf.em: Add include of elf/avr.h.
(avr_finish): New function.
(LDEMUL_FINISH): Added.

ld/testsuite/ChangeLog:

* ld-avr/relax-elf-flags-01.d: New file.
* ld-avr/relax-elf-flags-02.d: New file.
* ld-avr/relax-elf-flags-03.d: New file.
* ld-avr/relax-elf-flags-04.d: New file.
* ld-avr/relax-elf-flags-05.d: New file.
* ld-avr/relax-elf-flags-06.d: New file.
* ld-avr/relax-elf-flags-07.d: New file.
* ld-avr/relax-elf-flags-08.d: New file.
* ld-avr/relax-elf-flags-a.s: New file.
* ld-avr/relax-elf-flags-b.s: New file.

9 years agoAVR: Only set link-relax elf flag when appropriate.
Andrew Burgess [Sat, 22 Nov 2014 23:19:31 +0000 (23:19 +0000)]
AVR: Only set link-relax elf flag when appropriate.

The AVR target uses a bit in the elf header flags to indicate if the
object was assembled ready for linker relaxation.  Previously this flag
was always set, even when the object was not assembled ready for linker
relaxation.

This patch moves setting of the flag into the assembler, and sets it
only when the assembler is preparing the file for linker relaxation.

bfd/ChangeLog:

* elf32-avr.c (bfd_elf_avr_final_write_processing): Don't set
EF_AVR_LINKRELAX_PREPARED unconditionally.

gas/ChangeLog:

* config/tc-avr.c: Add include for elf/avr.h.
(avr_elf_final_processing): New function.
* config/tc-avr.h (elf_tc_final_processing): Define.
(avr_elf_final_processing): Declare

gas/testsuite/ChangeLog:

* gas/avr/link-relax-elf-flag-clear.d: New file.
* gas/avr/link-relax-elf-flag-set.d: New file.
* gas/avr/link-relax-elf-flag.s: New file.

9 years agosymtab.h (SYMBOL_DOMAIN_BITS): New macro.
Doug Evans [Tue, 23 Dec 2014 15:31:00 +0000 (07:31 -0800)]
symtab.h (SYMBOL_DOMAIN_BITS): New macro.

gdb/ChangeLog:

* symtab.h (SYMBOL_DOMAIN_BITS): New macro.
(struct symbol) <domain>: Use it.

9 years agoinitialize_objfile_symbol: Renamed from initialize_symbol.
Doug Evans [Tue, 23 Dec 2014 15:28:28 +0000 (07:28 -0800)]
initialize_objfile_symbol: Renamed from initialize_symbol.

gdb/ChangeLog:

* symtab.c (initialize_objfile_symbol): Renamed from initialize_symbol.
All callers updated.

9 years agoAdd langdef arg to la_lookup_symbol_nonlocal.
Doug Evans [Tue, 23 Dec 2014 15:24:48 +0000 (07:24 -0800)]
Add langdef arg to la_lookup_symbol_nonlocal.

gdb/ChangeLog:

* language.h (struct language_defn) <la_lookup_symbol_nonlocal>:
New arg language_defn.  All uses updated.

9 years agoReplace some symbol accessor macros with functions.
Doug Evans [Tue, 23 Dec 2014 15:21:10 +0000 (07:21 -0800)]
Replace some symbol accessor macros with functions.

gdb/ChangeLog:

* symtab.h (SYMBOL_SYMTAB): Delete
(SYMBOL_OBJFILE): Delete.
(symbol_symtab, symbol_set_symtab): Declare.
(symbol_objfile, symbol_arch): Declare.
* symtab.c (symbol_symtab): Replaces SYMBOL_SYMTAB.  All uses updated.
All references to symbol->symtab redirected through here.
(symbol_set_symtab): New function.  All assignments to SYMBOL_SYMTAB
redirected through here.
(symbol_arch): New function.
(symbol_objfile): New function.  Replaces SYMBOL_OBJFILE.
All uses updated.
* cp-namespace.c (cp_lookup_symbol_imports_or_template): Call
symbol_arch.
* findvar.c (default_read_var_value): Call symbol_arch.
* guile/scm-frame.c (gdbscm_frame_block): Call symbol_objfile.
* jv-lang.c (add_class_symtab_symbol): Call symbol_arch.
* printcmd.c (address_info): Call symbol_arch.
* tracepoint.c (scope_info): Call symbol_arch.

9 years agoThis patch add support for cpu marvell-whitney.
Nick Clifton [Tue, 23 Dec 2014 13:41:13 +0000 (13:41 +0000)]
This patch add support for cpu marvell-whitney.

         * gas/config/tc-arm.c (arm_cpus): Add core marvell-whitney.

9 years agoReformat the objdump.1 man output to avoid overlong lines.
Nick Clifton [Tue, 23 Dec 2014 13:11:10 +0000 (13:11 +0000)]
Reformat the objdump.1 man output to avoid overlong lines.

9 years agoReport an error for script multiply defined symbols
Alan Modra [Mon, 22 Dec 2014 00:41:50 +0000 (11:11 +1030)]
Report an error for script multiply defined symbols

or maybe not just yet, but this is better than a FIXME.

* ldexp.c (update_definedness): Return false if script symbol is
redefining a strong symbol in an object.
(exp_fold_tree_1 <etree_assign>): Set up for reporting a multiple
definition error, but for now leave disabled.

9 years agoUse a symbol flag bit to mark linker defined symbols
Alan Modra [Tue, 23 Dec 2014 08:37:23 +0000 (19:07 +1030)]
Use a symbol flag bit to mark linker defined symbols

Trying to use the SEC_LINKER_CREATED section flag to determine whether
a symbol is linker defined fails to work on targets like alpha that
define special SEC_COMMON sections.  These might contain symbols that
originated in an object file.

include/
* bfdlink.h (struct bfd_link_hash_entry): Comment non_ir_ref.  Add
linker_def.
bfd/
* elflink.c (_bfd_elf_define_linkage_sym): Set linker_def.
* linker.c (_bfd_generic_link_add_one_symbol): Clear linker_def
for CDEF, DEF, DEFW, COM.
ld/
* ldexp.c (exp_fold_tree_1 <etree_provide>): Test linker_def.
ld/testsuite/
* ld-powerpc/sdabase.s,
* ld-powerpc/sdabase.t,
* ld-powerpc/sdabase.d: New test.
* ld-powerpc/sdabase2.t,
* ld-powerpc/sdabase2.d: New test.
* ld-powerpc/powerpc.exp: Run them.

9 years agoDon't PROVIDE over top of common symbols
Alan Modra [Mon, 22 Dec 2014 00:19:23 +0000 (10:49 +1030)]
Don't PROVIDE over top of common symbols

This:
  int end[100000];
  int main(void) { end[99999] = 0; return 0; }
should not segfault.

ld/
* ldexp.c (exp_fold_tree_1 <etree_provide>): Leave bfd_link_hash_common
symbols alone.
ld/testsuite/
* ld-elf/endsym.s, *ld-elf/endsym.d: New test.

9 years agoCorrect logic for "defined by object"
Alan Modra [Mon, 22 Dec 2014 04:13:49 +0000 (14:43 +1030)]
Correct logic for "defined by object"

The old code missed testing bfd_link_hash_undefweak, and wrongly
excluded bfd_link_hash_common symbols.  It is also clearer to invert
the set of enum bfd_link_hash_type values tested.
bfd_link_hash_indirect and bfd_link_hash_warning will never appear
here.

* ldexp.c (update_definedness): Correct logic setting by_object.

9 years agoMove support code for linker script DEFINED to ldexp.c
Alan Modra [Mon, 22 Dec 2014 00:15:13 +0000 (10:45 +1030)]
Move support code for linker script DEFINED to ldexp.c

This moves support code for DEFINED to ldexp.c where it is used,
losing the lang_ prefix on identifiers.  Two new functions are needed
to initialize and clean up to hash table, but other than that there
are no functional changes here.

* ldexp.c (struct definedness_hash_entry, definedness_table)
(definedness_newfunc, symbol_defined, update_definedness): Move
and rename from..
* ldlang.h (struct lang_definedness_hash_entry): ..here,..
* ldlang.c (lang_definedness_table, lang_definedness_newfunc)
(lang_symbol_defined, lang_update_definedness): ..and here.
* ldexp.c (ldexp_init, ldexp_finish): New functions, extracted from..
* ldlang.c (lang_init, lang_finish): ..here.
* ldexp.h (ldexp_init, ldexp_finish): Declare.
* ldlang.h (lang_symbol_defined, lang_update_definedness): Delete.
* ldmain.c (main): Call ldexp_init and ldexp_finish.

9 years agoUpdated translations for the gas and gprof tools.
Nick Clifton [Tue, 23 Dec 2014 12:39:34 +0000 (12:39 +0000)]
Updated translations for the gas and gprof tools.

* po/es.po: Updated Esperanto translation.
* po/fr.po: Updated French translation.
* po/uk.po: Updated Ukrainian translation.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 23 Dec 2014 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoCast size to long to warn
H.J. Lu [Mon, 22 Dec 2014 23:29:21 +0000 (15:29 -0800)]
Cast size to long to warn

* dwarf.c (read_cie): Cast size to long to warn.

9 years agoMore fixes for invalid memory accesses exposed by fuzzed binaries.
Nick Clifton [Mon, 22 Dec 2014 22:44:34 +0000 (22:44 +0000)]
More fixes for invalid memory accesses exposed by fuzzed binaries.

PR binutils/17531
* dwarf.c (decode_location_expression): Check for an out of range
value for a DW_OP_GNU_entry_value expression.
(display_debug_lines_raw): Check for a partial
.debug_line. section being encountered without a prior, full
.debug.line section.
(display_debug_lines_decoded): Likewise.  Also check for
li_line_range being zero.
(display_debug_pubnames_worker): Check for an invalid pn_length
field.
(read_cie): Add range checks.
* elfcomm.c (setup_archive): Check for a negative longnames_size.

9 years agoMore fixes for memory access violations exposed by fuzzed binaries.
Nick Clifton [Mon, 22 Dec 2014 20:59:00 +0000 (20:59 +0000)]
More fixes for memory access violations exposed by fuzzed binaries.

PR binutils/17512
* archive.c (do_slurp_bsd_armap): Return if the parsed_size is
zero.
(bfd_slurp_armap): Zero terminate the name.
(bfd_generic_stat_arch_elt): If there is no header, fail.
* elf32-arc.c (arc_info_to_howto_rel): Replace BFD_ASSERT with
error message.
* elf32-avr.c (avr_info_to_howto_rela): Likewise.
* elf32-cr16c.c (elf_cr16c_info_to_howto_rel): Likewise.
* elf32-cris.c (cris_info_to_howto_rela): Likewise.
* elf32-d10v.c (d10v_info_to_howto_rel): Likewise.
* elf32-d30v.c (d30v_info_to_howto_rel): Likewise.
* elf32-dlx.c (dlx_rtype_to_howto): Likewise.
* elf32-epiphany.c (epiphany_info_to_howto_rela): Likewise.
* elf32-fr30.c (fr30_info_to_howto_rela): Likewise.
* elf32-frv.c (frv_info_to_howto_rela): Likewise.
* elf32-i960.c (elf32_i960_info_to_howto_rel): Likewise.
* elf32-ip2k.c (ip2k_info_to_howto_rela): Likewise.
* elf32-iq2000.c (iq2000_info_to_howto_rela): Likewise.
* elf32-lm32.c (lm32_info_to_howto_rela): Likewise.
* elf32-m32c.c (m32c_info_to_howto_rela): Likewise.
* elf32-m32r.c (m32r_info_to_howto_rel): Likewise.
* elf32-m68hc11.c (m68hc11_info_to_howto_rel): Likewise.
* elf32-m68hc12.c (m68hc11_info_to_howto_rel): Likewise.
* elf32-mep.c (mep_info_to_howto_rela): Likewise.
* elf32-metag.c (metag_info_to_howto_rela): Likewise.
* elf32-moxie.c (moxie_info_to_howto_rela): Likewise.
* elf32-msp430.c (msp430_info_to_howto_rela): Likewise.
* elf32-mt.c (mt_info_to_howto_rela): Likewise.
* elf32-nds32.c (nds32_info_to_howto_rel): Likewise.
* elf32-or1k.c (or1k_info_to_howto_rela): Likewise.
* elf32-rl78.c (rl78_info_to_howto_rela): Likewise.
* elf32-rx.c (rx_info_to_howto_rela): Likewise.
* elf32-v850.c (v850_elf_info_to_howto_rel): Likewise.
* elf32-visium.c (visium_info_to_howto_rela): Likewise.
* elf32-xgate.c (xgate_info_to_howto_rel): Likewise.
* elf32-xtensa.c (elf_xtensa_info_to_howto_rela): Likewise.
* elf64-mmix.c (mmix_info_to_howto_rela): Likewise.
* elf64-x86-64.c (elf_x86_64_reloc_type_lookup): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_bfd_reloc_from_type): Likewise.
* elf64-sparc.c (elf64_sparc_slurp_one_reloc_table): Add range
checking of reloc symbol index.
* mach-o.c (bfd_mach_o_canonicalize_one_reloc): If no symbols have
been provided then set the reloc's symbol to undefined.
* reloc.c (bfd_generic_get_relocated_section_contents): Add range
checking of the reloc to be applied.
* versados.c (process_otr): Add more range checks.
(versados_canonicalize_reloc): If the section is unknown, set the
symbol to undefined.
* vms-alpha.c (_bfd_vms_slurp_eisd): Add range checks.
(alpha_vms_object_p): Likewise.

9 years agogold/
Cary Coutant [Mon, 22 Dec 2014 18:13:37 +0000 (10:13 -0800)]
gold/
* powerpc.cc (Target_powerpc::relocate): Fix overflow check.

9 years agocp-namespace.c (cp_lookup_symbol_via_all_imports): New function.
Doug Evans [Mon, 22 Dec 2014 17:29:25 +0000 (09:29 -0800)]
cp-namespace.c (cp_lookup_symbol_via_all_imports): New function.

gdb/ChangeLog:

* cp-namespace.c (cp_lookup_symbol_via_all_imports): New function.
(cp_lookup_symbol_namespace): Call it.
(cp_lookup_symbol_nonlocal): Ditto.

9 years agocp-namespace.c (cp_lookup_symbol_via_imports): New arg "search_scope_first".
Doug Evans [Mon, 22 Dec 2014 17:20:50 +0000 (09:20 -0800)]
cp-namespace.c (cp_lookup_symbol_via_imports): New arg "search_scope_first".

gdb/ChangeLog:

* cp-namespace.c (cp_lookup_symbol_via_imports): New arg
"search_scope_first".  All callers updated.

9 years agocp-namespace.c (cp_lookup_nested_symbol_1): New function.
Doug Evans [Mon, 22 Dec 2014 17:11:44 +0000 (09:11 -0800)]
cp-namespace.c (cp_lookup_nested_symbol_1): New function.

gdb/ChangeLog:

* cp-namespace.c (cp_lookup_nested_symbol_1): New function.
(cp_basic_lookup_symbol): Renamed from lookup_symbol_file.  Delete
arg "search".  All callers updated.
(cp_lookup_bare_symbol): New function.
(cp_search_static_and_baseclasses): New function.
(cp_lookup_symbol_in_namespace): Rewrite, move more logic here.
(find_symbol_in_baseclass): Simplify, call cp_lookup_nested_symbol_1.
(cp_lookup_nested_symbol): Ditto.

9 years agocp-namespace.c (cp_lookup_symbol_in_namespace): Simplify.
Doug Evans [Mon, 22 Dec 2014 16:44:50 +0000 (08:44 -0800)]
cp-namespace.c (cp_lookup_symbol_in_namespace): Simplify.

gdb/ChangeLog:

* cp-namespace.c (cp_lookup_symbol_in_namespace): Simplify.

9 years agocp-namespace.c: Whitespace cleanup.
Doug Evans [Mon, 22 Dec 2014 16:42:02 +0000 (08:42 -0800)]
cp-namespace.c: Whitespace cleanup.

gdb/ChangeLog:

* cp-namespace.c: Whitespace cleanup.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 22 Dec 2014 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 21 Dec 2014 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agogdb/17394: cannot put breakpoint only in selected ASM file.
Mihail-Marian Nistor [Sat, 20 Dec 2014 16:04:44 +0000 (11:04 -0500)]
gdb/17394: cannot put breakpoint only in selected ASM file.

This patch fixes a problem when trying to insert a breakpoint on
a specific symbol defined in a specific file, eg:

    break foo.c:func

This currently works for files in C/C++/Ada, etc, but doesn't always
work for Asm files. Analysis of the problem showed that this related
to a limitation in gas, which does not generate debug info for functions/
symbols.  Thus, we have a symtab for the file ("info sources" shows
the file), but it contains no symbols.

When find_linespec_symbols is called in linespec_parse_basic, it calls
find_function_symbols, which uses add_matching_symbols_to_info to
collect all matching symbols.

That function does [pardon any mangled formatting]:

  for (ix = 0; VEC_iterate (symtab_ptr, info->file_symtabs, ix, elt); ++ix)
    {
      if (elt == NULL)
        {
          iterate_over_all_matching_symtabs (info->state, name, VAR_DOMAIN,
                                             collect_symbols, info,
                                             pspace, 1);
          search_minsyms_for_name (info, name, pspace);
        }
      else if (pspace == NULL || pspace == SYMTAB_PSPACE (elt))
        {
          /* Program spaces that are executing startup should have
             been filtered out earlier.  */
          gdb_assert (!SYMTAB_PSPACE (elt)->executing_startup);
          set_current_program_space (SYMTAB_PSPACE (elt));
          iterate_over_file_blocks (elt, name, VAR_DOMAIN,
                                    collect_symbols, info);
        }
    }

This iterates over the symtabs. In the failing use case, ELT is
non-NULL (points to the symtab for the .s file), so it calls
iterate_over_file_blocks. Herein is where the problem exists: it is
assumed that if NAME exists, it must exist in the given symtab -- a
reasonable assumption for "normal" (non-asm) cases. It never searches
minimal symbols (or in the global default symtab).

This patch fixes the problem by doing so. It is important to note that
iterating over minsyms is fairly expensive, so this patch only adds
that extra search if the language is language_asm and
iterate_over_file_blocks returns no symbols.

gdb/ChangeLog:
2014-12-20  Keith Seitz  <keiths@redhat.com>
            Mihail-Marian Nistor  <mihail.nistor@freescale.com>

        PR gdb/17394
        * linespec.c (struct collect_minsyms): Add new member `symtab'.
        (add_minsym): Handle cases where info.symtab is non-NULL.
        (search_minsyms_for_name): Add new parameter `symtab'.
        Handle limiting searches to a specific symtab.
        (add_matching_symtabs_to_info): Search through minimal symbols
        for language_asm files for which no new symbols are found.

gdb/testsuite/ChangeLog:
2014-12-20  Mihail-Marian Nistor  <mihail.nistor@freescale.com>

        PR gdb/17394
        * gdb.linespec/break-asm-file.c: New file.
        * gdb.linespec/break-asm-file.exp: New file.
        * gdb.linespec/break-asm-file0.s: New file.
        * gdb.linespec/break-asm-file1.s: New file.

9 years agoChange SometimesInlineFunction to "return i * i * 3;"
H.J. Lu [Sat, 20 Dec 2014 16:05:45 +0000 (08:05 -0800)]
Change SometimesInlineFunction to "return i * i * 3;"

The debug_msg test has 2 implementations of SometimesInlineFunction:

int SometimesInlineFunction(int i) { return i; }
int SometimesInlineFunction(int i) { return i * i; }

and One Definition Rule (ODR) violation detection expects they will be
compiled into functions of different sizes.  Hower, on x86, GCC 4.7 and
newer compile them into functions of the same size and ODR violation
detection test fails.  This patch changes

int SometimesInlineFunction(int i) { return i; }

to

int SometimesInlineFunction(int i) { return i * i * 3; }

so that it will be compiled into a function of larger size.

PR gold/14608
* testsuite/debug_msg.cc (SometimesInlineFunction): Changed
to "return i * i * 3;".

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 20 Dec 2014 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoRework the alignment check for BFD_RELOC_MIPS_18_PCREL_S3.
Matthew Fortune [Tue, 16 Dec 2014 12:39:22 +0000 (12:39 +0000)]
Rework the alignment check for BFD_RELOC_MIPS_18_PCREL_S3.

gas/

* config/tc-mips.c (md_apply_fix): Apply alignment check
to the symbol and offset rather than *valP for
BFD_RELOC_MIPS_18_PCREL_S3.  Also update the error message
for BFD_RELOC_MIPS_19_PCREL_S2.

gas/testsuite/

* gas/mips/r6-64.s: Remove .align directives from LDPC
instructions and add further tests for LDPC.
* gas/mips/r6-64-n32.d: remove the NOPs from LDPC expected
output and update for new tests.
* gas/mips/r6-64-n64.d: Likewise.
* gas/mips/ldpc-unalign.l: New file.
* gas/mips/ldpc-unalign.s: Likewise.
* gas/mips/mips.exp: Run ldpc-unalign test.

9 years agoFix octeon3 tests for targets with default abi != n32
Matthew Fortune [Thu, 18 Dec 2014 22:04:02 +0000 (22:04 +0000)]
Fix octeon3 tests for targets with default abi != n32

gas/testsuite/

* gas/mips/octeon3.d: Switch to use numeric register names.

9 years agoFix all failing FPXX tests for tx39-elf.
Matthew Fortune [Thu, 18 Dec 2014 21:28:07 +0000 (21:28 +0000)]
Fix all failing FPXX tests for tx39-elf.

ld/testsuite/

* ld-mips-elf/attr-gnu-4-00.d: Relax check for ISA extension.
* ld-mips-elf/attr-gnu-4-01.d: Likewise.
* ld-mips-elf/attr-gnu-4-02.d: Likewise.
* ld-mips-elf/attr-gnu-4-03.d: Likewise.
* ld-mips-elf/attr-gnu-4-08.d: Likewise.
* ld-mips-elf/attr-gnu-4-10.d: Likewise.
* ld-mips-elf/attr-gnu-4-11.d: Likewise.
* ld-mips-elf/attr-gnu-4-18.d: Likewise.
* ld-mips-elf/attr-gnu-4-20.d: Likewise.
* ld-mips-elf/attr-gnu-4-22.d: Likewise.
* ld-mips-elf/attr-gnu-4-28.d: Likewise.
* ld-mips-elf/attr-gnu-4-30.d: Likewise.
* ld-mips-elf/attr-gnu-4-33.d: Likewise.
* ld-mips-elf/attr-gnu-4-38.d: Likewise.
* ld-mips-elf/attr-gnu-4-44.d: Likewise.

9 years agoFix undefined weak symbol reloc tests
Matthew Fortune [Thu, 18 Dec 2014 20:08:38 +0000 (20:08 +0000)]
Fix undefined weak symbol reloc tests

ld/testsuite/

* ld-mips-elf/mips-elf.exp: Update undefweak-overflow tests.
* ld-mips-elf/undefweak-overflow-n32.d: Remove.
* ld-mips-elf/undefweak-overflow-n64.d: Likewise.
* ld-mips-elf/undefweak-overflow.s: Set mips64r6, noreorder and
add a label to mark the micromips region.
* ld-mips-elf/undefweak-overflow.d: Update expected output.

9 years agoMIPS SDE OS ABI support
Yao Qi [Fri, 19 Dec 2014 05:13:07 +0000 (13:13 +0800)]
MIPS SDE OS ABI support

This patch is to add SDE OS ABI support in GDB, which has been used in
codesourcery gdb tree for some years.

gdb:

2014-12-19  Maciej W. Rozycki  <macro@codesourcery.com>
    Nigel Stephens  <nigel@mips.com>
    Chris Dearman  <chris@mips.com>
    Luis Machado  <lgustavo@codesourcery.com>

* Makefile.in (ALL_TARGET_OBS): Add mips-sde-tdep.o.
(ALLDEPFILES): Add mips-sde-tdep.c.
* mips-sde-tdep.c: New file containg SDE specific code.
* configure.tgt (mips*-sde*-elf*): Add mips-sde-dep.o to
gdb_target_obs.
* defs.h (gdb_osabi): Add GDB_OSABI_SDE.
* osabi.c (gdb_osabi_names): Add SDE.
* NEWS: Mention the change.

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 19 Dec 2014 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoSet ppc COMMONPAGESIZE to 64k
Richard Henderson [Thu, 18 Dec 2014 21:40:25 +0000 (15:40 -0600)]
Set ppc COMMONPAGESIZE to 64k

bfd/
* elf32-ppc.c (ELF_COMMONPAGESIZE): Set to 64k.
* elf64-ppc.c (ELF_COMMONPAGESIZE): Likewise.

9 years agoA few comment cleanups
Simon Marchi [Thu, 18 Dec 2014 16:39:44 +0000 (11:39 -0500)]
A few comment cleanups

I stumbled upon a few comments that I think are outdated.

Comment for elfread.c (elf_symfile_init): As far as history goes in git,
I don't see anything related to that.

Comment for elfread.c (elf_symfile_read): References a parameter that was
removed in 1999.

Comment for struct sym_fns/sym_offsets: References a parameter that was
changed in 1999.

gdb/ChangeLog:

* elfread.c (elf_symfile_init): Remove stale comment.
(elf_symfile_read): Same.
* symfile.h (struct sym_fns): Same.

9 years agoMIPS: Provide FPU info and decode FCSR in `info float'
Yao Qi [Thu, 18 Dec 2014 12:47:28 +0000 (20:47 +0800)]
MIPS: Provide FPU info and decode FCSR in `info float'

This patch is the V2.  V1 can be found in
https://sourceware.org/ml/gdb-patches/2012-05/msg00938.html
V2 is to address Joel's comment
<https://sourceware.org/ml/gdb-patches/2012-06/msg00289.html> about
keeping dumping floating point registers.  Additionally, command
'info float' prints bits on nan2008 and abs2008.

------------------------------------------------------------------

 The change below provides a MIPS-specific handler for the:

(gdb) info float

command.  It provides information about the FPU type available (if any),
the FPU register width, and decodes the CP1 Floating Point Control and
Status Register (FCSR):

(gdb) print /x $fsr
$1 = 0xff83ffff
(gdb) info float
fpu type: double-precision
reg size: 32 bits
cond    : 0 1 2 3 4 5 6 7
cause   : inexact uflow oflow div0 inval unimp
mask    : inexact uflow oflow div0 inval
flags   : inexact uflow oflow div0 inval
rounding: -inf
flush   : zero

 One point to note about CP1.FCSR are the non-standard Flush-to-Nearest
and Flush-Override bits.  They are not a part of the MIPS architecture and
take two positions reserved for an implementation-dependent use in the
architecture.  They are present in all the FPU implementations made by
MIPS Technologies since the spin-off from SGI.

 I haven't been able to track down a single other MIPS FPU implementation
that would make any use of these bits and they are required to be
hardwired to zero by the architecture specification if unimplemented.
Therefore I think it makes sense to report them in the current way.

 GDB has no guaranteed access to the CP0 Processor Identification (PRId)
register to validate this feature properly and the ID information stored
in the CP1 Floating Point Implementation Register (FIR) is from my
experience not reliable enough (there's no Company ID available there for
once unlike in CP0.PRId and Processor ID is not guaranteed to be unique).

 As a side note we should probably dump CP1.FIR information as well, as
there's useful stuff indicating some FPU features there.  That's material
for another change however.

gdb/

2014-12-18  Nigel Stephens  <nigel@mips.com>
            Maciej W. Rozycki  <macro@codesourcery.com>

* mips-tdep.c (print_fpu_flags): New function.
(mips_print_float_info): Likewise.
(mips_gdbarch_init): Install mips_print_float_info as gdbarch
print_float_info routine.

gdb/testsuite/

2014-12-18  Nigel Stephens  <nigel@mips.com>
            Maciej W. Rozycki  <macro@codesourcery.com>

* gdb.base/float.exp: Handle the new output from "info float" on
MIPS targets.

9 years agoRefactor gdbarch method print_float_info
Yao Qi [Thu, 18 Dec 2014 12:47:28 +0000 (20:47 +0800)]
Refactor gdbarch method print_float_info

This patch is to change print_float_info gdbarch method for the
following two reasons,

 1. we want to add a default implementation of print_float_info to
    dump the float pointer registers.  It can be reused by backend to
    print something more than float point registers.
 2. we want to simplify the caller of print_float_info,
    infcmd.c:print_float_info.

gdb:

2014-12-18  Yao Qi  <yao@codesourcery.com>

  * gdbarch.sh (print_float_info): Change its type from 'M' to 'm'.
* gdbarch.c: Re-generated.
* gdbarch.h: Likewise.
* infcmd.c (default_print_float_info): New function.
(print_float_info): Removed.  Move code to
default_print_float_info.
(float_info): Adjust to call gdbarch_print_float_info.
* inferior.h (default_print_float_info): Declare it.

9 years agoRemove h8300_print_float_info
Yao Qi [Thu, 18 Dec 2014 12:47:27 +0000 (20:47 +0800)]
Remove h8300_print_float_info

In infcmd.c:print_float_info, if the architecture doesn't have gdbarch
method print_float_info implemented and doesn't float reggroup, GDB
will prints "No floating-point info available for this processor."
The h8300 port doesn't have float registers, and don't need to
implement print_float_info.  This patch is to remove it.

gdb:

2014-12-18  Yao Qi  <yao@codesourcery.com>

* h8300-tdep.c (h8300_print_float_info): Remove.
(h8300_gdbarch_init): Remove the call to
set_gdbarch_print_float_info.

9 years agoinfcmd.c (jump_command): Minor simplification.
Doug Evans [Thu, 18 Dec 2014 09:32:59 +0000 (01:32 -0800)]
infcmd.c (jump_command): Minor simplification.

gdb/ChangeLog:

* infcmd.c (jump_command): Minor simplification.

9 years agolanguage_lookup_primitive_type: Renamed from language_lookup_primitive_type_by_name.
Doug Evans [Thu, 18 Dec 2014 09:10:34 +0000 (01:10 -0800)]
language_lookup_primitive_type: Renamed from language_lookup_primitive_type_by_name.

gdb/ChangeLog:

* language.c (language_lookup_primitive_type): Renamed from
language_lookup_primitive_type_by_name.  All callers updated.

9 years agoFix file name in earlier entry.
Doug Evans [Thu, 18 Dec 2014 08:52:40 +0000 (00:52 -0800)]
Fix file name in earlier entry.

9 years agoDisplay DW_LANG_C11 as (C11).
Mark Wielaard [Thu, 18 Dec 2014 02:35:53 +0000 (13:05 +1030)]
Display DW_LANG_C11 as (C11).

* dwarf.c (read_and_display_attr_value): Change display name of
DW_LANG_C11 from (ANSI C11) to (C11).

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 18 Dec 2014 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix MinGW compilation
Jan Kratochvil [Wed, 17 Dec 2014 19:09:02 +0000 (20:09 +0100)]
Fix MinGW compilation

On Sun, 14 Dec 2014 07:00:28 +0100, Yao Qi wrote:
The build on mingw host is broken because mingw has no mkdtemp.

../../../git/gdb/compile/compile.c: In function 'get_compile_file_tempdir':
../../../git/gdb/compile/compile.c:194:3: error: implicit declaration of function 'mkdtemp' [-Werror=implicit-function-declaration]
   tempdir_name = mkdtemp (tname);
   ^
../../../git/gdb/compile/compile.c:194:16: error: assignment makes pointer from integer without a cast [-Werror]
   tempdir_name = mkdtemp (tname);
                ^
cc1: all warnings being treated as errors

In the end I have managed to test it by Wine myself:

$ wine build_win32/gdb/gdb.exe -q build_win32/gdb/gdb.exe -ex start -ex 'compile code 1' -ex 'set confirm no' -ex quit
[...]
Temporary breakpoint 1, main (argc=1, argv=0x241418) at ../../gdb/gdb.c:29
29        args.argc = argc;
Could not load libcc1.so: Module not found.

Even if it managed to load libcc1.so (it needs host-dependent name libcc1.dll)
then it would soon end up at least on:

default_infcall_mmap:
  error (_("This target does not support inferior memory allocation by mmap."));

As currently there is only:

linux-tdep.c:
  set_gdbarch_infcall_mmap (gdbarch, linux_infcall_mmap);

While one could debug Linux targets from MS-Windows host I find it somehow
overcomplicated now when we are trying to get it running at least on native
Linux x86*.

The 'compile' project needs a larger port effort to run on MS-Windows.

gdb/ChangeLog
2014-12-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix MinGW compilation.
* compile/compile.c (get_compile_file_tempdir): Call error if
!HAVE_MKDTEMP.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (AC_CHECK_FUNCS): Add mkdtemp.

gdb/testsuite/ChangeLog
2014-12-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix MinGW compilation.
* gdb.compile/compile-ops.exp: Update untested message if
!skip_compile_feature_tests.
* gdb.compile/compile-setjmp.exp: Likewise.
* gdb.compile/compile-tls.exp: Likewise.
* gdb.compile/compile.exp: Likewise.
* lib/gdb.exp (skip_compile_feature_tests): Check also "Command not
supported on this host".

9 years agovalue_maybe_namespace_elt: Remove redundant call to lookup_static_symbol.
Doug Evans [Wed, 17 Dec 2014 08:30:29 +0000 (00:30 -0800)]
value_maybe_namespace_elt: Remove redundant call to lookup_static_symbol.

Anytime you can remove a symbol lookup that loops over all objfiles
is A Good Thing.

The call to lookup_static_symbol in valops.c:value_maybe_namespace_elt
is redundant with this call in cp_lookup_nested_symbol:

/* Now search all static file-level symbols.  We have to do this
   for things like typedefs in the class.  We do not try to
   guess any imported namespace as even the fully specified
   namespace search is already not C++ compliant and more
   assumptions could make it too magic.  */

size = strlen (parent_name) + 2 + strlen (nested_name) + 1;
concatenated_name = alloca (size);
xsnprintf (concatenated_name, size, "%s::%s",
 parent_name, nested_name);
sym = lookup_static_symbol (concatenated_name, VAR_DOMAIN);
if (sym != NULL)
  return sym;

Earlier in value_maybe_namespace_elt we do this:

  sym = cp_lookup_symbol_namespace (namespace_name, name,
    get_selected_block (0), VAR_DOMAIN);

That sequence goes like:

value_maybe_namespace_elt
-> cp_lookup_symbol_namespace
-> cp_lookup_symbol_in_namespace
-> lookup_symbol_file
-> cp_lookup_nested_symbol
-> lookup_static_symbol

The call was added in commit 41f62f3939b1c69e68ef5652feb44fef90eb85c9.
https://sourceware.org/ml/gdb-patches/2010-06/msg00663.html
With a part 2 here:
https://sourceware.org/ml/gdb-patches/2010-06/msg00664.html

At the time the call to lookup_static_symbol (spelled
lookup_static_symbol_aux at the time) was needed.

However, this patch, 8dea366bbed7986295681c101dcfbd35aeb6dfc4,
https://sourceware.org/ml/gdb-patches/2012-11/msg00387.html
augmented lookup_symbol_file to call cp_lookup_nested_symbol
and introduced the redundancy.

It's kinda buried, so it's totally not unexpected that this happened.

gdb/ChangeLog:

* valops.c (value_maybe_namespace_elt): Remove redundant call to
lookup_static_symbol.

9 years agoNew parameter "debug symbol-lookup".
Doug Evans [Wed, 17 Dec 2014 08:17:27 +0000 (00:17 -0800)]
New parameter "debug symbol-lookup".

gdb/ChangeLog:

New parameter "debug symbol-lookup".
* NEWS: Mention it.
* cp-namespace.c (cp_lookup_symbol_imports_or_template): Add debug
output.
(cp_lookup_symbol_namespace, cp_lookup_symbol_nonlocal): Ditto.
(cp_lookup_nested_symbol): Ditto.
* language.c (language_lookup_primitive_type_by_name): Add debug
output.
* minsyms.c (lookup_minimal_symbol): Add debug output.
* objfiles.c (objfile_debug_name): Moved here, and renamed ...
* symfile-debug.c (debug_objfile_name): ... from here.  All callers
updated.
* objfiles.h (objfile_debug_name): Declare.
* symtab.h (symbol_lookup_debug): Declare.
* symtab.c (symbol_lookup_debug): New global.
(lookup_language_this): Add debug output.
(lookup_symbol_aux, lookup_symbol_in_block): Ditto.
(lookup_symbol_in_objfile_symtabs, lookup_symbol_via_quick_fns): Ditto.
(lookup_symbol_in_static_block, lookup_symbol_in_objfile): Ditto.
(_initialize_symtab): Add new parameter "debug symbol-lookup".

gdb/doc/ChangeLog:

* gdb.texinfo (Debugging Output): Document "debug symbol-lookup".

9 years agoMake buildsym set-up/tear-down more consistent, and document it.
Doug Evans [Wed, 17 Dec 2014 08:00:14 +0000 (00:00 -0800)]
Make buildsym set-up/tear-down more consistent, and document it.

gdb/ChangeLog:

* buildsym.c: Add comments describing how the buildsym machinery
is used by the various file formats.
(really_free_pendings): Enhance function comment.
See pending_macros to NULL.  Simplify resetting pending_addrmap.
Call free_buildsym_compunit.
(free_buildsym_compunit): Set current_subfile to NULL.
(prepare_for_building): New function.
(start_symtab): Call it.  Remove call to set_last_source_file.
(restart_symtab): New arg "cust".  All callers updated.
Simplify, call prepare_for_building.  Re-initialize buildsym_compunit.
(reset_symtab_globals): Enhance function comment.
Set local_symbols, file_symbols, global_symbols to NULL.
Set pending_macros to NULL.  Simplify resetting pending_addrmap.
Call free_buildysym_compunit.
(end_symtab_without_blockvector): Delete.  All callers updated.
(end_symtab_with_blockvector): Remove redundant call to
free_buildsym_compunit.
(augment_type_symtab): Remove arg "cust".  All callers updated.
(buildsym_init): Remove resetting of free_pendings, file_symbols,
global_symbols, pending_blocks, pending_macros.  Instead make
handling consistent with pending_addrmap: Assert value was reset
at end of previous symtab building.  Initialize context_stack here.

9 years agoboards/stabs.exp: New file.
Doug Evans [Wed, 17 Dec 2014 07:10:54 +0000 (23:10 -0800)]
boards/stabs.exp: New file.

gdb/ChangeLog:

* boards/stabs.exp: New file.

9 years agocp_lookup_symbol_via_imports: Renamed from cp_lookup_symbol_imports.
Doug Evans [Wed, 17 Dec 2014 06:19:15 +0000 (22:19 -0800)]
cp_lookup_symbol_via_imports: Renamed from cp_lookup_symbol_imports.

gdb/ChangeLog:

* cp-namespace.c (cp_lookup_symbol_via_imports): Renamed from
cp_lookup_symbol_imports.  All callers updated.

9 years agocp_find_type_baseclass_by_name: Renamed from find_type_baseclass_by_name.
Doug Evans [Wed, 17 Dec 2014 06:13:57 +0000 (22:13 -0800)]
cp_find_type_baseclass_by_name: Renamed from find_type_baseclass_by_name.

gdb/ChangeLog:

* cp-namespace.c (cp_find_type_baseclass_by_name): Renamed from
find_type_baseclass_by_name.  All callers updated.

9 years agosymtab.h (struct symbol_search) <symtab>: Delete, unnecessary.
Doug Evans [Wed, 17 Dec 2014 06:00:13 +0000 (22:00 -0800)]
symtab.h (struct symbol_search) <symtab>: Delete, unnecessary.

gdb/ChangeLog:

* symtab.h (struct symbol_search) <symtab>: Delete.  All uses updated.
* symtab.c (compare_search_syms): Use SYMBOL_SYMTAB accessor.
(print_symbol_info): Delete arg symtab.  All callers updated.
(symtab_symbol_info): Use SYMBOL_SYMTAB accessor.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 17 Dec 2014 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix internal error in gold when -Map and --compress-debug-sections are used
Cary Coutant [Tue, 16 Dec 2014 22:57:17 +0000 (14:57 -0800)]
Fix internal error in gold when -Map and --compress-debug-sections are used
together.

gold/
* mapfile.cc (Mapfile::print_input_section): Print uncompressed sizes.
(Mapfile::print_output_data): Use current_data_size() to avoid
assert for sections requiring postprocessing; if address is not valid,
print 0.
(Mapfile::print_output_section): Use current_data_size(); print note
that addresses and sizes are before compression.

9 years agoFix octeon3 testsuite fallout
Matthew Fortune [Tue, 16 Dec 2014 13:37:20 +0000 (13:37 +0000)]
Fix octeon3 testsuite fallout

gas/testsuite/

* gas/mips/attr-gnu-4-5.d: Ignore ASEs.
* gas/mips/attr-gnu-4-6.d: Likewise.
* gas/mips/attr-gnu-4-7.d: Likewise.
* gas/mips/attr-none-o32-fp64-nooddspreg.d: Likewise.
* gas/mips/attr-none-o32-fp64.d: Likewise.
* gas/mips/attr-none-o32-fpxx.d: Likewise.

9 years agoAdd in a JALRC alias and fix the NAL instruction.
Matthew Fortune [Tue, 16 Dec 2014 13:33:56 +0000 (13:33 +0000)]
Add in a JALRC alias and fix the NAL instruction.

opcodes/

* mips-opc.c (mips_builtin_opcodes): Add JALRC alias for JIALC.
Remove the operand from NAL.

gas/testsuite/

* gas/mips/r6.s: Test JALRC and NAL
* gas/mips/r6-n32.d: Add expected output for JALRC and NAL.
* gas/mips/r6-n64.d: Likewise.
* gas/mips/r6.d: Likewise.

9 years agoFix indentation of "maint print user-registers"
Andreas Arnez [Tue, 16 Dec 2014 15:06:42 +0000 (16:06 +0100)]
Fix indentation of "maint print user-registers"

This fixes a failure of the test case "complete 'info registers '" in
completion.exp on architectures where the user registers have numbers
above 99.  In that case the output of "maint print user-registers" was
no longer indented, and the regexp in the test case failed to add them
to the list of expected completion results.  The fix also swaps the
columns "Name" and "Nr", such that the indentation is always the same,
and to be consistent with the output of "maint print registers".

gdb/ChangeLog:

* user-regs.c (maintenance_print_user_registers): Swap "Nr" and
"Name" columns.  Assure that the output is always indented.

gdb/testsuite/ChangeLog:

* gdb.base/completion.exp: Adjust to format changes of "maint
print user-registers".

9 years agoFix a memory access violation triggeed by a fuzzed binary.
Nick Clifton [Tue, 16 Dec 2014 14:17:15 +0000 (14:17 +0000)]
Fix a memory access violation triggeed by a fuzzed binary.

PR binutils/17512
* format.c (bfd_check_format_matches): Check for a matching vector
before using match priorities.
* mach-o.c (bfd_mach_o_canonicalize_one_reloc): Fix off-by-one
errors with previous delta.

9 years ago[Linux] Ask kernel to kill inferior when GDB terminates
Joel Brobecker [Tue, 11 Nov 2014 06:07:21 +0000 (10:07 +0400)]
[Linux] Ask kernel to kill inferior when GDB terminates

This patch enhances GDB on GNU/Linux systems in the situation where
we are debugging an inferior that was created from GDB (as opposed
to attached to), by asking the kernel to kill the inferior if GDB
terminates without doing it itself.

This would typically happen when GDB encounters a problem and
crashes, or when it gets killed by an external process. This can
be observed by starting a program under GDB, and then killing
GDB with signal 9. After GDB is killed, the inferior still remains.

This patch also fixes GDBserver similarly.

This fix is conditional on the kernel supporting the PTRACE_O_EXITKILL
feature.  On older kernels, the behavior remains unchanged.

gdb/ChangeLog:

        * nat/linux-ptrace.h (PTRACE_O_EXITKILL): Define if not
        already defined.
        (linux_enable_event_reporting): Add parameter "attached".
        * nat/linux-ptrace.c (linux_test_for_exitkill): New forward
        declaration.  New function.
        (linux_check_ptrace_features): Add linux_test_for_exitkill call.
        (linux_enable_event_reporting): Add new parameter "attached".
        Do not call ptrace with the PTRACE_O_EXITKILL if ATTACHED is
        nonzero.
        * linux-nat.c (linux_init_ptrace): Add parameter "attached".
        Use it.  Update function description.
        (linux_child_post_attach, linux_child_post_startup_inferior):
        Update call to linux_enable_event_reporting.

gdb/gdbserver/ChangeLog:

        * linux-low.c (linux_low_filter_event): Update call to
        linux_enable_event_reporting following the addition of
        a new parameter to that function.

Tested on x86_64-linux, native and native-gdbserver.

I also verified by hand that the inferior gets killed when killing
GDB in the "run" case, while the inferior remains in the "attach"
case. Same for GDBserver.

9 years agoaarch64/gdbserver: fix floating point registers display
Catalin Udma [Tue, 16 Dec 2014 07:51:42 +0000 (09:51 +0200)]
aarch64/gdbserver: fix floating point registers display

When using aarch64 gdb with gdbserver, floating point registers are
not correctly displayed, as below:
  (gdb) info registers fpsr fpcr
  fpsr           <unavailable>
  fpcr           <unavailable>

To fix these problems, the missing fpsr and fpcr registers are added
when floating point registers are read/write
Add test for aarch64 floating point
PR server/17457

gdb/gdbserver/

    PR server/17457
    * linux-aarch64-low.c (AARCH64_FPSR_REGNO): New define.
    (AARCH64_FPCR_REGNO): Likewise.
    (AARCH64_NUM_REGS): Update to include fpsr/fpcr registers.
    (aarch64_fill_fpregset): Add missing fpsr/fpcr registers.
    (aarch64_store_fpregset): Likewise.

gdb/testsuite/

    PR server/17457
    * gdb.arch/aarch64-fp.c: New file.
    * gdb.arch/aarch64-fp.exp: New file.

Signed-off-by: Catalin Udma <catalin.udma@freescale.com>
9 years agoMove NEWS entries to the right section
Yao Qi [Mon, 15 Dec 2014 08:29:21 +0000 (16:29 +0800)]
Move NEWS entries to the right section

gdb:

2014-12-16  Yao Qi  <yao@codesourcery.com>

* NEWS: Move some entries to "Changes since GDB 7.8" section.

9 years agoReplace ARG_MAX with ARG_LAST
Yao Qi [Mon, 15 Dec 2014 13:40:29 +0000 (21:40 +0800)]
Replace ARG_MAX with ARG_LAST

We define an enum ARG_MAX in linux_infcall_mmap, but it is conflict
with macro ARG_MAX which is defined in /usr/include/linux/limits.h.
This causes a build failure below,

 gdb/linux-tdep.c: In function 'linux_infcall_mmap':
 gdb/linux-tdep.c:1945:70: error: expected identifier before numeric constant

the enum in the pre-processed source becomes:

  enum
    {
      ARG_ADDR, ARG_LENGTH, ARG_PROT, ARG_FLAGS, ARG_FD, ARG_OFFSET, 131072
    };

This patch is to replace ARG_MAX with ARG_LAST.

gdb:

2014-12-16  Yao Qi  <yao@codesourcery.com>

* linux-tdep.c (linux_infcall_mmap): Replace ARG_MAX with
ARG_LAST.

9 years agoMerge dg-extract-results.{sh,py} from GCC upstream
Sergio Durigan Junior [Tue, 16 Dec 2014 00:34:24 +0000 (19:34 -0500)]
Merge dg-extract-results.{sh,py} from GCC upstream

It has been a while since we don't sync this file with GCC upstream,
and in the meantime some interesting things have happened.  The most
interesting is the inclusion of a new dg-extract-results.py which is
apparently faster than its shell equivalent.

This merge will probably fix the bug described in

  <https://sourceware.org/ml/gdb-patches/2014-12/msg00421.html>

Though I am still proposing the patch for upstream GCC.  Once it gets
accepted, I will merge it too.

OK to apply?

gdb/testsuite/ChangeLog:
2014-12-15  Sergio Durigan Junior  <sergiodj@redhat.com>

Merge dg-extract-results.{sh,py} from GCC upstream (r210243,
r210637, r210913, r211666, r215400, r215817).

2014-05-08  Richard Sandiford  <rdsandiford@googlemail.com>
* dg-extract-results.py: New file.
* dg-extract-results.sh: Use it if the environment seems
suitable.

2014-05-20  Richard Sandiford  <rdsandiford@googlemail.com>

* dg-extract-results.py (parse_run): Handle warnings that
are printed before a test harness is run.

2014-05-25  Richard Sandiford  <rdsandiford@googlemail.com>

* dg-extract-results.py (Named): Remove __cmp__ method.
(output_variation): Use a key to sort variation.harnesses.

2014-06-14  Richard Sandiford  <rdsandiford@googlemail.com>

* dg-extract-results.py: For Python 3, force sys.stdout to
handle surrogate escape sequences.
(safe_open): New function.
(output_segment, main): Use it.

2014-09-19  Segher Boessenkool  <segher@kernel.crashing.org>

* dg-extract-results.py (Prog.result_re): Include options
in test name.

2014-10-02  Segher Boessenkool  <segher@kernel.crashing.org>

* dg-extract-results.py (output_variation): Always sort if
do_sum.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 16 Dec 2014 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoIntroduce utility function find_inferior_ptid
Simon Marchi [Mon, 15 Dec 2014 17:00:55 +0000 (12:00 -0500)]
Introduce utility function find_inferior_ptid

This patch introduces find_inferior_ptid to replace the common idiom

  find_inferior_pid (ptid_get_pid (...));

It replaces all the instances of that idiom that I found with the new
function.

No significant changes before/after the patch in the regression suite
on amd64 linux.

gdb/ChangeLog:

* inferior.c (find_inferior_ptid): New function.
* inferior.h (find_inferior_ptid): New declaration.
* ada-tasks.c (ada_get_task_number): Use find_inferior_ptid.
* corelow.c (core_pid_to_str): Same.
* darwin-nat.c (darwin_resume): Same.
* infrun.c (fetch_inferior_event): Same.
(get_inferior_stop_soon): Same.
(handle_inferior_event): Same.
(handle_signal_stop): Same.
* linux-nat.c (resume_lwp): Same.
(stop_wait_callback): Same.
* mi/mi-interp.c (mi_new_thread): Same.
(mi_thread_exit): Same.
* proc-service.c (ps_pglobal_lookup): Same.
* record-btrace.c (record_btrace_step_thread): Same.
* remote-sim.c (gdbsim_close_inferior): Same.
(gdbsim_resume): Same.
(gdbsim_stop): Same.
* sol2-tdep.c (sol2_core_pid_to_str): Same.
* target.c (memory_xfer_partial_1): Same.
(default_thread_address_space): Same.
* thread.c (thread_change_ptid): Same.
(switch_to_thread): Same.
(do_restore_current_thread_cleanup): Same.

9 years agotestsuite: expect possible pagination when starting gdb
Simon Marchi [Mon, 15 Dec 2014 16:46:44 +0000 (11:46 -0500)]
testsuite: expect possible pagination when starting gdb

When gdb starts, the lines that appear before the first prompt may get
paginated if the terminal in which the tests are ran is too small (in
terms of rows). These lines include the welcome/license message and
possibly more, such as "Reading symbols from...". Pagination is disabled
right after gdb is started (with "set height 0"), but this output happens
before we are able to set height.

If these lines get paginated, gdb waits for the user to press enter and
the test harness waits for gdb to print its prompt, resulting in a
deadlock.

My first idea was to launch gdb with --quiet. However, some lines are
still printed ("Reading symbols from...", some more stuff when attaching
with --pid, etc).

The proposed solution simply expects that pagination can occur after
starting gdb. If this is the case, it sends a "\n" and loops.

gdb/testsuite/Changelog:

* lib/gdb.exp (default_gdb_start): After starting gdb, loop
as long as we get pagination notifications.

9 years agoFix build with Python 3.4 (PR python/16784)
Simon Marchi [Mon, 15 Dec 2014 16:38:03 +0000 (11:38 -0500)]
Fix build with Python 3.4 (PR python/16784)

The type of the function pointer PyOS_ReadlineFunctionPointer (part of the
Python C API), which we use, slightly changed starting with Python 3.4. The
signature went from

PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);

to

PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);

The parameter that changed is the prompt text.

This commits adjust gdb accordingly by making the prompt_arg parameter
const, as well as the fallouts of that. I needed to rework how
annotations are added to the prompt, since the it is now const. If
annotations are enabled, it will make a copy of the prompt overwrite the
prompt variable that is used throughout the function. Otherwise, no copy
is done and the original prompt_arg value is passed.

I changed the signature of deprecated_readline_hook. I would've changed any
user of it, but it seems like nothing is using it,

Built-tested with python 2.7.x, 3.3.y and 3.4.z.

gdb/ChangeLog:

* defs.h (gdb_readline): Constify argument.
(gdb_readline_wrapper): Same.
(command_line_input): Same.
(deprecated_readline_hook): Same.
* top.c (deprecated_readline_hook): Same.
(gdb_readline): Same.
(gdb_readline_wrapper): Same.
(command_line_input): Constify argument. Pass prompt to
called functions instead of local_prompt, overwriting prompt
if using annotations.
* event-top.h (display_gdb_prompt): Constify argument.
* event-top.c (display_gdb_prompt): Same.
* python/py-gdb-readline.c (gdbpy_readline_wrapper): Constify
argument if building with Python 3.4 and up.

Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
9 years agopython extended prompt: Use os.getcwd() instead of os.getcwdu()
Simon Marchi [Mon, 15 Dec 2014 16:30:20 +0000 (11:30 -0500)]
python extended prompt: Use os.getcwd() instead of os.getcwdu()

It seems like using os.getcwdu() here is wrong both for Python 2 and Python 3.

For Python 2, this returns a 'unicode' object, which tries to get concatenated
to a 'str' object in substitute_prompt. The implicit conversion works when the
unicode string contains no accent. When it does contain an accent though,
displaying the prompt results in the following error:

(gdb) set extended-prompt \w
...
  File "/home/simark/build/binutils-gdb-python2/gdb/data-directory/python/gdb/prompt.py", line 138, in substitute_prompt
    result += str(cmd(arg))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 49: ordinal not in range(128)

When using os.getcwd() instead, it works correctly. I suppose that Python does
the necessary decoding internally.

For Python 3, this method simply does not exist. It works fine with os.getcwd().

gdb/ChangeLog:

* python/lib/gdb/prompt.py (_prompt_pwd): Use os.getcwd() instead of
os.getcwdu().

9 years agoCheck corrupt input
H.J. Lu [Mon, 15 Dec 2014 16:27:57 +0000 (08:27 -0800)]
Check corrupt input

PR ld/17713
* elflink.c (_bfd_elf_gc_mark_rsec): Check corrupt input.

9 years ago * Makefile.in (check-gdb.%): Restore.
Jason Merrill [Tue, 9 Dec 2014 20:50:03 +0000 (15:50 -0500)]
* Makefile.in (check-gdb.%): Restore.
* README: Mention it.

9 years agoUse PTRACE_SINGLESTEP_ONE when single-stepping one thread.
Joel Brobecker [Tue, 25 Nov 2014 16:12:10 +0000 (11:12 -0500)]
Use PTRACE_SINGLESTEP_ONE when single-stepping one thread.

Currently, when we receive a request to single-step one single thread
(Eg, when single-stepping out of a breakpoint), we use the
PTRACE_SINGLESTEP pthread request, which does single-step
the corresponding thread, but also resumes execution of all
other threads in the inferior.

This causes problems when debugging programs where another thread
receives multiple debug events while trying to single-step a specific
thread out of a breakpoint (with infrun traces turned on):

    (gdb) continue
    Continuing.
    infrun: clear_proceed_status_thread (Thread 126)
    [...]
    infrun: clear_proceed_status_thread (Thread 142)
    [...]
    infrun: clear_proceed_status_thread (Thread 146)
    infrun: clear_proceed_status_thread (Thread 125)
    infrun: proceed (addr=0xffffffff, signal=GDB_SIGNAL_DEFAULT, step=0)
    infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=1, current thread [Thread 142] at 0x10684838
    infrun: wait_for_inferior ()
    infrun: target_wait (-1, status) =
    infrun:   42000 [Thread 146],
    infrun:   status->kind = stopped, signal = GDB_SIGNAL_REALTIME_34
    infrun: infwait_normal_state
    infrun: TARGET_WAITKIND_STOPPED
    infrun: stop_pc = 0x10a187f4
    infrun: context switch
    infrun: Switching context from Thread 142 to Thread 146
    infrun: random signal (GDB_SIGNAL_REALTIME_34)
    infrun: switching back to stepped thread
    infrun: Switching context from Thread 146 to Thread 142
    infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=1, current thread [Thread 142] at 0x10684838
    infrun: prepare_to_wait
    [...handling of similar events for threads 145, 144 and 143 snipped...]
    infrun: prepare_to_wait
    infrun: target_wait (-1, status) =
    infrun:   42000 [Thread 146],
    infrun:   status->kind = stopped, signal = GDB_SIGNAL_REALTIME_34
    infrun: infwait_normal_state
    infrun: TARGET_WAITKIND_STOPPED
    infrun: stop_pc = 0x10a187f4
    infrun: context switch
    infrun: Switching context from Thread 142 to Thread 146
    ../../src/gdb/inline-frame.c:339: internal-error: skip_inline_frames: Assertion `find_inline_frame_state (ptid) == NULL' failed.

What happens is that GDB keeps sending requests to resume one specific
thread, and keeps receiving debugging events for other threads.
Things break down when the one of the other threads receives a debug
event for the second time (thread 146 in the example above).

This patch fixes the problem by making sure that only one thread
gets resumed, thus preventing the other threads from generating
an unexpected event.

gdb/gdbserver/ChangeLog:

        * lynx-low.c (lynx_resume): Use PTRACE_SINGLESTEP_ONE if N == 1.
        Remove FIXME comment about assumption about N.

9 years agoFix info mem command for 32 bits host/64 bits target
Catalin Udma [Mon, 15 Dec 2014 14:41:29 +0000 (16:41 +0200)]
Fix info mem command for 32 bits host/64 bits target

When running gdb on 32 bits host for 64 bits target, info mem command
truncates the target address to 32 bits, like in the example below
(gdb) set architecture powerpc:common64
(gdb) mem 0x100000000 0x200000000 rw
(gdb) info mem
1   y   0x0000000000000000 0x0000000000000000 rw nocache

gdb/ChangeLog:

        PR gdb/15684
        * memattr.c (mem_info_command): Remove "unsigned long" casts.

Signed-off-by: Catalin Udma <catalin.udma@freescale.com>
9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 15 Dec 2014 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoMention --compress-debug-sections default in NEWS
H.J. Lu [Sun, 14 Dec 2014 15:23:15 +0000 (07:23 -0800)]
Mention --compress-debug-sections default in NEWS

* NEWS: Mention --compress-debug-sections is on by default for
Linux/x86.

9 years agoCast current_group_size to unsigned long
H.J. Lu [Sun, 14 Dec 2014 14:59:20 +0000 (06:59 -0800)]
Cast current_group_size to unsigned long

* aarch64.cc (AArch64_relocate_functions::maybe_apply_stub):
Cast current_group_size to unsigned long when reporting error.

9 years agoCompress debug sections for Linux/x86 by default
H.J. Lu [Sun, 14 Dec 2014 14:41:03 +0000 (06:41 -0800)]
Compress debug sections for Linux/x86 by default

* config/tc-i386.c (flag_compress_debug): Default to compress
debug sections for Linux.

9 years agoHandle weak alias for PIE with copy reloc
H.J. Lu [Sun, 14 Dec 2014 07:37:22 +0000 (23:37 -0800)]
Handle weak alias for PIE with copy reloc

When there is a weak symbol with a real definition, the processor
independent code will have arranged for us to see the real definition
first.  We need to copy the needs_copy bit from the real definition and
check it when allowing copy reloc in PIE.

bfd/

PR ld/17689
* elf64-x86-64.c (elf_x86_64_link_hash_entry): Add needs_copy.
Change has_bnd_reloc to bit field.
(elf_x86_64_link_hash_newfunc): Initialize needs_copy and
has_bnd_reloc to 0.
(elf_x86_64_check_relocs): Set has_bnd_reloc to 1 instead
of TRUE.
(elf_x86_64_adjust_dynamic_symbol): Copy needs_copy from the
real definition to a weak symbol.
(elf_x86_64_allocate_dynrelocs): Also check needs_copy of a
weak symbol for PIE when discarding space for relocs against
symbols which turn out to need copy relocs.
(elf_x86_64_relocate_section): Also check needs_copy of a
weak symbol for PIE with copy reloc.

ld/testsuite/

PR ld/17689
* ld-x86-64/pr17689.out: New file.
* ld-x86-64/pr17689.rd: Likewise.
* ld-x86-64/pr17689a.c: Likewise.
* ld-x86-64/pr17689b.S: Likewise.

* ld-x86-64/x86-64.exp: Run PR ld/17689 tests.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 14 Dec 2014 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoutils.c (make_hex_string): Fix off-by-one error.
Doug Evans [Sat, 13 Dec 2014 22:04:05 +0000 (14:04 -0800)]
utils.c (make_hex_string): Fix off-by-one error.

gdb/ChangeLog:

* utils.c (make_hex_string): Fix off-by-one error.

9 years agoInternal error trying to print uninitialized string.
Joel Brobecker [Mon, 8 Dec 2014 15:37:00 +0000 (10:37 -0500)]
Internal error trying to print uninitialized string.

Trying to print the value of a string whose size is not known at
compile-time before it gets assigned a value can lead to the following
internal error:

    (gdb) p my_str
    $1 =
    /[...]/utils.c:1089: internal-error: virtual memory exhausted.

What happens is that my_str is described as a reference to an array
type whose bounds are dynamic. During the read of that variable's
value (in default_read_var_value), we end up resolving dynamic types
which, for reference types, makes us also resolve the target of that
reference type. This means we resolve our variable to a reference
to an array whose bounds are undefined, and unfortunately very far
appart.

So, when we pass that value to ada-valprint, and in particular to
da_val_print_ref, we eventually try to allocate too large of a buffer
corresponding to the (bogus) size of our array, hence the internal
error.

This patch fixes the problem by adding a size_check before trying
to print the dereferenced value. To perform this check, a function
that was previously specific to ada-lang.c (check_size) gets
exported, and renamed to something less prone to name collisions
(ada_ensure_varsize_limit).

gdb/ChangeLog:

        * ada-lang.h (ada_ensure_varsize_limit): Declare.
        * ada-lang.c (check_size): Remove advance declaration.
        (ada_ensure_varsize_limit): Renames check_size.
        Replace calls to check_size by calls to ada_ensure_varsize_limit
        throughout.
        * ada-valprint.c (ada_val_print_ref): Add call to
        ada_ensure_varsize_limit.  Add comment explaining why.

gdb/testsuite/ChangeLog:

        * gdb.ada/str_uninit: New testcase.

9 years agoAvoid use of sprintf in gdb/utils.c:make_hex_string
Joel Brobecker [Sat, 13 Dec 2014 15:19:03 +0000 (10:19 -0500)]
Avoid use of sprintf in gdb/utils.c:make_hex_string

The use of sprintf is discouraged in GDB. Use xsnprintf instead.

gdb/ChangeLog:

        * utils.c (make_hex_string): Replace use of sprintf by use of
        xsnprintf.

Tested on x86_64-linux.

9 years agoFix ARI warnings in gdb/compile/compile-object-load.c.
Joel Brobecker [Sat, 13 Dec 2014 15:02:26 +0000 (10:02 -0500)]
Fix ARI warnings in gdb/compile/compile-object-load.c.

gdb/ChangeLog:

        * compile/compile-object-load.c (link_callbacks_multiple_definition)
        (link_callbacks_warning, link_callbacks_einfo): Remove trailing
        newline at end of warning message.

Tested on x86_64-linux.

9 years agoAdd missing ChangeLog entry for PR backtrace/16215.
Joel Brobecker [Sat, 13 Dec 2014 15:25:41 +0000 (10:25 -0500)]
Add missing ChangeLog entry for PR backtrace/16215.

9 years agoAdd ChangeLog entries missing from the previous commit.
Joel Brobecker [Sat, 13 Dec 2014 15:24:14 +0000 (10:24 -0500)]
Add ChangeLog entries missing from the previous commit.

9 years agoconfigure gdb/gnulib with --disable-largefile if largefile support disabled.
Joel Brobecker [Wed, 3 Dec 2014 11:31:54 +0000 (06:31 -0500)]
configure gdb/gnulib with --disable-largefile if largefile support disabled.

This patch mostly aims at fixing a GDB build failure on 32bit Solaris
systems (Sparc and x86), due to a recent gnulib update adding the
readlink module. But it might also fix related issues when configuring
with --disable-largefile.

A side-effect of the gnulib readlink module addition is that it caused
largefile support to be added as well, and in particular
gnulib/import/m4/largefile.m4 introduced the following new #define in
gnulib's config.in:

| +/* Number of bits in a file offset, on hosts where this is settable. */
| +#undef _FILE_OFFSET_BITS

When defined to 64, it triggers an issue with procfs.h while trying
to build sparc-sol2-nat.c:

| #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
| #error  "Cannot use procfs in the large file compilation environment"
| #endif

As it turns out, this is a fairly familiar problem, and one of
the reasons behind ACX_LARGEFILE having been created. In that macro,
we have some code which disables largefile support on solaris hosts:

|   sparc-*-solaris*|i[3-7]86-*-solaris*)
| changequote([,])dnl
|     # On native 32bit sparc and ia32 solaris, large-file and procfs support
|     # are mutually exclusive; and without procfs support, the bfd/ elf module
|     # cannot provide certain routines such as elfcore_write_prpsinfo
|     # or elfcore_write_prstatus.  So unless the user explicitly requested
|     # large-file support through the --enable-largefile switch, disable
|     # large-file support in favor of procfs support.
|     test "${target}" = "${host}" -a "x$plugins" = xno \
|       && : ${enable_largefile="no"}
|     ;;

But gnulib ignores this fact, and so tries to determine how to
enable large-file support irrespective of whether we want it or not.
This patch fixes the issue by passing --disable-largefile to gnulib's
configure when large-file support in GDB is disabled. This is done
by first enhancing ACX_CONFIGURE_DIR to allow us to pass extra
arguments to be passed to the configure command, and then by modifying
GDB's configure to pass --disable-largefile if large-file support
is disabled.

gdb/ChangeLog:

* acx_configure_dir.m4 (ACX_CONFIGURE_DIR): Add support for
        new "EXTRA-ARGS" parameter.
* configure.ac: If large-file support is disabled in GDB,
        pass --disable-largefile to ACX_CONFIGURE_DIR call for "gnulib".
* configure: Regenerate.

gdb/gdbserver/ChangeLog:

* configure.ac: If large-file support is disabled in GDBserver,
        pass --disable-largefile to ACX_CONFIGURE_DIR call for "gnulib".
        * configure: Regenerate.

Tested by rebuilding on sparc-solaris and x86_64-linux (with gdbserver).
This fixes the build failure on sparc-solaris. I also verified in
gnulib's config.log file that we pass --disable-largefile in the solaris
case, while we do not in the GNU/Linux case.

9 years agoFix 7.8 regression: resolve_dynamic_struct: Assertion `TYPE_NFIELDS (type) > 0' ...
Jan Kratochvil [Sat, 13 Dec 2014 14:31:59 +0000 (15:31 +0100)]
Fix 7.8 regression: resolve_dynamic_struct: Assertion `TYPE_NFIELDS (type) > 0' (PR 17642)

https://sourceware.org/bugzilla/show_bug.cgi?id=17642

Regression since:
commit 012370f6818657a816df1463ee71ca4e4ee40b33
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 8 11:26:44 2014 -0600
    handle VLA in a struct or union

Bugreport:
Regression with gdb scripts for Linux kernel
https://sourceware.org/ml/gdb/2014-08/msg00127.html

That big change after "else" is just reindentation.

gdb/ChangeLog
2014-12-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

PR symtab/17642
* gdbtypes.c (resolve_dynamic_type_internal): Apply check_typedef to
TYPE if not TYPE_CODE_TYPEDEF.

gdb/testsuite/ChangeLog
2014-12-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

PR symtab/17642
* gdb.base/vla-stub-define.c: New file.
* gdb.base/vla-stub.c: New file.
* gdb.base/vla-stub.exp: New file.

9 years agoLift DWARF unwinder restriction in dwarf2-frame.c::dwarf2_frame_cfa
Joel Brobecker [Fri, 21 Nov 2014 03:59:35 +0000 (04:59 +0100)]
Lift DWARF unwinder restriction in dwarf2-frame.c::dwarf2_frame_cfa

GDB is currently broken on all SPARC targets when using GCC 4.9.
When trying to print any local variable:

    (gdb) p x
    can't compute CFA for this frame

This is related to the fact that the compiler now generates DWARF 4
debugging info by default, and in particular that it now emits
DW_OP_call_frame_cfa, which triggers a limitation in dwarf2_frame_cfa:

   /* This restriction could be lifted if other unwinders are known to
      compute the frame base in a way compatible with the DWARF
      unwinder.  */
   if (!frame_unwinder_is (this_frame, &dwarf2_frame_unwind)
       && !frame_unwinder_is (this_frame, &dwarf2_tailcall_frame_unwind))
     error (_("can't compute CFA for this frame"));

We couldn't append the dwarf2 unwinder to all SPARC targets because
it does not work properly with StackGhost:
    https://www.sourceware.org/ml/gdb-patches/2014-07/msg00012.html

We also later discovered that using the DWARF2 unwinder means
using it for computing the function's return address, which
is buggy when it comes to functions returning a struct (where
the return address is saved-pc+12 instead of saved-pc+8).
This is because GCC is emitting the info about the return address
as %o7/%i7 instead of the actual return address.  For functions
that have debugging info, we compensate by looking at the function's
return type and add the extra +4, but for function without debug
info, we're stuck.

EricB and I twisted the issue in all the directions we could think of,
and unfortunately couldn't find a way to make it work without
introduction one regression or another.

But, stepping back a little, just removing the restriction seems to work
well for us on all both sparc-elf and {sparc,sparc64}-solaris.
After reviewing the previous discussions about this test, I could
not figure out whether some unwinders were already known to have
incompatible CFAs or if the concern was purely theoretical:
    https://www.sourceware.org/ml/gdb-patches/2009-06/msg00191.html
    https://www.sourceware.org/ml/gdb-patches/2009-07/msg00570.html
    https://www.sourceware.org/ml/gdb-patches/2009-09/msg00027.html

At the moment, we took the approach of trying it out, and see what
happens...

gdb/ChangeLog:

        PR backtrace/16215:
        * dwarf2-frame.c (dwarf2_frame_cfa): Remove the restriction
        the frame unwinder must either be the dwarf2_frame_unwind
        or the dwarf2_tailcall_frame_unwind.  Verify that this_frame's
        stack_addr is valid before calling get_frame_base.  Throw
        an error if not valid.

Tested on sparc-solaris and sparc-elf with AdaCore's testsuite
(the FSF testsuite crashes all of AdaCore's solaris machines).

9 years agovalue_maybe_namespace_elt: Remove unnecessary test of result != NULL.
Doug Evans [Sat, 13 Dec 2014 07:25:46 +0000 (23:25 -0800)]
value_maybe_namespace_elt: Remove unnecessary test of result != NULL.

Both allocate_value and value_of_variable are guaranteed to return non-NULL.

gdb/ChangeLog:

* valops.c (value_maybe_namespace_elt): Remove unnecessary test of
result != NULL.

9 years agoRename cp_is_anonymous to cp_is_in_anonymous.
Doug Evans [Sat, 13 Dec 2014 06:33:26 +0000 (22:33 -0800)]
Rename cp_is_anonymous to cp_is_in_anonymous.

gdb/ChangeLog:

* cp-support.h (cp_is_in_anonymous): Renamed from cp_is_anonymous.
All callers updated.  Rename arg "namespace" to "symbol_name".

9 years agoGive quick_symbol_functions "methods" a consistent naming scheme.
Doug Evans [Sat, 13 Dec 2014 06:27:23 +0000 (22:27 -0800)]
Give quick_symbol_functions "methods" a consistent naming scheme.
Add missing function comments.

gdb/ChangeLog:

* psymtab.c (psym_map_symtabs_matching_filename): Renamed from
partial_map_symtabs_matching_filename.  All uses updated.
(psym_find_pc_sect_compunit_symtab): Renamed from
find_pc_sect_compunit_symtab_from_partial.  All uses updated.
Add function comment.
(psym_lookup_symbol): Renamed from lookup_symbol_aux_psymtabs.
All uses updated.  Add function comment.
(psym_relocate): Renamed from relocate_psymtabs.  All uses updated.
Add function comment.
(psym_find_last_source_symtab): Renamed from
find_last_source_symtab_from_partial.  All uses updated.
Add function comment.
(psym_forget_cached_source_info): Renamed from
forget_cached_source_info_partial.  All uses updated.
Add function comment.
(psym_print_stats): Renamed from print_psymtab_stats_for_objfile.
All uses updated.  Add function comment.
(psym_dump): Renamed from dump_psymtabs_for_objfile.  All uses
updated.  Add function comment.
(psym_expand_symtabs_for_function): Renamed from
read_symtabs_for_function.  All uses updated.  Update function comment.
(psym_expand_all_symtabs): Renamed from expand_partial_symbol_tables.
All uses updated.  Add function comment.
(psym_expand_symtabs_with_fullname): Renamed from
read_psymtabs_with_fullname.  All uses updated.  Add function comment.
(psym_map_symbol_filenames): Renamed from map_symbol_filenames_psymtab.
All uses updated.  Add function comment.
(psym_map_matching_symbols): Renamed from map_matching_symbols_psymtab.
All uses updated.
(psym_expand_symtabs_matching): Renamed from
expand_symtabs_matching_via_partial.  All uses updated.
Add function comment.
(psym_has_symbols): Renamed from objfile_has_psyms.  All uses updated.
Add function comment.

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 13 Dec 2014 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agothe "compile" command
Tom Tromey [Wed, 14 May 2014 20:35:45 +0000 (14:35 -0600)]
the "compile" command

This final patch adds the new "compile" command and subcommands, and
all the machinery needed to make it work.

A shared library supplied by gcc is used for all communications with
gcc.  Types and most aspects of symbols are provided directly by gdb
to the compiler using this library.

gdb provides some information about the user's code using plain text.
Macros are emitted this way, and DWARF location expressions (and
bounds for VLA) are compiled to C code.

This hybrid approach was taken because, on the one hand, it is better
to provide global declarations and such on demand; but on the other
hand, for local variables, translating DWARF location expressions to C
was much simpler than exporting a full compiler API to gdb -- the same
result, only easier to implement, understand, and debug.

In the ordinary mode, the user's expression is wrapped in a dummy
function.  After compilation, gdb inserts the resulting object code
into the inferior, then calls this function.

Access to local variables is provided by noting which registers are
used by location expressions, and passing a structure of register
values into the function.  Writes to registers are supported by
copying out these values after the function returns.

This approach was taken so that we could eventually implement other
more interesting features based on this same infrastructure; for
example, we're planning to investigate inferior-side breakpoint
conditions.

gdb/ChangeLog
2014-12-12  Phil Muldoon  <pmuldoon@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>
    Tom Tromey  <tromey@redhat.com>

* NEWS: Update.
* symtab.h (struct symbol_computed_ops) <generate_c_location>: New
field.
* p-lang.c (pascal_language_defn): Update.
* opencl-lang.c (opencl_language_defn): Update.
* objc-lang.c (objc_language_defn): Update.
* m2-lang.c (m2_language_defn): Update.
* language.h (struct language_defn) <la_get_compile_instance,
la_compute_program>: New fields.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Update.
* jv-lang.c (java_language_defn): Update.
* go-lang.c (go_language_defn): Update.
* f-lang.c (f_language_defn): Update.
* dwarf2loc.h (dwarf2_compile_property_to_c): Declare.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): New
functions.
(dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update.
* defs.h (enum compile_i_scope_types): New.
(enum command_control_type) <compile_control>: New constant.
(struct command_line) <control_u>: New field.
* d-lang.c (d_language_defn): Update.
* compile/compile.c: New file.
* compile/compile-c-support.c: New file.
* compile/compile-c-symbols.c: New file.
* compile/compile-c-types.c: New file.
* compile/compile.h: New file.
* compile/compile-internal.h: New file.
* compile/compile-loc2c.c: New file.
* compile/compile-object-load.c: New file.
* compile/compile-object-load.h: New file.
* compile/compile-object-run.c: New file.
* compile/compile-object-run.h: New file.
* cli/cli-script.c (multi_line_command_p, print_command_lines)
(execute_control_command, process_next_line)
(recurse_read_control_structure): Handle compile_control.
* c-lang.h (c_get_compile_context, c_compute_program): Declare.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Update.
* ada-lang.c (ada_language_defn): Update.
* Makefile.in (SUBDIR_GCC_COMPILE_OBS, SUBDIR_GCC_COMPILE_SRCS):
New variables.
(SFILES): Add SUBDIR_GCC_COMPILE_SRCS.
(HFILES_NO_SRCDIR): Add compile.h.
(COMMON_OBS): Add SUBDIR_GCC_COMPILE_OBS.
(INIT_FILES): Add SUBDIR_GCC_COMPILE_SRCS.
(compile.o, compile-c-types.o, compile-c-symbols.o)
(compile-object-load.o, compile-object-run.o, compile-loc2c.o)
(compile-c-support.o): New targets.

gdb/doc/ChangeLog
2014-12-12  Phil Muldoon  <pmuldoon@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.texinfo (Altering): Update.
(Compiling and Injecting Code): New node.

gdb/testsuite/ChangeLog
2014-12-12  Phil Muldoon  <pmuldoon@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>
    Tom Tromey  <tromey@redhat.com>

* configure.ac: Add gdb.compile/.
* configure: Regenerate.
* gdb.compile/Makefile.in: New file.
* gdb.compile/compile-ops.exp: New file.
* gdb.compile/compile-ops.c: New file.
* gdb.compile/compile-tls.c: New file.
* gdb.compile/compile-tls.exp: New file.
* gdb.compile/compile-constvar.S: New file.
* gdb.compile/compile-constvar.c: New file.
* gdb.compile/compile-mod.c: New file.
* gdb.compile/compile-nodebug.c: New file.
* gdb.compile/compile-setjmp-mod.c: New file.
* gdb.compile/compile-setjmp.c: New file.
* gdb.compile/compile-setjmp.exp: New file.
* gdb.compile/compile-shlib.c: New file.
* gdb.compile/compile.c: New file.
* gdb.compile/compile.exp: New file.
* lib/gdb.exp (skip_compile_feature_tests): New proc.

9 years agoadd s390_gcc_target_options
Jan Kratochvil [Wed, 14 May 2014 20:33:41 +0000 (14:33 -0600)]
add s390_gcc_target_options

This adds s390_gcc_target_options, an implementation of the new
"gcc_target_options" gdbarch method.  This was needed because the
default implementation of the method doesn't work properly for S390,
as this architecture needs "-m31" rather than "-m32".

gdb/ChangeLog
2014-12-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

* s390-linux-tdep.c (s390_gcc_target_options): New function.
(s390_gdbarch_init): Add it to gdbarch.

9 years agoadd linux_infcall_mmap
Jan Kratochvil [Wed, 14 May 2014 20:32:09 +0000 (14:32 -0600)]
add linux_infcall_mmap

This implements the new gdbarch "infcall_mmap" method for Linux.

gdb/ChangeLog
2014-12-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

* linux-tdep.c: Include objfiles.h and infcall.h.
(GDB_MMAP_MAP_PRIVATE, GDB_MMAP_MAP_ANONYMOUS, linux_infcall_mmap): New
function.
(linux_init_abi): Add linux_infcall_mmap to gdbarch.

9 years agoexport dwarf2_reg_to_regnum_or_error
Jan Kratochvil [Wed, 14 May 2014 20:30:37 +0000 (14:30 -0600)]
export dwarf2_reg_to_regnum_or_error

This exports a utility function, dwarf2_reg_to_regnum_or_error, that
was previously private to dwarf2loc.c.

gdb/ChangeLog
2014-12-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2loc.h (dwarf2_reg_to_regnum_or_error): Declare.
* dwarf2loc.c (dwarf2_reg_to_regnum_or_error): Rename from
translate_register.  Now public.
(dwarf2_compile_expr_to_ax): Update.

9 years agomake dwarf_expr_frame_base_1 public
Tom Tromey [Wed, 14 May 2014 20:28:58 +0000 (14:28 -0600)]
make dwarf_expr_frame_base_1 public

This exports dwarf_expr_frame_base_1 so that other code can use it.

gdb/ChangeLog
2014-12-12  Tom Tromey  <tromey@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2loc.c (dwarf_expr_frame_base_1): Remove declaration.
(dwarf_expr_frame_base): Update caller.
(dwarf_expr_frame_base_1): Rename to ...
(func_get_frame_base_dwarf_block): ... this and make it public.
(dwarf2_compile_expr_to_ax, locexpr_describe_location_piece): Update
callers.
* dwarf2loc.h (func_get_frame_base_dwarf_block): New declaration.