external/binutils.git
8 years agoMove logic out of symbol_find_demangled_name
Tom Tromey [Thu, 26 May 2016 21:04:07 +0000 (15:04 -0600)]
Move logic out of symbol_find_demangled_name

This patch moves most of the demangling logic out of
symbol_find_demangled_name into the various language_defn objects.

The simplest way to do this seemed to be to add a new method to
language_defn.  This is shame given the existing la_demangle, but
given Ada's unusual needs, and the differing demangling options
between languages, la_demangle didn't seem to fit.

In order to make this work, I made enum language order-sensitive.
This helps preserve the current ordering of demangling operations.

2016-06-23  Tom Tromey  <tom@tromey.com>

* symtab.c (symbol_find_demangled_name): Loop over languages and
use language_sniff_from_mangled_name.
* rust-lang.c (rust_sniff_from_mangled_name): New function.
(rust_language_defn): Update.
* p-lang.c (pascal_language_defn): Update.
* opencl-lang.c (opencl_language_defn): Update.
* objc-lang.c (objc_sniff_from_mangled_name): New function.
(objc_language_defn): Update.
* m2-lang.c (m2_language_defn): Update.
* language.h (struct language_defn) <la_sniff_from_mangled_name>: New
field.
(language_sniff_from_mangled_name): Declare.
* language.c (language_sniff_from_mangled_name): New function.
(unknown_language_defn, auto_language_defn, local_language_defn):
Update.
* jv-lang.c (java_sniff_from_mangled_name): New function.
(java_language_defn): Use it.
* go-lang.c (go_sniff_from_mangled_name): New function.
(go_language_defn): Use it.
* f-lang.c (f_language_defn): Update.
* defs.h (enum language): Reorder.
* d-lang.c (d_sniff_from_mangled_name): New function.
(d_language_defn): Use it.
* cp-support.h (gdb_sniff_from_mangled_name): Declare.
* cp-support.c (gdb_sniff_from_mangled_name): New function.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Update.
* ada-lang.c (ada_sniff_from_mangled_name): New function.
(ada_language_defn): Use it.

8 years agoMove filename extensions into language_defn
Tom Tromey [Thu, 26 May 2016 16:33:28 +0000 (10:33 -0600)]
Move filename extensions into language_defn

This moves filename extensions from a function in symfile.c out to
each language_defn.  I think this is an improvement because it means
less digging around when writing a new language port.

2016-06-23  Tom Tromey  <tom@tromey.com>

* ada-lang.c (ada_extensions): New array.
(ada_language_defn): Use it.
* c-lang.c (c_extensions): New array.
(c_language_defn): Use it.
(cplus_extensions): New array.
(cplus_language_defn): Use it.
(asm_extensions): New array.
(asm_language_defn): Use it.
(minimal_language_defn): Update.
* d-lang.c (d_extensions): New array.
(d_language_defn): Use it.
* f-lang.c (f_extensions): New array.
(f_language_defn): Use it.
* go-lang.c (go_language_defn): Update.
* jv-lang.c (java_extensions): New array.
(java_language_defn): Use it.
* language.c (add_language): Call add_filename_language.
(unknown_language_defn, auto_language_defn, local_language_defn):
Update.
* language.h (struct language_defn) <la_filename_extensions>: New
field.
* m2-lang.c (m2_language_defn): Update.
* objc-lang.c (objc_extensions): New array.
(objc_language_defn): Use it.
* opencl-lang.c (opencl_language_defn): Update.
* p-lang.c (p_extensions): New array.
(pascal_language_defn): Use it.
* rust-lang.c (rust_extensions): New array.
(rust_language_defn): Use it.
* symfile.c (add_filename_language): No longer static.  Make "ext"
const.
(init_filename_language_table): Remove.
(_initialize_symfile): Update.
* symfile.h (add_filename_language): Declare.

8 years agoUse VEC for filename_language_table
Tom Tromey [Thu, 26 May 2016 16:22:03 +0000 (10:22 -0600)]
Use VEC for filename_language_table

This patch changes filename_language_table to be a VEC.  This seemed
like a reasonable cleanup over the old code.

2016-06-23  Tom Tromey  <tom@tromey.com>

* symfile.c (filename_language_table): Now a VEC.
(fl_table_size, fl_table_next): Remove.
(add_filename_language): Use VEC_safe_push.
(set_ext_lang_command, info_ext_lang_command)
(deduce_language_from_filename): Use VEC_iterate.
(init_filename_language_table): Use VEC_empty.

8 years agoMake gdbpy_parameter static
Tom Tromey [Thu, 9 Jun 2016 21:07:55 +0000 (15:07 -0600)]
Make gdbpy_parameter static

While working on the next patch in this series, I noticed that
gdbpy_parameter did not need to be exported.  This makes it "static".

2016-06-23  Tom Tromey  <tom@tromey.com>

* python/python.c (gdbpy_parameter): Now static.
* python/python-internal.h (gdbpy_parameter): Don't declare.

8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Jun 2016 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoFix bug with grouping sections.
Cary Coutant [Thu, 23 Jun 2016 16:45:25 +0000 (09:45 -0700)]
Fix bug with grouping sections.

The fix for PR 15370 did not correctly check all patterns in a group,
but instead threw all unassigned sections into the group. This patch
fixes that.

2016-06-23  Cary Coutant  <ccoutant@gmail.com>
    Igor Kudrin  <ikudrin@accesssoftek.com>

gold/
PR gold/15370
* script-sections.cc
(Output_section_element_input::set_section_addresses): Keep bin_count
separate from input_pattern_count.
* testsuite/script_test_12.t: Add another section .x4.
* testsuite/script_test_12i.t: Likewise.
* testsuite/script_test_12a.c: Likewise.
* testsuite/script_test_12b.c: Likewise.

8 years agoFix compilation error in MSYS2 environment.
Igor Kudrin [Thu, 23 Jun 2016 15:50:18 +0000 (08:50 -0700)]
Fix compilation error in MSYS2 environment.

gold/
* gold-threads.cc (impl_threads::Lock_impl_threads): Fix typos.

8 years agoPR gdb/16483 - simplify "info frame-filters" output
Tom Tromey [Mon, 20 Jun 2016 16:28:37 +0000 (10:28 -0600)]
PR gdb/16483 - simplify "info frame-filters" output

PR gdb/16483 notes that the output of "info frame-filters" is quite
voluminous.  In particular it prints an entry for each objfile, even if
only to say that the objfile does not have any associated frame filters.

I think it's better to only print output when there is a frame filter.
There's nothing worth doing with the no-frame-filter information, and
limiting the output makes it much more readable.

Built and regtested on x86-64 Fedora 23.

2016-06-23  Tom Tromey  <tom@tromey.com>

PR gdb/16483:
* python/lib/gdb/command/frame_filters.py
(InfoFrameFilter.list_frame_filters): Rename to print_list.  Print
nothing if no filters found.  Return value indicating whether
filters were printed.
(InfoFrameFilter.print_list): Remove.
(InfoFrameFilter.invoke): Print message if no frame filters
found.

2016-06-23  Tom Tromey  <tom@tromey.com>

PR gdb/16483:
* gdb.python/py-framefilter.exp: Add "info frame-filter" test
before any filters are loaded.

8 years agoMIPS/GAS: Keep the original microMIPS symbol reference in branch relocs
Maciej W. Rozycki [Thu, 23 Jun 2016 10:33:52 +0000 (11:33 +0100)]
MIPS/GAS: Keep the original microMIPS symbol reference in branch relocs

Keep original microMIPS symbols in references from branch relocations so
that the ISA bit is retained and can be verified for validity in static
link.  No need to update WRT MIPS16 symbols because we keep them all
anyway for other reasons.

gas/
* config/tc-mips.c (b_reloc_p): New function.
(mips_fix_adjustable): Also keep the original microMIPS symbol
referred from branch relocations.
* testsuite/gas/mips/branch-local-1.d: New test.
* testsuite/gas/mips/branch-local-n32-1.d: New test.
* testsuite/gas/mips/branch-local-n64-1.d: New test.
* testsuite/gas/mips/micromips@branch-misc-4-64.d: Update
relocations.
* testsuite/gas/mips/branch-local-1.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new cases.

8 years ago[ARC] Misc minor edits/fixes
Graham Markall [Tue, 21 Jun 2016 19:25:29 +0000 (20:25 +0100)]
[ARC] Misc minor edits/fixes

The code supporting -mspfp, -mdpfp, and -mfpuda options are in
sections of code that are commented as being for backward
compatibility only, and having no effect. However, they do have an
effect, enabling the SPX, DPX, and DPA instruction subclasses
respectively. This commit moves the code supporting these options
away from the comments indicating that they are dummy options, and
also fixes a small issue where -mnps400 had the additional effect
of enabling SPX instructions.

A couple of other minor edits (that make no functional change) are
also included.

gas/ChangeLog:

        * config/tc-arc.c (options, md_longopts, md_parse_option):
        Move -mspfp, -mdpfp and -mfpuda out of the sections for
        dummy options. Correct erroneous enabling of SPFP
        instructions when using -mnps400.

include/ChangeLog:

        * opcode/arc.h: Make insn_class_t alphabetical again.

opcodes/ChangeLog:

        * arc-opc.c: Correct description of availability of NPS400
        features.

8 years agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Jun 2016 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoMIPS/LD/testsuite: Use wildcard address matching in `undefweak-overflow'
Maciej W. Rozycki [Wed, 22 Jun 2016 23:41:34 +0000 (00:41 +0100)]
MIPS/LD/testsuite: Use wildcard address matching in `undefweak-overflow'

So that test case updates result in legible dump pattern changes.

ld/
* testsuite/ld-mips-elf/undefweak-overflow.d: Use wildcard
address matching.

8 years agoMIPS/LD/testsuite: Uniquely identify `undefweak-overflow' tests
Maciej W. Rozycki [Wed, 22 Jun 2016 23:29:14 +0000 (00:29 +0100)]
MIPS/LD/testsuite: Uniquely identify `undefweak-overflow' tests

ld/
* testsuite/ld-mips-elf/mips-elf.exp: Uniquely identify
`undefweak-overflow' tests.

8 years agoMIPS/GAS: Handle resolved R6 PC-relative relocations (ChangeLog)
Maciej W. Rozycki [Tue, 21 Jun 2016 20:22:39 +0000 (21:22 +0100)]
MIPS/GAS: Handle resolved R6 PC-relative relocations (ChangeLog)

Add missing ChangeLog entry for commit 41947d9e38c4 ("MIPS/GAS: Handle
resolved R6 PC-relative relocations").

8 years agoAdd support for yet some more new ISA 3.0 instructions.
Peter Bergner [Wed, 22 Jun 2016 22:55:17 +0000 (17:55 -0500)]
Add support for yet some more new ISA 3.0 instructions.

opcodes/
* ppc-opc.c (RM, DRM, VXASH, VXASH_MASK, XMMF, XMMF_MASK): New defines.
(powerpc_opcodes) <brd, brh, brw, mffsce, mffscdrn, mffscdrni,
mffscrn, mffscrni, mffsl, nandxor, rldixor, setbool,
xor3>: New mnemonics.
<setb>: Change to a VX form instruction.
(insert_sh6): Add support for rldixor.
(extract_sh6): Likewise.

gas/
* testsuite/gas/ppc/power9.d <brd, brh, brw, mffs, mffs., mffsce,
mffscdrn, mffscdrni, mffscrn, mffscrni, mffsl, nandxor, rldixor,
setbool, xor3>: New tests.
* testsuite/gas/ppc/power9.s: Likewise.

8 years agoaddmore extern C
Trevor Saunders [Sat, 4 Jun 2016 03:11:46 +0000 (23:11 -0400)]
addmore extern C

opcodes/ChangeLog:

2016-06-22  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* arc-ext.h: Wrap in extern C.

include/ChangeLog:

2016-06-22  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* elf/dlx.h: Wrap in extern C.
* elf/xtensa.h: Likewise.
* opcode/arc.h: Likewise.

8 years agoFix various binutils testsuite failures.
Nick Clifton [Wed, 22 Jun 2016 13:42:26 +0000 (14:42 +0100)]
Fix various binutils testsuite failures.

* testsuite/binutils-all/ar.exp: Skip tests for Alpha target.
Skip bfdtest1 tests for tic30 target.
* testsuite/binutils-all/arm/objdump.exp: Skip for aout arm
target.
* testsuite/binutils-all/compress.exp: Expect some tests to fail
on the nds32.
* testsuite/binutils-all/copy-3.d: Skip for go32 targets.
* testsuite/binutils-all/copy-4.d: Skip for AIX and linuxecoff
targets.
* testsuite/binutils-all/nm.exp: Treat beos based targets as ELF
targets.
* testsuite/binutils-all/objcopy.exp: Only run reverse bytes tests
if the bintest.o file was created.  Use the
get_standard_section_names proc to get the name of the data
section.
* testsuite/binutils-all/objdump.exp: Update regexps to allow for
RX section names.
* testsuite/binutils-all/readelf.exp: Use
get_standard_section_names proc to get the name of the data
section.
* testsuite/binutils-all/readelf.r: Allow for non standard text
section names.
* testsuite/binutils-all/readelf.s: Update regexps for tilepro.
* testsuite/binutils-all/size.exp: Allow for non standard section
names.
* testsuite/binutils-all/update-section.exp: Expect comapre 1vs4
to fail on mips targets.
* testsuite/lib/utils-lib.exp (default_binutils_run): Use
get_standard_section_names proc.
(run_dump_test): Likewise.
(proc get_standard_section_names): New proc.

8 years agogold: Add a linker configure option --enable-relro
H.J. Lu [Wed, 22 Jun 2016 12:39:22 +0000 (05:39 -0700)]
gold: Add a linker configure option --enable-relro

Add a configure option --enable-relro to decide whether -z relro should
be enabled by default.  Default to yes.

PR ld/20283
* NEWS: Mention --enable-relro.
* configure.ac: Add --enable-relro.
(DEFAULT_LD_Z_RELRO): New.  Set by --enable-relro and default
to 1.
* config.in: Regenerated.
* configure: Likewise.
* options.h (General_options::relro): Default to
DEFAULT_LD_Z_RELRO.

8 years agold: Add a linker configure option --enable-relro
H.J. Lu [Wed, 22 Jun 2016 12:37:24 +0000 (05:37 -0700)]
ld: Add a linker configure option --enable-relro

Add a configure option --enable-relro to decide whether -z relro should
be enabled in ELF linker by default.  Default to yes for all Linux
targets, except FRV, HPPA, IA64 and MIPS, since many relro tests fail
on these targets.

PR ld/20283
* NEWS: Mention --enable-relro.
* configure.ac: Add --enable-relro.
(DEFAULT_LD_Z_RELRO): New.  Set by --enable-relro.
* configure.tgt (ac_default_ld_z_relro): Default it to 1 for
some Linux targets.
* config.in: Regenerated.
* configure: Likewise.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set
link_info.relro to DEFAULT_LD_Z_RELRO.
* testsuite/config/default.exp (ld_elf_shared_opt): New.
* testsuite/lib/ld-lib.exp (run_dump_test): Pass
$ld_elf_shared_opt to ld for ELF targets with shared object
support.
(run_ld_link_tests): Likewise.

8 years agotilegx: move TILEGX_NUM_PIPELINE_ENCODINGS to tilegx_pipeline enum
Trevor Saunders [Sat, 28 May 2016 15:54:51 +0000 (11:54 -0400)]
tilegx: move TILEGX_NUM_PIPELINE_ENCODINGS to tilegx_pipeline enum

Its closely related to what the encodings are, more than a set of random
constants, so it seems to make sense to put it here.

include/ChangeLog:

2016-06-22  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* opcode/tilegx.h: Move TILEGX_NUM_PIPELINE_ENCODINGS into
tilegx_pipeline.

8 years agoxtensa: include elf/xtensa.h in tc-xtensa.c
Trevor Saunders [Sat, 4 Jun 2016 20:45:13 +0000 (16:45 -0400)]
xtensa: include elf/xtensa.h in tc-xtensa.c

There's no reason to define these macros twice.

gas/ChangeLog:

2016-06-22  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* config/tc-xtensa.c: Include elf/xtensa.h.

8 years agoIncrease size of string buffer used to hold printed versions of timestamps.
Nick Clifton [Wed, 22 Jun 2016 08:55:50 +0000 (09:55 +0100)]
Increase size of string buffer used to hold printed versions of timestamps.

binutils* readelf.c (dynamic_section_mips_val): Increase size of timebuf.
(process_mips_specific): Likewise.
(process_gnu_liblist): Likewise.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 22 Jun 2016 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoMIPS/GAS: Handle resolved R6 PC-relative relocations
Maciej W. Rozycki [Tue, 21 Jun 2016 20:22:39 +0000 (21:22 +0100)]
MIPS/GAS: Handle resolved R6 PC-relative relocations

Complement commit 7361da2c952e ("Add support for MIPS R6.") and fix
internal errors like:

foo.s: Assembler messages:
foo.s: Internal error!
Assertion failure in md_apply_fix at .../gas/config/tc-mips.c:15028.
Please report this bug.

triggered by resolved R6 PC-relative relocations in sources containing
R6 code fragments wrapped into ISA override blocks embedded within code
otherwise assembled for an older ISA.

gas/
* config/tc-mips.c (calculate_reloc) <BFD_RELOC_HI16_S_PCREL>
<BFD_RELOC_LO16_PCREL>: New switch cases.
(md_apply_fix) <BFD_RELOC_HI16_S_PCREL, BFD_RELOC_LO16_PCREL>:
Move switch cases along `BFD_RELOC_MIPS_JMP'.
<BFD_RELOC_MIPS_21_PCREL_S2, BFD_RELOC_MIPS_26_PCREL_S2>
<BFD_RELOC_MIPS_18_PCREL_S3, BFD_RELOC_MIPS_19_PCREL_S2>: Handle
the resolved case.
* testsuite/gas/mips/pcrel-reloc-4.d: New test.
* testsuite/gas/mips/pcrel-reloc-4-r6.d: New test.
* testsuite/gas/mips/pcrel-reloc-5.d: New test.
* testsuite/gas/mips/pcrel-reloc-5-r6.d: New test.
* testsuite/gas/mips/pcrel-reloc-6.d: New test.
* testsuite/gas/mips/pcrel-reloc-6.l: New list test.
* testsuite/gas/mips/pcrel-reloc-4.s: New test source.
* testsuite/gas/mips/pcrel-reloc-6.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

