binutils-gdb.git
9 years agoUse dynamic text relocs for protected vars
Alan Modra [Mon, 23 Feb 2015 06:15:05 +0000 (16:45 +1030)]
Use dynamic text relocs for protected vars

Rather than reporting a link error on attempting to use dynbss for
protected vars, use dynamic text relocs.

* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Heed -z nocopyreloc.
Use text relocs rather than giving an error on trying to use
.dynbss for protected shared lib vars.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 26 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoobjcopy: Factor out some of the option parsing code.
Andrew Burgess [Fri, 20 Feb 2015 20:12:56 +0000 (20:12 +0000)]
objcopy: Factor out some of the option parsing code.

This patch splits out some of the option parsing code, increasing code
reuse.

binutils/ChangeLog:

* objcopy.c (init_section_add): New function.
(section_add_load_file): New function.
(copy_main): Make use of new functions.

9 years agoAVR/ld: Use .avr.prop data during linker relaxation.
Andrew Burgess [Thu, 8 Jan 2015 22:07:48 +0000 (22:07 +0000)]
AVR/ld: Use .avr.prop data during linker relaxation.

Make use of the data held within the .avr.prop section during linker
relaxation in order to maintain the properties of the .org and .align
directives.

In relation to the .align directives, if enough bytes are deleted before
a .align directive then the alignment can be moved while still
maintaining the alignment requirement.

bfd/ChangeLog:

* elf32-avr.c (struct elf_avr_section_data): New structure.
(struct avr_relax_info): New structure.
(elf_avr_new_section_hook): New function.
(struct elf_avr_section_data): Add relax_info.
(get_avr_relax_info): New function.
(init_avr_relax_info): New function.
(elf32_avr_relax_delete_bytes): Find next property record before
deleting bytes.  When deleting don't move bytes beyond the next
property record.
(avr_elf32_assign_records_to_section): New function.
(avr_property_record_compare): New function.
(avr_load_all_property_sections): New function.
(elf32_avr_relax_section): Load property data.  After relaxing the
section, move any .align directives that have enough deleted bytes
before them.
(bfd_elf32_new_section_hook): Define.

ld/testsuite/ChangeLog:

* ld-avr/avr-prop-1.d: New file.
* ld-avr/avr-prop-1.s: New file.
* ld-avr/avr-prop-2.d: New file.
* ld-avr/avr-prop-2.s: New file.
* ld-avr/avr-prop-3.d: New file.
* ld-avr/avr-prop-3.s: New file.
* ld-avr/avr-prop-4.d: New file.
* ld-avr/avr-prop-4.s: New file.

9 years agoavr/objdump: Support dumping .avr.prop section.
Andrew Burgess [Thu, 8 Jan 2015 21:55:43 +0000 (21:55 +0000)]
avr/objdump: Support dumping .avr.prop section.

Add support to objdump for dumping the .avr.prop section in a structured
way.

binutils/ChangeLog:

* od-elf32_avr.c: Add elf32-avr.h include.
(OPT_AVRPROP): Define.
(options[]): Add 'avr-prop' entry.
(elf32_avr_help): Add avr-prop help text.
(elf32_avr_dump_avr_prop): New function.
(elf32_avr_dump): Add check for avr-prop.

bfd/ChangeLog:

* elf32-avr.h (struct avr_property_header): New strucure.
(avr_elf32_load_property_records): Declare.
(avr_elf32_property_record_name): Declare.
* elf32-avr.c: Add bfd_stdint.h include.
(retrieve_local_syms): New function.
(get_elf_r_symndx_section): New function.
(get_elf_r_symndx_offset): New function.
(internal_reloc_compare): New function.
(struct avr_find_section_data): New structure.
(avr_is_section_for_address): New function.
(avr_find_section_for_address): New function.
(avr_elf32_load_records_from_section): New function.
(avr_elf32_load_property_records): New function.
(avr_elf32_property_record_name): New function.

gas/testsuite/ChangeLog:

* gas/avr/avr-prop-1.d: New file.
* gas/avr/avr-prop-1.s: New file.

9 years agoavr/gas: Write out data to track .org/.align usage.
Andrew Burgess [Thu, 8 Jan 2015 20:55:10 +0000 (20:55 +0000)]
avr/gas: Write out data to track .org/.align usage.

Adds support to the assembler to write out data for tracking the use of
.org and .align directives.  This data is collected within the assembler
and written out to a section ".avr.prop" (if there's anything to write
out).

This patch does not add any tests.  The next patch in this series will
add a better mechanism for visualising the contents of .avr.prop which
will make writing tests much easier.

This patch also does not make any use of this collected data, that will
also come along in a later patch; the intended consumer is the linker,
during linker relaxation this information will be used to ensure that
the .org and .align directives are honoured.

bfd/ChangeLog:

* elf32-avr.h (AVR_PROPERTY_RECORD_SECTION_NAME): Define.
(AVR_PROPERTY_RECORDS_VERSION): Define.
(AVR_PROPERTY_SECTION_HEADER_SIZE): Define.
(struct avr_property_record): New structure.

gas/ChangeLog:

* config/tc-avr.c: Add elf32-avr.h include.
(struct avr_property_record_link): New structure.
(avr_output_property_section_header): New function.
(avr_record_size): New function.
(avr_output_property_record): New function.
(avr_create_property_section): New function.
(avr_handle_align): New function.
(exclude_section_from_property_tables): New function.
(create_record_for_frag): New function.
(append_records_for_section): New function.
(avr_create_and_fill_property_section): New function.
(avr_post_relax_hook): New function.
* config/tc-avr.h (md_post_relax_hook): Define.
(avr_post_relax_hook): Declare.
(HANDLE_ALIGN): Define.
(avr_handle_align): Declare.
(strut avr_frag_data): New structure.
(TC_FRAG_TYPE): Define.

9 years ago[SH] Fix clrs, sets, pref insn arch memberships.
Oleg Endo [Wed, 25 Feb 2015 20:22:54 +0000 (21:22 +0100)]
[SH] Fix clrs, sets, pref insn arch memberships.

opcodes/
* sh-opc.h (clrs, sets): Mark as arch_sh3_nommu_up instead of
arch_sh_up.
(pref): Mark as arch_sh2a_nofpu_or_sh3_nommu_up instead of
arch_sh2a_nofpu_or_sh4_nommu_nofpu_up.

gas/testsuite/
* gas/sh/arch/arch.exp: Replace dead code to generate expected .s files
with ...
* gas/sh/arch/sh-opc-gen-as.pl: ... this new script.
* gas/sh/arch/arch_expected.txt: Regenerate.
* gas/sh/arch/sh-dsp.s: Likewise.
* gas/sh/arch/sh-opc-gen-as.pl: Likewise.
* gas/sh/arch/sh.s: Likewise.
* gas/sh/arch/sh2.s: Likewise.
* gas/sh/arch/sh2a-nofpu-or-sh3-nommu.s: Likewise.
* gas/sh/arch/sh2a-nofpu-or-sh4-nommu-nofpu.s: Likewise.
* gas/sh/arch/sh2a-nofpu.s: Likewise.
* gas/sh/arch/sh2a-or-sh3e.s: Likewise.
* gas/sh/arch/sh2a-or-sh4.s: Likewise.
* gas/sh/arch/sh2a.s: Likewise.
* gas/sh/arch/sh2e.s: Likewise.
* gas/sh/arch/sh3-dsp.s: Likewise.
* gas/sh/arch/sh3-nommu.s: Likewise.
* gas/sh/arch/sh3.s: Likewise.
* gas/sh/arch/sh3e.s: Likewise.
* gas/sh/arch/sh4-nofpu.s: Likewise.
* gas/sh/arch/sh4-nommu-nofpu.s: Likewise.
* gas/sh/arch/sh4.s: Likewise.
* gas/sh/arch/sh4a-nofpu.s: Likewise.
* gas/sh/arch/sh4a.s: Likewise.
* gas/sh/arch/sh4al-dsp.s: Likewise.

ld/testsuite/
* ld-sh/arch/arch_expected.txt: Regenerate.
* ld-sh/arch/sh-dsp.s: Likewise.
* ld-sh/arch/sh.s: Likewise.
* ld-sh/arch/sh2.s: Likewise.
* ld-sh/arch/sh2a-nofpu-or-sh3-nommu.s: Likewise.
* ld-sh/arch/sh2a-nofpu-or-sh4-nommu-nofpu.s: Likewise.
* ld-sh/arch/sh2a-nofpu.s: Likewise.
* ld-sh/arch/sh2a-or-sh3e.s: Likewise.
* ld-sh/arch/sh2a-or-sh4.s: Likewise.
* ld-sh/arch/sh2a.s: Likewise.
* ld-sh/arch/sh2e.s: Likewise.
* ld-sh/arch/sh3-dsp.s: Likewise.
* ld-sh/arch/sh3-nommu.s: Likewise.
* ld-sh/arch/sh3.s: Likewise.
* ld-sh/arch/sh3e.s: Likewise.
* ld-sh/arch/sh4-nofpu.s: Likewise.
* ld-sh/arch/sh4-nommu-nofpu.s: Likewise.
* ld-sh/arch/sh4.s: Likewise.
* ld-sh/arch/sh4a-nofpu.s: Likewise.
* ld-sh/arch/sh4a.s: Likewise.
* ld-sh/arch/sh4al-dsp.s: Likewise.

9 years ago[gas][ARM] Document supported ARMv8 cores.
Kyrylo Tkachov [Wed, 25 Feb 2015 13:40:08 +0000 (13:40 +0000)]
[gas][ARM] Document supported ARMv8 cores.

2015-02-25  Matthew Wahab  <matthew.wahab@arm.com>

* doc/c-arm.texi (-mcpu=): Add cortex-a53, cortex-a57 and
cortex-a72.

9 years ago[aarch64] Fix one fail in gdb.xml/tdesc-regs.exp
Yao Qi [Wed, 25 Feb 2015 10:39:59 +0000 (10:39 +0000)]
[aarch64] Fix one fail in gdb.xml/tdesc-regs.exp

Hi,
I see the following fail in aarch64-linux-gnu testing...

(gdb) set tdesc file /XXX/gdb/testsuite/gdb.xml/single-reg.xml^M
warning: Architecture rejected target-supplied description^M
(gdb) FAIL: gdb.xml/tdesc-regs.exp: set tdesc file single-reg.xml

core-regs isn't set for aarch64 target, and looks it is an oversight
when aarch64 port was added.

gdb/testsuite:

2015-02-25  Yao Qi  <yao.qi@linaro.org>

* gdb.xml/tdesc-regs.exp: Set core-regs to aarch64-core.xml for
aarch64*-*-* target.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 25 Feb 2015 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoAdds support for emulating V850 e3v5 instructions to the simulator.
Nick Clifton [Tue, 24 Feb 2015 17:58:50 +0000 (17:58 +0000)]
Adds support for emulating V850 e3v5 instructions to the simulator.

* v850.igen: Add more e3v5 support.
(FMAF.S): New pattern.
(FMSF.S): New pattern.
(FNMAF.S): New pattern.
(FNMSF.S): New pattern.
(cnvq15q30): New pattern.
(cnvq30q15): New pattern.
(cnvq31q62): New pattern.
(cnvq62q31): New pattern.
(dup.h): New pattern.
(dup.w): New pattern.
(expq31): New pattern.
(modadd): New pattern.
(mov.dw): New pattern.
(mov.h): New pattern.
(mov.w): New pattern.
(pki16i32): New pattern.
(pki16ui8): New pattern.
(pki32i16): New pattern.
(pki64i32): New pattern.
(pkq15q31): New pattern.
(pkq30q31): New pattern.
(pkq31q15): New pattern.
(pkui8i16): New pattern.
(vabs.h): New pattern.
(vabs.w): New pattern.
(vadd.dw): New placeholder pattern.
(vadd.h): New placeholder pattern.
(vadd.w): New placeholder pattern.
(vadds.h): New placeholder pattern.
(vadds.w): New placeholder pattern.
(vaddsat.h): New placeholder pattern.
(vaddsat.w): New placeholder pattern.
(vand): New pattern.
(vbiq.h): New placeholder pattern.
(vbswap.dw): New placeholder pattern.
(vbswap.h): New placeholder pattern.
(vbswap.w): New placeholder pattern.
(vcalc.h): New placeholder pattern.
(vcalc.w): New placeholder pattern.
(vcmov): New placeholder pattern.

9 years agoAdds support for generating notes in V850 binaries.
Nick Clifton [Tue, 24 Feb 2015 17:54:09 +0000 (17:54 +0000)]
Adds support for generating notes in V850 binaries.

bfd * elf32-v850.c (v850_set_note): New function.  Creates a Renesas
style note entry.
(v850_elf_make_note_section): New function.  Creates a note
section.
(v850_elf_create_sections): New function.  Create a note section
if one is not already present.
(v850_elf_set_note): New function.  Adds a note to a bfd.
(v850_elf_copy_private_bfd_data): New function.  Copies V850
notes.
(v850_elf_merge_notes): New function.  Merges V850 notes.
(print_v850_note): New function.  Displays a V850 note.
(v850_elf_print_notes): New function. Displays all notes attached
to a bfd.
(v850_elf_merge_private_bfd_data): Call v850_elf_merge_notes.
(v850_elf_print_private_bfd_data): Call v850_elf_print_notes.
(v850_elf_fake_sections): Set the type of the V850 note section.
* bfd-in.h (v850_elf_create_sections): Add prototype.
(v850_elf_set_note): Add prototype.
* bfd-in2.h: Regenerate.

binutils* readelf.c (get_machine_flags): Remove deprecated V850 machine
flags.
(get_v850_section_type_name): New function.  Handles V850 special
sections.
(get_section_type_name): Add support for V850.
(get_v850_elf_note_type): New function.  Returns the name of a
V850 note.
(print_v850_note): New function.  Prints a V850 note.
(process_v850_notes): New function.  Prints V850 notes.
(process_note_sections): Add support for V850.

binutils/testsute
* binutils-all/objcopy.exp: Skip the strip-10 test for the V850.

gas * config/tc-v850.c (soft_float): New variable.
(v850_data_8): New variable.
(md_show_usage): Add -msoft-float/-mhard-float.
(md_parse_option): Likewise.
(md_begin): Set the default value of soft_float.
(v850_md_end): New function.  Creates a note section.
* config/tc-v850.h (md_end): Define.
* doc/c-v850.texi: Document -msoft-float/-mhard-float.

gas/testsuite
* gas/elf/elf.exp: Add special version of the section2 test for
the V850.
* gas/elf/section2.e-v850: New file.

include/elf
* v850.h (EF_RH850_SIMD): Delete deprecated flag.
(EF_RH850_CACHE): Likewise.
(EF_RH850_MMU): Likewise.
(EF_RH850_DATA_ALIGN8): Likewise.
(SHT_RENESAS_IOP): Fix typo in name.
(SHT_RENESAS_INFO): Define.
(V850_NOTE_SECNAME): Define.
(SIZEOF_V850_NOTE): Define.
(V850_NOTE_NAME): Define.
(enum v850_notes): New enum.
(NUM_V850_NOTES): Define.

ld/ChangeLog
2015-02-24  Nick Clifton  <nickc@redhat.com>

* Makefile.am (ev850.c): Add dependency upon
$(srcdir)/emultempl/v850elf.em.
(ev850_rh850.c): Likewise.
* Makefile.in: Regenerate.
* emultempl/v850elf.em: New file.
* emulparams/v850.sh (EXTRA_EM_FILE): Define.
* emulparams/v850_rh850.sh (EXTRA_EM_FILE): Define.
* scripttempl/v850.sc: Add .note.renesas section.
* scripttempl/v850_rh850.sc: Likewise.

ld/testsuite
* ld-elf/extract-symbol-1sec.d: Expect to fail on the V850.

9 years agoFixes compiling peXXigen under MAC OS/X where the wcsncasecmp function is not available.
Nick Clifton [Tue, 24 Feb 2015 17:01:23 +0000 (17:01 +0000)]
Fixes compiling peXXigen under MAC OS/X where the wcsncasecmp function is not available.

* configure.ac (AC_CHECK_HEADERS): Add wctype.h.
* configure: Regenerate.
* config.in: Regenerate.
* peXXigen.c: Include wctype.h if HAVE_WCTYPE_H is defined.
(u16_mbtowc): Use wint_t types if HAVE_WCTYPE_H is defined.
(rsrc_cmp): Use towlower instead of wcsncasecmp if HAVE_WCTYPE_H
is defined.

9 years agoreadelf: handle corrupted chains better
Mike Frysinger [Tue, 24 Feb 2015 06:47:51 +0000 (01:47 -0500)]
readelf: handle corrupted chains better

The current chain walker tries to protect itself against loops, by only
works with loops of length 1: a chain that points to itself.  If you have
a chain longer than that (3->4->3->4->...), readelf will still hang.

Since we know the max length of the chain, simply abort when we've walked
more times than that.  The only way that could have happened is if there
was a loop.

9 years agoAdd aligned string merge test
Alan Modra [Tue, 24 Feb 2015 12:34:20 +0000 (23:04 +1030)]
Add aligned string merge test

* ld-elf/merge3.s, * ld-elf/merge3.d: New test.

9 years agoSpeed up the display of unwind tables by using a binary chop search to locate functio...
Dmitry Antipov [Tue, 24 Feb 2015 13:21:10 +0000 (13:21 +0000)]
Speed up the display of unwind tables by using a binary chop search to locate function symbols.

* readelf.c (find_symbol_for_address): Use a binary search to
speed up symbol location.  Skip check for function symbol type.
(*_unw_aux_info): Add funtab and nfuns fields contains a sorted
list of function symbols.
(dump_ia64_unwind): Initialise the funtab and nfuns fields and
pass them to find_symbol_for_address.
(dump_hppa_unwind): Likewise.
(arm_print_vma_and_name): Pass funtab to find_symbol_for_address.
(dump_arm_unwind): Initialise the funtab and nfuns fields.

9 years agoThis patch modifies the AVR linker script templates to use __<name>_REGION_LENGTH__...
Senthil Kumar Selvaraj [Tue, 24 Feb 2015 11:26:28 +0000 (11:26 +0000)]
This patch modifies the AVR linker script templates to use __<name>_REGION_LENGTH__ symbols, if provided, for setting memory region lengths, defaulting to the current constant values otherwise.

ld * scripttempl/avr.sc: Add new user_signatures region. Define and Use
symbols for all region lengths.
* scripttempl/avrtiny.sc: Define and use symbols for all region lengths.

testsuite * ld-avr/region_overflow.d: New test.
* ld-avr/region_overflow.s: Likewise.

9 years agoImproves the warning message produyced by objdump when it cannot load a section.
Nick Clifton [Tue, 24 Feb 2015 11:10:07 +0000 (11:10 +0000)]
Improves the warning message produyced by objdump when it cannot load a section.

* objdump.c (dump_section): Extend the warning message displayed
when a section cannot be loaded.

9 years agoFix the detection of illegal memory accesses in the MSP430 simulator.
Nick Clifton [Tue, 24 Feb 2015 10:27:07 +0000 (10:27 +0000)]
Fix the detection of illegal memory accesses in the MSP430 simulator.

* msp430-sim.c (sim_open): Allocate memory regions matching those
declared in the libgloss/msp430 linker scripts.
Allow sim_load_file to fail.
(get_op): Test the correct address bit when checking for out of
range addresses.
Include the address in the error message when an illegal access to
the hardware multiplier is detected.
(put_op): Test the correct address bit when checking for out of
range addresses.

9 years agoFix the gas test align2 for the PDP11 by ensuring that the .text and .data sections...
Nick Clifton [Tue, 24 Feb 2015 10:13:51 +0000 (10:13 +0000)]
Fix the gas test align2 for the PDP11 by ensuring that the .text and .data sections are written to their aligned sizes.

* pdp11.c (set_section_contents): Pad the .text and .data sections
to their aligned sizes.

9 years agoPowerPC64 GOLD: complain on misaligned _DS relocs
Alan Modra [Tue, 24 Feb 2015 07:46:26 +0000 (18:16 +1030)]
PowerPC64 GOLD: complain on misaligned _DS relocs

PR 18010
* powerpc.cc (Powerpc_relocate_functions::addr16_ds): Always
complain if value is not a multiple of four.
(Target_powerpc::Relocate::relocate): Correct handling of
R_POWERPC_GOT_TPREL16 and R_POWERPC_GOT_TPREL16_LO for ppc64.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 24 Feb 2015 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix typo in earlier entry.
Doug Evans [Mon, 23 Feb 2015 21:39:45 +0000 (13:39 -0800)]
Fix typo in earlier entry.

9 years agoPR gdb/18008: Fix typo in documentation
Sergio Durigan Junior [Mon, 23 Feb 2015 21:15:29 +0000 (16:15 -0500)]
PR gdb/18008: Fix typo in documentation

This obvious patch fixes a typo in our documentation
(s/problam/problem).

gdb/doc/ChangeLog:
2015-02-23  Sergio Durigan Junior  <sergiodj@redhat.com>

PR gdb/18008
* gdb.texinfo (maint internal-error, maint internal-warning, maint
demangler-warning): Fix typo ("problam").

9 years agogdbserver: redo stepping over breakpoint that was on top of a permanent breakpoint
Pedro Alves [Mon, 23 Feb 2015 18:59:38 +0000 (18:59 +0000)]
gdbserver: redo stepping over breakpoint that was on top of a permanent breakpoint

I'm going to add an alternate mechanism of breakpoint trap
identification to 'check_stopped_by_breakpoint' that does not rely on
checking the instruction at PC.  The mechanism currently used to tell
whether we're stepping over a permanent breakpoint doesn't fit in that
new method.  This patch redoes the whole logic in a different way that
works with both old and new methods, in essence moving the "stepped
permanent breakpoint" detection "one level up".  It makes lower level
check_stopped_by_breakpoint always the adjust the PC, and then has
linux_wait_1 advance the PC past the breakpoint if necessary.  This
ends up being better also because this now handles
non-decr_pc_after_break targets too.  Before, such targets would get
stuck forever reexecuting the breakpoint instruction.

Tested on x86_64 Fedora 20.

gdb/gdbserver/ChangeLog:
2015-02-23  Pedro Alves  <palves@redhat.com>

* linux-low.c (check_stopped_by_breakpoint): Don't check if the
thread was doing a step-over; always adjust the PC if
we stepped over a permanent breakpoint.
(linux_wait_1): If we stepped over breakpoint that was on top of a
permanent breakpoint, manually advance the PC past it.

9 years agodelete_breakpoints: Rewrite using gdb_test_multiple
Pedro Alves [Mon, 23 Feb 2015 17:35:09 +0000 (17:35 +0000)]
delete_breakpoints: Rewrite using gdb_test_multiple