8 years agoMIPS/GAS: Fix null pointer dereferences in R6 PC-relative relocation checks
Maciej W. Rozycki [Tue, 21 Jun 2016 19:12:00 +0000 (20:12 +0100)]
MIPS/GAS: Fix null pointer dereferences in R6 PC-relative relocation checks

Avoid segmentation faults in alignment checks made in `md_apply_fix' for
BFD_RELOC_MIPS_18_PCREL_S3 and BFD_RELOC_MIPS_19_PCREL_S2 relocations
caused by dereferencing `fixP->fx_addsy' which will be null if the
relocation processed has been fully resolved.

gas/
* config/tc-mips.c (md_apply_fix) <BFD_RELOC_MIPS_18_PCREL_S3>
<BFD_RELOC_MIPS_19_PCREL_S2>: Avoid null pointer dereferences
via `fixP->fx_addsy'.

8 years agoMIPS/GAS: Correct BFD_RELOC_MIPS_18_PCREL_S3 calculation
Maciej W. Rozycki [Tue, 21 Jun 2016 17:54:16 +0000 (18:54 +0100)]
MIPS/GAS: Correct BFD_RELOC_MIPS_18_PCREL_S3 calculation

The PC-relative R_MIPS_PC18_S3 relocation and consequently its BFD
internal BFD_RELOC_MIPS_18_PCREL_S3 representation is calculated from
the address of the aligned doubleword containing the location being
relocated: (sign_extend(A) + S - (P & ~0x7)) >> 3 rather than the
address of the location itself.  Reflect this in calculations made by
GAS so that the relocated field is set correctly if resolved by GAS,
such as with local symbols in the same section which do not require
relocations to be propagated to the link stage.

gas/
* config/tc-mips.c (md_pcrel_from) <BFD_RELOC_MIPS_18_PCREL_S3>:
Calculate relocation from the containing aligned doubleword.
(tc_gen_reloc) <BFD_RELOC_MIPS_18_PCREL_S3>: Calculate the
addend from the containing aligned doubleword.

8 years agoMIPS/GAS: Use the module level ISA setting for R6 relaxation
Maciej W. Rozycki [Tue, 21 Jun 2016 15:01:27 +0000 (16:01 +0100)]
MIPS/GAS: Use the module level ISA setting for R6 relaxation

Use the module level ISA setting rather than the last ISA selected with
a `.set' directive in the source file in determination as to whether to
keep PC-relative relocations and then with the original symbol referred,
for the purpose of R6 linker relaxation.

This is so that with e.g. code like this:

b foo
.set mips32r2
...

it's the command line options or any `.module' directive that decides
how to encode any relocation for `foo' rather than the presence of `.set
mips32r2'.

gas/
* config/tc-mips.c (mips_force_relocation): Use `file_mips_opts'
rather than `mips_opts' for the R6 ISA check.
(mips_fix_adjustable): Likewise.
* testsuite/gas/mips/pcrel-reloc-1.d: New test.
* testsuite/gas/mips/pcrel-reloc-1-r6.d: New test.
* testsuite/gas/mips/pcrel-reloc-2.d: New test.
* testsuite/gas/mips/pcrel-reloc-2-r6.d: New test.
* testsuite/gas/mips/pcrel-reloc-3.d: New test.
* testsuite/gas/mips/pcrel-reloc-3-r6.d: New test.
* testsuite/gas/mips/pcrel-reloc-1.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

8 years agoMIPS/BFD: Don't stop processing on a cross-mode jump conversion error
Maciej W. Rozycki [Tue, 21 Jun 2016 13:06:27 +0000 (14:06 +0100)]
MIPS/BFD: Don't stop processing on a cross-mode jump conversion error