Because delete_breakpoints uses gdb_expect directly, an internal error
results in slow timeouts instead of quickly bailing out.  This patch
rewrites the procedure to use gdb_test_multiple instead, while
preserving the existing general logic ("delete breakpoints" + "info
breakpoints").

gdb/testsuite/
2015-02-23  Pedro Alves  <palves@redhat.com>

* lib/gdb.exp (delete_breakpoints): Rewrite using
gdb_test_multiple.

9 years agoAdds a space between the operands of the RL78's MOV instruction for consistency with...
Vinay [Mon, 23 Feb 2015 17:16:30 +0000 (17:16 +0000)]
Adds a space between the operands of the RL78's MOV instruction for consistency with the disassembling of other instructions.

* rl78-decode.opc (MOV): Added space between two operands for
'mov' instruction in index addressing mode.
* rl78-decode.c: Regenerate.

9 years agoAdd support for the h8300-linux target.
Yoshinori Sato [Mon, 23 Feb 2015 17:04:53 +0000 (17:04 +0000)]
Add support for the h8300-linux target.

ld * Makefile.am: (ALL_EMULATION_SOURCES): Add new emulations.
* Makefile.in: Regenerate.
* configure.tgt: Add h8300-*-linux
* emulparams/h8300elf_linux.sh: Add new emulation.
* emulparams/h8300helf_linux.sh: Likewise.
* emulparams/h8300self_linux.sh: Likewise.
* emulparams/h8300sxelf_linux.sh: Likewise.

bfd * config.bfd: Add h8300-*-linux.
* configure.ac: Add h8300_elf32_linux_vec.
* configure: Regenerate.
* elf32-h8300.c: Likewise.
* targets.c(_bfd_target_vector): Likewise.

gas * config/tc-h8300.c (line_separater_chars): Add a version for
h8300-linux that includes a separator.
(default_mach): New variable.
(md_main): Use it.
(md_longopts): Add '--march' option.
(md_parse_option): Parse the new option.
* config/tc-h8300.h (TARGET_FORMAT): Add elf32-h8300-linux.
* configure.tgt: Add h8300-*-linux
* doc/c-h8300.texi: Document --march.

9 years agoremote.c: simplify parsing stop reasons in T stop replies
Pedro Alves [Mon, 23 Feb 2015 16:45:39 +0000 (16:45 +0000)]
remote.c: simplify parsing stop reasons in T stop replies

We need to be careful with parsing optional stop reasons that start
with an hex character ("awatch", "core"), as GDBs that aren't aware of
them parse them as real numbers.  That's silly of course, given that
there should be a colon after those magic "numbers".  So if strtol on
"abbz:" doesn't return "first invalid char" pointing to the colon, we
know that "abbz" isn't really a register number.  It must be optional
stop info we don't know about.  This adjusts GDB to work that way,
removing the need for the special casing done upfront:

  /* If this packet is an awatch packet, don't parse the 'a'
     as a register number.  */
  if (strncmp (p, "awatch", strlen("awatch")) != 0
      && strncmp (p, "core", strlen ("core") != 0))

For as long as we care about compatibility with GDB 7.9, we'll need to
continue to be careful about this, so I added a comment.

Tested on x86_64 Fedora 20, native gdbserver.

gdb/ChangeLog:
2015-02-23  Pedro Alves  <palves@redhat.com>

* remote.c (skip_to_semicolon): New function.
(remote_parse_stop_reply) <T stop reply>: Use it.  Don't
special case the stop reasons that look like hex numbers
upfront.  Instead handle real register numbers after matching
all the known stop reasons.

9 years agoFixes a problem where "ld -ixxx" would report an error of "ld: bad -rpath option".
Nick Clifton [Mon, 23 Feb 2015 15:33:56 +0000 (15:33 +0000)]
Fixes a problem where "ld -ixxx" would report an error of "ld: bad -rpath option".

* lexsup.c (parse_args): Produce a more reasonable error message
when -ixxx or -rxxx is the last option on the linker command line.

9 years agoFixes the generation of dwarf line debug information for the msp430, even in the...
Nick Clifton [Mon, 23 Feb 2015 14:53:02 +0000 (14:53 +0000)]
Fixes the generation of dwarf line debug information for the msp430, even in the presence of function sections and linker garbage collection.

PR 17940
* dwarf2dbg.c (out_header): When generating dwarf sections use
real symbols not temps for the start and end symbols.
* config/tc-msp430.h (TC_FORCE_RELOCATION_SUB_SAME): Also prevent
adjustments to relocations in debug sections.
(TC_LINKRELAX_FIXUP): Likewise.

* elf32-msp430.c (msp430_elf_relax_delete_bytes): Adjust debug
symbols at end of sections.  Adjust function sizes.

9 years agoFixes a typo in the license notice in include/elf/score.h
Nick Clifton [Mon, 23 Feb 2015 13:43:11 +0000 (13:43 +0000)]
Fixes a typo in the license notice in include/elf/score.h

PR 17915
* score.h: Fix typo in license header.

9 years agogdb.base/info-os.c: Include stdlib.h
Pedro Alves [Mon, 23 Feb 2015 14:03:48 +0000 (14:03 +0000)]
gdb.base/info-os.c: Include stdlib.h

Fixes:

 > gdb compile failed, /gdb/testsuite/gdb.base/info-os.c: In function 'main':
 > /gdb/testsuite/gdb.base/info-os.c:65:3: warning: implicit declaration of function 'atexit' [-Wimplicit-function-declaration]
 >    atexit (ipc_cleanup);
 >    ^
 > FAIL: gdb.base/info-os.exp: cannot compile test program

with recent GCCs.

gdb/testsuite/ChangeLog:
2015-02-23  Pedro Alves  <palves@redhat.com>

* gdb.base/info-os.c: Include stdlib.h.

9 years agoFixes a couple of typos in the license header of the cpu-w65.c file.
Nick Clifton [Mon, 23 Feb 2015 13:39:51 +0000 (13:39 +0000)]
Fixes a couple of typos in the license header of the cpu-w65.c file.

PR 17914
* cpu-w65.c: Correct typos in license notice.

9 years agogdbserver: 64-bit kernel / 32-inferior, syscall restarting
Pedro Alves [Mon, 23 Feb 2015 13:03:10 +0000 (13:03 +0000)]
gdbserver: 64-bit kernel / 32-inferior, syscall restarting

$ make check RUNTESTFLAGS="--target_board=native-gdbserver/-m32 clone-thread_db.exp"

gdb.log shows:

  Running target native-gdbserver/-m32
  ...
  clone-thread_db: src/gdb/testsuite/gdb.threads/clone-thread_db.c:57: thread_fn: Assertion `res != -1' failed.
  ...
  (gdb) FAIL: gdb.threads/clone-thread_db.exp: continue to end

That was waitpid returning -1 / EINTR.  We don't see that when testing
with unix/-m32 (native debugging).  Turns out to be that when
debugging a 32-bit inferior, a 64-bit GDBserver is reading/writing
$orig_eax from/to the wrong ptrace register buffer offset.  When
gdbserver is 64-bit, the ptrace register buffer is in 64-bit layout,
so the register is found at "ORIG_EAX * 8", not at "ORIG_EAX * 4".

Fixes these with --target_board=native-gdbserver/-m32 on x86_64 Fedora 20:

    -FAIL: gdb.threads/clone-thread_db.exp: continue to end
    +PASS: gdb.threads/clone-thread_db.exp: continue to end

    -FAIL: gdb.threads/hand-call-in-threads.exp: all dummies popped
    +PASS: gdb.threads/hand-call-in-threads.exp: all dummies popped
     PASS: gdb.threads/hand-call-in-threads.exp: breakpoint on all_threads_running
     PASS: gdb.threads/hand-call-in-threads.exp: breakpoint on hand_call
     PASS: gdb.threads/hand-call-in-threads.exp: disable scheduler locking
    @@ -29339,15 +29331,15 @@ PASS: gdb.threads/hand-call-in-threads.e
     PASS: gdb.threads/hand-call-in-threads.exp: discard hand call, thread 4
     PASS: gdb.threads/hand-call-in-threads.exp: discard hand call, thread 5
     PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 1
    -FAIL: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 2
    -FAIL: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 3
    -FAIL: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 4
    +PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 2
    +PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 3
    +PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 4
     PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 5
     PASS: gdb.threads/hand-call-in-threads.exp: enable scheduler locking
     PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 1
    -FAIL: gdb.threads/hand-call-in-threads.exp: hand call, thread 2
    -FAIL: gdb.threads/hand-call-in-threads.exp: hand call, thread 3
    -FAIL: gdb.threads/hand-call-in-threads.exp: hand call, thread 4
    +PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 2
    +PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 3
    +PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 4
     PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 5
     PASS: gdb.threads/hand-call-in-threads.exp: prepare to discard hand call, thread 1
     PASS: gdb.threads/hand-call-in-threads.exp: prepare to discard hand call, thread 2

gdb/gdbserver/ChangeLog
2015-02-23  Pedro Alves  <palves@redhat.com>

* linux-x86-low.c (REGSIZE): Define in both 32-bit and 64-bit
modes.
(x86_fill_gregset, x86_store_gregset): Use it when handling
$orig_eax.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 23 Feb 2015 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agosim/erc32: Use readline.h for readline types and functions.
Jiri Gaisler [Thu, 19 Feb 2015 22:31:34 +0000 (23:31 +0100)]
sim/erc32: Use readline.h for readline types and functions.

Use gdb's readline.h for readline types.

9 years agoSet GOLD_DEFAULT_SIZE to 32 for x32
H.J. Lu [Sun, 22 Feb 2015 13:18:50 +0000 (05:18 -0800)]
Set GOLD_DEFAULT_SIZE to 32 for x32

* configure.ac (default_size): Set to 32 for x32.
* configure: Regenerated.

9 years agotestcase for PR symtab/17855
Doug Evans [Sun, 22 Feb 2015 17:11:55 +0000 (09:11 -0800)]
testcase for PR symtab/17855

gdb/testsuite/ChangeLog:

PR symtab/17855
* gdb.ada/exec_changed.exp: Add second test where symbol lookup cache
is read after symbols have been re-read.
* gdb.ada/exec_changed/first.adb (First): New procedure Break_Me.
* gdb.ada/exec_changed/second.adb (Second): Ditto.

9 years agoPR c++/17976, symtab/17821
Doug Evans [Sun, 22 Feb 2015 05:58:31 +0000 (21:58 -0800)]
PR c++/17976, symtab/17821

This patch addresses two issues.

The basic problem is that "(anonymous namespace)" doesn't get entered
into the symbol table because when dwarf2read.c:new_symbol_full is called
the DIE has no name (dwarf2_name returns NULL).

PR 17976: ptype '(anonymous namespace)' should work like any namespace

PR 17821: perf issue looking up (anonymous namespace)

bash$ gdb monster-program
(gdb) mt set per on
(gdb) mt set symbol-cache-size 0
(gdb) break (anonymous namespace)::foo

Before:

Command execution time: 3.266289 (cpu), 6.169030 (wall)
Space used: 811429888 (+12910592 for this command)

After:

Command execution time: 1.264076 (cpu), 4.057408 (wall)
Space used: 798781440 (+0 for this command)

gdb/ChangeLog:

PR c++/17976, symtab/17821
* cp-namespace.c (cp_search_static_and_baseclasses): New parameter
is_in_anonymous.  All callers updated.
(find_symbol_in_baseclass): Ditto.
(cp_lookup_nested_symbol_1): Ditto.  Don't search all static blocks
for symbols in an anonymous namespace.
* dwarf2read.c (namespace_name): Don't call dwarf2_name, fetch
DW_AT_name directly.
(dwarf2_name): Convert missing namespace name to
CP_ANONYMOUS_NAMESPACE_STR.

gdeb/testsuite/ChangeLog:

* gdb.cp/anon-ns.exp: Add test for ptype '(anonymous namespace)'.

9 years agosim/erc32: File loading via command line did not work
Jiri Gaisler [Thu, 19 Feb 2015 22:31:25 +0000 (23:31 +0100)]
sim/erc32: File loading via command line did not work

* sis.c (main) load binary file from argv parameters

9 years agosim/erc32: Fix incorrect simulator performance report
Jiri Gaisler [Thu, 19 Feb 2015 22:31:24 +0000 (23:31 +0100)]
sim/erc32: Fix incorrect simulator performance report

9 years agosim/erc32: Remove unused defines in Makefile and switch off statistics
Jiri Gaisler [Thu, 19 Feb 2015 22:31:23 +0000 (23:31 +0100)]
sim/erc32: Remove unused defines in Makefile and switch off statistics

9 years agosim/erc32: Use fenv.h for host FPU access
Jiri Gaisler [Thu, 19 Feb 2015 22:31:22 +0000 (23:31 +0100)]
sim/erc32: Use fenv.h for host FPU access

9 years agosim/erc32: Perform pseudo-init if binary linked to non-zero address.
Jiri Gaisler [Thu, 19 Feb 2015 22:31:21 +0000 (23:31 +0100)]
sim/erc32: Perform pseudo-init if binary linked to non-zero address.

Binaries produced by most erc32 tool-chains do not include
system initialization. sis will detect this and initialize
necessary registers for memory and timer control.

9 years agosim/erc32: Corrected wrong CPU implementation and version ID in psr
Jiri Gaisler [Thu, 19 Feb 2015 22:31:20 +0000 (23:31 +0100)]
sim/erc32: Corrected wrong CPU implementation and version ID in psr

9 years agosim/erc32: Disassembly in stand-alone mode did not work.
Jiri Gaisler [Thu, 19 Feb 2015 22:31:19 +0000 (23:31 +0100)]
sim/erc32: Disassembly in stand-alone mode did not work.

The API to print_insn_sparc() has changed over the years ...

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 22 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agobinutils: readelf: add missing newline to warning message
Mike Frysinger [Sat, 21 Feb 2015 21:10:04 +0000 (16:10 -0500)]
binutils: readelf: add missing newline to warning message

9 years agoTestsuite patch for: i386: Fix internal error when prstatus in core file is too big
Jan Kratochvil [Sat, 21 Feb 2015 14:24:20 +0000 (15:24 +0100)]
Testsuite patch for: i386: Fix internal error when prstatus in core file is too big

gdb/testsuite/ChangeLog
2015-02-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

PR corefiles/17808
* gdb.arch/i386-biarch-core.core.bz2: New file.
* gdb.arch/i386-biarch-core.exp: New file.

9 years agogdb.threads/multi-create-ns-info-thr.exp and native-extended-remote board
Pedro Alves [Sat, 21 Feb 2015 12:03:23 +0000 (12:03 +0000)]
gdb.threads/multi-create-ns-info-thr.exp and native-extended-remote board

The buildbot shows that the new
gdb.threads/multi-create-ns-info-thr.exp test is timing out when
tested with --target=native-extended-remote.  The reason is:

 No breakpoints or watchpoints.
 (gdb) break main
 Breakpoint 1 at 0x10000b00: file ../../../binutils-gdb/gdb/testsuite/gdb.threads/multi-create.c, line 72.
 (gdb) run
 Starting program: /home/gdb-buildbot/fedora-21-ppc64be-1/fedora-ppc64be-native-extended-gdbserver/build/gdb/testsuite/outputs/gdb.threads/multi-create-ns-info-thr/multi-cre
 ate-ns-info-thr
 Process /home/gdb-buildbot/fedora-21-ppc64be-1/fedora-ppc64be-native-extended-gdbserver/build/gdb/testsuite/outputs/gdb.threads/multi-create-ns-info-thr/multi-create-ns-inf
 o-thr created; pid = 16266
 Unexpected vCont reply in non-stop mode: T0501:00003fffffffd190;40:00000080560fe290;thread:p3f8a.3f8a;core:0;
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 (gdb) break multi-create.c:45
 Breakpoint 2 at 0x10000994: file ../../../binutils-gdb/gdb/testsuite/gdb.threads/multi-create.c, line 45.
 (gdb) commands
 Type commands for breakpoint(s) 2, one per line.

Non-stop tests don't really work with the
--target_board=native-extended-remote board, because tests toggle
non-stop on after GDB is already connected to gdbserver, while
Currently, non-stop must be enabled before connecting.

This adjusts the test to bail if running to main fails, like all other
non-stop tests.

Note non-stop tests do work with --target_board=native-gdbserver.

gdb/testsuite/ChangeLog:
2015-02-21  Pedro Alves  <palves@redhat.com>

* gdb.threads/multi-create-ns-info-thr.exp: Return early if
runto_main fails.

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 21 Feb 2015 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix gdb.base/solib-corrupted.exp after dtrace probes changes
Pedro Alves [Fri, 20 Feb 2015 23:10:53 +0000 (23:10 +0000)]
Fix gdb.base/solib-corrupted.exp after dtrace probes changes

Commit 6f9b8491 (Adapt `info probes' to support printing probes of
different types.) added a new type column to "info probes".  That
caused a solib-corrupted.exp regression:

 ~~~~~~~~~~~~~~~~~~~~~
 Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/solib-corrupted.exp ...
 FAIL: gdb.base/solib-corrupted.exp: corrupted list

 === gdb Summary ===

 # of expected passes            2
 # of unexpected failures        1
 ~~~~~~~~~~~~~~~~~~~~~

Tested on x86_64 Fedora 20.

gdb/testsuite/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

* gdb.base/solib-corrupted.exp: Expect "stap" as first column of
info probes.

9 years agoGNU/Linux: Stop using libthread_db/td_ta_thr_iter
Pedro Alves [Fri, 20 Feb 2015 20:21:59 +0000 (20:21 +0000)]
GNU/Linux: Stop using libthread_db/td_ta_thr_iter

TL;DR - GDB can hang if something refreshes the thread list out of the
target while the target is running.  GDB hangs inside td_ta_thr_iter.
The fix is to not use that libthread_db function anymore.

Long version:

Running the testsuite against my all-stop-on-top-of-non-stop series is
still exposing latent non-stop bugs.

I was originally seeing this with the multi-create.exp test, back when
we were still using libthread_db thread event breakpoints.  The
all-stop-on-top-of-non-stop series forces a thread list refresh each
time GDB needs to start stepping over a breakpoint (to pause all
threads).  That test hits the thread event breakpoint often, resulting
in a bunch of step-over operations, thus a bunch of thread list
refreshes while some threads in the target are running.

The commit adds a real non-stop mode test that triggers the issue,
based on multi-create.exp, that does an explicit "info threads" when a
breakpoint is hit.  IOW, it does the same things the as-ns series was
doing when testing multi-create.exp.

The bug is a race, so it unfortunately takes several runs for the test
to trigger it.  In fact, even when setting the test running in a loop,
it sometimes takes several minutes for it to trigger for me.

The race is related to libthread_db's td_ta_thr_iter.  This is
libthread_db's entry point for walking the thread list of the
inferior.

Sometimes, when GDB refreshes the thread list from the target,
libthread_db's td_ta_thr_iter can somehow see glibc's thread list as a
cycle, and get stuck in an infinite loop.

The issue is that when a thread exits, its thread control structure in
glibc is moved from a "used" list to a "cache" list.  These lists are
simply circular linked lists where the "next/prev" pointers are
embedded in the thread control structure itself.  The "next" pointer
of the last element of the list points back to the list's sentinel
"head".  There's only one set of "next/prev" pointers for both lists;
thus a thread can only be in one of the lists at a time, not in both
simultaneously.

So when thread C exits, simplifying, the following happens.  A-C are
threads.  stack_used and stack_cache are the list's heads.

Before:

  stack_used -> A -> B -> C -> (&stack_used)
  stack_cache -> (&stack_cache)

After:

  stack_used -> A -> B -> (&stack_used)
  stack_cache -> C -> (&stack_cache)

td_ta_thr_iter starts by iterating at the list's head's next, and
iterates until it sees a thread whose next pointer points to the
list's head again.  Thus in the before case above, C's next points to
stack_used, indicating end of list.  In the same case, the stack_cache
list is empty.

For each thread being iterated, td_ta_thr_iter reads the whole thread
object out of the inferior.  This includes the thread's "next"
pointer.

In the scenario above, it may happen that td_ta_thr_iter is iterating
thread B and has already read B's thread structure just before thread
C exits and its control structure moves to the cached list.

Now, recall that td_ta_thr_iter is running in the context of GDB, and
there's no locking between GDB and the inferior.  From it's local copy
of B, td_ta_thr_iter believes that the next thread after B is thread
C, so it happilly continues iterating to C, a thread that has already
exited, and is now in the stack cache list.

After iterating C, td_ta_thr_iter finds the stack_cache head, which
because it is not stack_used, td_ta_thr_iter assumes it's just another
thread.  After this, unless the reverse race triggers, GDB gets stuck
in td_ta_thr_iter forever walking the stack_cache list, as no thread
in thatlist has a next pointer that points back to stack_used (the
terminating condition).

Before fully understanding the issue, I tried adding cycle detection
to GDB's td_ta_thr_iter callback.  However, td_ta_thr_iter skips
calling the callback in some cases, which means that it's possible
that the callback isn't called at all, making it impossible for GDB to
break the loop.  I did manage to get GDB stuck in that state more than
once.

Fortunately, we can avoid the issue altogether.  We don't really need
td_ta_thr_iter for live debugging nowadays, given PTRACE_EVENT_CLONE.
We already know how to map and lwp id to a thread id without iterating
(thread_from_lwp), so use that more.

gdb/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

* linux-nat.c (linux_handle_extended_wait): Call
thread_db_notice_clone whenever a new clone LWP is detected.
(linux_stop_and_wait_all_lwps, linux_unstop_all_lwps): New
functions.
* linux-nat.h (thread_db_attach_lwp): Delete declaration.
(thread_db_notice_clone, linux_stop_and_wait_all_lwps)
(linux_unstop_all_lwps): Declare.
* linux-thread-db.c (struct thread_get_info_inout): Delete.
(thread_get_info_callback): Delete.
(thread_from_lwp): Use td_thr_get_info and record_thread.
(thread_db_attach_lwp): Delete.
(thread_db_notice_clone): New function.
(try_thread_db_load_1): If /proc is mounted and shows the
process'es task list, walk over all LWPs and call thread_from_lwp
instead of relying on td_ta_thr_iter.
(attach_thread): Don't call check_thread_signals here.  Split the
tail part of the function (which adds the thread to the core GDB
thread list) to ...
(record_thread): ... this function.  Call check_thread_signals
here.
(thread_db_wait): Don't call thread_db_find_new_threads_1.  Always
call thread_from_lwp.
(thread_db_update_thread_list): Rename to ...
(thread_db_update_thread_list_org): ... this.
(thread_db_update_thread_list): New function.
(thread_db_find_thread_from_tid): Delete.
(thread_db_get_ada_task_ptid): Simplify.
* nat/linux-procfs.c: Include <sys/stat.h>.
(linux_proc_task_list_dir_exists): New function.
* nat/linux-procfs.h (linux_proc_task_list_dir_exists): Declare.