As with commit ed53407eec9e ("MIPS/BFD: Don't stop processing on
`bfd_reloc_outofrange'") don't bail out right away and instead continue
processing on a cross-mode jump conversion error, so that any further
issues are also reported.  Adjust message formatting accordingly, using
`%X' to abort processing at conclusion.  Remove the full stop from the
end of the message, for consistency across error reporting.

Adjust the corresponding test case accordingly and make it trigger the
error twice.

bfd/
* elfxx-mips.c (mips_elf_perform_relocation): Call
`info->callbacks->einfo' rather than `*_bfd_error_handler' and
use the `%X%H' format for the cross-mode jump conversion error
message.  Remove the full stop from the end of the message.
Continue processing rather than returning failure.

ld/
* testsuite/ld-mips-elf/mode-change-error-1a.s: Trigger an error
twice rather than once.
* testsuite/ld-mips-elf/mode-change-error-1.d: Adjust
accordingly.  Remove the full stop from the end of the message.

8 years agoImprove user experience in printing Fortran derived types.
Walfred Tedeschi [Tue, 21 Jun 2016 13:15:04 +0000 (15:15 +0200)]
Improve user experience in printing Fortran derived types.

Output for Fortran derived classes is like:

  "( 9, 'abc')"

with this changes the output is changed to:

  "( lucky_number = 9, letters = 'abc')"

2016-06-21  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* f-valprint.c (f_val_print): Add field names for printing
derived types fields.

gdb/testsuite:

* gdb.fortran/derived-type.exp (print q): Add fields to the output.
* gdb.fortran/vla-type.exp (print twov): Fix vla tests with
structs.
* gdb.fortran/derived-type-function.exp: New file.
* gdb.fortran/derived-type-function.f90: New file.

8 years agoArc assembler: Convert nps400 from a machine type to an extension.
Graham Markall [Tue, 21 Jun 2016 13:03:08 +0000 (14:03 +0100)]
Arc assembler: Convert nps400 from a machine type to an extension.

gas * config/tc-arc.c (check_cpu_feature, md_parse_option):
Add nps400 option and feature. Add check for nps400
feature. Refactor existing checks to check subclass before
feature enablement.
(md_show_usage): Document flags for NPS-400 and add some other
undocumented flags.
(cpu_type): Remove nps400 CPU type entry
(check_zol): Remove bfd_mach_arc_nps400 case.
(md_show_usage): Add help on -mcpu=nps400.
(cpu_types): Add entry for nps400 as arc700 plus nps400 extension
set.
* doc/c-arc.texi: Document the -mnps400, -mspfp, -mdpfp, and
-fpuda flags.  Document -mcpu=nps400.
* testsuite/gas/arc/nps-400-0.d: Use -mcpu=arc700 -mnps400. Change
expected flags to match ARC700 instead of NPS400.
* testsuite/gas/arc/nps-400-1.d: Use -mcpu=arc700 -mnps400.
* testsuite/gas/arc/nps-400-2.d: Likewise.
* testsuite/gas/arc/nps-400-3.d: Likewise.
* testsuite/gas/arc/nps-400-4.d: Likewise.
* testsuite/gas/arc/nps-400-5.d: Likewise.
* testsuite/gas/arc/nps-400-6.d: Likewise.
* testsuite/gas/arc/nps-400-7.d: Likewise.
* testsuite/gas/arc/textinsn2op01.s: Change opcode of myinsn to
avoid clash with cbba instruction.
* testsuite/gas/arc/textinsn2op01.d: Likewise.
* testsuite/gas/arc/textinsn3op.d: Likewise.
* testsuite/gas/arc/textinsn3op.s: Likewise.
* testsuite/gas/arc/nps-400-0.d: Test using NPS-400 using
-mcpu=nps400 as an alternative to -mcpu=arc700 -mnps400 flags.

binutils* readelf.c (decode_ARC_machine_flags): Remove E_ARC_MACH_NPS400
case.

ld * testsuite/ld-arc/nps-1a.d: Use -mcpu=arc700 -mnps400.
* testsuite/ld-arc/nps-1b.d: Likewise.

include * opcode/arc.h: Add nps400 extension and instruction
subclass.
Remove ARC_OPCODE_NPS400
* elf/arc.h: Remove E_ARC_MACH_NPS400

opcodes * arc-dis.c (arc_insn_length): Add comment on instruction length.
Use same method for determining instruction length on ARC700 and
NPS-400.
(arc_insn_length, print_insn_arc): Remove bfd_mach_arc_nps400.
* arc-nps400-tbl.h: Make all nps400 instructions ARC700 instructions
with the NPS400 subclass.
* arc-opc.c: Likewise.

bfd * archures.c: Remove bfd_mach_arc_nps400.
* bfd-in2.h: Likewise.
* cpu-arc.c (arch_info_struct): Likewise.
* elf32-arc.c (arc_elf_object_p, arc_elf_final_write_processing):
Likewise.

8 years agoS390 gdbserver: Mark local funcs/vars as static
Andreas Arnez [Tue, 21 Jun 2016 11:26:11 +0000 (13:26 +0200)]
S390 gdbserver: Mark local funcs/vars as static

Compiling with '-Wmissing-declarations' yields warnings in
linux-s390-low.c.  To fix this, mark appropriate functions as static.

gdb/gdbserver/ChangeLog:

* linux-s390-low.c (s390_emit_eq_goto): Mark function static.
(s390_emit_ne_goto): Likewise.
(s390_emit_lt_goto): Likewise.
(s390_emit_le_goto): Likewise.
(s390_emit_gt_goto): Likewise.
(s390_emit_ge_goto): Likewise.
(s390x_emit_eq_goto): Likewise.
(s390x_emit_ne_goto): Likewise.
(s390x_emit_lt_goto): Likewise.
(s390x_emit_le_goto): Likewise.
(s390x_emit_gt_goto): Likewise.
(s390x_emit_ge_goto): Likewise.
(s390_emit_ops_impl): Mark variable static.
(s390x_emit_ops): Likewise.

8 years agoS390: Fix typo "s930" -> "s390"
Andreas Arnez [Tue, 21 Jun 2016 11:26:11 +0000 (13:26 +0200)]
S390: Fix typo "s930" -> "s390"

This fixes a typo in the name of the "last-break" regset.

gdb/ChangeLog:

* s390-linux-tdep.c (s390_iterate_over_regset_sections): Fix typo
in name of last-break regset.

8 years agoUpdate gold to version 1.12.
Cary Coutant [Tue, 21 Jun 2016 03:13:08 +0000 (20:13 -0700)]
Update gold to version 1.12.

gold/
* NEWS: Add new features in 1.12.
* version.cc (version_string): Bump to 1.12.

8 years agoAdd "new-ui console" tests
Pedro Alves [Tue, 21 Jun 2016 00:11:57 +0000 (01:11 +0100)]
Add "new-ui console" tests

This adds a test that uses new-ui to create a secondary console, and
then runs some basic smoke tests.  It ensures that:

 - synchronous commands send output to the UI that initiated it

 - asynchronous events like breakpoint hits are reported on all
   consoles.

 - "new-ui" without arguments doesn't crash.

 - The "new-ui" command doesn't repeat.

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

* gdb.base/new-ui.exp: New file.
* lib/mi-support.exp (switch_gdb_spawn_id): Move to ...
* lib/gdb.exp (switch_gdb_spawn_id): ... here.
(with_spawn_id): New procedure.

8 years agoAlways switch fork child to the main UI
Pedro Alves [Tue, 21 Jun 2016 00:11:57 +0000 (01:11 +0100)]
Always switch fork child to the main UI

The following scenario:

 - gdb started in normal CLI mode.

 - separate MI channel created with new-ui

 - inferior output redirected with the "set inferior-tty" command.

 - use -exec-run in the MI channel to run the inferior

is presently mishandled.

When we create the inferior, in fork-child.c, right after vfork, we'll
close all the file descriptors in the vfork child, and then dup the
tty to file descriptors 0/1/2, create a session, etc.  Note that when
we close all descriptors, we close the file descriptors behind
gdb_stdin/gdb_stdout/gdb_stderr of all secondary UIs...  So if
anything goes wrong in the child and it calls warning/error, it'll end
up writting to the current UI's stdout/stderr streams, which are
backed by file descriptors that have since been closed.  Because this
happens in a vfork region, the corresponding stdin/stdout/stderr in
the parent/gdb end up corrupted.

The fix is to switch to the main UI right after the vfork, so that
gdb_stdin/gdb_stdout/gdb_stderr are correctly mapped to
stdin/stdout/stderr (and thus to file descriptors 0/1/2), so this code
works as it has always worked.

(Technically, we're doing a lot of stuff we shouldn't be doing after a
vfork, while we should only be calling async-signal-safe functions.)

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* fork-child.c (fork_inferior): Switch the child to the main UI
right after vfork.  Save/restore the current UI in the parent.
Flush outputs of the main UI instead of the current UI.

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

* gdb.mi/mi-exec-run.exp: New file.

8 years agoMake mi-break.exp always expect breakpoint commands output on the main UI
Pedro Alves [Tue, 21 Jun 2016 00:11:56 +0000 (01:11 +0100)]
Make mi-break.exp always expect breakpoint commands output on the main UI

mi-break.exp regresses when tested with MI running on a secondary UI,
with RUNTESTFLAGS="FORCE_SEPARATE_MI_TTY=1".

The problem is simply that the test sets a breakpoint, and attaches
"print" commands to the breakpoint.  Since breakpoint commands always
run with the main UI as current UI, the breakpoint command's output
goes to the main UI.  So we need to tweak the test to expect it there.

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

* gdb.mi/mi-break.exp (test_breakpoint_commands): Always expect
breakpoint command's output on the main UI.
(test_break): New procedure, factored out from calls in the top
level.
(top level): Use foreach_with_prefix to test MI as main UI and as
separate UI.

8 years agoSend deleted watchpoint-scope output to all UIs
Pedro Alves [Tue, 21 Jun 2016 00:11:56 +0000 (01:11 +0100)]
Send deleted watchpoint-scope output to all UIs

Testing with:

  make check RUNTESTFLAGS="SEPARATE_MI_TTY=1"

shows this, in gdb.mi/mi-watch.exp:

 -*stopped,reason="watchpoint-scope",wpnum="2",frame={addr="0x00000000004005cb",
 +*stopped,frame={addr="0x00000000004005cb",
 (...)
 -PASS: gdb.mi/mi-watch.exp: hw: watchpoint trigger
 +FAIL: gdb.mi/mi-watch.exp: hw: watchpoint trigger (unknown output after running)

That is, we lose the "watchpoint-scope" output on the MI UI.

This commit fixes it, and makes the test run with MI running as both
main UI and separate UI.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* breakpoint.c (watchpoint_check): Send watchpoint-deleted output
to all UIs.

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

* gdb.mi/mi-watch.exp (test_watchpoint_creation_and_listing)
(test_awatch_creation_and_listing)
(test_rwatch_creation_and_listing, test_watchpoint_triggering):
Remove 'type' parameter.
(test_watchpoint_all): New parameter mi_mode.  Remove
with_test_prefix.
(top level): Use foreach_with_prefix, and add main/separate UI MI
testing axis.

8 years agoAdd testing infrastruture bits for running with MI on a separate UI
Pedro Alves [Tue, 21 Jun 2016 00:11:55 +0000 (01:11 +0100)]
Add testing infrastruture bits for running with MI on a separate UI

With this, a specific test may can start GDB with MI on a separate UI
by using:

  mi_gdb_start separate-mi-tty

In addition, it's also possible to run the whole testsuite with MI on
a separate tty, with:

 make check RUNTESTFLAGS="FORCE_SEPARATE_MI_TTY=1"

gdb_main_spawn_id and mi_spawn_id are added so that tests may expect
output from either channel.

While at it, inferior_spawn_id was not being cleared when gdb exits,
unlike the other spawn ids, thus a test that starts gdb more than once
would end up using a stale spawn id.

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

* README (Testsuite Parameters): Document FORCE_SEPARATE_MI_TTY.
* lib/gdb.exp (default_gdb_exit): Clear inferior_spawn_id.
* lib/mi-support.exp (mi_uncatched_gdb_exit): Unset
gdb_main_spawn_id, mi_spawn_id, unset inferior_spawn_id.
(gdb_main_spawn_id, mi_spawn_id): Declare and
comment.
(mi_create_inferior_pty): New procedure,
factored out from default_mi_gdb_start.
(switch_gdb_spawn_id, mi_gdb_start_separate_mi_tty): New
procedures.
(default_mi_gdb_start): Call mi_gdb_start_separate_mi_tty if the
separate-mi-tty option is specified, or SEPARATE_MI_TTY is set.
Use mi_create_inferior_pty.
(mi_gdb_start): Use eval to pass down args list.

8 years ago[DOC] Document support for running interpreters on separate UIs
Pedro Alves [Tue, 21 Jun 2016 00:11:55 +0000 (01:11 +0100)]
[DOC] Document support for running interpreters on separate UIs

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* NEWS: Mention support for running interpreters on separate
UIs and the new new-ui command.

gdb/doc/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* gdb.texinfo (Interpreters): Update intepreter-exec section,
document new-ui and explain use case.

8 years agoAdd new command to create extra console/mi UIs
Pedro Alves [Tue, 21 Jun 2016 00:11:55 +0000 (01:11 +0100)]
Add new command to create extra console/mi UIs

With all the previous plumbing in place, it's now easy to add a
command that actually creates a new console/mi UI.

The intended use case is to make it possible and easy for MI frontends
to provide a fully featured GDB console to users, with readline
support, command line editing, history, etc., just like if gdb was
started on the command line.  Currently MI frontends have to try to
implement all of that theirselves and make use of "-interpreter-exec
console ...", which is far from perfect.  If you ever tried Eclipse's
gdb console window, you'll know what I mean...

Instead of trying to multiplex console through MI, this command let's
just leverage all the built in readline/editing support already inside
gdb.

The plan is for the MI frontend to start GDB in regular console mode,
running inside a terminal emulator widget embedded in Eclipse (which
already exists, for supporting the shell widget; other frontends have
similar widgets), and then tell GDB to run a full MI interpreter on an
specified input/output device, independent of the console.

My original prototype planned to do things the other way around --
start GDB in MI mode, and then start an extra CLI console on separate
tty.  I handed over that prototype to Marc Khouzam @ Eclipse CDT, and
after experimentation and discussion, we ended up concluding that
starting GDB in CLI mode instead was both easier and actually also
supported an interesting use case -- connect an Eclipse frontend to a
GDB that is already running outside Eclipse.

The current usage is "new-ui <interpreter> <tty>".

E.g., on a terminal run this scriplet:

 $ cat gdb-client
 #!/bin/bash

 reset
 tty
 tail -f /dev/null

 $ gdb-client
 /dev/pts/15

Now run gdb on another terminal, and tell it to start a MI interpreter
on the tty of the other terminal:

 ...
 (gdb) new-ui mi /dev/pts/15
 New UI allocated

Now back to the the gdb-client terminal, we'll get an MI prompt, ready
for MI input:

 /dev/pts/15
 =thread-group-added,id="i1"
 (gdb)

You can also start a new UI running a CLI, with:

 (gdb) new-ui console /dev/pts/15

Though note that this console won't support readline command editing.
It works as if "set editing off" was entered.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* interps.c (set_top_level_interpreter): New function, factored
out from captured_main.
(interpreter_completer): Make extern.
* interps.h (set_top_level_interpreter, interpreter_completer):
New declarations.
(captured_main): Use set_top_level_interpreter.
* top.c [!O_NOCTTY] (O_NOCTTY): Define as 0.
(open_terminal_stream, new_ui_command): New functions.
(init_main): Install the "new-ui" command.

8 years agoMake stdin be per UI
Pedro Alves [Tue, 21 Jun 2016 00:11:54 +0000 (01:11 +0100)]
Make stdin be per UI

This commit makes each UI have its own "stdin" stream pointer.  This
is used to determine whether the "from_tty" argument to
execute_command, etc. should be true.

Related, this commit makes input_from_terminal_p take an UI parameter,
and then avoids the gdb_has_a_terminal in it.  gdb_has_a_terminal only
returns info on gdb's own main/primary terminal (the real stdin).
However, the places that call input_from_terminal_p really want to
know is whether the command came from an interactive tty.  This patch
thus renames input_from_terminal_p to input_interactive_p for clarity,
and then makes input_interactive_p check for "set interactive" itself,
along with ISATTY, instead of calling gdb_has_a_terminal.  Actually,
quit_force wants to call input_interactive_p _after_ stdin is closed,
we can't call ISATTY that late.  So instead we save the result of
ISATTY in a field of the UI.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* cli/cli-script.c (read_next_line): Adjust to per-UI stdin.
(read_command_lines): Use input_interactive_p instead of
input_from_terminal_p.
* defs.h (struct ui): Forward declare.
(input_from_terminal_p): Rename to ...
(input_interactive_p): ... this.
* event-top.c (stdin_event_handler): Pass 0 as from_tty argument
to quit_command.
(command_handler): Adjust to per-UI stdin.
(handle_line_of_input): Adjust to per-UI stdin and use
input_interactive_p instead of ISATTY and input_from_terminal_p.
(gdb_readline_no_editing_callback): Adjust to per-UI stdin.
(command_line_handler): Always pass true as "from_tty" parameter
of handle_line_of_input and execute_command.
(async_sigterm_handler): Pass 0 as from_tty argument to
quit_command.
* inflow.c (interactive_mode, show_interactive_mode): Moved to ...
(gdb_has_a_terminal): Don't check interactive_mode here.
(_initialize_inflow): Don't install "set interactive-mode" here.
* main.c (captured_command_loop): Adjust to per-UI stdin.
* mi/mi-interp.c (mi_execute_command_wrapper): Adjust to per-UI
stdin.
* top.c (new_ui): Save the stdin stream and whether it's a tty.
(dont_repeat): Adjust to per-UI stdin.
(command_line_input): Adjust to per-UI stdin and to use
input_interactive_p.
(quit_force): Write history if any UI supports interactive input.
(interactive_mode, show_interactive_mode): Move here, from
inflow.c.
(input_from_terminal_p): Rename to ...
(input_interactive_p): ... this, and check the "interactive_mode"
global instead of calling gdb_has_a_terminal.
(_initialize_top): Install "set interactive-mode" here.
* top.h (struct ui) <stdin_stream, input_interactive_p>: New
fields.
* utils.c (quit): Pass 0 as from_tty argument to quit_force.
(defaulted_query): Adjust to per-UI stdin and to use
input_interactive_p.

8 years agoHandle UI's terminal closing
Pedro Alves [Tue, 21 Jun 2016 00:11:54 +0000 (01:11 +0100)]
Handle UI's terminal closing

Without this, GDB exits if a secondary UIs terminal/input stream is
closed:

 $ ./gdb -ex "new-ui mi /dev/pts/6"
 New UI allocated
 <<< close /dev/pts/6
 (gdb) Error detected on fd 9
 $

We want that for the main UI, but not secondary UIs.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* event-top.c (stdin_event_handler): Don't quit gdb if it was a
secondary UI's input stream that closed.  Instead, just delete the
UI.

8 years agoMake main_ui be heap allocated
Pedro Alves [Tue, 21 Jun 2016 00:11:53 +0000 (01:11 +0100)]
Make main_ui be heap allocated

This is preparation for being able to create more than one UI object.

The change to gdb_main to stop using catch_errors is necessary because
catch_errors references current_uiout, which expands to
current_ui->m_current_ui, which would crash because current_ui is not
initialized yet at that point.  It didn't trigger earlier in the
series because before this patch, main_ui/current_ui always start out
non-NULL.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* event-top.c (main_ui_): Delete.
(main_ui, current_ui, ui_list): No longer initialize here.
* main.c (captured_main): UI initialization code factored out to
new new_ui function.
(gdb_main): Wrap captured_main with TRY/CATCH instead of
catch_errors.
* top.c (highest_ui_num): New global.
(new_ui): New function.
* top.h (struct ui) <num>: New field.
(new_ui): New declaration.

8 years agoOnly send sync execution command output to the UI that ran the command
Pedro Alves [Tue, 21 Jun 2016 00:11:53 +0000 (01:11 +0100)]
Only send sync execution command output to the UI that ran the command

Currently when a "step", "next", etc. finishes, the current source
line is printed on all console UIs.

This patch makes the CLI and TUI interpreters reuse MI's logic to only
emit console output related to a synchronous command on the
console-like interpreter that started the command in the first place.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* cli/cli-interp.c (cli_on_normal_stop): Bail out early if there's
nothing to print.  Use should_print_stop_to_console.
* tui/tui-interp.c (tui_on_normal_stop): Likewise.

8 years agoPush thread->control.command_interp to the struct thread_fsm
Pedro Alves [Tue, 21 Jun 2016 00:11:53 +0000 (01:11 +0100)]
Push thread->control.command_interp to the struct thread_fsm

I noticed that if we step into an inline function, step_1 never
reaches proceed, and thus nevers sets the thread's
tp->control.command_interp.  Because of that,
should_print_stop_to_console fails to determine that is should print
stop output to the console.

The fix is to set the thread's command_interp earlier.  However, I
realized that we can move that field to the thread_fsm, given that its
lifetime is exactly the same as thread_fsm.  So the patch plumbs all
fsms constructors to take the command interp and store it in the
thread_fsm.

We can see the fix in action, with e.g., the gdb.opt/inline-cmds.exp
test, and issuing a step when stopped at line 67:

 &"s\n"
 ^running
 *running,thread-id="all"
 (gdb)
 ~"67\t  result = func2 ();\n"
 *stopped,reason="end-stepping-range",frame={addr="0x00000000004004d0",func="main",args=[],file="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.opt/inline-cmds.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.opt/inline-cmds.c",line="67"},thread-id="1",stopped-threads="all",core="0"
 (gdb)
 s
 &"s\n"
 ^running
 *running,thread-id="all"
 (gdb)
+ ~"func2 () at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.opt/inline-cmds.c:67\n"
+ ~"67\t  result = func2 ();\n"
 *stopped,reason="end-stepping-range",frame={addr="0x00000000004004d0",func="func2",args=[],file="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.opt/inline-cmds.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.opt/inline-cmds.c",line="67"},thread-id="1",stopped-threads="all",core="0"
 (gdb)

(The inline-cmds.exp command is adjusted to exercise this.)

(Due to the follow_fork change, this also fixes "next N" across a fork
with "set follow-fork child" with "set detach-on-fork on".  Commands
that rely on internal breakpoints, like "finish" will still require
more work to migrate breakpoints etc. to the child thread.)

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* breakpoint.c (new_until_break_fsm): Add 'cmd_interp' parameter.
(until_break_fsm_should_stop, until_break_fsm_clean_up): Add
thread parameter.
(until_break_command): Pass command interpreter to thread fsm
ctor.
* cli/cli-interp.c (should_print_stop_to_console): Adjust.
* gdbthread.h (struct thread_control_state) <command_interp>:
Delete field.
* infcall.c (new_call_thread_fsm): Add 'cmd_interp' parameter.
Pass it down.
(call_thread_fsm_should_stop): Add thread parameter.
(call_function_by_hand_dummy): Pass command interpreter to thread
fsm ctor.  Pass thread pointer to fsm clean up method.
* infcmd.c: Include interps.h.
(struct step_command_fsm) <thread>: Delete field.
(new_step_command_fsm): Add 'cmd_interp' parameter.  Pass it down.
(step_command_fsm_prepare): Remove references to fsm's thread
field.
(step_1): Pass command interpreter to thread
fsm ctor.  Pass thread pointer to fsm clean up method.
(step_command_fsm_should_stop, step_command_fsm_clean_up): Add
thread parameter and use it.
(new_until_next_fsm): Add 'cmd_interp' parameter.  Pass it down.
(until_next_fsm_should_stop, until_next_fsm_clean_up): Add thread
parameter and use it.
(until_next_command): Pass command interpreter to thread fsm ctor.
(struct finish_command_fsm) <thread>: Delete field.
(finish_command_fsm_ops): Add NULL slot for should_notify_stop.
(new_finish_command_fsm): Add 'cmd_interp' parameter and pass it
down.  Remove thread parameter and adjust.
(finish_command_fsm_should_stop, finish_command_fsm_clean_up): Add
thread parameter and use it.
(finish_command): Pass command interpreter to thread fsm ctor.
Don't pass thread.
* infrun.c (follow_fork): Move thread fsm to child fork instead of
command interpreter, only.
(clear_proceed_status_thread): Remove reference to command_interp.
(proceed): Don't record the thread's command interpreter.
(clean_up_just_stopped_threads_fsms): Pass thread to fsm clean_up
method.
(fetch_inferior_event): Pass thread to fsm should_stop method.
* thread-fsm.c (thread_fsm_ctor): Add 'cmd_interp' parameter.
Store it.
(thread_fsm_clean_up, thread_fsm_should_stop): Add thread
parameter and pass it down.
* thread-fsm.h (struct thread_fsm) <command_interp>: New field.
(struct thread_fsm_ops) <clean_up, should_stop>: Add thread
parameter.
(thread_fsm_ctor): Add 'cmd_interp' parameter.
(thread_fsm_clean_up, thread_fsm_should_stop): Add thread
parameter.
* thread.c (thread_cancel_execution_command): Pass thread to
thread fsm clean_up method.

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

* gdb.opt/inline-cmds.c: Add "set mi break here" marker.
* gdb.opt/inline-cmds.exp: Add MI tests.

8 years agoNew function should_print_stop_to_console
Pedro Alves [Tue, 21 Jun 2016 00:11:52 +0000 (01:11 +0100)]
New function should_print_stop_to_console

There's code in the MI interpreter that decides whether a stop should
be sent to MI's console stream.  Move this check to the CLI
interpreter code, so that we can reuse it in both the CLI and TUI
interpreters.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* cli/cli-interp.c: Include gdbthread.h and thread-fsm.h.
(should_print_stop_to_console): New function, factored out from
mi_on_normal_stop_1.
* cli/cli-interp.h (should_print_stop_to_console): Declare.
* mi/mi-interp.c (mi_on_normal_stop_1): Use
should_print_stop_to_console.  Pass it the current UI's console
interpreter.
* mi/mi-main.c (captured_mi_execute_command): Use the
INTERP_CONSOLE symbol rather than explicit "console".

8 years agoFix for spurious prompts in secondary UIs
Pedro Alves [Tue, 21 Jun 2016 00:11:52 +0000 (01:11 +0100)]
Fix for spurious prompts in secondary UIs

Running mi-break.exp with MI on a secondary UI reveals that MI emits
spurious prompts compared MI running as primary UI:

   -exec-continue
   ^running
   *running,thread-id="all"
   (gdb)
   =breakpoint-modified,bkpt={number="9",type="breakpoint",disp="keep",enabled="y",func="callee2",line="39",script={"set $i=0","while $i<10","print $i","set $i=$i+1","end","continue"}}
   ~"\n"
   ~"Breakpoint 9, callee2 (intarg=2, strarg=0x400730 \"A string argument.\") at ...src/gdb/testsuite/gdb.mi/basics.c:39\n"
   ~"39\t  callee3 (strarg);\n"
   *stopped,reason="breakpoint-hit",disp="keep",bkptno="9",frame={addr="0x00000000004005dd",func="callee2",...
   *running,thread-id="all"
>> (gdb)
   =breakpoint-modified,bkpt={number="9",...
   ~"\n"
   ~"Breakpoint 9, callee2 (intarg=2, strarg=0x400730 \"A string argument.\") at ...src/gdb/testsuite/gdb.mi/basics.c:39\n"
   ~"39\t  callee3 (strarg);\n"
   *stopped,reason="breakpoint-hit",disp="keep",bkptno="9",...
   *running,thread-id="all"
   ~"[Inferior 1 (process 12639) exited normally]\n"
   =thread-exited,id="1",group-id="i1"
   =thread-group-exited,id="i1",exit-code="0"
   *stopped,reason="exited-normally"
   FAIL: gdb.mi/mi-break.exp: intermediate stop and continue
   FAIL: gdb.mi/mi-break.exp: test hitting breakpoint with commands (timeout)

Note the line marked >> above.

The test sets a breakpoint that runs "continue", a foreground command.
When we get to run the "continue", we've already emitted the *stopped
event on the MI UI, and set its prompt state to PROMPT_NEEDED (this is
done from within normal_stop).  Since inferior events are always
handled with the main UI as current UI, breakpoint commands always run
with the main UI as current UI too.  This means that the "continue"
ends up always disabling the prompt on the main UI, instead of the UI
that had just been done with synchronous execution.

I think we'll want to extend this with a concept of "set of
threads/inferiors a UI/interpreter is blocked waiting on", but I'm
leaving that for a separate series.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* infcmd.c (prepare_execution_command): Use
all_uis_on_sync_execution_starting.
* infrun.c (all_uis_on_sync_execution_starting): New function.
* infrun.h (all_uis_on_sync_execution_starting): Declare.

8 years agoReplace the sync_execution global with a new enum prompt_state tristate
Pedro Alves [Tue, 21 Jun 2016 00:11:51 +0000 (01:11 +0100)]
Replace the sync_execution global with a new enum prompt_state tristate

When sync_execution (a boolean) is true, it means we're running a
foreground command -- we hide the prompt stop listening to input, give
the inferior the terminal, then go to the event loop waiting for the
target to stop.

With multiple independent UIs, we need to track whether each UI is
synchronously blocked waiting for the target.  IOW, if you do
"continue" in one console, that console stops accepting commands, but
you should still be free to type other commands in the others
consoles.

Just simply making sync_execution be per-UI alone not sufficient,
because of this in fetch_inferior_event:

  /* If the inferior was in sync execution mode, and now isn't,
     restore the prompt (a synchronous execution command has finished,
     and we're ready for input).  */
  if (current_ui->async && was_sync && !sync_execution)
    observer_notify_sync_execution_done ();

We'd have to record at entry the "was_sync" state for each UI, not
just of the current UI.

This patch instead replaces the sync_execution flag by a per-UI
tristate flag indicating the command line prompt state:

 enum prompt_state
 {
   /* The command line is blocked simulating synchronous execution.
      This is used to implement the foreground execution commands
      ('run', 'continue', etc.).  We won't display the prompt and
      accept further commands until the execution is actually over.  */
   PROMPT_BLOCKED,

   /* The command finished; display the prompt before returning back to
      the top level.  */
   PROMPT_NEEDED,

   /* We've displayed the prompt already, ready for input.  */
   PROMPTED,
 ;

I think the end result is _much_ clearer than the current code, and,
it addresses the original motivation too.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* annotate.c: Include top.h.
(async_background_execution_p): Delete.
(print_value_flags): Check the UI's prompt state rather then
async_background_execution_p.
* event-loop.c (start_event_loop): Set the prompt state to
PROMPT_NEEDED.
* event-top.c (display_gdb_prompt, async_enable_stdin)
(async_disable_stdin): Check the current UI's prompt state instead
of the sync_execution global.
(command_line_handler): Set the prompt state to PROMPT_NEEDED
before running a command, and display the prompt if still needed
afterwards.
* infcall.c (struct call_thread_fsm) <waiting_ui>: New field.
(new_call_thread_fsm): New parameter 'waiting_ui'.  Store it.
(call_thread_fsm_should_stop): Set the prompt state to
PROMPT_NEEDED.
(run_inferior_call): Adjust to temporarily set the prompt state to
PROMPT_BLOCKED instead of using the sync_execution global.
(call_function_by_hand_dummy): Pass the current UI to
new_call_thread_fsm.
* infcmd.c: Include top.h.
(continue_1): Check the current UI's prompt state instead of the
sync_execution global.
(continue_command): Validate global execution state before calling
prepare_execution_command.
(step_1): Call all_uis_check_sync_execution_done.
(attach_post_wait): Don't call async_enable_stdin here.  Remove
reference to sync_execution.
* infrun.c (sync_execution): Delete global.
(follow_fork_inferior)
(reinstall_readline_callback_handler_cleanup): Check the current
UI's prompt state instead of the sync_execution global.
(check_curr_ui_sync_execution_done)
(all_uis_check_sync_execution_done): New functions.
(fetch_inferior_event): Call all_uis_check_sync_execution_done
instead of trying to determine whether the global sync execution
changed.
(handle_no_resumed): Check the prompt state of all UIs.
(normal_stop): Emit the no unwait-for even to all PROMPT_BLOCKED
UIs.  Emit the "Switching to" notification to all UIs.  Enable
stdin in all UIs.
* infrun.h (sync_execution): Delete.
(all_uis_check_sync_execution_done): Declare.
* main.c (captured_command_loop): Don't call
interp_pre_command_loop if the prompt is blocked.
(catch_command_errors, catch_command_errors_const): Adjust.
(captured_main): Set the initial prompt state to PROMPT_NEEDED.
* mi/mi-interp.c (display_mi_prompt): Set the prompt state to
PROMPTED.
(mi_interpreter_resume): Don't clear sync_execution.  Remove hack
comment.
(mi_execute_command_input_handler): Set the prompt state to
PROMPT_NEEDED before executing the command, and only display the
prompt if the prompt state is PROMPT_NEEDED afterwards.
(mi_on_resume_1): Adjust to check the prompt state.
* target.c (target_terminal_inferior): Adjust to check the prompt
state.
* top.c (wait_sync_command_done, maybe_wait_sync_command_done)
(execute_command): Check the current UI's prompt state instead of
sync_execution.
* top.h (enum prompt_state): New.
(struct ui) <prompt_state>: New field.
(ALL_UIS): New macro.

8 years agoMake gdb_in_secondary_prompt_p() be per UI
Pedro Alves [Tue, 21 Jun 2016 00:11:51 +0000 (01:11 +0100)]
Make gdb_in_secondary_prompt_p() be per UI

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* top.c (gdb_secondary_prompt_depth): Delete.
(gdb_in_secondary_prompt_p): Add ui parameter.  Use it.
(gdb_readline_wrapper_cleanup, gdb_readline_wrapper): Adjust to
per-UI gdb_secondary_prompt_depth.
* top.h (struct ui) <secondary_prompt_depth>: New field.

8 years agoSimplify starting the command event loop
Pedro Alves [Tue, 21 Jun 2016 00:11:51 +0000 (01:11 +0100)]
Simplify starting the command event loop

All interpreter types (CLI/TUI/MI) print the prompt, and then call
start_event_loop.

Because we'll need an interpreter hook to display the
interpreter-specific prompt before going back to the event loop,
without actually starting an event loop, this patch moves the
start_event_loop call to common code, and replaces the command_loop
hook with a pre_command_look hook, that now just prints the prompt.

Turns out to be a cleanup on its own right anyway.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* cli/cli-interp.c (cli_interpreter_pre_command_loop): New
function.
(cli_interp_procs): Install it instead of cli_command_loop.
* cli/cli-interp.h (cli_interpreter_pre_command_loop): Declare.
* event-top.c (cli_command_loop): Delete.
* interps.c (interp_new): Remove reference to command_loop_proc.
(current_interp_command_loop): Delete.
(interp_pre_command_loop): New function.
(interp_command_loop_ftype): Delete.
* interps.h (interp_pre_command_loop_ftype): New typedef.
(struct interp_procs) <command_loop_proc>: Delele field.
<pre_command_loop_proc>: New field.
(current_interp_command_loop): Delete declaration.
(interp_pre_command_loop): New declaration.
* main.c (captured_command_loop): Call interp_pre_command_loop
instead of current_interp_command_loop and start an event loop.
* mi/mi-interp.c (mi_command_loop): Delete.
(mi_interpreter_pre_command_loop): New.
(mi_interp_procs): Update.
* tui/tui-interp.c (tui_interp_procs): Install
cli_interpreter_pre_command_loop instead of cli_command_loop.

8 years agoMake raw_stdout be per MI instance
Pedro Alves [Tue, 21 Jun 2016 00:11:50 +0000 (01:11 +0100)]
Make raw_stdout be per MI instance

Each MI instance should obviously have its own raw output channel,
along with save_raw_stdout.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* interps.c (current_interpreter): New function.
* interps.h (current_interpreter): New declaration.
* mi/mi-cmds.h (raw_stdout): Delete declaration.
* mi/mi-common.h (struct mi_interp) <raw_stdout,
saved_raw_stdout>: New field.
* mi/mi-interp.c (display_mi_prompt): New parameter 'mi'.  Adjust
to per-UI raw_stdout.
(mi_interpreter_init): Adjust to per-UI raw_stdout.
(mi_on_sync_execution_done, mi_execute_command_input_handler)
(mi_command_loop): Pass MI instance to display_mi_prompt.
(mi_on_normal_stop_1, mi_output_running_pid, mi_on_resume_1)
(mi_on_resume): Adjust to per-UI raw_stdout.
(saved_raw_stdout): Delete.
(mi_set_logging): Adjust to per-UI raw_stdout and
saved_raw_stdout.
* mi/mi-main.c (raw_stdout): Delete.
(mi_cmd_gdb_exit, captured_mi_execute_command)
(mi_print_exception, mi_load_progress): Adjust to per-UI
raw_stdout.
(print_diff_now, mi_print_timing_maybe): New ui_file parameter.
Pass it along.
(print_diff): New ui_file parameter.  Send output there instead of
raw_stdout.
* mi/mi-main.h (struct ui_file): Forward declare.
(mi_print_timing_maybe): Add ui_file parameter.

8 years agoIntroduce display_mi_prompt
Pedro Alves [Tue, 21 Jun 2016 00:11:50 +0000 (01:11 +0100)]
Introduce display_mi_prompt

Just a refactor.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* mi/mi-interp.c (display_mi_prompt): New function.

8 years agoMake target_terminal_inferior/ours almost nops on non-main UIs
Pedro Alves [Tue, 21 Jun 2016 00:11:49 +0000 (01:11 +0100)]
Make target_terminal_inferior/ours almost nops on non-main UIs

Since we always run the inferior in the main console (unless "set
inferior-tty" is in effect), when some UI other than the main one
calls target_terminal_inferior/target_terminal_inferior, then we only
register/unregister the UI's input from the event loop, but leave the
main UI's terminal settings as is.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* target.c (target_terminal_inferior): Bail out after
unregistering input_fd if not on the main UI.
(target_terminal_ours): Bail out after registering input_fd if not
on the main UI.
(target_terminal_ours_for_output): Bail out if not on the main UI.

8 years agoAlways process target events in the main UI
Pedro Alves [Tue, 21 Jun 2016 00:11:49 +0000 (01:11 +0100)]
Always process target events in the main UI

This makes target events always be always processed with the main UI
as current UI.  This way, warnings, debug output, etc. are always
consistently sent to the main console.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* event-top.c (restore_ui_cleanup): Make extern.
* infrun.c (fetch_inferior_event): Always switch to the main UI.
* top.h (restore_ui_cleanup): Declare.

8 years agoMake command line editing (use of readline) be per UI
Pedro Alves [Tue, 21 Jun 2016 00:11:48 +0000 (01:11 +0100)]
Make command line editing (use of readline) be per UI

Due to the way that readline's API works (based on globals), we can
only have one instance of readline in a process.  So the goal of this
patch is to only allow editing in the main UI, and make sure that only
one UI calls into readline.  Some MI paths touch readline variables
currently, which is bad as that is changing variables that matter for
the main console UI.  This patch fixes those.

This actually fixes a nasty bug -- starting gdb in MI mode ("gdb
-i=mi"), and then doing "set editing on" crashes GDB, because MI is
not prepared to use readline:

 set editing on
 &"set editing on\n"
 =cmd-param-changed,param="editing",value="on"
 ^done
 (gdb)
 p 1
 readline: readline_callback_read_char() called with no handler!
 Aborted (core dumped)

The fix for that was to add an interp_proc method to query the
interpreter whether it actually supports editing.  New test included.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

PR mi/20034
* cli/cli-interp.c: Include cli-interp.h and event-top.h.
(cli_interpreter_resume): Pass 1 to gdb_setup_readline.  Set the
UI's input_handler here.
(cli_interpreter_supports_command_editing): New function.
(cli_interp_procs): Install it.
* cli/cli-interp.h: New file.
* event-top.c (async_command_editing_p): Rename to ...
(set_editing_cmd_var): ... this.
(change_line_handler): Add parameter 'editing', and use it.  Bail
early if the interpreter doesn't support editing.  Don't touch
readline state if editing is off.
(gdb_rl_callback_handler_remove, gdb_rl_callback_handler_install)
(gdb_rl_callback_handler_reinstall): Assert the current UI is the
main UI.
(display_gdb_prompt): Don't call gdb_rl_callback_handler_remove if
not using readline.  Check whether the current UI is using command
editing instead of checking the async_command_editing_p global.
(set_async_editing_command): Delete.
(gdb_setup_readline): Add 'editing' parameter.  Only allow editing
on the main UI.  Don't touch readline state if editing is off.
(gdb_disable_readline): Don't touch readline state if editing is
off.
* event-top.h (gdb_setup_readline): Add 'int' parameter.
(set_async_editing_command): Delete declaration.
(change_line_handler, command_line_handler): Declare.
(async_command_editing_p): Rename to ...
(set_editing_cmd_var): ... this.
* infrun.c (reinstall_readline_callback_handler_cleanup): Check
whether the current UI has editing enabled rather than checking
the async_command_editing_p global.
* interps.c (interp_supports_command_editing): New function.
* interps.h (interp_supports_command_editing_ftype): New typedef.
(struct interp_procs) <supports_command_editing_proc>: New field.
(interp_supports_command_editing): Declare.
* mi/mi-interp.c (mi_interpreter_resume): Pass 0 to
gdb_setup_readline.  Don't clear the async_command_editing_p
global.  Update comments.
* top.c (gdb_readline_wrapper_line, gdb_readline_wrapper): Check
whether the current UI has editing enabled rather than checking
the async_command_editing_p global.  Don't touch readline state if
editing is off.
(undo_terminal_modifications_before_exit): Switch to the main UI.
Unconditionally call gdb_disable_readline.
(set_editing): New function.
(show_async_command_editing_p): Rename to ...
(show_editing): ... this.  Show the state of the current UI.
(_initialize_top): Adjust.
* top.h (struct ui) <command_editing>: New field.
* tui/tui-interp.c: Include cli/cli-interp.h.
(tui_resume): Pass 1 to gdb_setup_readline.  Set the UI's
input_handler.
(tui_interp_procs): Install
cli_interpreter_supports_command_editing.
* tui/tui-io.c (tui_getc): Check whether the current UI has
editing enabled rather than checking the async_command_editing_p
global.

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

PR mi/20034
* gdb.mi/mi-editing.exp: New file.

8 years agoMake current_ui_out be per UI
Pedro Alves [Tue, 21 Jun 2016 00:11:48 +0000 (01:11 +0100)]
Make current_ui_out be per UI

Similarly to gdb_stdout&co.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* top.c: Call gen_ret_current_ui_field_ptr for current_uiout.
* top.h (struct ui) <m_current_uiout>: New field.
* ui-out.c (current_uiout): Delete.
* ui-out.h (current_uiout): Delete.
(current_ui_current_uiout_ptr): New declaration.
(current_uiout): Reimplement as wrapper around
current_ui_current_uiout_ptr.

8 years agoDelete def_uiout
Pedro Alves [Tue, 21 Jun 2016 00:11:48 +0000 (01:11 +0100)]
Delete def_uiout

Currently, current_uiout starts out pointing to def_uiout, a dummy
ui_out implementation.

Since we create a replacement uiout early on as soon as we create the
interpreter, we never actually use def_uiout.  So this patch removes
it.

The proof that it works is that starting with current_uiout set to
NULL does not crash.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* ui-out.c (default_ui_out_impl): Delete.
(def_uiout): Delete.
(current_uiout): Set to NULL.
(default_table_begin, default_table_body, default_table_end)
(default_table_header, default_begin, default_end)
(default_field_int, default_field_skip, default_field_string)
(default_field_fmt, default_spaces, default_text, default_message)
(default_wrap_hint, default_flush, default_data_destroy): Delete.

8 years agoMake out and error streams be per UI
Pedro Alves [Tue, 21 Jun 2016 00:11:47 +0000 (01:11 +0100)]
Make out and error streams be per UI

stderr_fileopen () references stderr directly, which doesn't work when
we have a separate UI with its own stderr-like stream.  So this also
adds a "errstream" to "struct ui", and plumbs stderr_fileopen to take
a stream parameter.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* event-top.c (gdb_setup_readline): Pass the UI's outstream and
errstream to stdout_fileopen and stderr_fileopen.
* exceptions.c: Include top.h.
(print_flush): Open the current UI's outstream file descriptor,
instead of hardcoding file descriptor 1.
* main.c (captured_main): Save the main UI's out and error
streams.  Adjust stderr_fileopen call.
* top.h (struct ui) <outstream, errstream>: New fields.
* ui-file.c (stderr_fileopen): Add stream parameter.  Use it
instead of stderr.
* ui-file.h (stderr_fileopen): Add stream parameter and update
comment.

8 years agoMake input_fd be per UI
Pedro Alves [Tue, 21 Jun 2016 00:11:47 +0000 (01:11 +0100)]
Make input_fd be per UI

And with that, we can switch the current UI to the UI whose input
descriptor woke up the event loop.  IOW, if the user types in UI 2,
the event loop wakes up, switches to UI 2, and processes the input.
Next the user types in UI 3, the event loop wakes up and switches to
UI 3, etc.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* event-top.c (input_fd): Delete.
(stdin_event_handler): Switch to the UI whose input descriptor got
the event.  Adjust to per-UI input_fd.
(gdb_setup_readline): Don't set the input_fd global.  Adjust to
per-UI input_fd.
(gdb_disable_readline): Adjust to per-UI input_fd.
* event-top.h (input_fd): Delete declaration.
* linux-nat.c (linux_nat_terminal_inferior): Don't remove input_fd
from the event-loop here.
(linux_nat_terminal_ours): Don't register input_fd in the
event-loop here.
* main.c (captured_main): Adjust to per-UI input_fd.
* remote.c (remote_terminal_inferior): Don't remove input_fd from
the event-loop here.
(remote_terminal_ours): Don't register input_fd in the event-loop
here.
* target.c: Include top.h and event-top.h.
(target_terminal_inferior): Remove input_fd from the event-loop
here.
(target_terminal_ours): Register input_fd in the event-loop.
* top.h (struct ui) <input_fd>: New field.

8 years agoMake instream be per UI
Pedro Alves [Tue, 21 Jun 2016 00:11:46 +0000 (01:11 +0100)]
Make instream be per UI

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* cli/cli-script.c (execute_user_command, read_next_line)
(read_next_line): Adjust to per-UI instream.
* event-top.c (stdin_event_handler, command_handler)
(handle_line_of_input, command_line_handler)
(gdb_readline_no_editing_callback, async_sigterm_handler)
(gdb_setup_readline): Likewise.
* inflow.c: Include top.h.
(gdb_has_a_terminal, child_terminal_init_with_pgrp)
(gdb_save_tty_state, child_terminal_inferior)
(child_terminal_ours_1, copy_terminal_info): Use the main UI.
(initialize_stdin_serial): Adjust to per-UI instream.
* main.c (captured_command_loop, captured_main): Adjust to per-UI
instream.
* mi/mi-interp.c (mi_execute_command_wrapper): Likewise.
* python/python.c (python_interactive_command): Likewise.
* terminal.h (struct ui): Forward declare.
(initialize_stdin_serial): Add struct ui parameter.
* top.c (instream): Delete.
(do_restore_instream_cleanup, read_command_file, dont_repeat)
(gdb_readline_no_editing, command_line_input)
(input_from_terminal_p, gdb_init): Adjust to per-UI instream.
* top.h (struct ui) <instream>: New field.
(instream): Delete declaration.
(quit): Adjust to per-UI instream.

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

* gdb.gdb/selftest.exp (do_steps_and_nexts): Add new regexp.

8 years agoAlways run async signal handlers in the main UI
Pedro Alves [Tue, 21 Jun 2016 00:11:46 +0000 (01:11 +0100)]
Always run async signal handlers in the main UI

Async signal handlers have no connection to whichever was the current
UI, and thus always run on the main one.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* event-loop.c: Include top.h.
(invoke_async_signal_handlers): Switch to the main UI.
* event-top.c (main_ui_): Update comment.
(main_ui): New global.
* top.h (main_ui): Declare.

8 years agoMake the intepreters output to all UIs
Pedro Alves [Tue, 21 Jun 2016 00:11:45 +0000 (01:11 +0100)]
Make the intepreters output to all UIs

When we have multiple consoles, MI channels, etc., then we need to
broadcast breakpoint hits, etc. to all UIs.  In the past, I've
adjusted most of the run control to communicate events to the
interpreters through observer notifications, so events would be
properly sent to console and MI streams, in sync and async modes.

This patch does the next logical step -- have each interpreter's
observers output interpreter-specific info to _all_ UIs.

Note that when we have multiple instances of active cli/tui
interpreters, then the cli_interp and tui_interp globals no longer
work.  This is addressed by this patch.

Also, the interpreters currently register some observers when resumed
and remove them when suspended.  If we have multiple instances of the
interpreters, and they can be suspended/resumed at different,
independent times, that no longer works.  What we instead do is always
install the observers, and then have the observers themselves know
when to do nothing.

An earlier prototype of this series did the looping over struct UIs in
common code, and then dispatched events to the interpreters through a
matching interp_on_foo method for each observer.  That turned out a
lot more complicated than the present solution, as we'd end up with
having to create a new interp method every time some interpreter
wanted to listen to some observer notification, resulting in a lot of
duplicated make-work and more coupling than desirable.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* cli/cli-interp.c (cli_interp): Delete.
(as_cli_interp): New function.
(cli_on_normal_stop, cli_on_signal_received)
(cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited)
(cli_on_no_history): Send output to all CLI UIs.
(cli_on_sync_execution_done, cli_on_command_error): Skip output if
the top level interpreter is not a CLI.
(cli_interpreter_init): Don't set cli_interp or install observers
here.
(_initialize_cli_interp): Install observers here.
* event-top.c (main_ui_, ui_list): New globals.
(current_ui): Point to main_ui_.
(restore_ui_cleanup, switch_thru_all_uis_init)
(switch_thru_all_uis_cond, switch_thru_all_uis_next): New
functions.
* mi/mi-interp.c (as_mi_interp): New function.
(mi_interpreter_init): Don't install observers here.
(mi_on_sync_execution_done): Skip output if the top level
interpreter is not a MI.
(mi_new_thread, mi_thread_exit, mi_record_changed)
(mi_inferior_added, mi_inferior_appeared, mi_inferior_exit)
(mi_inferior_removed): Send output to all MI UIs.
(find_mi_interpreter, mi_interp_data): Delete.
(find_mi_interp): New function.
(mi_on_signal_received, mi_on_end_stepping_range)
(mi_on_signal_exited, mi_on_exited, mi_on_no_history): Send output
to all MI UIs.
(mi_on_normal_stop): Rename to ...
(mi_on_normal_stop_1): ... this.
(mi_on_normal_stop): Reimplement, sending output to all MI UIs.
(mi_traceframe_changed, mi_tsv_created, mi_tsv_deleted)
(mi_tsv_modified, mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified, mi_output_running_pid): Send output to
all MI UIs.
(mi_on_resume): Rename to ...
(mi_on_resume_1): ... this.  Don't handle infcalls here.
(mi_on_resume): Reimplement, sending output to all MI UIs.
(mi_solib_loaded, mi_solib_unloaded, mi_command_param_changed)
(mi_memory_changed): Send output to all MI UIs.
(report_initial_inferior): Install observers here.
* top.h (struct ui) <next>: New field.
(ui_list): Declare.
(struct switch_thru_all_uis): New.
(switch_thru_all_uis_init, switch_thru_all_uis_cond)
(switch_thru_all_uis_next): Declare.
(SWITCH_THRU_ALL_UIS): New macro.
* tui/tui-interp.c (tui_interp): Delete global.
(as_tui_interp): New function.
(tui_on_normal_stop, tui_on_signal_received)
(tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited)
(tui_on_no_history): Send output to all TUI UIs.
(tui_on_sync_execution_done, tui_on_command_error): Skip output if
the top level interpreter is not a TUI.
(tui_init): Don't set tui_interp or install observers here.
(_initialize_tui_interp): Install observers here.

8 years agoIntroduce interpreter factories
Pedro Alves [Tue, 21 Jun 2016 00:11:45 +0000 (01:11 +0100)]
Introduce interpreter factories

If every UI instance has its own set of interpreters, then the current
scheme of creating the interpreters at GDB initialization time no
longer works.  We need to create them whenever a new UI instance is
created.

The scheme implemented here has each interpreter register a factory
callback that when called creates a new instance of a specific
interpreter type.  Then, when some code in gdb looks up an interpreter
(always by name), if there's none yet, the factory method is called to
construct one.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* cli/cli-interp.c (cli_uiout): Delete, moved into ...
(struct cli_interp): ... this new structure.
(cli_on_normal_stop, cli_on_signal_received)
(cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited)
(cli_on_no_history): Use interp_ui_out.
(cli_interpreter_init): If top level, set the cli_interp global.
(cli_interpreter_init): Return the interp's data instead of NULL.
(cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust
to cli_uiout being in the interpreter's data.
(cli_interp_procs): New, factored out from _initialize_cli_interp.
(cli_interp_factory): New function.
(_initialize_cli_interp): Call interp_factory_register.
* interps.c (get_interp_info): New, factored out from ...
(get_current_interp_info): ... this.
(interp_new): Add parameter 'data'.  Store it.
(struct interp_factory): New function.
(interp_factory_p): New typedef.  Define a VEC_P.
(interpreter_factories): New global.
(interp_factory_register): New function.
(interp_add): Add 'ui' parameter.  Use get_interp_info and
interp_lookup_existing.
(interp_lookup): Rename to ...
(interp_lookup_existing): ... this.  Add 'ui' parameter.  Don't
check for NULL or empty name here.
(interp_lookup): Add 'ui' parameter and reimplement.
(interp_set_temp, interpreter_exec_cmd): Adjust.
(interpreter_completer): Complete on registered interpreter
factories instead of interpreters.
* interps.h (interp_factory_func): New typedef.
(interp_factory_register): Declare.
(interp_new, interp_add): Adjust.
(interp_lookup): Declare.
* main.c (captured_main): Adjust.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust.
(mi_interp_procs): New, factored out from
_initialize_mi_interp.
(mi_interp_factory): New function.
* python/python.c (execute_gdb_command): Adjust.
* tui/tui-interp.c (tui_init): If top level, set the tui_interp
global.
(tui_interp_procs): New.
(tui_interp_factory): New function.
(_initialize_tui_interp): Call interp_factory_register.

8 years agoMake the interpreters be per UI
Pedro Alves [Tue, 21 Jun 2016 00:11:45 +0000 (01:11 +0100)]
Make the interpreters be per UI

Make each UI have its own interpreter list, top level interpreter,
current interpreter, etc.  The "interpreter_async" global is not
really specific to an struct interp (it crosses interpreter-exec ...),
so I moved it to "struct ui" directly, while the other globals were
left hidden in interps.c, opaque to the rest of GDB.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* breakpoint.c (bpstat_do_actions_1): Access the current UI's
async field instead of the interpreter_async global.
* cli/cli-script.c (execute_user_command, while_command)
(if_command, script_from_file): Likewise.
* compile/compile.c: Include top.h instead of interps.h.
(compile_file_command, compile_code_command)
(compile_print_command): Access the current UI's async field
instead of the interpreter_async global.
* guile/guile.c: Include top.h instead of interps.h.
(guile_repl_command, guile_command, gdbscm_execute_gdb_command):
Access the current UI's async field instead of the
interpreter_async global.
* guile/scm-ports.c: Include top.h instead of interps.h.
(ioscm_with_output_to_port_worker): Access the current UI's async
field instead of the interpreter_async global.
* inf-loop.c (inferior_event_handler): Likewise.
* infcall.c (run_inferior_call): Likewise.
* infrun.c (reinstall_readline_callback_handler_cleanup)
(fetch_inferior_event): Likewise.
* interps.c (interpreter_async): Delete.
(struct ui_interp_info): New.
(get_current_interp_info): New function.
(interp_list, current_interpreter, top_level_interpreter_ptr):
Delete.
(interp_add, interp_set, interp_lookup, interp_ui_out)
(current_interp_set_logging, interp_set_temp)
(current_interp_named_p): Adjust to per-UI interpreters.
(command_interpreter): Delete.
(command_interp, current_interp_command_loop, interp_quiet_p)
(interp_exec, interpreter_exec_cmd, interpreter_completer)
(top_level_interpreter, top_level_interpreter_data): Adjust to
per-UI interpreters.
* interps.h (interpreter_async): Delete.
* main.c (captured_command_loop): Access the current UI's async
field instead of the interpreter_async global.
* python/python.c (python_interactive_command, python_command)
(execute_gdb_command): Likewise.
* top.c (maybe_wait_sync_command_done, execute_command_to_string):
Access the current UI's async field instead of the
interpreter_async global.
* top.h (struct tl_interp_info): Forward declare.
(struct ui) <interp_info, async>: New fields.

8 years agoMake gdb_stdout&co be per UI
Pedro Alves [Tue, 21 Jun 2016 00:11:44 +0000 (01:11 +0100)]
Make gdb_stdout&co be per UI

We need to have these send output to the proper UI.

However, this patch still make them look like globals.  Kind of like
__thread variables, if you will.  Changing everything throughout to
write something like current_ui->gdb_stdout instead would be massive
overkill, IMNSHO.

This leaves gdb_stdtargin/stdtarg/stdtargerr global, but maybe that was a
mistake, I'm not sure -- IIRC, MI formats target I/O differently, so
if we have a separate MI channel, then I guess target output should go
there instead of to gdb's stdout.  OTOH, maybe GDB should send that
instead to "set inferior-tty", instead of multiplexing it over MI.  We
can always fix those later when it gets clearer where they should go.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* main.c (gdb_stdout, gdb_stderr, gdb_stdlog, gdb_stdin): Delete
globals.
(gen_ret_current_ui_field_ptr): New macro.  Use it to generate
wrappers for gdb_stdout, gdb_stderr, gdb_stdlog and gdb_stdin.
* top.h (struct ui) <m_gdb_stdout, m_gdb_stdin, m_gdb_stderr,
m_gdb_stdlog>: New fields.
(current_ui_gdb_stdout_ptr, current_ui_gdb_stdin_ptr)
(current_ui_gdb_stderr_ptr, current_ui_gdb_stdlog_ptr): Declare.
(gdb_stdout, gdb_stdin, gdb_stderr, gdb_stdlog): Reimplement as
macros.

8 years agoIntroduce "struct ui"
Pedro Alves [Tue, 21 Jun 2016 00:11:44 +0000 (01:11 +0100)]
Introduce "struct ui"

This is a step towards supporting multiple consoles/MIs, each on its
own stdio streams / terminal.

See intro comment in top.h.

(I've had trouble picking a name for this object.  I've started out
with "struct console" originally.  But then this is about MI as well,
and there's "interpreter-exec console", which is specifically about
the CLI...

So I changed to "struct terminal", but, then we have a terminal object
that works when the input is not a terminal as well ...

Then I sort of gave up and renamed it to "struct top_level".  But it
then gets horribly confusing when we talk about the "top level
interpreter that's running on the current top level".

In the end, I realized we're already sort of calling this "ui", in
struct ui_out, struct ui_file, and a few coments here and there.)

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* event-top.c: Update readline-related comments.
(input_handler, call_readline): Delete globals.
(gdb_rl_callback_handler): Call the current UI's input_handler
method.
(change_line_handler): Adjust to set current UI's properties
instead of globals.
(current_ui_, current_ui): New globals.
(get_command_line_buffer): Rewrite to refer to the current UI.
(stdin_event_handler): Adjust to call the call_readline method of
the current UI.
(gdb_readline_no_editing_callback): Adjust to call the current UI's
input_handler method.
(gdb_setup_readline): Adjust to set current UI's properties
instead of globals.
* event-top.h (call_readline, input_handler): Delete declarations.
* mi/mi-interp.c (mi_interpreter_resume): Adjust to set current
UI's properties instead of globals.
* top.c (gdb_readline_wrapper_cleanup): Adjust to set current UI's
properties instead of globals.
(gdb_readline_wrapper): Adjust to call and set current UI's
methods instead of globals.
* top.h: Include buffer.h and event-loop.h.
(struct ui): New struct.
(current_ui): New declaration.

8 years ago[Ada catchpoints] Fix "warning: failed to get exception name: No definition of \...
Pedro Alves [Tue, 21 Jun 2016 00:11:43 +0000 (01:11 +0100)]
[Ada catchpoints] Fix "warning: failed to get exception name: No definition of \"e.full_name\" in current context"

Looking at testsuite results, I noticed this warning in an MI test:

 ~"\nCatchpoint "
 ~"2, "
 &"warning: failed to get exception name: No definition of \"e.full_name\" in current context.\n"
 ~"exception at 0x000000000040192d in foo () at /home/pedro/brno/pedro/gdb/mygit/src/gdb/testsuite/gdb.ada/mi_catch_ex/foo.adb:20\n"
 ~"20\t      raise Constraint_Error;  -- SPOT1\n"
 *stopped,reason="breakpoint-hit",disp="keep",bkptno="2",exception-name="CONSTRAINT_ERROR",frame={addr="0x000000000040192d",func="foo",args=[],file="/home/pedro/brno/pedro/gdb/mygit/src/gdb/testsuite/gdb.ada/mi_catch_ex/foo.adb",fullname="/home/pedro/brno/pedro/gdb/mygit/src/gdb/testsuite/gdb.ada/mi_catch_ex/foo.adb",line="20"},thread-id="1",stopped-threads="all",core="5"
 (gdb)
 PASS: gdb.ada/mi_catch_ex.exp: continue until CE caught by all-exceptions catchpoint

The problem is that:

  - MI prints the breakpoint hit twice: once on the MI stream;
    another time on the console stream.

  - After printing the Ada catchpoint hit, gdb selects a non-current
    frame, from within the catchpoint's print_it routine.

So the second time the breakpoint is printed, the selected frame is no
longer the current frame, and then evaluating e.full_name in
ada_exception_name_addr fails.

This commit fixes the problem and enhances the gdb.ada/mi_catch_ex.exp
test to make sure the catchpoint hit is printed correctly on the
console stream too.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* ada-lang.c (ada_exception_name_addr_1): Add comment.
(print_it_exception): Select the current frame.

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

* gdb.ada/mi_catch_ex.exp (continue_to_exception): New procedure.
(top level): Use it instead of mi_execute_to.

8 years agoPrepare gdb.python/mi-py-events.exp for Python/MI in separate channels
Pedro Alves [Tue, 21 Jun 2016 00:11:43 +0000 (01:11 +0100)]
Prepare gdb.python/mi-py-events.exp for Python/MI in separate channels

Similarly to 5068630ad34dce5fefbe68d70d3a50cd8b92f71e
(gdb.python/py-events.exp and normal_stop observers ordering) [1],
this commit makes the gdb.python/py-mi-events.exp test not rely on
order in which MI and Python observers run, or even on where each
observer sends its output to.

This shows up as a problem when testing with MI running as a separate
terminal, for example, where Python event output and MI output go to
different channels, even.  But in any case, relying on the order in
which observers run is always going to be fragile.

The fix is to save the string output in the handlers in some variables
and then having MI print them explicitly, instead of printing them
directly from the Python events.

Tested on x86_64 Fedora 23.

https://sourceware.org/ml/gdb-patches/2015-07/msg00290.html

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

* gdb.python/py-mi-events-gdb.py (stop_handler_str)
(cont_handler_str): New.
(signal_stop_handler): Set stop_handler_str instead of printing to
stdout.
(continue_handler): Set cont_handler_str instead of printing to
stdout.
* gdb.python/py-mi-events.exp: Ues mi_execute_to instead of
mi_send_resuming_command.  Print stop_handler_str and
cont_handler_str instead of expecting the python events print
directly.

8 years agoAutomatic date update in version.in
GDB Administrator [Tue, 21 Jun 2016 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoMIPS/GAS/testsuite: Uniquely identify MIPS64r6 tests
Maciej W. Rozycki [Mon, 20 Jun 2016 22:36:01 +0000 (23:36 +0100)]
MIPS/GAS/testsuite: Uniquely identify MIPS64r6 tests

gas/
* testsuite/gas/mips/r6-64-n32.d: Change the `name' tag.
* testsuite/gas/mips/r6-64-n64.d: Likewise.

8 years agoMIPS/GAS: Update comment on jump reloc conversion
Maciej W. Rozycki [Mon, 20 Jun 2016 22:39:20 +0000 (23:39 +0100)]
MIPS/GAS: Update comment on jump reloc conversion

Complement commit 44d3da233815 ("MIPS/GAS: Treat local jump relocs the
same no matter if REL or RELA") and update and clarify the comment on
jump reloc conversion.

gas/
* config/tc-mips.c (mips_fix_adjustable): Update comment on jump
reloc conversion.

8 years agogold/x86: Handle output without PLT
H.J. Lu [Mon, 20 Jun 2016 19:28:20 +0000 (12:28 -0700)]
gold/x86: Handle output without PLT

If there is no PLT in output, return 0 for first_plt_entry_offset and
plt_entry_size.

PR gold/20245
* i386.cc (Target_i386::first_plt_entry_offset): Return 0 if
plt_ is NULL.
(Target_i386::plt_entry_size): Likewise.
(Target_x86_64<size>::first_plt_entry_offset): Likewise.
(Target_x86_64<size>::plt_entry_size): Likewise.

8 years agoAdd support for MIPS .rld_map section.
Vladimir Radosavljevic [Mon, 20 Jun 2016 19:10:53 +0000 (12:10 -0700)]
Add support for MIPS .rld_map section.

Includes DT_MIPS_RLD_MAP and DT_MIPS_RLD_MAP_REL dynamic tags and
__RLD_MAP symbol.

2016-06-20  Vladimir Radosavljevic  <Vladimir.Radosavljevic@imgtec.com>

elfcpp/
        * elfcpp.h (DT_MIPS_RLD_MAP_REL): New enum constant.
gold/
        * mips.cc (Target_mips::Target_mips): Initialize rld_map_.
        (Target_mips::rld_map_): New data member.
        (Target_mips::do_finalize_sections): Add support for
        DT_MIPS_RLD_MAP and DT_MIPS_RLD_MAP_REL dynamic tags,
        .rld_map section, and __RLD_MAP symbol.
        (Target_mips::do_dynamic_tag_custom_value): Add support for
        DT_MIPS_RLD_MAP_REL dynamic tag.
        * output.cc (Output_data_dynamic::get_entry_offset): New method
        definition.
        * output.h (Output_data_dynamic::get_entry_offset): New method
        declaration.

8 years agoAdd unaligned check for R_MIPS_PC16.
Vladimir Radosavljevic [Mon, 20 Jun 2016 19:06:56 +0000 (12:06 -0700)]
Add unaligned check for R_MIPS_PC16.

gold/
        * mips.cc (Mips_relocate_functions::relpc16): Add unaligned check.

8 years agoAdd support for Mips32r6 and Mips64r6.
Vladimir Radosavljevic [Mon, 20 Jun 2016 18:45:18 +0000 (11:45 -0700)]
Add support for Mips32r6 and Mips64r6.

elfcpp/
* mips.h (R_MIPS_PC21_S2, R_MIPS_PC26_S2, R_MIPS_PC18_S3,
R_MIPS_PC19_S2, R_MIPS_PCHI16, R_MIPS_PCLO16): New enums for
Mips32r6 and Mips64r6 relocations.
(r6_isa): New function.
gold/
* mips.cc (relocation_needs_la25_stub): Add support for relocs:
R_MIPS_PC21_S2 and R_MIPS_PC26_S2.
(hi16_reloc): Add support for R_MIPS_PCHI16 relocation.
(is_matching_lo16_reloc): Likewise.
(lo16_reloc): Add support for R_MIPS_PCLO16 relocation.
(Mips_output_data_plt::plt_entry_r6): New static data member for
R6 PLT entry.
(Target_mips::is_output_r6): New method.
(Target_mips::Mips_mach): Add new enum constants.
(Mips_relocate_functions::Status): Likewise.
(Mips_relocate_functions::pchi16_relocs): New static data member.
(Mips_relocate_functions::relpc21): New method.
(Mips_relocate_functions::relpc26): Likewise.
(Mips_relocate_functions::relpc18): Likewise.
(Mips_relocate_functions::relpc19): Likewise.
(Mips_relocate_functions::relpchi16): Likewise.
(Mips_relocate_functions::do_relpchi16): Likewise.
(Mips_relocate_functions::relpclo16): Likewise.
(Mips_output_data_plt::do_write): Add support for Mips r6 plt
entry.
(Target_mips::mips_32bit_flags): Add E_MIPS_ARCH_32R6 support.
(Target_mips::elf_mips_mach): Add E_MIPS_ARCH_32R6 and
E_MIPS_ARCH_64R6 support.
(Target_mips::update_abiflags_isa): Likewise.
(mips_get_size_for_reloc): Add support for relocs: R_MIPS_PCHI16,
R_MIPS_PCLO16, R_MIPS_PC21_S2, R_MIPS_PC26_S2, R_MIPS_PC18_S3 and
R_MIPS_PC19_S2.
(Target_mips::Scan::local): Add support for relocs: R_MIPS_PCHI16
and R_MIPS_PCLO16.
(Target_mips::Scan::global): Add support for relocs:
R_MIPS_PC21_S2 and R_MIPS_PC26_S2.
(Target_mips::Relocate::relocate): Call functions for resolving
Mips32r6 and Mips64r6 relocations, and print error message for
STATUS_PCREL_UNALIGNED.
(Target_mips::Scan::get_reference_flags): Add support for relocs:
R_MIPS_PCHI16, R_MIPS_PCLO16, R_MIPS_PC21_S2, R_MIPS_PC26_S2,
R_MIPS_PC18_S3 and R_MIPS_PC19_S2.
(Target_mips::elf_mips_mach_name): Add E_MIPS_ARCH_32R6 and
E_MIPS_ARCH_64R6 support.

8 years agoUse the IR symbol table for the IR input object
H.J. Lu [Mon, 20 Jun 2016 12:10:29 +0000 (05:10 -0700)]
Use the IR symbol table for the IR input object

ELF linker shouldn't skip the IR object when searching the symbol table
of an archive element.  If linker doesn't know if the object file is an
IR object, it should give LTO plugin a chance to get the correct symbol
table and use the IR symbol table if the input is an IR object.

bfd/

PR ld/18250
PR ld/20267
* elflink.c: Include plugin.h if BFD_SUPPORTS_PLUGINS is
defined.
(elf_link_is_defined_archive_symbol): Call
bfd_link_plugin_object_p on unknown plugin object and use the
IR symbol table if the input is an IR object.
* plugin.c (bfd_link_plugin_object_p): New function.
* plugin.h (bfd_link_plugin_object_p): New prototype.

ld/

PR ld/20267
* testsuite/ld-plugin/lto.exp (lto_link_tests): Add test for
PR ld/20267.
(lto_run_tests): Likewise.
* testsuite/ld-plugin/pr20267a.c: New file.
* testsuite/ld-plugin/pr20267b.c: Likewise.

8 years agoUpdate the feature set for the Vulcan AArch64 cpu.
Virendra Pathak [Mon, 20 Jun 2016 08:26:43 +0000 (09:26 +0100)]
Update the feature set for the Vulcan AArch64 cpu.

gas * config/tc-aarch64.c (aarch64_cpus): Update vulcan feature set.

8 years agoPR ld/20276: Set non_ir_ref on common symbol
Alan Modra [Mon, 20 Jun 2016 00:23:50 +0000 (09:53 +0930)]
PR ld/20276: Set non_ir_ref on common symbol

Also, don't check alignment on symbol from plugin dummy input.

bfd/
PR ld/20276
* elflink.c (elf_link_add_object_symbols): Don't check alignment
on symbol from plugin dummy input.
ld/
PR ld/20276
* plugin.c (plugin_notice): Set non_ir_ref on common symbols.
* testsuite/ld-plugin/lto.exp (lto_link_tests): Add test for
PR ld/20276.
(lto_run_tests): Likewise.
* testsuite/ld-plugin/pass.out: New file.
* testsuite/ld-plugin/pr20276a.c: Likewise.
* testsuite/ld-plugin/pr20276b.c: Likewise.

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Jun 2016 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Jun 2016 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoRename bfd_plugin_uknown to bfd_plugin_unknown
H.J. Lu [Sat, 18 Jun 2016 21:15:31 +0000 (14:15 -0700)]
Rename bfd_plugin_uknown to bfd_plugin_unknown

bfd/

* bfd.c (bfd_plugin_format): Rename bfd_plugin_uknown to
bfd_plugin_unknown.
* bfd-in2.h: Regenerated.
* plugin.c (bfd_plugin_object_p): Replace bfd_plugin_uknown
with bfd_plugin_unknown.

ld/

* plugin.c (plugin_object_p): Replace bfd_plugin_uknown
with bfd_plugin_unknown.

8 years agoDon't generate PLT for IFUNC GOT/pointer reference
H.J. Lu [Sat, 18 Jun 2016 16:16:52 +0000 (09:16 -0700)]
Don't generate PLT for IFUNC GOT/pointer reference

If a backend supports it, PLT entry isn't needed when all references
to a STT_GNU_IFUNC symbols are done via GOT or static function pointers.
For GOT entries, We generate dynamic R_*_GLOB_DAT relocations for
preemptable symbols and R_*_IRELATIVE relocations for non-preemptable
symbols to update them with real function address.  For static pointer
pointers, we generate dynamic pointer relocations and store them in:

1. .rel[a].ifunc section in PIC object.
2. .rel[a].got section in dynamic executable.
3. .rel[a].iplt section in static executable.

We don't allocate GOT entry if it isn't used.

bfd/

PR ld/20253
* elf-bfd.h (_bfd_elf_allocate_ifunc_dyn_relocs): Add an
bfd_boolean argument.
* elf-ifunc.c (_bfd_elf_create_ifunc_sections): Replace
"shared object" with "PIC object" in comments.
(_bfd_elf_allocate_ifunc_dyn_relocs): Updated.  Replace
"shared object" with "PIC object" in comments.  Avoid PLT if
requested.  Generate dynamic relocations for non-GOT references.
Make room for the special first entry in PLT and allocate PLT
entry only for PLT and PC-relative references.  Store dynamic
GOT relocations in .rel[a].iplt section for static executables.
If PLT isn't used, always use GOT for symbol value.  Don't
allocate GOT entry if it isn't used.
* elf32-i386.c (elf_i386_check_relocs): Increment PLT reference
count only in the code section.  Allocate dynamic pointer
relocation against STT_GNU_IFUNC symbol in the non-code section.
(elf_i386_adjust_dynamic_symbol): Increment PLT reference count
only for PC-relative references.
(elf_i386_allocate_dynrelocs): Pass TRUE to
_bfd_elf_allocate_ifunc_dyn_relocs.
(elf_i386_relocate_section): Allow R_386_GOT32/R_386_GOT32X
relocations against STT_GNU_IFUNC symbols without PLT.  Generate
dynamic pointer relocation against STT_GNU_IFUNC symbol in
the non-code section and store it in the proper REL section.
Don't allow non-pointer relocation against STT_GNU_IFUNC symbol
without PLT.
(elf_i386_finish_dynamic_symbol): Generate dynamic
R_386_IRELATIVE and R_386_GLOB_DAT GOT relocations against
STT_GNU_IFUNC symbols without PLT.
(elf_i386_finish_dynamic_sections): Don't handle local
STT_GNU_IFUNC symbols here.
(elf_i386_output_arch_local_syms): Handle local STT_GNU_IFUNC
symbols here.
(elf_backend_output_arch_local_syms): New.
* elf32-x86-64.c (elf_i386_check_relocs): Increment PLT reference
count only in the code section.  Allocate dynamic pointer
relocation against STT_GNU_IFUNC symbol in the non-code section.
(elf_x86_64_adjust_dynamic_symbol): Increment PLT reference
count only for PC-relative references.
(elf_x86_64_allocate_dynrelocs): Pass TRUE to
_bfd_elf_allocate_ifunc_dyn_relocs.
(elf_x86_64_relocate_section): Allow R_X86_64_GOTPCREL,
R_X86_64_GOTPCRELX, R_X86_64_REX_GOTPCRELX and
R_X86_64_GOTPCREL64 relocations against STT_GNU_IFUNC symbols
without PLT.  Generate dynamic pointer relocation against
STT_GNU_IFUNC symbol in the non-code section and store it in
the proper RELA section.  Don't allow non-pointer relocation
against STT_GNU_IFUNC symbol without PLT.
(elf_x86_64_finish_dynamic_symbol): Generate dynamic
R_X86_64_IRELATIVE and R_X86_64_GLOB_DAT GOT relocations against
STT_GNU_IFUNC symbols without PLT.
(elf_x86_64_finish_dynamic_sections): Don't handle local
STT_GNU_IFUNC symbols here.
(elf_x86_64_output_arch_local_syms): Handle local STT_GNU_IFUNC
symbols here.
(elf_backend_output_arch_local_syms): New.
* elfnn-aarch64.c (elfNN_aarch64_allocate_ifunc_dynrelocs):
Pass FALSE to _bfd_elf_allocate_ifunc_dyn_relocs.

ld/

PR ld/20253
* testsuite/ld-i386/i386.exp: Run PR ld/20253 tests.
* testsuite/ld-i386/no-plt.exp: Likewise.
* testsuite/ld-x86-64/no-plt.exp: Likewise.
* testsuite/ld-i386/pr13302.d: Remove .rel.plt section.
* testsuite/ld-ifunc/ifunc-13-i386.d: Likewise.
* testsuite/ld-ifunc/ifunc-13-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-15-i386.d: Likewise.
* testsuite/ld-ifunc/ifunc-15-x86-64.d: Likewise.
* testsuite/ld-x86-64/pr13082-5a.d: Likewise.
* testsuite/ld-x86-64/pr13082-5b.d: Likewise.
* testsuite/ld-x86-64/pr13082-6a.d: Likewise.
* testsuite/ld-x86-64/pr13082-6b.d: Likewise.
* testsuite/ld-i386/pr20244-2a.d: Remove .plt section.
* testsuite/ld-ifunc/ifunc-21-i386.d: Likewise.
* testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-22-i386.d: Likewise.
* testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise.
* testsuite/ld-i386/pr20244-2b.d: Updated.
* testsuite/ld-i386/pr20244-2c.d: Likewise.
* testsuite/ld-ifunc/ifunc-18a-i386.d: Likewise.
* testsuite/ld-ifunc/ifunc-18a-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-18b-i386.d: Likewise.
* testsuite/ld-ifunc/ifunc-18b-x86-64.d: Likewise.
* testsuite/ld-i386/pr20253-1a.c: New file.
* testsuite/ld-i386/pr20253-1b.S: Likewise.
* testsuite/ld-i386/pr20253-1c.S: Likewise.
* testsuite/ld-i386/pr20253-1d.S: Likewise.
* testsuite/ld-i386/pr20253-2a.c: Likewise.
* testsuite/ld-i386/pr20253-2b.S: Likewise.
* testsuite/ld-i386/pr20253-2c.S: Likewise.
* testsuite/ld-i386/pr20253-2d.S: Likewise.
* testsuite/ld-i386/pr20253-3.d: Likewise.
* testsuite/ld-i386/pr20253-3.s: Likewise.
* testsuite/ld-i386/pr20253-4.s: Likewise.
* testsuite/ld-i386/pr20253-4a.d: Likewise.
* testsuite/ld-i386/pr20253-4b.d: Likewise.
* testsuite/ld-i386/pr20253-4c.d: Likewise.
* testsuite/ld-i386/pr20253-5.d: Likewise.
* testsuite/ld-i386/pr20253-5.s: Likewise.
* testsuite/ld-ifunc/ifunc-23-x86.s: Likewise.
* testsuite/ld-ifunc/ifunc-23a-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-23b-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-23c-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-24-x86.s: Likewise.
* testsuite/ld-ifunc/ifunc-24a-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-24b-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-24c-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-25-x86.s: Likewise.
* testsuite/ld-ifunc/ifunc-25a-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-25b-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-25c-x86.d: Likewise.
* testsuite/ld-x86-64/pr20253-1.s: Likewise.
* testsuite/ld-x86-64/pr20253-1a.d: Likewise.
* testsuite/ld-x86-64/pr20253-1b.d: Likewise.
* testsuite/ld-x86-64/pr20253-1c.d: Likewise.
* testsuite/ld-x86-64/pr20253-1d.d: Likewise.
* testsuite/ld-x86-64/pr20253-1e.d: Likewise.
* testsuite/ld-x86-64/pr20253-1f.d: Likewise.
* testsuite/ld-x86-64/pr20253-1g.d: Likewise.
* testsuite/ld-x86-64/pr20253-1h.d: Likewise.
* testsuite/ld-x86-64/pr20253-1i.d: Likewise.
* testsuite/ld-x86-64/pr20253-1j.d: Likewise.
* testsuite/ld-x86-64/pr20253-1k.d: Likewise.
* testsuite/ld-x86-64/pr20253-1l.d: Likewise.
* testsuite/ld-x86-64/pr20253-2a.c: Likewise.
* testsuite/ld-x86-64/pr20253-2b.S: Likewise.
* testsuite/ld-x86-64/pr20253-2c.S: Likewise.
* testsuite/ld-x86-64/pr20253-2d.S: Likewise.
* testsuite/ld-x86-64/pr20253-3.d: Likewise.
* testsuite/ld-x86-64/pr20253-3.s: Likewise.
* testsuite/ld-x86-64/pr20253-4.s: Likewise.
* testsuite/ld-x86-64/pr20253-4a.d: Likewise.
* testsuite/ld-x86-64/pr20253-4b.d: Likewise.
* testsuite/ld-x86-64/pr20253-4c.d: Likewise.
* testsuite/ld-x86-64/pr20253-4d.d: Likewise.
* testsuite/ld-x86-64/pr20253-4e.d: Likewise.
* testsuite/ld-x86-64/pr20253-4f.d: Likewise.
* testsuite/ld-x86-64/pr20253-5.s: Likewise.
* testsuite/ld-x86-64/pr20253-5a.d: Likewise.
* testsuite/ld-x86-64/pr20253-5b.d: Likewise.
* testsuite/ld-ifunc/ifunc-18a-i386.d: Remove extra IRELATIVE
relocation.
* testsuite/ld-ifunc/ifunc-18a-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-18b-i386.d: Likewise.
* testsuite/ld-ifunc/ifunc-18b-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-18a.s: Fix a typo.
* testsuite/ld-x86-64/x86-64.exp: Run pr20253-1 tests.

8 years agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Jun 2016 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoAdd a test case for the jit-reader interface
Sanjoy Das [Fri, 17 Jun 2016 18:24:08 +0000 (19:24 +0100)]
Add a test case for the jit-reader interface

Originally intended to be committed on 2013-01-17 in
675921c059dbaddd02ab2eb8a1eaf77b3ac727dd (Test case for the
jit-reader), but by mistake the files were not added.  Fortunately
they still work.

gdb/testsuite/ChangeLog:
2016-06-17  Sanjoy Das  <sanjoy@playingwithpointers.com>

* gdb.base/jit-reader.exp: New file.
* gdb.base/jithost.c: New file.
* gdb.base/jithost.h: New file.
* gdb.base/jitreader.c : New file.
* gdb.base/jit-protocol.h: New file.

8 years agoAdd support for Thumb-2 long branch veneers
Thomas Preud'homme [Fri, 17 Jun 2016 17:26:08 +0000 (18:26 +0100)]
Add support for Thumb-2 long branch veneers

2016-06-17  Thomas Preud'homme  <thomas.preudhomme@arm.com>
    Tony Wang  <tony.wang@arm.com>

bfd/
* elf32-arm.c (elf32_arm_stub_long_branch_thumb2_only): Define stub
sequence.
(stub_long_branch_thumb2_only): Define stub.
(arm_stub_is_thumb): Add case for arm_stub_long_branch_thumb2_only.
(arm_stub_long_branch_thumb2_only): Likewise.
(arm_type_of_stub): Use arm_stub_long_branch_thumb2_only for Thumb-2
capable targets.

ld/
* testsuite/ld-arm/arm-elf.exp (Thumb-Thumb farcall M profile):
Assemble for ARMv6-M.
(Thumb2-Thumb2 farcall M profile): New testcase.
* testsuite/ld-arm/farcall-thumb2-thumb2-m.d: New file.
* testsuite/ld-arm/jump-reloc-veneers-cond-long-backward.d: Update to
reflect the use of Thumb-2 veneers for Thumb-2 capable targets.
* testsuite/ld-arm/jump-reloc-veneers-cond-long.d: Likewise.

8 years agoExtend step-over-syscall.exp with different detach-on-fork and follow-fork modes
Yao Qi [Fri, 17 Jun 2016 09:25:13 +0000 (10:25 +0100)]
Extend step-over-syscall.exp with different detach-on-fork and follow-fork modes

This patch extends step-over-syscall.exp by setting different values to
detach-on-fork and follow-fork.

gdb/testsuite:

2016-06-17  Yao Qi  <yao.qi@linaro.org>

* gdb.base/step-over-syscall.exp (break_cond_on_syscall): New
parameters follow_fork and detach_on_fork.  Set follow-fork-mode
and detach-on-fork.  Adjust tests.
(top level): Invoke break_cond_on_syscall with combinations of
syscall, follow-fork-mode and detach-on-fork.

8 years agoHandle reinsert breakpoints for vforked child
Yao Qi [Fri, 17 Jun 2016 09:25:13 +0000 (10:25 +0100)]
Handle reinsert breakpoints for vforked child

When a thread is doing step-over with reinsert breakpoint, and the
instruction executed is a syscall doing vfork, both parent and child
share the memory, so the reinsert breakpoint in the space is visible
to both of them.  Also, removing the reinsert breakpoints from the
child will effectively remove them from the parent.  We should
carefully manipulate reinsert breakpoints for both processes.

What we are doing here is that

 - uninsert reinsert breakpoints from the parent before cloning the
   breakpoint list.  We use "uninsert" instead of "remove", because
   we need to "reinsert" them back after vfork is done.  In fact,
   "uninsert" removes them from both child and parent process space.
 - reinsert breakpoints in parent process are still copied to child's
   breakpoint list,
 - remove them from child's breakpoint list as what we did for fork,
   at this point, reinsert breakpoints are removed from the child and
   the parent, but they are still tracked by the parent's breakpoint
   list,
 - once vfork is done, "reinsert" them back to the parent,

gdb/gdbserver:

2016-06-17  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (handle_extended_wait): Call
uninsert_reinsert_breakpoints for the parent process.  Remove
reinsert breakpoints from the child process.  Reinsert them to
the parent process when vfork is done.
* mem-break.c (uninsert_reinsert_breakpoints): New function.
(reinsert_reinsert_breakpoints): New function.
* mem-break.h (uninsert_reinsert_breakpoints): Declare
(reinsert_reinsert_breakpoints): Declare.

8 years agoDelete reinsert breakpoints from forked child
Yao Qi [Fri, 17 Jun 2016 09:25:13 +0000 (10:25 +0100)]
Delete reinsert breakpoints from forked child

When a thread is stepping over a syscall instruction with software
single step, GDBserver inserts reinsert breakpoints at the next pcs.
If the syscall call is fork, the forked child has reinsert breakpoint
in its space, and GDBserver clones parent's breakpoint list to child's.
When GDBserver resumes the child, its bp_reinsert is zero, but has
reinsert breakpoints, so the following assert is triggered if I apply
the patch extending step-over-syscall.exp.

gdb/gdbserver/linux-low.c:4292: A problem internal to GDBserver has been detected.^M
void linux_resume_one_lwp_throw(lwp_info*, int, int, siginfo_t*): Assertion `!has_reinsert_breakpoints (proc)' failed.

gdb/gdbserver:

2016-06-17  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (handle_extended_wait): If the parent is doing
step-over, remove the reinsert breakpoints from the forked child.

8 years agoStep over exit with reinsert breakpoints
Yao Qi [Fri, 17 Jun 2016 09:25:12 +0000 (10:25 +0100)]
Step over exit with reinsert breakpoints

This patch fixes a GDBserver crash when one thread is stepping over
a syscall instruction which is exit.  Step-over isn't finished due
to the exit, but GDBserver doesn't clean up the state of step-over,
so in the wait next time, GDBserver will wait on step_over_bkpt,
which is already exited, and GDBserver crashes because
'requested_child' is NULL.  See gdbserver logs below,

Need step over [LWP 14858]? yes, found breakpoint at 0x2aaaaad91307^M
proceed_all_lwps: found thread 14858 needing a step-over^M
Starting step-over on LWP 14858.  Stopping all threads^M
>>>> entering void stop_all_lwps(int, lwp_info*)
....
<<<< exiting void stop_all_lwps(int, lwp_info*)^M
Done stopping all threads for step-over.^M
pc is 0x2aaaaad91307^M
Writing 0f to 0x2aaaaad91307 in process 14858^M
Could not find fast tracepoint jump at 0x2aaaaad91307 in list (uninserting).^M
  pending reinsert at 0x2aaaaad91307^M
  step from pc 0x2aaaaad91307^M
Resuming lwp 14858 (step, signal 0, stop not expected)^M

 # Start step-over for LWP 14858

>>>> entering ptid_t linux_wait_1(ptid_t, target_waitstatus*, int)
....
LLFE: 14858 exited.
...
<<<< exiting ptid_t linux_wait_1(ptid_t, target_waitstatus*, int)

  # LWP 14858 exited
.....
>>>> entering ptid_t linux_wait_1(ptid_t, target_waitstatus*, int)^M
linux_wait_1: [<all threads>]^M
step_over_bkpt set [LWP 14858.14858], doing a blocking wait

  # but step_over_bkpt is still LWP 14858, which is wrong

The fix is to finish step-over if it is ongoing, and unsuspend other
threads.  Without the fix in linux-low.c, GDBserver will crash in
with running gdb.base/step-over-exit.exp.

gdb/gdbserver:

2016-06-17  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (unsuspend_all_lwps): Declare.
(linux_low_filter_event): If thread exited, call finish_step_over.
If step-over is finished, unsuspend other threads.

gdb/testsuite:

2016-06-17  Yao Qi  <yao.qi@linaro.org>

* gdb.base/step-over-exit.c: New.
* gdb.base/step-over-exit.exp: New.

8 years agoMore assert checks on reinsert breakpoint
Yao Qi [Fri, 17 Jun 2016 09:25:12 +0000 (10:25 +0100)]
More assert checks on reinsert breakpoint

This patch adds more asserts, so the incorrect or sub-optimal
reinsert breakpoints manipulations (from the tests in the following
patches) can trigger them.

gdb/gdbserver:

2016-06-17  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (linux_resume_one_lwp_throw): Assert
has_reinsert_breakpoints returns false.
* mem-break.c (delete_disabled_breakpoints): Assert
bp type isn't reinsert_breakpoint.

8 years agoSwitch to current thread in finish_step_over
Yao Qi [Fri, 17 Jun 2016 09:25:12 +0000 (10:25 +0100)]
Switch to current thread in finish_step_over

This patch adds some sanity check that reinsert breakpoints must be
there when doing step-over on software single step target.  The check
triggers an assert when running forking-threads-plus-breakpoint.exp
on arm-linux target,

 gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M
 int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed.

the error happens when GDBserver has already resumed a thread of
process A for step-over (and wait for it hitting reinsert breakpoint),
but receives detach request for process B from GDB, which is shown in
the backtrace below,

 (gdb) bt
 #2  0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703
 #3  0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749
 #4  complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760
 #5  linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503
 #6  0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974
 #7  handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347
 #8  0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429
 #9  0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184
 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547
 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719
 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804

the sanity check tries to find the reinsert breakpoint from process B,
but nothing is found.  It is wrong, we need to search in process A,
since we started step-over of a thread of process A.

 (gdb) p lwp->thread->entry.id
 $3 = {pid = 25120, lwp = 25131, tid = 0}
 (gdb) p current_thread->entry.id
 $4 = {pid = 25228, lwp = 25228, tid = 0}

This patch switched current_thread to the thread we are doing step-over
in finish_step_over.

gdb/gdbserver:

2016-06-17  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (maybe_hw_step): New function.
(linux_resume_one_lwp_throw): Call maybe_hw_step.
(finish_step_over): Switch current_thread to lwp temporarily,
and assert has_reinsert_breakpoints returns true.
(proceed_one_lwp): Call maybe_hw_step.
* mem-break.c (has_reinsert_breakpoints): New function.
* mem-break.h (has_reinsert_breakpoints): Declare.

8 years agogdb: new AndesTech NDS32 port
Yan-Ting Lin [Fri, 17 Jun 2016 07:25:08 +0000 (15:25 +0800)]
gdb: new AndesTech NDS32 port

gdb/ChangeLog:

* Makefile.in (ALL_TARGET_OBS): Add nds32-tdep.o.
(HFILES_NO_SRCDIR): Add nds32-tdep.h.
(ALLDEPFILES): Add nds32-tdep.c.
* NEWS: Mention new NDS32 port.
* configure.tgt: Add NDS32.
* nds32-tdep.c: New file.
* nds32-tdep.h: New file.
* features/Makefile (XMLTOC): Add nds32.xml.
* features/nds32-core.xml: New file.
* features/nds32-fpu.xml: New file.
* features/nds32-system.xml: New file.
* features/nds32.c: New file (generated).
* features/nds32.xml: New file.

gdb/doc/ChangeLog:

* gdb.texinfo (Standard Target Features): Document NDS32 features.
(NDS32 Features): New Section.

gdb/testsuite/ChangeLog:

* gdb.base/float.exp: Add target check for nds32*-*-*.
* gdb.xml/tdesc-regs.exp: Set core-regs for nds32*-*-*.

8 years agoopcodes,gas: sparc: fix rdasr,wrasr,rdpr,wrpr,rdhpr,wrhpr insns.
Jose E. Marchesi [Fri, 17 Jun 2016 09:15:43 +0000 (02:15 -0700)]
opcodes,gas: sparc: fix rdasr,wrasr,rdpr,wrpr,rdhpr,wrhpr insns.

This patch fixes and expands the definition of the read/write
instructions for ancillary-state, privileged and hyperprivileged
registers in opcodes.

It also adds support for three new v9m hyperprivileged registers:
%hmcdper, %hmcddfr and %hva_mask_nz.

Finally, the patch expands existing tests (and adds several new ones) in
order to cover all the read/write instructions in all its variants.

opcodes/ChangeLog:

2016-06-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* sparc-opc.c (rdasr): New macro.
(wrasr): Likewise.
(rdpr): Likewise.
(wrpr): Likewise.
(rdhpr): Likewise.
(wrhpr): Likewise.
(sparc_opcodes): Use the macros above to fix and expand the
definition of read/write instructions from/to
asr/privileged/hyperprivileged instructions.
* sparc-dis.c (v9_hpriv_reg_names): Add %hmcdper, %hmcddfr and
%hva_mask_nz.  Prefer softint_set and softint_clear over
set_softint and clear_softint.
(print_insn_sparc): Support %ver in Rd.

gas/ChangeLog:

2016-06-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* config/tc-sparc.c (hpriv_reg_table): Add registers %hmcdper,
%hmcddfr and %hva_mask_nz.
(sparc_ip): New handling of asr/privileged/hyperprivileged
registers, adapted to the new form of the sparc opcodes table.
* testsuite/gas/sparc/rdasr.s: New file.
* testsuite/gas/sparc/rdasr.d: Likewise.
* testsuite/gas/sparc/wrasr.s: Likewise.
* testsuite/gas/sparc/wrasr.d: Likewise.
* testsuite/gas/sparc/sparc.exp (sparc_elf_setup): Add rdasr and
wrasr tests.
* testsuite/gas/sparc/rdpr.d: Use -Av9m, as some privileged
registers require it.
* testsuite/gas/sparc/wrpr.s: Complete to cover all privileged
registers and write instruction modalities.
* testsuite/gas/sparc/wrpr.d: Likewise.
* testsuite/gas/sparc/rdhpr.s: Likewise for hyperprivileged
registers.
* testsuite/gas/sparc/rdhpr.d: Likewise.
* testsuite/gas/sparc/wrhpr.s: Likewise.
* testsuite/gas/sparc/wrhpr.d: Likewise.

8 years agoopcodes,gas: adjust sparc insns and make GAS aware of it
Jose E. Marchesi [Fri, 17 Jun 2016 09:14:18 +0000 (02:14 -0700)]
opcodes,gas: adjust sparc insns and make GAS aware of it

This patch marks the SPARC instructions in the opcodes table with their
proper opcode architectures, and makes the assembler aware of them.
This allows the assembler to properly realize when a new instruction
needs a higher architecture (after v9b) and to react accordingly
emitting an error message or bumping the architecture.

It also expands architecture mismatch tests to cover architectures
higher than v9b, and fixes a couple of minor bugs in the GAS testsuite.

opcodes/ChangeLog:

2016-06-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* sparc-opc.c (sparc_opcodes): Adjust instructions opcode
architecture according to the hardware capabilities they require.
(sparc_priv_regs): New table.
(sparc_hpriv_regs): Likewise.
(sparc_asr_regs): Likewise.
(v9anotv9m): Define.

gas/ChangeLog:

2016-06-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* config/tc-sparc.c (sparc_arch_table): adjust the GAS
architectures to use the right opcode architecture.
(sparc_md_end): Handle v9{c,d,e,v,m}.
(sparc_ip): Fix some comments.
* testsuite/gas/sparc/ldx_efsr.d: Fix the architecture of this
instruction, which is v9d.
* testsuite/gas/sparc/mwait.s: Remove the `rd %mwait,%g1'
instruction from the test, as %mwait is not readable.
* testsuite/gas/sparc/mwait.d: Likewise.
* testsuite/gas/sparc/mism-1.s: Expand to check v9b and v9e
mismatch architecture errors.
* testsuite/gas/sparc/mism-2.s: New file.

8 years agogas: sparc: fix collision of registers and pseudo-ops.
Jose E. Marchesi [Fri, 17 Jun 2016 09:13:30 +0000 (02:13 -0700)]
gas: sparc: fix collision of registers and pseudo-ops.

The current sparc assembler breaks when the name of an ancillary-state
register, privileged register or hyperprivileged register has a
%-pseudo-operation name as a prefix.  For example, %hmcdper and %hm(),
or %hintp and %hi().

This patch fixes it by introducing a new table `perc_table' (for
%-table) that contains an entry for every %name supported by the
assembler, other than the general registers.  This table is used to
detect name collisions when the assembler tries to detect a %-pseudo-op.

This patch also fixes a related bug, making sure that v9a_asr_table and
hpriv_reg_table are sorted in reverse lexicographic order, as otherwise
the search code may fail.

gas/ChangeLog:

2016-06-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* config/tc-sparc.c (priv_reg_table): Use NULL instead of the
empty string to mark the end of the array.
(hpriv_reg_table): Likewise.
(v9a_asr_table): Likewise.
(cmp_reg_entry): Handle entries with NULL names.
(F_POP_V9): Define.
(F_POP_PCREL): Likewise.
(F_POP_TLS_CALL): Likewise.
(F_POP_POSTFIX): Likewise.
(struct pop_entry): New type.
(pop_table): New variable.
(enum pop_entry_type): New type.
(struct perc_entry): Likewise.
(NUM_PERC_ENTRIES): Define.
(perc_table): New variable.
(cmp_perc_entry): New function.
(md_begin): Sort hpriv_reg_table and v9a_asr_table, and initialize
perc_table.
(sparc_ip): Handle entries with NULL names in priv_reg_table,
hpriv_reg_table and v9a_asr_table.  Use perc_table to handle
%-pseudo-ops.

8 years agobfd,opcodes: sparc: new opcode v9{c,d,e,v,m} architectures and bfd machine numbers.
Jose E. Marchesi [Fri, 17 Jun 2016 09:12:48 +0000 (02:12 -0700)]
bfd,opcodes: sparc: new opcode v9{c,d,e,v,m} architectures and bfd machine numbers.

This patch adds support for the opcode architectures
SPARC_OPCODE_ARCH_V9{C,D,E,V,M} and its associated BFD machine numbers
bfd_mach_sparc_v9{c,d,e,v,m} and bfd_mach_sparc_v8plus{c,d,e,v,m}.

Note that for arches up to v9b (UltraSPARC III), the detection of the
BFD machine type was based on the bits in the e_machine field of the ELF
header.  However, there are no more available bits in that field, so
this patch takes the approach of using the hardware capabilities stored
in the object attributes HWCAPS/HWCAPS2 in order to characterize the
machine the object was built for.

bfd/ChangeLog:

2016-06-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* archures.c (bfd_mach_sparc_v8plusc): Define.
(bfd_mach_sparc_v9c): Likewise.
(bfd_mach_sparc_v8plusd): Likewise.
(bfd_mach_sparc_v9d): Likewise.
(bfd_mach_sparc_v8pluse): Likewise.
(bfd_mach_sparc_v9e): Likewise.
(bfd_mach_sparc_v8plusv): Likewise
(bfd_mach_sparc_v9v): Likewise.
(bfd_mach_sparc_v8plusm): Likewise.
(bfd_mach_sparc_v9m): Likewise.
(bfd_mach_sparc_v9_p): Adapt to v8plusm and v9m.
(bfd_mach_sparc_64bit_p): Likewise.
* bfd-in2.h: Regenerate.
* cpu-sparc.c (arch_info_struct): Add entries for
bfd_mach_sparc_v8plus{c,d,e,v,m} and bfd_mach_sparc_v9{c,d,e,v,m}.
* aoutx.h (machine_type): Handle bfd_mach_sparc_v8plus{c,d,e,v,m}
and bfd_mach_sparc_v9{c,d,e,v,m}.
* elf32-sparc.c (elf32_sparc_final_write_processing): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_object_p): Likewise.

include/ChangeLog:

2016-06-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* opcode/sparc.h (enum sparc_opcode_arch_val): Add
SPARC_OPCODE_ARCH_V9C, SPARC_OPCODE_ARCH_V9D,
SPARC_OPCODE_ARCH_V9E, SPARC_OPCODE_ARCH_V9V and
SPARC_OPCODE_ARCH_V9M.

opcodes/ChangeLog:

2016-06-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* sparc-dis.c (MASK_V9): Add SPARC_OPCODE_ARCH_V9{C,D,E,V,M}.
(compute_arch_mask): Handle bfd_mach_sparc_v8plus{c,d,e,v,m} and
bfd_mach_sparc_v9{c,d,e,v,m}.
* sparc-opc.c (MASK_V9C): Define.
(MASK_V9D): Likewise.
(MASK_V9E): Likewise.
(MASK_V9V): Likewise.
(MASK_V9M): Likewise.
(v6): Add MASK_V9{C,D,E,V,M}.
(v6notlet): Likewise.
(v7): Likewise.
(v8): Likewise.
(v9): Likewise.
(v9andleon): Likewise.
(v9a): Likewise.
(v9b): Likewise.
(v9c): Define.
(v9d): Likewise.
(v9e): Likewise.
(v9v): Likewise.
(v9m): Likewise.
(sparc_opcode_archs): Add entry for v9{c,d,e,v,m}.

8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 17 Jun 2016 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoAdd missing ChangeLog entries
H.J. Lu [Thu, 16 Jun 2016 19:38:34 +0000 (12:38 -0700)]
Add missing ChangeLog entries

commit bf52d7c72035679e6b3ab601133c56a4388f4dc9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jun 15 10:35:38 2016 -0700

    Don't check undefined symbol for IFUNC reloc

8 years agoDon't check undefined symbol for IFUNC reloc
H.J. Lu [Wed, 15 Jun 2016 17:35:38 +0000 (10:35 -0700)]
Don't check undefined symbol for IFUNC reloc

Since x86 elf_*_check_relocs is called after all symbols have been
resolved, there is no need to check undefined symbols for relocations
against IFUNC symbols.

bfd/

* elf32-i386.c (elf_i386_check_relocs): Don't check undefined
symbols for relocations against IFUNC symbols.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.

ld/

* testsuite/ld-i386/i386.exp: Run pr19636-2e-nacl.
* testsuite/ld-i386/pr19636-2e.d: Skip for NaCl targets.
Remove .rel.plt section.
* testsuite/ld-i386/pr19636-2e-nacl.d: New file.

8 years agobfd/s390: Fix DT_PLTRELSZ in presence of R_390_IRELATIVE.
Marcin Koƛcielnicki [Wed, 8 Jun 2016 12:01:31 +0000 (14:01 +0200)]
bfd/s390: Fix DT_PLTRELSZ in presence of R_390_IRELATIVE.

This was broken by 4ade44b727ee77adaa9c22719935d012e253a5e6,
which changed the calculation to use the .rela.plt linker section
instead of its output section - thus skipping .rela.iplt .
Fix the calculations to include it.

bfd/ChangeLog:

* elf32-s390.c (elf_s390_finish_dynamic_sections): Include
.rela.iplt in DT_PLTRELSZ.
* elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise,
for DT_PLTRELSZ and DT_RELASZ as well.