gdb/gdbserver/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

* thread-db.c: Include "nat/linux-procfs.h".
(thread_db_init): Skip listing new threads if the kernel supports
PTRACE_EVENT_CLONE and /proc/PID/task/ is accessible.

gdb/testsuite/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

* gdb.threads/multi-create-ns-info-thr.exp: New file.

9 years agolinux-nat.c: fix a few lin_lwp_attach_lwp issues
Pedro Alves [Fri, 20 Feb 2015 20:21:59 +0000 (20:21 +0000)]
linux-nat.c: fix a few lin_lwp_attach_lwp issues

This function has a few latent bugs that are triggered by a non-stop
mode test that will be added in a subsequent patch.

First, as described in the function's intro comment, the function is
supposed to return 1 if we're already auto attached to the thread, but
haven't processed the PTRACE_EVENT_CLONE event of its parent thread
yet.

Then, we may find that we're trying to attach to a clone child that
hasn't yet stopped for its initial stop, and therefore 'waitpid(...,
WNOHANG)' returns 0.  In that case, we're currently adding the LWP to
the stopped_pids list, which results in linux_handle_extended_wait
skipping the waitpid call on the child, and thus confusing things
later on when the child eventually reports the stop.

Then, the tail end of lin_lwp_attach_lwp always sets the
last_resume_kind of the LWP to resume_stop, which is wrong given that
the user may be doing "info threads" while some threads are running.

And then, the else branch of lin_lwp_attach_lwp always sets the
stopped flag of the LWP.  This branch is reached if the LWP is the
main LWP, which may well be running at this point (to it's wrong to
set its 'stopped' flag).

AFAICS, there's no reason anymore for special-casing the main/leader
LWP here:

- For the "attach" case, linux_nat_attach already adds the main LWP to
the lwp list, and sets its 'stopped' flag.

- For the "run" case, after linux_nat_create_inferior, end up in
linux_nat_wait_1 here:

  /* The first time we get here after starting a new inferior, we may
     not have added it to the LWP list yet - this is the earliest
     moment at which we know its PID.  */
  if (ptid_is_pid (inferior_ptid))
    {
      /* Upgrade the main thread's ptid.  */
      thread_change_ptid (inferior_ptid,
  ptid_build (ptid_get_pid (inferior_ptid),
      ptid_get_pid (inferior_ptid), 0));

      lp = add_initial_lwp (inferior_ptid);
      lp->resumed = 1;
    }

... which adds the LWP to the LWP list already, before
lin_lwp_attach_lwp can ever be reached.

gdb/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

* linux-nat.c (lin_lwp_attach_lwp): No longer special case the
main LWP.  Handle the case of waitpid returning 0 if we're already
attached to the LWP.  Don't set the LWP's last_resume_kind to
resume_stop if we already knew about the LWP.
(linux_nat_filter_event): Add debug logs.

9 years agoGarbage collect forward_target_decr_pc_after_break
Pedro Alves [Thu, 19 Feb 2015 20:48:49 +0000 (20:48 +0000)]
Garbage collect forward_target_decr_pc_after_break

The definition was removed a year ago, but the declaration managed to
stay behind.

gdb/ChangeLog
2015-02-20  Pedro Alves  <palves@redhat.com>

* target.h (forward_target_decr_pc_after_break): Delete
declaration.

9 years agofix gdbserver/linux-low'c's pending status handling
Pedro Alves [Thu, 19 Feb 2015 20:48:54 +0000 (20:48 +0000)]
fix gdbserver/linux-low'c's pending status handling

Another fix I'm working made schedlock.exp fail with gdbserver
frequently.  Looking deeper, it turns out to be a pre-existing bug.

status_pending_p_callback is filtering out LWPs incorrectly.  The
result is that that sometimes status_pending_p_callback returns a
pending event for an LWP that isn't expected, and then GDBserver gets
very confused.

E.g,. when doing a step-over, linux_wait_for_event is called with a
particular LWP's ptid, meaning events for all other LWPs should be
left pending, but here we see it retuning an event for some other LWP:

 linux_wait_1: [<all threads>]
 step_over_bkpt set [LWP 29577.29577], doing a blocking wait      <--------
 my_waitpid (-1, 0x40000001)
 my_waitpid (-1, 0x80000001): status(57f), 0
 LWFE: waitpid(-1, ...) returned 0, ERRNO-OK
 pc is 0x4007a0
 src/gdb/gdbserver/linux-low.c:2587: A problem internal to GDBserver has been detected.
 linux_wait_1: got event for 29581                                <--------

 Remote connection closed
 (gdb) FAIL: gdb.threads/schedlock.exp: continue to breakpoint: return to loop (initial)
 delete breakpoints

Tested on x86_64 Fedora 20.

gdb/gdbserver/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

* linux-low.c (status_pending_p_callback): Use ptid_match.

9 years agoFix no-attach-trace.exp with "target remote" / gdbserver
Pedro Alves [Fri, 20 Feb 2015 19:50:36 +0000 (19:50 +0000)]
Fix no-attach-trace.exp with "target remote" / gdbserver

 $ make check RUNTESTFLAGS="--target_board=native-gdbserver no-attach-trace.exp"
 ...
 (gdb) trace main
 Tracepoint 1 at 0x400594: file /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.trace/no-attach-trace.c, line 25.
 (gdb) PASS: gdb.trace/no-attach-trace.exp: set tracepoint on main
 tstart
 You can't do that when your target is `exec'
 (gdb) FAIL: gdb.trace/no-attach-trace.exp: tstart

Even though this target supports tracing, the test restarts GDB and
doesn't do gdb_run_cmd so does not reconnect to the remote target.  So
at that point, GDB only has the "exec" target, which obviously doesn't
do tracing.

The test is about doing "tstart" before running a program, so the fix
is to do gdb_target_supports_trace with whatever target GDB ends up
connected after clean_restart.

Tested on x86_64 Fedora 20, native, native-gdbserver and
native-extended-gdbserver boards.  The test passes with the latter,
and is skipped with the first two.

gdb/testsuite/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

* gdb.trace/no-attach-trace.exp: Don't run to main.  Do
clean_restart before gdb_target_supports_trace.

9 years agoPR18006: internal error if threaded program calls clone(CLONE_VM)
Pedro Alves [Fri, 20 Feb 2015 19:00:21 +0000 (19:00 +0000)]
PR18006: internal error if threaded program calls clone(CLONE_VM)

On GNU/Linux, if a pthreaded program has a thread call clone(CLONE_VM)
directly, and then that clone LWP hits a debug event (breakpoint,
etc.) GDB internal errors.  Threaded programs shouldn't really be
calling clone directly, but GDB shouldn't crash either.

The crash looks like this:

 (gdb) break clone_fn
 Breakpoint 2 at 0x4007d8: file clone-thread_db.c, line 35.
 (gdb) r
 ...
 [Thread debugging using libthread_db enabled]
 ...
 src/gdb/linux-nat.c:1030: internal-error: lin_lwp_attach_lwp: Assertion `lwpid > 0' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.

The problem is that 'clone' ends up clearing the parent thread's tid
field in glibc's thread data structure.  For x86_64, the glibc code in
question is here:

  sysdeps/unix/sysv/linux/x86_64/clone.S:

   ...
          testq   $CLONE_THREAD, %rdi
          jne     1f
          testq   $CLONE_VM, %rdi
          movl    $-1, %eax            <----
          jne     2f
          movl    $SYS_ify(getpid), %eax
          syscall
  2:      movl    %eax, %fs:PID
          movl    %eax, %fs:TID        <----
  1:

When GDB refreshes the thread list out of libthread_db, it finds a
thread with LWP with pid -1 (the clone's parent), which naturally
isn't yet on the thread list.  GDB then tries to attach to that bogus
LWP id, which is caught by that assertion.

The fix is to detect the bad PID early.

Tested on x86-64 Fedora 20.  GDBserver doesn't need any fix.

gdb/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

PR threads/18006
* linux-thread-db.c (thread_get_info_callback): Return early if
the thread's lwp id is -1.

gdb/testsuite/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

PR threads/18006
* gdb.threads/clone-thread_db.c: New file.
* gdb.threads/clone-thread_db.exp: New file.

9 years agoDocument the GDB 7.9 release in gdb/ChangeLog
Joel Brobecker [Fri, 20 Feb 2015 17:20:23 +0000 (21:20 +0400)]
Document the GDB 7.9 release in gdb/ChangeLog

gdb/ChangeLog:

GDB 7.9 released.

9 years agoS390: Support new vector register sections
Andreas Arnez [Fri, 20 Feb 2015 09:39:53 +0000 (10:39 +0100)]
S390: Support new vector register sections

The IBM z13 has new 128-bit wide vector registers v0-v31, where v0-v15
include the existing 64-bit wide floating point registers.  The Linux
kernel presents the vector registers as two additional register sets,
one for the right halves of v0-v15 and another one for the full
registers v16-v31.  Thus a new core file may contain two new register
note sections, and this patch adds support to binutils for them.

bfd/
* elf-bfd.h (elfcore_write_s390_vxrs_low): Add prototype.
(elfcore_write_s390_vxrs_high): Likewise.
* elf.c (elfcore_grok_s390_vxrs_low): New function.
(elfcore_grok_s390_vxrs_high): New function.
(elfcore_grok_note): Call them.
(elfcore_write_s390_vxrs_low): New function.
(elfcore_write_s390_vxrs_high): New function.
(elfcore_write_register_note): Call them.

binutils/
* readelf.c (get_note_type): Add NT_S390_VXRS_LOW and
NT_S390_VXRS_HIGH.

include/elf/
* common.h (NT_S390_VXRS_LOW): New macro.
(NT_S390_VXRS_HIGH): Likewise.

9 years agosim: drop unused headers
Mike Frysinger [Thu, 19 Feb 2015 09:09:54 +0000 (04:09 -0500)]
sim: drop unused headers

These look like left over hacks from the days where we had to protect
ourselves from the compiler and C library.  None of these checks are
relevant, and we have common configure logic to do header tests.  Punt
them all now.

9 years agosim: drop unused sim_kill function
Mike Frysinger [Thu, 19 Feb 2015 09:04:02 +0000 (04:04 -0500)]
sim: drop unused sim_kill function

This has been deprecated for a long time and no one calls it.

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 20 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agosim: ChangeLog: Correct the related items position and format.
Chen Gang [Thu, 19 Feb 2015 22:51:12 +0000 (06:51 +0800)]
sim: ChangeLog: Correct the related items position and format.

Move several items from sim/ChangeLog to sim/*/ChangeLog. Also remove
the incorrect white space in sim/common/ChangeLog.

9 years agoWrap a few opcodes headers in extern "C" for C++
Pedro Alves [Thu, 12 Feb 2015 09:59:03 +0000 (09:59 +0000)]
Wrap a few opcodes headers in extern "C" for C++

These are sufficient to link an --enable-targets=all GDB build in C++
mode, on x86_64 Fedora 20.

include/opcode/
2015-02-19  Pedro Alves  <palves@redhat.com>

* cgen.h [__cplusplus]: Wrap in extern "C".
* msp430-decode.h [__cplusplus]: Likewise.
* nios2.h [__cplusplus]: Likewise.
* rl78.h [__cplusplus]: Likewise.
* rx.h [__cplusplus]: Likewise.
* tilegx.h [__cplusplus]: Likewise.

opcodes/
2015-02-19  Pedro Alves  <palves@redhat.com>

* microblaze-dis.h [__cplusplus]: Wrap in extern "C".

9 years agofloatformat.h: Wrap in extern "C"
Pedro Alves [Thu, 19 Feb 2015 22:44:44 +0000 (22:44 +0000)]
floatformat.h: Wrap in extern "C"

Just like libiberty.h.  So that C++ programs, such as GDB when built
as a C++ program, can use it.

include/ChangeLog:
2015-02-19  Pedro Alves  <palves@redhat.com>

* floatformat.h [__cplusplus]: Wrap in extern "C".

9 years ago2015-02-19 Steve Ellcey <sellcey@imgtec.com>
Steve Ellcey [Thu, 19 Feb 2015 22:42:37 +0000 (14:42 -0800)]
2015-02-19  Steve Ellcey  <sellcey@imgtec.com>

* dtrace-probe.c (dtrace_process_dof_probe): Initialize arg.expr.
(dtrace_get_probes) Change type of variable 'dof'.

9 years agoFix non executable stack handling when calling functions in the inferior.
Antoine Tremblay [Thu, 12 Feb 2015 19:55:08 +0000 (14:55 -0500)]
Fix non executable stack handling when calling functions in the inferior.

When gdb creates a dummy frame to execute a function in the inferior,
the process may generate a SIGSEGV, SIGTRAP or SIGILL because the stack
is non executable. If the signal handler set in gdb has option print
or stop enabled for these signals gdb handles this correctly.

However, in the case of noprint and nostop the signal is short-circuited
and the inferior process is sent the signal directly. This causes the
inferior to crash because of gdb.

This patch adds a check for SIGSEGV, SIGTRAP or SIGILL so that these
signals are sent to gdb rather than short-circuited in the inferior.
gdb then handles them properly and the inferior process does not
crash.

This patch also fixes the same behavior in gdbserver.

Also added a small testcase to test the issue called catch-gdb-caused-signals.

This applies to Linux only, tested on Linux.

gdb/ChangeLog:
PR breakpoints/16812
* linux-nat.c (linux_nat_filter_event): Report SIGTRAP,SIGILL,SIGSEGV.
* nat/linux-ptrace.c (linux_wstatus_maybe_breakpoint): Add.
* nat/linux-ptrace.h: Add linux_wstatus_maybe_breakpoint.

gdb/gdbserver/ChangeLog:
PR breakpoints/16812
* linux-low.c (wstatus_maybe_breakpoint): Remove.
(linux_low_filter_event): Update wstatus_maybe_breakpoint name.
(linux_wait_1): Report SIGTRAP,SIGILL,SIGSEGV.

gdb/testsuite/ChangeLog:
PR breakpoints/16812
* gdb.base/catch-gdb-caused-signals.c: New file.
* gdb.base/catch-gdb-caused-signals.exp: New file.

9 years ago[gdb/ax] small "setv" fix and documentation's adjustment.
David Taylor [Thu, 19 Feb 2015 14:53:50 +0000 (18:53 +0400)]
[gdb/ax] small "setv" fix and documentation's adjustment.

gdb/doc/agentexpr.texi documents the "setv" opcode as follow:

    @item @code{setv} (0x2d) @var{n}: @result{} @var{v}
    Set trace state variable number @var{n} to the value found on the top
    of the stack.  The stack is unchanged, so that the value is readily
    available if the assignment is part of a larger expression.  The
    handling of @var{n} is as described for @code{getv}.

The @item line is incorrect (and does not match with its
description), so this patch fixes it.

Additionally, in gdb/common/ax.def we find the line:

    DEFOP (setv, 2, 0, 0, 1, 0x2d)

From the comment earlier in the file:

       Each line is of the form:

       DEFOP (name, size, data_size, consumed, produced, opcode)
[...]
       CONSUMED is the number of stack elements consumed.
       PRODUCED is the number of stack elements produced.

which is saying that nothing is consumed and one item is produced.
Both should be 0 or both should be 1.

This patch sets them both to 1, which seems better since if nothing
is on the stack an error will occur.

gdb/ChangeLog:

        * common/ax.def (setv): Fix consumed entry in setv DEFOP.

gdb/doc/ChangeLog:

        * agentexpr.texi (Bytecode Descriptions): Fix summary line for setv.

Tested on x86_64-linux.

9 years agoUse nm/readelf with "failif"
H.J. Lu [Thu, 19 Feb 2015 12:45:27 +0000 (04:45 -0800)]
Use nm/readelf with "failif"

PR ld/4317
* ld-i386/compressed1.d: Use nm/readelf with "failif".
* ld-x86-64/compressed1.d: Likewise.
* ld-x86-64/pie1.d: Likewise.

9 years agoFix buffer overrun in verilog code
Branko Drevensek [Thu, 19 Feb 2015 11:35:21 +0000 (22:05 +1030)]
Fix buffer overrun in verilog code

PR 17995
* verilog.c (verilog_write_record): Correct buffer size.

9 years agosim: microblaze: fix build failure after opcodes update
Mike Frysinger [Thu, 19 Feb 2015 08:41:36 +0000 (03:41 -0500)]
sim: microblaze: fix build failure after opcodes update

Commit 07774fccc3280323f43db9ed204f628503b34663 update the microblaze
opcodes table to avoid C++ collisions, but missed updating the sim.
That caused it to fail to build due to missing keywords.

9 years agotidy _bfd_elf_define_linkage_sym
Alan Modra [Mon, 16 Feb 2015 20:48:15 +0000 (07:18 +1030)]
tidy _bfd_elf_define_linkage_sym

* elflink.c (_bfd_elf_define_linkage_sym): Set 'bed' earlier.

9 years agogas doc warning fixes
Alan Modra [Sat, 14 Feb 2015 08:02:48 +0000 (18:32 +1030)]
gas doc warning fixes

* doc/as.texinfo (Local Symbol Names): Don't use ':' in pxref.
* doc/c-i386.texi: Reorder i386-Bugs after i386-Arch.

9 years agoStrip undefined symbols from .symtab
Alan Modra [Wed, 18 Feb 2015 06:32:39 +0000 (17:02 +1030)]
Strip undefined symbols from .symtab

bfd/
PR ld/4317
* elflink.c (elf_link_input_bfd): Drop undefined local syms.
(elf_link_output_extsym): Drop local and global undefined syms.
Tidy.  Expand comment.
ld/testsuite/
PR ld/4317
* ld-aarch64/gc-tls-relocs.d, * ld-cris/locref2.d,
* ld-elf/ehdr_start-weak.d, * ld-elf/group1.d,
* ld-i386/compressed1.d, * ld-ia64/error1.d, * ld-ia64/error2.d,
* ld-ia64/error3.d, * ld-mips-elf/pic-and-nonpic-1.nd,
* ld-mmix/undef-3.d, * ld-powerpc/tlsexe.r, * ld-powerpc/tlsexetoc.r,
* ld-powerpc/tlsso.r, * ld-powerpc/tlstocso.r,
* ld-x86-64/compressed1.d, * ld-x86-64/pie1.d: Update.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 19 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoAdd missing gdb/ChangeLog entry for previous change.
Patrick Palka [Wed, 18 Feb 2015 23:50:51 +0000 (18:50 -0500)]
Add missing gdb/ChangeLog entry for previous change.

9 years agoAsynchronously resize the TUI
Patrick Palka [Tue, 17 Feb 2015 16:13:43 +0000 (11:13 -0500)]
Asynchronously resize the TUI

This patch teaches the TUI to resize itself asynchronously instead of
synchronously.  Asynchronously resizing the screen when the underlying
terminal gets resized is the more intuitive behavior and is surprisingly
simple to implement thanks to GDB's async infrastructure.

The implementation is straightforward.  TUI's SIGWINCH handler is just
tweaked to asynchronously invoke a new callback,
tui_async_resize_screen, which is responsible for safely resizing the
screen.  Care must be taken to not to attempt to asynchronously resize
the screen while the TUI is not active.  When the TUI is not active, the
callback will do nothing, but the screen will yet be resized in the next
call to tui_enable() by virtue of win_resized being TRUE.

(So, after the patch there are still two places where the screen gets
resized: one in tui_enable() and the other now in
tui_async_resize_screen() as opposed to being in
tui_handle_resize_during_io().  The one in tui_enable() is still
necessary to handle the case where the terminal gets resized inside the
CLI: in that case, the TUI still needs resizing, but it must wait until
the TUI gets re-enabled.)

gdb/ChangeLog:

* tui/tui-io.c (tui_handle_resize_during_io): Remove this
function.
(tui_putc): Don't call tui_handle_resize_during_io.
(tui_getc): Likewise.
(tui_mld_getc): Likewise.
* tui/tui-win.c: Include event-loop.h and tui/tui-io.h.
(tui_sigwinch_token): New static variable.
(tui_initialize_win): Adjust documentation.  Set
tui_sigwinch_token.
(tui_async_resize_screen): New asynchronous callback.
(tui_sigwinch_handler): Adjust documentation.  Asynchronously
invoke tui_async_resize_screen.

9 years agoFactorize target program transformations in the GDB_AC_TRANSFORM macro.
Jose E. Marchesi [Wed, 18 Feb 2015 12:52:53 +0000 (13:52 +0100)]
Factorize target program transformations in the GDB_AC_TRANSFORM macro.

This patch introduces a new M4 macro GDB_AC_TRANSFORM to avoid repeating
the common idiom which is the transformation of target program names,
i.e. from gdb to sparc64-linux-gnu-gdb.  It also makes gdb/configure.ac
and gdb/testsuite/configure.ac to use the new macro.

gdb/ChangeLog:

2015-02-18  Jose E. Marchesi  <jose.marchesi@oracle.com>

* configure: Regenerated.
* configure.ac: Use GDB_AC_TRANSFORM.
* Makefile.in (aclocal_m4_deps): Added transform.m4.
* acinclude.m4: sinclude transform.m4.
* transform.m4: New file.
(GDB_AC_TRANSFORM): New macro.

gdb/testsuite/ChangeLog:

2015-02-18  Jose E. Marchesi  <jose.marchesi@oracle.com>

* configure: Regenerated.
* configure.ac: Use GDB_AC_TRANSFORM.
* aclocal.m4: sinclude ../transform.m4.

9 years agoFix gold error: hidden symbol '...' is not defined locally
Alan Modra [Wed, 18 Feb 2015 12:06:35 +0000 (22:36 +1030)]
Fix gold error: hidden symbol '...' is not defined locally

Found when applying relocs in .debug that reference removed functions.

PR 17954
* powerpc.cc (Global_symbol_visitor_opd::operator()): Set default
visibility.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 18 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoSimplify Garbage_collection::add_reference a bit.
Rafael Ávila de Espíndola [Tue, 17 Feb 2015 15:49:41 +0000 (10:49 -0500)]
Simplify Garbage_collection::add_reference a bit.

this->section_reloc_map_[src_id] is created if it doesn't exist, so there
is no point in doing a find.

9 years agoavoid std::vector copy.
Rafael Ávila de Espíndola [Tue, 17 Feb 2015 15:47:02 +0000 (10:47 -0500)]
avoid std::vector copy.

9 years agoUse std::upper_bound to simplify code a bit.
Rafael Ávila de Espíndola [Tue, 17 Feb 2015 15:43:20 +0000 (10:43 -0500)]
Use std::upper_bound to simplify code a bit.

With std::upper_bound we don't have to check p->input_offset > input_offset.

9 years agoAnnounce the DTrace USDT probes support in NEWS.
Jose E. Marchesi [Tue, 17 Feb 2015 15:43:48 +0000 (16:43 +0100)]
Announce the DTrace USDT probes support in NEWS.

This patch simply adds a small entry to `Changes since GDB 7.8' announcing the
support for dtrace probes.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* NEWS: Announce the support for DTrace SDT probes.

9 years agoDocumentation for DTrace USDT probes.
Jose E. Marchesi [Tue, 17 Feb 2015 15:42:15 +0000 (16:42 +0100)]
Documentation for DTrace USDT probes.

This patch modifies the `Static Probe Points' section on the GDB
manual in order to cover the support for DTrace USDT probes, in
addition to SystemTap SDT probes.

gdb/doc/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* gdb.texinfo (Static Probe Points): Add cindex `static probe
point, DTrace'.
(Static Probe Points): Modified to cover DTrace probes in addition
to SystemTap probes.  Also modified to cover the `enable probe'
and `disable probe' commands.

9 years agoSimple testsuite for DTrace USDT probes.
Jose E. Marchesi [Tue, 17 Feb 2015 15:41:16 +0000 (16:41 +0100)]
Simple testsuite for DTrace USDT probes.

This patch adds some simple tests testing the support for DTrace USDT
probes.  The testsuite will be skipped as unsupported in case the user
does not have DTrace installed on her system.  The tests included in the
test suite test breakpointing on DTrace probes, enabling and disabling
probes, printing of probe arguments of several types and also
breakpointing on several probes with the same name.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* lib/dtrace.exp: New file.
* gdb.base/dtrace-probe.exp: Likewise.
* gdb.base/dtrace-probe.d: Likewise.
* gdb.base/dtrace-probe.c: Likewise.
* lib/pdtrace.in: Likewise.
* configure.ac: Output variables with the transformed names of
the strip, readelf, as and nm tools.  AC_SUBST lib/pdtrace.in.
* configure: Regenerated.

9 years agoSupport for DTrace USDT probes in x86_64 targets.
Jose E. Marchesi [Tue, 17 Feb 2015 15:04:01 +0000 (16:04 +0100)]
Support for DTrace USDT probes in x86_64 targets.

This patch adds the target-specific code in order to support the
calculation of DTrace probes arguments in x86_64 targets, and also the
enabling and disabling of probes.  This is done by implementing the
`dtrace_*' gdbarch handlers.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* amd64-linux-tdep.c: Include "parser-defs.h" and "user-regs.h".
(amd64_dtrace_parse_probe_argument): New function.
(amd64_dtrace_probe_is_enabled): Likewise.
(amd64_dtrace_enable_probe): Likewise.
(amd64_dtrace_disable_probe): Likewise.
(amd64_linux_init_abi): Register the
`gdbarch_dtrace_probe_argument', `gdbarch_dtrace_enable_probe',
`gdbarch_dtrace_disable_probe' and
`gdbarch_dtrace_probe_is_enabled' hooks.
(amd64_dtrace_disabled_probe_sequence_1): New constant.
(amd64_dtrace_disabled_probe_sequence_2): Likewise.
(amd64_dtrace_enable_probe_sequence): Likewise.
(amd64_dtrace_disable_probe_sequence): Likewise.

9 years agoNew probe type: DTrace USDT probes.
Jose E. Marchesi [Tue, 17 Feb 2015 15:03:22 +0000 (16:03 +0100)]
New probe type: DTrace USDT probes.

This patch adds a new type of probe to GDB: the DTrace USDT probes.  The new
type is added by providing functions implementing all the entries of the
`probe_ops' structure defined in `probe.h'.  The implementation is
self-contained and does not depend on DTrace source code in any way.

gdb/ChangeLog:

2015-02-7  Jose E. Marchesi  <jose.marchesi@oracle.com>

* breakpoint.c (BREAK_ARGS_HELP): Help string updated to mention
the -probe-dtrace new vpossible value for PROBE_MODIFIER.
* configure.ac (CONFIG_OBS): dtrace-probe.o added if BFD can
handle ELF files.
* Makefile.in (SFILES): dtrace-probe.c added.
* configure: Regenerate.
* dtrace-probe.c: New file.
(SHT_SUNW_dof): New constant.
(dtrace_probe_type): New enum.
(dtrace_probe_arg): New struct.
(dtrace_probe_arg_s): New typedef.
(struct dtrace_probe_enabler): New struct.
(dtrace_probe_enabler_s): New typedef.
(dtrace_probe): New struct.
(dtrace_probe_is_linespec): New function.
(dtrace_dof_sect_type): New enum.
(dtrace_dof_dofh_ident): Likewise.
(dtrace_dof_encoding): Likewise.
(DTRACE_DOF_ENCODE_LSB): Likewise.
(DTRACE_DOF_ENCODE_MSB): Likewise.
(dtrace_dof_hdr): New struct.
(dtrace_dof_sect): Likewise.
(dtrace_dof_provider): Likewise.
(dtrace_dof_probe): Likewise.
(DOF_UINT): New macro.
(DTRACE_DOF_PTR): Likewise.
(DTRACE_DOF_SECT): Likewise.
(dtrace_process_dof_probe): New function.
(dtrace_process_dof): Likewise.
(dtrace_build_arg_exprs): Likewise.
(dtrace_get_arg): Likewise.
(dtrace_get_probes): Likewise.
(dtrace_get_probe_argument_count): Likewise.
(dtrace_can_evaluate_probe_arguments): Likewise.
(dtrace_evaluate_probe_argument): Likewise.
(dtrace_compile_to_ax): Likewise.
(dtrace_probe_destroy): Likewise.
(dtrace_gen_info_probes_table_header): Likewise.
(dtrace_gen_info_probes_table_values): Likewise.
(dtrace_probe_is_enabled): Likewise.
(dtrace_probe_ops): New variable.
(info_probes_dtrace_command): New function.
(_initialize_dtrace_probe): Likewise.
(dtrace_type_name): Likewise.

9 years agoNew gdbarch functions: dtrace_parse_probe_argument, dtrace_probe_is_enabled, dtrace_e...
Jose E. Marchesi [Tue, 17 Feb 2015 14:54:44 +0000 (15:54 +0100)]
New gdbarch functions: dtrace_parse_probe_argument, dtrace_probe_is_enabled, dtrace_enable_probe, dtrace_disable_probe.

This patch adds several gdbarch functions (along with the corresponding
predicates): `dtrace_parse_probe_argument', `dtrace_probe_is_enabled',
`dtrace_enable_probe' and `dtrace_disable_probe'.  These functions will
be implemented by target-specific code, and called from the DTrace
probes implementation in order to calculate the value of probe
arguments, and manipulate is-enabled probes.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* gdbarch.sh (dtrace_parse_probe_argument): New.
(dtrace_probe_is_enabled): Likewise.
(dtrace_enable_probe): Likewise.
(dtrace_disable_probe): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.

9 years agoNew commands `enable probe' and `disable probe'.
Jose E. Marchesi [Tue, 17 Feb 2015 14:51:07 +0000 (15:51 +0100)]
New commands `enable probe' and `disable probe'.

This patch adds the above-mentioned commands to the generic probe
abstraction implemented in probe.[ch].  The effects associated to
enabling or disabling a probe depend on the type of probe being
handled, and is triggered by invoking two back-end hooks in
`probe_ops'.

In case some particular probe type does not support the notion of
enabling and/or disabling, the corresponding fields on `probe_ops' can
be initialized to NULL.  This is the case of SystemTap probes.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* stap-probe.c (stap_probe_ops): Add NULLs in the static
stap_probe_ops for `enable_probe' and `disable_probe'.
* probe.c (enable_probes_command): New function.
(disable_probes_command): Likewise.
(_initialize_probe): Define the cli commands `enable probe' and
`disable probe'.
(parse_probe_linespec): New function.
(info_probes_for_ops): Use parse_probe_linespec.
* probe.h (probe_ops): New hooks `enable_probe' and
`disable_probe'.

gdb/doc/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* gdb.texinfo (Static Probe Points): Cover the `enable probe' and
`disable probe' commands.

9 years agoMove `compute_probe_arg' and `compile_probe_arg' to probe.c
Jose E. Marchesi [Tue, 17 Feb 2015 14:50:19 +0000 (15:50 +0100)]
Move `compute_probe_arg' and `compile_probe_arg' to probe.c

This patch moves the `compute_probe_arg' and `compile_probe_arg' functions
from stap-probe.c to probe.c.  The rationale is that it is reasonable to
assume that all backends will provide the `$_probe_argN' convenience
variables, and that the user must be placed on the PC of the probe when
requesting that information.  The value and type of the argument can still be
determined by the probe backend via the `pops->evaluate_probe_argument' and
`pops->compile_to_ax' handlers.

Note that a test in gdb.base/stap-probe.exp had to be adjusted because the "No
SystemTap probe at PC" messages are now "No probe at PC".

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* probe.c (compute_probe_arg): Moved from stap-probe.c
(compile_probe_arg): Likewise.
(probe_funcs): Likewise.
* stap-probe.c (compute_probe_arg): Moved to probe.c.
(compile_probe_arg): Likewise.
(probe_funcs): Likewise.

gdb/testsuite/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* gdb.base/stap-probe.exp (stap_test): Remove "SystemTap" from
expected message when trying to access $_probe_* convenience
variables while not on a probe.

9 years agoAdapt `info probes' to support printing probes of different types.
Jose E. Marchesi [Tue, 17 Feb 2015 14:49:12 +0000 (15:49 +0100)]
Adapt `info probes' to support printing probes of different types.

A "probe type" (backend for the probe abstraction implemented in
probe.[ch]) can extend the information printed by `info probes' by
defining additional columns.  This means that when `info probes' is
used to print all the probes regardless of their types, some of the
columns will be "not applicable" to some of the probes (like, say, the
Semaphore column only makes sense for SystemTap probes).  This patch
makes `info probes' fill these slots with "n/a" marks (currently it
breaks the table) and not include headers for which no actual probe
has been found in the list of defined probes.

This patch also adds support for a new generic column "Type", that
displays the type of each probe.  SystemTap probes identify themselves
as "stap" probes.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* probe.c (print_ui_out_not_applicables): New function.
(exists_probe_with_pops): Likewise.
(info_probes_for_ops): Do not include column headers for probe
types for which no probe has been actually found on any object.
Also invoke `print_ui_out_not_applicables' in order to match the
column rows with the header when probes of several types are
listed.
Print the "Type" column.
* probe.h (probe_ops): Added a new probe operation `type_name'.
* stap-probe.c (stap_probe_ops): Add `stap_type_name'.
(stap_type_name): New function.

9 years agoProperly place the NULL STT_FILE symbol revistited
Alan Modra [Mon, 16 Feb 2015 22:44:59 +0000 (09:14 +1030)]
Properly place the NULL STT_FILE symbol revistited

I was having a little closer look at what is going on here and noticed
that HJ unconditionally emits a NULL STT_FILE symbol before emitting
forced local symbols.  That means we really don't need a second pass
over forced local symbols.  The only reason for two passes is when
some forced local symbol can be emitted before the NULL STT_FILE.  So
I set about removing the second pass, updating the testsuite all over
again.  It's also unnecessary to emit the NULL STT_FILE when no
previous file symbol has been emitted.

bfd/
PR ld/17975
* elflink.c (struct elf_outext_info): Remove need_second_pass
and second_pass.
(elf_link_output_extsym): Delete code handling second forced
local pass.  Move code emitting NULL STT_FILE symbol later, so
that it can be omitted if forced local is stripped.  Don't
emit the NULL STT_FILE if no file symbols have been output.
(bfd_elf_final_link): Remove second forced local pass.
* elf32-ppc.c (add_stub_sym): Set linker_def on linker syms.
(ppc_elf_size_dynamic_sections): Likewise.
* elf64-ppc.c (ppc_build_one_stub): Likewise.
(build_global_entry_stubs): Likewise.
(ppc64_elf_build_stubs): Likewise.
ld/testsuite/
PR ld/17975
* ld-aarch64/gc-tls-relocs.d, * ld-alpha/tlspic.rd,
* ld-cris/libdso-2.d, * ld-i386/tlsdesc-nacl.rd, * ld-i386/tlsdesc.rd,
* ld-i386/tlsnopic-nacl.rd, * ld-i386/tlsnopic.rd,
* ld-i386/tlspic-nacl.rd, * ld-i386/tlspic.rd, * ld-ia64/tlspic.rd,
* ld-powerpc/tlsexe.r, * ld-powerpc/tlsexetoc.r,
* ld-powerpc/tlsso.r, * ld-powerpc/tlstocso.r,
* ld-s390/tlspic.rd, * ld-s390/tlspic_64.rd,
* ld-sparc/tlssunnopic32.rd, * ld-sparc/tlssunnopic64.rd,
* ld-sparc/tlssunpic32.rd, * ld-sparc/tlssunpic64.rd,
* ld-tic6x/shlib-1.rd, * ld-tic6x/shlib-1b.rd, * ld-tic6x/shlib-1r.rd,
* ld-tic6x/shlib-1rb.rd, * ld-tic6x/shlib-noindex.rd,
* ld-x86-64/tlsdesc-nacl.rd, * ld-x86-64/tlsdesc.rd,
* ld-x86-64/tlspic-nacl.rd, * ld-x86-64/tlspic.rd: Update.

9 years agoRemove superfluous function key_is_command_char()
Patrick Palka [Tue, 17 Feb 2015 13:06:10 +0000 (08:06 -0500)]
Remove superfluous function key_is_command_char()

The function key_is_command_char() is simply a predicate that determines
whether the function tui_dispatch_ctrl_char() will do anything useful.
Since tui_dispatch_ctrl_char() performs the same checks as
key_is_command_char() it is unnecessary to keep key_is_command_char()
around.  This patch removes this useless function and instead
unconditionally calls tui_dispatch_ctrl_char() inside its only caller,
tui_getc().

gdb/ChangeLog:

* tui/tui-io.c (tui_getc): Don't call key_is_command_char.
(key_is_command_char): Delete.

9 years agoTUI: resize windows to new terminal size before displaying them
Pedro Alves [Tue, 17 Feb 2015 10:05:52 +0000 (10:05 +0000)]
TUI: resize windows to new terminal size before displaying them

If the user:

   #1 - disables the TUI
   #2 - resizes the terminal
   #3 - and then re-enables the TUI

the next wgetch() returns KEY_RESIZE.  This indicates to the ncurses
client that ncurses detected that the terminal has been resized.  We
don't handle KEY_RESIZE anywhere, so it gets passed on to readline
which interprets it as a multibyte character, and then the end result
is that the first key press after enabling the TUI is misinterpreted.

We shouldn't really need to handle KEY_RESIZE (and not all ncurses
implementations have that).  We have our own SIGWINCH handler, and,
when we re-enable the TUI, we explicitly detect terminal resizes and
resize all windows.  The reason ncurses currently does detects a
resize is that something within tui_enable forces a refresh/display of
some window before we get to do the actual resizing.  Setting a break
on ncurses' 'resizeterm' function helps find the culprit(s):

 (top-gdb) bt
 #0  resizeterm (ToLines=28, ToCols=114) at ../../ncurses/base/resizeterm.c:462
 #1  0x0000003b42812f3f in _nc_update_screensize (sp=0x2674730) at ../../ncurses/tinfo/lib_setup.c:443
 #2  0x0000003b0821cbe0 in doupdate () at ../../ncurses/tty/tty_update.c:726
 #3  0x0000003b08215539 in wrefresh (win=0x2a7bc00) at ../../ncurses/base/lib_refresh.c:65
 #4  0x00000000005257cb in tui_refresh_win (win_info=0xd73d60 <_locator>) at /home/pedro/gdb/mygit/src/gdb/tui/tui-wingeneral.c:60
 #5  0x000000000052265b in tui_show_locator_content () at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:269
 #6  0x00000000005273a6 in tui_set_key_mode (mode=TUI_COMMAND_MODE) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:321
 #7  0x00000000005278c7 in tui_enable () at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:494
 #8  0x0000000000527011 in tui_rl_switch_mode (notused1=1, notused2=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:108

That is, tui_enable calls tui_set_key_mode before we've resized all
windows, and that refreshes a window as side effect.

And if we're already debugging something (there's a frame), then we'll
instead show a window from within tui_show_frame_info:

 (top-gdb) bt
 #0  resizeterm (ToLines=28, ToCols=114) at ../../ncurses/base/resizeterm.c:462
 #1  0x0000003b42812f3f in _nc_update_screensize (sp=0x202e6c0) at ../../ncurses/tinfo/lib_setup.c:443
 #2  0x0000003b0821cbe0 in doupdate () at ../../ncurses/tty/tty_update.c:726
 #3  0x0000003b08215539 in wrefresh (win=0x2042890) at ../../ncurses/base/lib_refresh.c:65
 #4  0x00000000005257cb in tui_refresh_win (win_info=0xd73d60 <_locator>) at /home/pedro/gdb/mygit/src/gdb/tui/tui-wingeneral.c:60
 #5  0x000000000052265b in tui_show_locator_content () at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:269
 #6  0x0000000000522931 in tui_show_frame_info (fi=0x16b9cc0) at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:364
 #7  0x00000000005278ba in tui_enable () at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:491
 #8  0x0000000000527011 in tui_rl_switch_mode (notused1=1, notused2=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:108

The fix is to resize windows earlier.

gdb/ChangeLog:
2015-02-17  Pedro Alves  <palves@redhat.com>

* tui/tui.c (tui_enable): Resize windows before anything
might show a window.

9 years agoFix GDB build fail on Aarch64 when -fno-common is enabled
Maxim Ostapenko [Mon, 16 Feb 2015 16:24:53 +0000 (20:24 +0400)]
Fix GDB build fail on Aarch64 when -fno-common is enabled

Current trunk GDB (and gdb-7.8.1 too) fails to build on Aarch64 when
-fno-common is enabled.  It fails during link stage due to multiple
definition of `tdesc_aarch64':

...
[  199s] aarch64-linux-nat.o: In function `initialize_tdesc_aarch64':
[  199s]
/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/features/aarch64.c:11:
multiple definition of `tdesc_aarch64'
[  199s]
aarch64-tdep.o:/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/objfiles.h:540:
first defined here
[  199s] aarch64-linux-nat.o: In function `initialize_tdesc_aarch64':
[  199s]
/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/features/aarch64.c:11:
multiple definition of `tdesc_aarch64'
[  199s]
aarch64-tdep.o:/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/objfiles.h:540:
first defined here
[  199s] collect2: error: ld returned 1 exit status
[  199s] make[2]: *** [gdb] Error 1
...

This happens because struct target_desc *tdesc_aarch64 is defined in
gdb/features/aarch64.c, which is included by two files
(gdb/aarch64-linux-nat.c and gdb/aarch64-tdep.c).

gdb/Changelog
2015-02-17  Max Ostapenko  <m.ostapenko@partner.samsung.com>

PR gdb/17984
* aarch64-linux-nat.c: Don't include features/aarch64.c anymore.
(aarch64_linux_read_description): Remove initialize_tdesc_aarch64
call.
* aarch64-tdep.h (tdesc_aarch64): Declare.

9 years ago[gold] Recognize DWARF5/GCC5 DW_LANG_Fortran03 and DW_LANG_Fortran08.
Mark Wielaard [Mon, 9 Feb 2015 23:02:34 +0000 (00:02 +0100)]
[gold] Recognize DWARF5/GCC5 DW_LANG_Fortran03 and DW_LANG_Fortran08.

DWARFv5 defines and GCC5 may output two new DW_LANG constants for the
Fortran 2003 and Fortran 2008 standards. Recognize both in gold gdb-index
as unsupported.

For consistency also add the other new DWARF5/GCC5 language constants in
the elfcpp::DW_LANG enum to match include/dwarf2.h.

elfcpp/ChangeLog:

* dwarf.h (enum DW_LANG): Add DW_LANG_C_plus_plus_11,
DW_LANG_C11, DW_LANG_C_plus_plus_14, DW_LANG_Fortran03 and
DW_LANG_Fortran08 from ../include/dwarf2.h.

gold/ChangeLog:

* gdb-index.cc (Gdb_index_info_reader::visit_top_die): Recognize
DW_LANG_Fortran03 and DW_LANG_Fortran08.

9 years agoFix --dynamic-list so that symbols not in the list are still exported.
Cary Coutant [Tue, 17 Feb 2015 06:15:12 +0000 (22:15 -0800)]
Fix --dynamic-list so that symbols not in the list are still exported.

In PR 13577, the complaint was that -Bsymbolic was overriding the binding
behavior for symbols listed in the --dynamic-list by setting the DT_SYMBOLIC
tag in the dynamic table. In reading the Gnu ld manual, I decided that
--dynamic-list should be mutually exclusive of -Bsymbolic, and modified
gold so that --dynamic-list would treat symbols listed as preemptible,
and all other symbols as internally bound. I was wrong.

PR 16992 shows that with --dynamic-list (and not -Bsymbolic), a symbol
not listed in the dynamic list is being internally bound within the
shared library, but because it's still in the dynamic symbol table, we
expose it to a COPY relocation, and things go really bad from there.

(I can reproduce the same failure, simply by turning on -Bsymbolic-functions
with the Gnu linker. Even though the symbol is bound internally, it's
still exported to the dynamic symbol table, and is exposed to a COPY
relocation.)

I've backed out part of the fix for PR 13577, and -Bsymbolic (or
-Bsymbolic-functions) can now be used with --dynamic-list, but if the
two are used together, we do not set DT_SYMBOLIC or DF_SYMBOLIC
(this matches Gnu ld behavior). We now treat symbols listed in the
dynamic list as premptible, but we do not automatically treat symbols
not listed there as non-premptible.

gold/
PR gold/13577
PR gold/16992
* layout.cc (Layout::finish_dynamic_section): Don't set DT_SYMBOLIC or
DF_SYMBOLIC if --dynamic-list option is used.
* options.cc (General_options::finalize): --dynamic-list is not
mutually exclusive with -Bsymbolic.
* symtab.h (Symbol::is_preemptible): Don't exclude dynamic symbols not
listed in --dynamic-list.
* testsuite/Makefile.am (dynamic_list_lib2.so): Add
-Bsymbolic-functions.
* testsuite/Makefile.in: Regenerate.