binutils-gdb.git
6 years agoremote-sim.c: Remove unused variables
Simon Marchi [Mon, 16 Jul 2018 18:07:09 +0000 (14:07 -0400)]
remote-sim.c: Remove unused variables

gdb/ChangeLog:

* remote-sim.c (gdbsim_target::close,
gdbsim_target::mourn_inferior): Remove unused variables.

6 years agoAdd missing ChangeLog entry
Simon Marchi [Mon, 16 Jul 2018 18:08:26 +0000 (14:08 -0400)]
Add missing ChangeLog entry

I forgot to append the ChangeLog entry to the last commit...

6 years agoFix compilation error in ia64-tdep.c with libunwind-ia64
Simon Marchi [Sat, 7 Jul 2018 15:10:49 +0000 (11:10 -0400)]
Fix compilation error in ia64-tdep.c with libunwind-ia64

Commit

  9018be22e022 ("Make target_read_alloc & al return vectors")

failed to update the code in ia64-tdep.c, for HAVE_LIBUNWIND_IA64_H.
This patch fixes that.

gdb/ChangeLog:

* ia64-tdep.c (ktab_buf): New global.
(getunwind_table): Return a gdb::optional<gdb::byte_vector>.
(get_kernel_table): Adjust.

6 years agoUse outermost_context_p in more places
Tom Tromey [Mon, 21 May 2018 05:42:01 +0000 (23:42 -0600)]
Use outermost_context_p in more places

This changes a few explicit checks of context_stack_depth to use
outermost_context_p instead.  This simplifies some future work.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* xcoffread.c (read_xcoff_symtab): Use outermost_context_p.
* dwarf2read.c (using_directives, new_symbol): Use
outermost_context_p.
* dbxread.c (process_one_symbol): Use outermost_context_p.
* coffread.c (coff_symtab_read): Use outermost_context_p.

6 years agoMove the using directives to buildsym_compunit
Tom Tromey [Mon, 21 May 2018 05:28:39 +0000 (23:28 -0600)]
Move the using directives to buildsym_compunit

This moves the globals local_using_directives and
global_using_directives to be members of buildsym_compunit, and adds
the necessary accessors.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (using_directives, read_func_scope)
(read_lexical_block_scope): Update.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
* buildsym.h (local_using_directives, global_using_directives):
Don't declare.
(get_local_using_directives, set_local_using_directives)
(get_global_using_directives): Declare.
* buildsym.c (struct buildsym_compunit) <m_local_using_directives,
m_global_using_directives>: New members.
(finish_block_internal, prepare_for_building)
(reset_symtab_globals, end_symtab_get_static_block)
(push_context): Update.
(get_local_using_directives, set_local_using_directives)
(get_global_using_directives): New functions.
(buildsym_init): Update.

6 years agoMake free_pending_blocks static
Tom Tromey [Mon, 21 May 2018 04:45:44 +0000 (22:45 -0600)]
Make free_pending_blocks static

free_pending_blocks can be static because scoped_free_pendings (et al)
arrange for it to be NULL in the "steady state".  This removes a
couple of unnecessary calls to free_pending_blocks and changes it to
be static.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* xcoffread.c (xcoff_initial_scan): Don't call
free_pending_blocks.
* dbxread.c (dbx_symfile_read): Don't call free_pending_blocks.
* buildsym.h (class scoped_free_pendings): Add constructor.
(free_pending_blocks): Don't declare.
* buildsym.c (scoped_free_pendings::scoped_free_pendings): New.
(free_pending_blocks): Now static.

6 years agoMove the subfile stack to buildsym_compunit
Tom Tromey [Mon, 21 May 2018 02:48:44 +0000 (20:48 -0600)]
Move the subfile stack to buildsym_compunit

This moves the global subfile_stack to be a member of
buildsym_compunit.  It also change this to be a std::vector, which
simplifies the code.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* buildsym.h (push_subfile, pop_subfile): Update declarations.
* buildsym.c (struct buildsym_compunit) <m_subfile_stack>: New
member.
(struct subfile_stack): Remove.
(subfile_stack): Remove.
(push_subfile, pop_subfile, buildsym_init): Update.

6 years agoUse gdb_assert in two places in buildsym.c
Tom Tromey [Sun, 20 May 2018 22:15:14 +0000 (16:15 -0600)]
Use gdb_assert in two places in buildsym.c

This changes buildsym.c to use gdb_assert rather than internal_error
in a couple of spots.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* buildsym.c (push_subfile): Use gdb_assert.
(pop_subfile): Use gdb_assert.

6 years agoRemove merge_symbol_lists
Tom Tromey [Sun, 20 May 2018 18:07:44 +0000 (12:07 -0600)]
Remove merge_symbol_lists

I discovered that merge_symbol_lists is unused, so this removes it.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* buildsym.h (merge_symbol_lists): Remove.
* buildsym.c (merge_symbol_lists): Remove.

6 years agoMove scan_file_globals declaration to stabsread.h
Tom Tromey [Sun, 20 May 2018 18:06:43 +0000 (12:06 -0600)]
Move scan_file_globals declaration to stabsread.h

scan_file_globals is defined in stabsread.c, so move its declaration
to stabsread.h.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* stabsread.c (scan_file_globals): Update comment.
* stabsread.h (scan_file_globals): Move from buildsym.h.
* buildsym.h (scan_file_globals): Move to stabsread.h.

6 years agoRemove buildsym_new_init
Tom Tromey [Sun, 20 May 2018 17:25:20 +0000 (11:25 -0600)]
Remove buildsym_new_init

buildsym_new_init is just an alias for buildsym_init.  This removes
it.  In the long run buildsym_init will also go away; this patch just
helps make things a bit clearer in the meantime.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* xcoffread.c (xcoff_new_init): Update.
* mipsread.c (mipscoff_new_init): Update.
* mdebugread.c (mdebug_build_psymtabs): Update.
* elfread.c (elf_new_init): Update.
* dbxread.c (dbx_new_init, coffstab_build_psymtabs)
(elfstab_build_psymtabs, stabsect_build_psymtabs): Update.
* buildsym.h (buildsym_new_init): Don't declare.
* buildsym.c (buildsym_new_init): Remove.

6 years agoMove within_function to stabsread
Tom Tromey [Sun, 20 May 2018 17:19:14 +0000 (11:19 -0600)]
Move within_function to stabsread

The global within_function is only used by a few symbol readers.  This
patch moves the global out of buildsym and into stabsread, which
seemed like a better fit.  It also arranges for the existing readers
to clear the global at the appropriate time.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* stabsread.h (within_function): Move from buildsym.h.
* stabsread.c (start_stabs): Clear within_function.
* coffread.c (coff_start_symtab): Clear within_function.
* buildsym.h (within_function): Move to stabsread.h.
* buildsym.c (prepare_for_building): Update.

6 years agoMove processing_gcc to stabsread
Tom Tromey [Sun, 20 May 2018 17:16:57 +0000 (11:16 -0600)]
Move processing_gcc to stabsread

processing_gcc is also only used by stabsread -- it is set by the
DWARF reader, but this turns out not to be needed.  So, this patch
moves processing_gcc and removes the assignment from the DWARF reader.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* stabsread.h (processing_gcc_compilation): Move from buildsym.h.
* dwarf2read.c (dwarf2_start_symtab): Don't set
processing_gcc_compilation.
* buildsym.h (processing_gcc_compilation): Move to stabsread.h.

6 years agoMove some code from buildsym to stabsread
Tom Tromey [Sun, 20 May 2018 17:13:12 +0000 (11:13 -0600)]
Move some code from buildsym to stabsread

A few things that currently reside in buildsym.c turn out to be
specific to the stabs reader.  This patch moves these from
buildsym.[ch] to stabsread.[ch].

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* stabsread.h (HASHSIZE, hashname, symnum, next_symbol_text)
(next_symbol_text_func): Move from buildsym.h.
* stabsread.c (hashname): Move from buildsym.c.
* buildsym.h (HASHSIZE, symnum, next_symbol_text)
(next_symbol_text_func, hashname): Move to stabsread.h.
* buildsym.c: Don't include bcache.h
(hashname): Move to stasbread.c.

6 years agoMake context_stack_size static in buildsym.c
Tom Tromey [Sun, 20 May 2018 17:12:57 +0000 (11:12 -0600)]
Make context_stack_size static in buildsym.c

context_stack_size is declared in buildsym.h, but only used in
buildsym.c.  This makes it static in buildsym.c.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* buildsym.h (context_stack_size): Don't declare.
* buildsym.c (context_stack_size): New global.

6 years agoMove processing_acc_compilation to dbxread.c
Tom Tromey [Sun, 20 May 2018 17:04:16 +0000 (11:04 -0600)]
Move processing_acc_compilation to dbxread.c

processing_acc_compilation is only used in dbxread.c, so move it
there.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* dbxread.c (processing_acc_compilation): New global.
* buildsym.h (processing_acc_compilation): Don't declare.

6 years agoMove last_source_start_addr to buildsym_compunit
Tom Tromey [Sun, 20 May 2018 17:01:37 +0000 (11:01 -0600)]
Move last_source_start_addr to buildsym_compunit

This moves the global last_source_start_addr into buildsym_compunit,
adding some accessors as well.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* xcoffread.c (aix_process_linenos, complete_symtab): Update.
* dbxread.c (read_ofile_symtab): Update.
* coffread.c (coff_start_symtab, coff_end_symtab): Update.
* buildsym.h (last_source_start_addr): Remove.
(set_last_source_start_addr, get_last_source_start_addr):
Declare.
* buildsym.c (buildsym_compunit::buildsym_compunit): Add last_addr
parameter.
(struct buildsym_compunit) <m_last_source_start_addr>: New
member.
(prepare_for_building): Remove start_addr parameter.
(start_symtab, restart_symtab, end_symtab_get_static_block)
(end_symtab_with_blockvector): Update.
(set_last_source_start_addr, get_last_source_start_addr): New
functions.

6 years agoMove have_line_numbers to buildsym_compunit
Tom Tromey [Sun, 20 May 2018 16:48:41 +0000 (10:48 -0600)]
Move have_line_numbers to buildsym_compunit

This moves the global have_line_numbers into buildsym_compunit.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* buildsym.c (struct buildsym_compunit) <m_have_line_numbers>: New
member.
(have_line_numbers): Remove.
(record_line, prepare_for_building, end_symtab_get_static_block)
(augment_type_symtab): Update.

6 years agoMove pending_macros to buildsym_compunit
Tom Tromey [Sun, 20 May 2018 16:46:25 +0000 (10:46 -0600)]
Move pending_macros to buildsym_compunit

This moves the pending_macros global into buildsym_compunit.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* buildsym.c (~buildsym_compunit): Free the macro table.
(struct buildsym_compunit) <get_macro_table, release_macros>: New
methods.
<m_pending_macros>: New member.
(pending_macros): Remove.
(~scoped_free_pendings, get_macro_table, prepare_for_building)
(reset_symtab_globals, end_symtab_get_static_block)
(end_symtab_with_blockvector, augment_type_symtab)
(buildsym_init): Update.

6 years agoMove last_source file to buildsym_compunit
Tom Tromey [Sun, 20 May 2018 16:39:24 +0000 (10:39 -0600)]
Move last_source file to buildsym_compunit

This moves the global last_source_file into buildsym_compunit.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* buildsym.c (buildsym_compunit::buildsym_compunit): Add name
parameter.
(buildsym_compunit::set_last_source_file): New method.
<m_last_source_file>: New member.
(prepare_for_building): Remove "name" parameter.
(start_symtab, restart_symtab, reset_symtab_globals): Update.
(last_source_file): Remove.
(set_last_source_file, get_last_source_file): Update.

6 years agoAdd assert in prepare_for_building
Tom Tromey [Sun, 20 May 2018 16:25:53 +0000 (10:25 -0600)]
Add assert in prepare_for_building

This adds an assertion in prepare_for_building.  This was useful for
verifying whether some subsequent changes were valid.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* buildsym.c (prepare_for_building): Add assert.

6 years agoChange buildsym_compunit::comp_dir to be a unique_xmalloc_ptr
Tom Tromey [Sun, 20 May 2018 16:22:19 +0000 (10:22 -0600)]
Change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr

This change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr.
This is just a small cleanup to remove some manual memory management.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* buildsym.c (~buildsym_compunit): Update.
(struct buildsym_compunit) <comp_unit>: Now a unique_xmalloc_ptr.
(start_subfile, patch_subfile_names)
(end_symtab_with_blockvector): Update.

6 years agoUse new and delete for buildsym_compunit
Tom Tromey [Sun, 20 May 2018 16:20:53 +0000 (10:20 -0600)]
Use new and delete for buildsym_compunit

This changes buildsym_compunit to use new and delete.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* buildsym.c (struct buildsym_compunit): Add constructor,
destructor, initializers.
(start_buildsym_compunit): Remove.
(free_buildsym_compunit): Use "delete".
(start_symtab, restart_symtab): Use "new".

6 years agoUpdate release making notes to metion checking for new top level files.
Nick Clifton [Mon, 16 Jul 2018 13:14:17 +0000 (14:14 +0100)]
Update release making notes to metion checking for new top level files.

* README-how-to-make-a-release: Add note to check for new top
level files and add them to the src-release.sh script.

6 years agoUpdate the src-release script to include the new top level files test-driver and...
Nick Clifton [Mon, 16 Jul 2018 13:10:35 +0000 (14:10 +0100)]
Update the src-release script to include the new top level files test-driver and ar-lib.

* src-release.sh (DEVO_SUPPORT): Add test-driver and ar-lib.

6 years agox86: fix operand size checking
Jan Beulich [Mon, 16 Jul 2018 06:19:21 +0000 (08:19 +0200)]
x86: fix operand size checking

Currently mov to/from control, debug, and test register insns accept any
size GPR operand (general pattern: templates with D set and both
operands being registers in distinct register files). This is due to
improper checking of the reverse case, including not informing the
caller whether a straight and/or reverse match was successful.

The helper functions need to be told two indexes: One to index the given
operand types array, and the other to index the template one. The caller
must attempt a further straight match only if the function reported a
straight match (and respectively for reverse matches).

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 16 Jul 2018 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix filename in prior ChangeLog entry
Simon Marchi [Sun, 15 Jul 2018 14:40:49 +0000 (10:40 -0400)]
Fix filename in prior ChangeLog entry

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 15 Jul 2018 00:01:15 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years agoFix internal error when using --emit-relocs with plugins.
Cary Coutant [Sat, 14 Jul 2018 18:52:27 +0000 (11:52 -0700)]
Fix internal error when using --emit-relocs with plugins.

When an .eh_frame section has deferred layout because of plugins, gold
was neglecting to mark the section as deferred. When we later processed
the corresponding relocation section, we were then ignoring it, causing
the internal error later on in the link.

gold/
PR gold/23397
* object.cc (Sized_relobj_file::do_layout): Mark section as deferred.
* testsuite/Makefile.am (plugin_test_1): Add --emit-relocs option to
existing test case.
* testsuite/Makefile.in: Regenerate.

6 years agoFix problem causing duplicated linker-generated symbols with versions.
Cary Coutant [Sat, 14 Jul 2018 19:29:03 +0000 (12:29 -0700)]
Fix problem causing duplicated linker-generated symbols with versions.

When generating _end, _edata, etc. symbols, and a version script provides
a version name, and we are linking against another shared library that
provides those symbols with a different version, gold ends up trying to
resolve the other shared library's symbols to the new definitions, resulting
in two copies of each symbol, one as default, and one as non-default.
This patch tests for that condition, and ignores the symbols provided
by the other shared library.

gold/
PR gold/23409
* symtab.cc (Symbol_table::define_special_symbol): Add check for
version name on existing symbol.
* testsuite/Makefile.am (ver_test_pr23409): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/ver_test_pr23409.sh: New test script.
* testsuite/ver_test_pr23409_1.script: New version script.
* testsuite/ver_test_pr23409_2.script: New version script.

6 years agoUpdate the notes on how to make a binutils release.
Nick Clifton [Sat, 14 Jul 2018 19:23:52 +0000 (20:23 +0100)]
Update the notes on how to make a binutils release.

* README-how-to-make-a-release: Updated with corrections based on
the 2.31 release experience.

6 years agoRemove struct keyword in range-based for loop
Simon Marchi [Sat, 14 Jul 2018 02:06:34 +0000 (22:06 -0400)]
Remove struct keyword in range-based for loop

Fix this with  gcc 6.3.0:

/home/simark/src/binutils-gdb/gdb/symfile.c: In function 'void set_objfile_default_section_offset(objfile*, const section_addr_info&, CORE_ADDR)':
/home/simark/src/binutils-gdb/gdb/symfile.c:2114:14: error: types may not be defined in a for-range-declaration [-Werror]
   for (const struct other_sections *objf_sect : objf_addrs_sorted)
              ^~~~~~
gdb/ChangeLog:

* symfile.c (set_objfile_default_section_offset): Remove struct
keyword.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 14 Jul 2018 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agosim: Add Stafford Horne as or1k maintainer.
Stafford Horne [Fri, 13 Jul 2018 20:59:26 +0000 (05:59 +0900)]
sim: Add Stafford Horne as or1k maintainer.

Since I helped upstream the or1k port I would like to claim myself as
maintainer.

sim/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

* MAINTAINERS (or1k): Add myself as or1k maintainer.

Signed-off-by: Stafford Horne <shorne@gmail.com>
6 years agogdb: Add Stafford Horne as or1k maintainer.
Stafford Horne [Fri, 13 Jul 2018 20:59:26 +0000 (05:59 +0900)]
gdb: Add Stafford Horne as or1k maintainer.

Since I helped upstream openrisc I would like to claim responsibility to
maintain it.

gdb/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

* (Responsible Maintainers): Add myself as or1k maintainer.

Signed-off-by: Stafford Horne <shorne@gmail.com>
6 years agoExpect for another variant of error message when gdbserver cannot resolve hostname
Sergio Durigan Junior [Fri, 13 Jul 2018 20:20:34 +0000 (16:20 -0400)]
Expect for another variant of error message when gdbserver cannot resolve hostname

I've noticed that on a few hosts, when given an invalid hostname,
gdbserver fails with:

  spawn /../../gdb/gdbserver/gdbserver --once tcp8:123:2353 /gdb/build/fedora-s390x/build/gdb/testsuite/outputs/gdb.server/server-connect/server-connect
  tcp8:123:2353: cannot resolve name: No address associated with hostname
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  Exiting

Unfortunately, this causes a fail on the new
gdb.server/server-connect.exp test (introduced by the IPv6 patch):

  FAIL: gdb.server/server-connect.exp: tcp8: start gdbserver: gdbserver should fail but did not

This happens because we're expecting for another variant of this error
message:

  cannot resolve name: Name or service not known

Therefore, this patch extends the helper function 'gdbserver_start' to
also recognize the "No address associated with hostname" message.
This "fixes" the testcase on the hosts that use this variant.

gdb/testsuite/ChangeLog:
2018-07-13  Sergio Durigan Junior  <sergiodj@redhat.com>

* lib/gdbserver-support.exp (gdbserver_start): Expect for the
message "No address associated with hostname" when gdbserver
cannot resolve the hostname.

6 years agoRemove a warning on macOS
Tom Tromey [Fri, 13 Jul 2018 17:14:57 +0000 (11:14 -0600)]
Remove a warning on macOS

This removes a clang warning coming from -Wmissing-braces.

ChangeLog
2018-07-13  Tom Tromey  <tom@tromey.com>

* symfile.c (set_objfile_default_section_offset): Use extra braces
around initializer.

6 years agoAdd a test that relocs are correctly generated for missing build notes.
Nick Clifton [Fri, 13 Jul 2018 14:48:49 +0000 (15:48 +0100)]
Add a test that relocs are correctly generated for missing build notes.

* testsuite/gas/elf/missing-build-notes.s: New test.  Checks that
relocs are correctly generated for missing build notes.
* testsuite/gas/elf/missing-build-notes.d: New file.  Expected
output from objdump.
* testsuite/gas/elf/elf.exp: Run the new test.

6 years agoAllow bit-patterns in the immediate field of ARM neon mov instructions.
Nick Clifton [Fri, 13 Jul 2018 10:46:44 +0000 (11:46 +0100)]
Allow bit-patterns in the immediate field of ARM neon mov instructions.

* config/tc-arm.c (do_neon_mov): When converting an integer
immediate into a floating point value, check that the conversion
is valid.  Also warn if the immediate is valid as both a floating
point value and a bit pattern.
* testsuite/gas/arm/vfp-mov-enc.s: Add instructions that use
floating point bit patterns.
* testsuite/gas/arm/vfp-mov-enc.d: Add regexps for the disassembly
of the new insns.

6 years agoS390: Fix displaced stepping of "basr r,0"
Andreas Arnez [Fri, 13 Jul 2018 10:46:14 +0000 (12:46 +0200)]
S390: Fix displaced stepping of "basr r,0"

The BASR instruction behaves differently depending on whether the second
operand is a number from 1 to 15, or zero.  In the former case BASR jumps
to the address contained in the general register of that number, but in
the latter case no jump is performed.  GDB's displaced-stepping logic does
not distinguish these cases, although it should.

This is fixed.  In the case where no jump is performed the PC is adjusted
to point back after the original instruction.  Otherwise the PC is left
alone.

gdb/ChangeLog:

* s390-tdep.c (s390_displaced_step_fixup): Adjust PC for a
non-branching basr.

6 years agoGDBserver: Pass process_info pointer to target_kill
Pedro Alves [Fri, 13 Jul 2018 09:28:47 +0000 (10:28 +0100)]
GDBserver: Pass process_info pointer to target_kill

We start from a process_info pointer, pass down process->pid, and
then the target_kill implementations need to find the process from the
pid again.  Pass the process_info pointer down directly instead.

gdb/gdbserver/ChangeLog:
2018-07-13  Pedro Alves  <palves@redhat.com>

* linux-low.c (linux_kill): Change parameter to process_info
pointer instead of pid.  Adjust.
* lynx-low.c (lynx_kill): Likewise.
* nto-low.c (nto_kill): Likewise.
* spu-low.c (spu_kill): Likewise.
* win32-low.c (win32_kill): Likewise.
* server.c (handle_v_kill, kill_inferior_callback)
(detach_or_kill_for_exit): Adjust.
* target.c (kill_inferior): Change parameter to process_info
pointer instead of pid.  Adjust.
* target.h (struct target_ops) <kill>: Change parameter to
process_info pointer instead of pid.  Adjust all implementations
and callers.
(kill_inferior): Likewise.

6 years agoGDBserver: Pass process_info pointer to target_detach and target_join
Pedro Alves [Fri, 13 Jul 2018 09:28:46 +0000 (10:28 +0100)]
GDBserver: Pass process_info pointer to target_detach and target_join

We start from a process_info pointer, pass down process->pid, and then
the target_detach and target_join implementations need to find the
process from the pid again.  Pass the process_info pointer down
directly instead.

gdb/gdbserver/ChangeLog:
2018-07-13  Pedro Alves  <palves@redhat.com>

* linux-low.c (linux_detach, linux_join): Change parameter to
process_info pointer instead of pid.  Adjust.
* lynx-low.c (lynx_detach, lynx_join): Likewise.
* nto-low.c (nto_detach): Likewise.
* spu-low.c (spu_detach, spu_join): Likewise.
* win32-low.c (win32_detach, win32_join): Likewise.
* server.c (handle_detach, detach_or_kill_for_exit): Adjust.
* target.h (struct target_ops) <detach, join>: Change parameter to
process_info pointer instead of pid.  Adjust all implementations
and callers.
(detach_inferior, join_inferior): Rename 'pid' parameter to
'proc'.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 13 Jul 2018 00:01:06 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years agoAdd a self-test for cli-utils.c
Philippe Waroquiers [Mon, 21 May 2018 07:16:13 +0000 (09:16 +0200)]
Add a self-test for cli-utils.c

tests added for:
* number_or_range_parser
  In particular, it tests the cur_tok when parsing is finished.

* parse_flags

* parse_flags_qcs

gdb/ChangeLog
2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/cli-utils-selftests.c
* unittests/cli-utils-selftests.c: New file.

6 years agoModify gdb.threads/pthreads.exp to test FLAG qcs arguments for thread apply.
Philippe Waroquiers [Sun, 20 May 2018 18:31:27 +0000 (20:31 +0200)]
Modify gdb.threads/pthreads.exp to test FLAG qcs arguments for thread apply.

Also, add prefixes to make some non unique tests unique.

gdb/testsuite/ChangeLog
2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.threads/pthreads.exp: Test qcs FLAG arguments.
Add some test prefixes to make tests unique.

6 years agoAdd a test for 'frame apply'
Philippe Waroquiers [Thu, 12 Jul 2018 21:04:13 +0000 (23:04 +0200)]
Add a test for 'frame apply'

gdb/testsuite/ChangeLog
2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.base/frameapply.c: New file.
* gdb.base/frameapply.exp: New file.

6 years agoAnnounce the user visible changes for frame/thread apply in NEWS.
Philippe Waroquiers [Thu, 12 Jul 2018 21:02:14 +0000 (23:02 +0200)]
Announce the user visible changes for frame/thread apply in NEWS.

'frame apply', faas, taas, tfaas commands and [FLAG]... arg for thread apply.

gdb/ChangeLog
2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* NEWS: Mention new commands.  Mention change to 'thread apply'.

6 years agoDocuments the new commands 'frame apply', faas, taas, tfaas
Philippe Waroquiers [Sun, 24 Jun 2018 11:02:43 +0000 (13:02 +0200)]
Documents the new commands 'frame apply', faas, taas, tfaas

Documents the new commands 'frame apply', faas, taas, tfaas.
Documents the new arguments [FLAG]... added to 'thread apply'.

gdb/doc/ChangeLog
2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.texinfo (Debugging Programs with Multiple Threads):
Document changes to 'thread apply'.  Document 'taas'.
Document 'tfaas'.
(Examining the Stack): Document 'frame apply'.  Document 'faas'.

6 years agoAdd [FLAG]... arguments to 'thread apply'.
Philippe Waroquiers [Sat, 5 May 2018 18:33:38 +0000 (20:33 +0200)]
Add [FLAG]... arguments to 'thread apply'.

Enhance 'thread apply' command to also accept [FLAG]... arguments.

An example usage for this new argument:
   thread apply all -s frame apply all -s p some_local_var_somewhere
      Prints the thread id, frame location and some_local_var_somewhere
      value in frames of threads that have such local var.

To make the life of the user easier, the most typical use cases
have shortcuts :
   taas  : shortcut for 'thread apply all -s'
   tfaas : shortcut for 'thread apply all -s frame apply all -s"

An example usage :
   tfaas p some_local_var_somewhere
     same as the longer:
        'thread apply all -s frame apply all -s p some_local_var_somewhere'

gdb/ChangeLog
2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* thread.c (thr_try_catch_cmd): New function.
(thread_apply_all_command): Handle qcs flags.
(thread_apply_command): Handle qcs flags.
(taas_command): New function.
(tfaas_command): New function.
(_initialize_thread): Update to setup the new commands 'taas
and 'tfaas'. Change doc string for 'thread apply'.

6 years agoImplement frame apply [all | COUNT | -COUNT | level LEVEL... ] [FLAG]... COMMAND.
Philippe Waroquiers [Sat, 5 May 2018 18:27:11 +0000 (20:27 +0200)]
Implement frame apply [all | COUNT | -COUNT | level LEVEL... ] [FLAG]... COMMAND.

Implement frame apply [all | COUNT | -COUNT | level LEVEL... ] [FLAG]... COMMAND.
Also implement the command 'faas COMMAND', a shortcut for
'frame apply all -s COMMAND'.

The syntax of 'frame apply' to specify some innermost or outermost
frames is similar to 'backtrace' command, using COUNT or -COUNT.

To apply a COMMAND to a more specific set of frames, the following
new command and syntax can be used:
frame apply level LEVEL... [FLAG]... COMMAND
where LEVEL is one or more frame levels or range of frame levels.

The new command 'frame apply' allows to apply a COMMAND to a number of frames,
or to all frames, or to a set of frames.
The optional [FLAG]... arguments allow to control what output to produce
and how to handle errors raised when applying COMMAND to a frame.

Some example usages for this new command:
   frame apply all info frame
      Produce info frame for all frames.
   frame apply all p $sp
      For each frame, print the location, followed by the frame sp.
   frame apply all -q p $sp
      Same as before, but -q flag (q = quiet) indicates to only print
      the frames sp.
   frame apply all p some_local_var_somewhere
      Print some_local_var_somewhere in all frames. 'frame apply'
      will abort as soon as the print command fails.
   frame apply all -c p some_local_var_somewhere
      Same as before, but -c flag (c = continue) means to
      print the error and continue applying command in case the
      print command fails.
   frame apply all -s p some_local_var_somewhere
      Same as before, but -s flag (s = silent) means to
      be silent for frames where the print command fails.
      In other words, this allows to 'search' the frame in which
      some_local_var_somewhere can be printed.
   frame apply all -s -q p some_local_var_somewhere
      Same as before, but does not print the frame info in which
      the variable is found.
   frame apply level 2-4 5 8-10 -s p i = i + 1
      Increments i in the identified frames.

gdb/ChangeLog
2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* stack.c: (trailing_outermost_frame): New function, mostly
extracted from backtrace_command_1.
(leading_innermost_frame): New function.
(backtrace_command_1): Update to call trailing_outermost_frame.
(frame_apply_command_count): New function.
(frame_apply_level_command): New function.
(frame_apply_all_command): New function.
(frame_apply_command): New function.
(faas_command): New function.
(frame_cmd_list): New variable.
(_initialize_stack): Update to setup the new commands 'frame apply'
and 'faas'.

6 years agoAdd helper functions parse_flags and parse_flags_qcs
Philippe Waroquiers [Sat, 5 May 2018 18:20:56 +0000 (20:20 +0200)]
Add helper functions parse_flags and parse_flags_qcs

Add helper functions parse_flags and parse_flags_qcs.
parse_flags helper function allows to look for a set of flags at
the start of a string.
A flag must be given individually.

parse_flags_qcs is a specialised helper function to handle
the flags -q, -c and -s, that are used in the new command 'frame apply'
and in the command 'thread apply.

Modify number_or_range_parser::get_number to differentiate a
- followed by digits from a - followed by an alpha (i.e. a flag or an option).
That is needed for the addition of the [FLAG]... arguments to
thread apply ID... [FLAG]... COMMAND

Remove bool number_or_range_parser::m_finished, rather
implement the 'finished' logic inside number_or_range_parser::finished.
The new logic properly detects the end of parsing even if not at
end of the string. This ensures that number_or_range_parser::cur_tok
really points past the last parsed token when parsing is finished.
Before, it was always pointing at the end of the string.
As parsing now is finished directly when not positioned on a number,
number_is_in_list must do an error check before the loop getting all
numbers.

The error message for 'thread apply -$unknownconvvar p 1'
is now the more clear:
  Convenience variable must have integer value.
  Invalid thread ID: -$unknownconvvar p 1
instead of previously:
  negative value

gdb/ChangeLog
2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* cli-utils.c (number_or_range_parser::get_number): Only handle
numbers or convenience var as numbers.
(parse_flags): New function.
(parse_flags_qcs): New function.
(number_or_range_parser::finished): Ensure parsing end is detected
before end of string.
* cli-utils.h (parse_flags): New function.
(parse_flags_qcs): New function.
(number_or_range_parser): Remove m_finished bool.
(number_or_range_parser::skip_range): Set m_in_range to false.

gdb/testsuite/ChangeLog
2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.base/skip.exp: Update expected error message.

6 years agoMIPS/LD/testsuite: Correct mips-elf.exp test ABI/emul/endian arrangement
Maciej W. Rozycki [Thu, 12 Jul 2018 19:01:44 +0000 (20:01 +0100)]
MIPS/LD/testsuite: Correct mips-elf.exp test ABI/emul/endian arrangement

Similarly to commit 86b24e15c45b ("MIPS/LD/testsuite: Correct
comm-data.exp test ABI/emul/endian arrangement") update the mips-elf.exp
test script to:

- correctly select emulations for targets using non-traditional MIPS
  emulations,

- correctly select ABIs for targets that do not support all of them,

- use the default endianness selection where possible to benefit targets
  that support only one,

- simplify test invocation by providing ABI-specific `run_dump_test'
  wrappers, specifically `run_dump_test_o32', `run_dump_test_n32',
  `run_dump_test_n64' and `run_dump_test_eabi', which remove the need to
  use conditionals across the Expect script or to repeat ABI-specific
  GAS and LD flags with each invocation,

removing numerous test failures for `mips-sgi-irix6', `mips64-openbsd',
`mips64el-openbsd' and `mips64el-ps2-elf' targets and broadening
coverage for several MIPS targets.

There are some new failures for the `mips64el-ps2-elf' target with tests
that were not previously run for that target:

FAIL: MIPS16 link branch to absolute expression (n32)
FAIL: MIPS16 link branch to absolute expression 1 (n32)
FAIL: MIPS16 link branch to absolute expression 2 (n32)
FAIL: microMIPS link branch to absolute expression (n32)
FAIL: MIPS ELF got reloc n32
FAIL: MIPS ELF xgot reloc n32
FAIL: undefined weak symbol overflow (n32)
FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs n32
FAIL: ld-mips-elf/attr-gnu-4-0-n32-ph
FAIL: ld-mips-elf/attr-gnu-4-1-n32-ph
FAIL: ld-mips-elf/attr-gnu-4-2-n32-ph
FAIL: ld-mips-elf/attr-gnu-4-3-n32-ph
FAIL: MIPSr6 JALR reloc unaligned/cross-mode link test (n32)

which are mostly due to dump discrepancies caused by mapping differences
coming from the default linker scripts used by these test cases, or
sometimes because of the specific MIPS processor architecture recorded
in the ELF file taking precedence over the general MIPS ISA level also
recorded.  Finally, the R_MIPS16_HI16/R_MIPS16_LO16 relocation test
failure is a preexisting issue with the IRIX style emulation.

These failures will have to be addressed separately.

ld/
* testsuite/ld-mips-elf/mips-elf.exp (run_dump_test_abi)
(run_dump_test_o32, run_dump_test_n32, run_dump_test_n64)
(run_dump_test_eabi): New procedures.
(has_newabi, has_elf32): Remove variables.
(has_abi): New associative array variable.
(abi_asflags, abi_ldflags): Update settings across targets.
(irixemul): New variable.
Replace `run_dump_test' calls where applicable throughout with
`run_dump_test_o32', `run_dump_test_n32', `run_dump_test_n64'
and `run_dump_test_eabi' as appropriate.  Remove explicit
passing of `abi_asflags' and `abi_ldflags'.  Use `noarch' for
tests that require their own architecture setting.  Force the
big endianness for tests that require it.  Select the endianness
required for `objdump invocation with the `reloc-2' test.
Conditionalize tests run via `run_ld_link_tests' on the ABI
required and use the ABI list from the `has_abi' array where
appropriate.
* testsuite/ld-mips-elf/attr-gnu-4-0-n32-ph.d: Remove ABI and
endianness selection options from `ld' and `source' tags.  Relax
output format matching.
* testsuite/ld-mips-elf/attr-gnu-4-0-n64-ph.d: Likewise.
* testsuite/ld-mips-elf/attr-gnu-4-1-n32-ph.d: Likewise.
* testsuite/ld-mips-elf/attr-gnu-4-1-n64-ph.d: Likewise.
* testsuite/ld-mips-elf/attr-gnu-4-2-n32-ph.d: Likewise.
* testsuite/ld-mips-elf/attr-gnu-4-2-n64-ph.d: Likewise.
* testsuite/ld-mips-elf/attr-gnu-4-3-n32-ph.d: Likewise.
* testsuite/ld-mips-elf/attr-gnu-4-3-n64-ph.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-addend-micromips-n32.d: Remove
ABI and endianness selection options from `as', `ld', `source'
tags, and also the `-march=from-abi' option.  Remove the `as'
tag where it would become empty.
* testsuite/ld-mips-elf/bal-jalx-addend-micromips-n64.d:
Likewise.
* testsuite/ld-mips-elf/bal-jalx-addend-micromips.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-addend-n32.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-addend-n64.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-addend.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-local-micromips-n32.d:
Likewise.
* testsuite/ld-mips-elf/bal-jalx-local-micromips-n64.d:
Likewise.
* testsuite/ld-mips-elf/bal-jalx-local-micromips.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-local-n32.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-local-n64.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-local.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n32.d:
Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n64.d:
Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips.d:
Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-n32.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-n64.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-micromips-n32.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-micromips-n64.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-micromips.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-n32.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-n64.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic.d: Likewise.
* testsuite/ld-mips-elf/branch-absolute-addend-n32.d: Likewise.
* testsuite/ld-mips-elf/branch-absolute-addend-n64.d: Likewise.
* testsuite/ld-mips-elf/branch-absolute-addend.d: Likewise.
* testsuite/ld-mips-elf/branch-absolute-n32.d: Likewise.
* testsuite/ld-mips-elf/branch-absolute-n64.d: Likewise.
* testsuite/ld-mips-elf/branch-absolute.d: Likewise.
* testsuite/ld-mips-elf/dyn-sec64.d: Likewise.
* testsuite/ld-mips-elf/eh-frame1-n32.d: Likewise.
* testsuite/ld-mips-elf/eh-frame1-n64.d: Likewise.
* testsuite/ld-mips-elf/eh-frame2-n32.d: Likewise.
* testsuite/ld-mips-elf/eh-frame2-n64.d: Likewise.
* testsuite/ld-mips-elf/elf-rel-got-n32-embed.d: Likewise.
* testsuite/ld-mips-elf/elf-rel-got-n32.d: Likewise.
* testsuite/ld-mips-elf/elf-rel-got-n64-embed.d: Likewise.
* testsuite/ld-mips-elf/elf-rel-got-n64-irix.d: Likewise.
* testsuite/ld-mips-elf/elf-rel-got-n64.d: Likewise.
* testsuite/ld-mips-elf/elf-rel-xgot-n32-embed.d: Likewise.
* testsuite/ld-mips-elf/elf-rel-xgot-n32.d: Likewise.
* testsuite/ld-mips-elf/elf-rel-xgot-n64-embed.d: Likewise.
* testsuite/ld-mips-elf/elf-rel-xgot-n64-irix.d: Likewise.
* testsuite/ld-mips-elf/elf-rel-xgot-n64.d: Likewise.
* testsuite/ld-mips-elf/emit-relocs-1.d: Likewise.
* testsuite/ld-mips-elf/got-dump-2.d: Likewise.
* testsuite/ld-mips-elf/got-page-2.d: Likewise.
* testsuite/ld-mips-elf/jal-global-overflow-0.d: Likewise.
* testsuite/ld-mips-elf/jal-global-overflow-1.d: Likewise.
* testsuite/ld-mips-elf/jal-local-overflow-0.d: Likewise.
* testsuite/ld-mips-elf/jal-local-overflow-1.d: Likewise.
* testsuite/ld-mips-elf/jalbal.d: Likewise.
* testsuite/ld-mips-elf/jalx-addend-n32.d: Likewise.
* testsuite/ld-mips-elf/jalx-addend-n64.d: Likewise.
* testsuite/ld-mips-elf/jalx-addend.d: Likewise.
* testsuite/ld-mips-elf/jalx-local-n32.d: Likewise.
* testsuite/ld-mips-elf/jalx-local-n64.d: Likewise.
* testsuite/ld-mips-elf/jalx-local.d: Likewise.
* testsuite/ld-mips-elf/jr-to-b-1.d: Likewise.
* testsuite/ld-mips-elf/jr-to-b-2.d: Likewise.
* testsuite/ld-mips-elf/lsi-4010-isa.d: Likewise.
* testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d:
Likewise.
* testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d:
Likewise.
* testsuite/ld-mips-elf/micromips-branch-absolute-addend.d:
Likewise.
* testsuite/ld-mips-elf/micromips-branch-absolute-n32.d:
Likewise.
* testsuite/ld-mips-elf/micromips-branch-absolute-n64.d:
Likewise.
* testsuite/ld-mips-elf/micromips-branch-absolute.d: Likewise.
* testsuite/ld-mips-elf/mips16-branch-2.d: Likewise.
* testsuite/ld-mips-elf/mips16-branch-3.d: Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-1.d: Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-2.d: Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend-1.d:
Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n32-1.d:
Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n32.d:
Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n64-1.d:
Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n64.d:
Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend.d:
Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-n32-1.d:
Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-n32-2.d:
Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-n32.d: Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-n64-1.d:
Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-n64-2.d:
Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute-n64.d: Likewise.
* testsuite/ld-mips-elf/mips16-branch-absolute.d: Likewise.
* testsuite/ld-mips-elf/mips16-branch-addend-2.d: Likewise.
* testsuite/ld-mips-elf/mips16-branch-addend-3.d: Likewise.
* testsuite/ld-mips-elf/mips16-hilo-n32.d: Likewise.
* testsuite/ld-mips-elf/mips16-pcrel-0.d: Likewise.
* testsuite/ld-mips-elf/mips16-pcrel-1.d: Likewise.
* testsuite/ld-mips-elf/mips16-pcrel-addend-2.d: Likewise.
* testsuite/ld-mips-elf/mips16-pcrel-addend-6.d: Likewise.
* testsuite/ld-mips-elf/mips16-pcrel-n32-0.d: Likewise.
* testsuite/ld-mips-elf/mips16-pcrel-n32-1.d: Likewise.
* testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-0.d: Likewise.
* testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-1.d: Likewise.
* testsuite/ld-mips-elf/mips16e2-pcrel-0.d: Likewise.
* testsuite/ld-mips-elf/mips16e2-pcrel-1.d: Likewise.
* testsuite/ld-mips-elf/mips16e2-pcrel-addend-2.d: Likewise.
* testsuite/ld-mips-elf/mips16e2-pcrel-addend-6.d: Likewise.
* testsuite/ld-mips-elf/mips16e2-pcrel-n32-0.d: Likewise.
* testsuite/ld-mips-elf/mips16e2-pcrel-n32-1.d: Likewise.
* testsuite/ld-mips-elf/mips16e2-pcrel-n64-sym32-0.d: Likewise.
* testsuite/ld-mips-elf/mips16e2-pcrel-n64-sym32-1.d: Likewise.
* testsuite/ld-mips-elf/multi-got-1.d: Likewise.
* testsuite/ld-mips-elf/multi-got-hidden-1.d: Likewise.
* testsuite/ld-mips-elf/multi-got-hidden-2.d: Likewise.
* testsuite/ld-mips-elf/multi-got-no-shared.d: Likewise.
* testsuite/ld-mips-elf/no-shared-1-n32.d: Likewise.
* testsuite/ld-mips-elf/no-shared-1-n64.d: Likewise.
* testsuite/ld-mips-elf/no-shared-1-o32.d: Likewise.
* testsuite/ld-mips-elf/pic-and-nonpic-2.d: Likewise.
* testsuite/ld-mips-elf/pic-and-nonpic-3-error.d: Likewise.
* testsuite/ld-mips-elf/pic-and-nonpic-4-error.d: Likewise.
* testsuite/ld-mips-elf/pie-n32.d: Likewise.
* testsuite/ld-mips-elf/pie-n64.d: Likewise.
* testsuite/ld-mips-elf/pie-o32.d: Likewise.
* testsuite/ld-mips-elf/rel32-n32.d: Likewise.
* testsuite/ld-mips-elf/rel32-o32.d: Likewise.
* testsuite/ld-mips-elf/rel64.d: Likewise.
* testsuite/ld-mips-elf/relax-jalr-n32.d: Likewise.
* testsuite/ld-mips-elf/reloc-1-n32.d: Likewise.
* testsuite/ld-mips-elf/reloc-1-n64.d: Likewise.
* testsuite/ld-mips-elf/reloc-2.d: Likewise.
* testsuite/ld-mips-elf/reloc-3-n32.d: Likewise.
* testsuite/ld-mips-elf/reloc-local-overflow.d: Likewise.
* testsuite/ld-mips-elf/textrel-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-2.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-ignore-2.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-ignore-micromips.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-branch-ignore-mips16.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-branch-ignore-r6-1.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-branch-micromips.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-mips16.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-r6-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-r6-2.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-0.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-2.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-3.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-0.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-1.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-0.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-1.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-jump-micromips.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jump-mips16.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jump.d: Likewise.
* testsuite/ld-mips-elf/unaligned-ldpc-0.d: Likewise.
* testsuite/ld-mips-elf/unaligned-ldpc-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-lwpc-0.d: Likewise.
* testsuite/ld-mips-elf/unaligned-lwpc-1.d: Likewise.

6 years agoMIPS/LD/testsuite: Limit reloc 6 tests to DSO targets
Maciej W. Rozycki [Thu, 12 Jul 2018 19:01:44 +0000 (20:01 +0100)]
MIPS/LD/testsuite: Limit reloc 6 tests to DSO targets

Complement commit 500c05ddbe98 ("MIPS/ld/testsuite: Limit export class
call reloc tests to DSO targets") and also check for target's shared
library support in determining whether to run reloc 6 tests, which
require it.  No changes in results as all targets currently enabled for
NewABI testing support shared libraries.

ld/
* testsuite/ld-mips-elf/mips-elf.exp: Limit reloc 6 tests to
shared library targets.

6 years agoDeclare 'ioarg' (from ser-tcp.c:try_connect) as 'u_long' when on Windows (and unbreak...
Sergio Durigan Junior [Thu, 12 Jul 2018 17:03:31 +0000 (13:03 -0400)]
Declare 'ioarg' (from ser-tcp.c:try_connect) as 'u_long' when on Windows (and unbreak build on mingw32)

When building GDB on mingw32, it fails with:

  ../../binutils-gdb/gdb/ser-tcp.c: In function 'int try_connect(const addrinfo*, unsigned int*)':
  ../../binutils-gdb/gdb/ser-tcp.c:176:25: error: invalid conversion from 'int*' to 'u_long* {aka long unsigned int*}' [-fpermissive]
     ioctl (sock, FIONBIO, &ioarg);
   ^~~~~~
  In file included from ../../binutils-gdb/gdb/serial.h:23:0,
   from ../../binutils-gdb/gdb/ser-tcp.c:21:
  /usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:977:34: note:   initializing argument 3 of 'int ioctlsocket(SOCKET, long int, u_long*)'
     WINSOCK_API_LINKAGE int WSAAPI ioctlsocket(SOCKET s,__LONG32 cmd,u_long *argp);
    ^~~~~~~~~~~
  make[2]: *** [Makefile:1610: ser-tcp.o] Error 1

The problem happens because the IPv6
commit (c7ab0aef11d91b637bf091aa9176b8dc4aadee46) wrongly removed the
code responsible for declaring 'ioarg' with a different type if
building for Windows.  This patch restores that.

gdb/ChangeLog:
2018-07-12  Sergio Durigan Junior  <sergiodj@redhat.com>

* ser-tcp.c (try_connect): Declare 'ioarg' as 'u_long' if building
on Windows.

6 years agoThis patch adds support for the SSBB and PSSBB speculation barrier instructions to...
Nick Clifton [Thu, 12 Jul 2018 14:46:17 +0000 (15:46 +0100)]
This patch adds support for the SSBB and PSSBB speculation barrier instructions to the AArch64 assembler and disassembler.

For more details see: https://static.docs.arm.com/ddi0596/a/DDI_0596_ARM_a64_instruction_set_architecture.pdf

opcodes * aarch64-tbl.h (aarch64_opcode_table): Add entry for
ssbb and pssbb and update dsb flags to F_HAS_ALIAS.
* aarch64-asm-2.c: Regenerate.
* aarch64-dis-2.c: Regenerate.
* aarch64-opc-2.c: Regenerate.

gas * testsuite/gas/aarch64/system.s: Add test for ssbb
and pssbb.
* testsuite/gas/aarch64/system.d: Update accordingly
and remove explicit addresses.

6 years agoAdd remainder of Em16 restrictions for AArch64 gas.
Tamar Christina [Thu, 12 Jul 2018 09:28:46 +0000 (10:28 +0100)]
Add remainder of Em16 restrictions for AArch64 gas.

This adds the missing Em16 constraints the rest of the instructions requiring them
and also adds a testcase to test all the instructions so these are checked from
now on.

The Em16 operand constrains the valid registers to the lower 16 registers when used
with a half precision qualifier.

The list has been cross checked (by hand) through the Arm ARM version Ca.

opcodes/

PR binutils/23192
* aarch64-tbl.h (sqdmlal, sqdmlal2, smlsl, smlsl2, sqdmlsl, sqdmlsl2,
mul, smull, smull2, sqdmull, sqdmull2, sqdmulh, sqrdmulh, mla, umlal,
umlal2, mls, umlsl, umlsl2, umull, umull2, sqdmlal, sqdmlsl, sqdmull,
sqdmulh, sqrdmulh): Use Em16.

gas/

PR binutils/23192
* testsuite/gas/aarch64/illegal-by-element.s: New.
* testsuite/gas/aarch64/illegal-by-element.d: New.
* testsuite/gas/aarch64/illegal-by-element.l: New.

6 years agoreadelf: Don't print section type twice for --section-details
Francois H. Theron [Wed, 11 Jul 2018 16:14:16 +0000 (18:14 +0200)]
readelf: Don't print section type twice for --section-details

* readelf.c (process_section_headers): Don't print section type
twice for --section-details.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 12 Jul 2018 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoImplement IPv6 support for GDB/gdbserver
Sergio Durigan Junior [Fri, 18 May 2018 05:29:24 +0000 (01:29 -0400)]
Implement IPv6 support for GDB/gdbserver

This patch implements IPv6 support for both GDB and gdbserver.  Based
on my research, it is the fourth attempt to do that since 2006.  Since
I used ideas from all of the previous patches, I also added their
authors's names on the ChangeLogs as a way to recognize their
efforts.  For reference sake, you can find the previous attempts at:

  https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html

  https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html

  https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html

The basic idea behind the patch is to start using the new
'getaddrinfo'/'getnameinfo' calls, which are responsible for
translating names and addresses in a protocol-independent way.  This
means that if we ever have a new version of the IP protocol, we won't
need to change the code again (or, at least, won't have to change the
majority of the code).

The function 'getaddrinfo' returns a linked list of possible addresses
to connect to.  Dealing with multiple addresses proved to be a hard
task with the current TCP auto-retry mechanism implemented on
ser-tcp:net_open.  For example, when gdbserver listened only on an
IPv4 socket:

  $ ./gdbserver --once 127.0.0.1:1234 ./a.out

and GDB was instructed to try to connect to both IPv6 and IPv4
sockets:

  $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out

the user would notice a somewhat big delay before GDB was able to
connect to the IPv4 socket.  This happened because GDB was trying to
connect to the IPv6 socket first, and had to wait until the connection
timed out before it tried to connect to the IPv4 socket.

For that reason, I had to rewrite the main loop and implement a new
method for handling multiple connections.  After some discussion,
Pedro and I agreed on the following algorithm:

  1) For each entry returned by 'getaddrinfo', we try to open a socket
  and connect to it.

  2.a) If we have a successful 'connect', we just use that connection.

  2.b) If we don't have a successfull 'connect', but if we've got a
  ECONNREFUSED (meaning the the connection was refused), we keep track
  of this fact by using a flag.

  2.c) If we don't have a successfull 'connect', but if we've got a
  EINPROGRESS (meaning that the connection is in progress), we perform
  a 'select' call on the socket until we have a result (either a
  successful connection, or an error on the socket).

  3) If tcp_auto_retry is true, and we haven't gotten a successful
  connection, and at least one of our attempts failed with
  ECONNREFUSED, then we wait a little bit (i.e., call
  'wait_for_connect'), check to see if there was a
  timeout/interruption (in which case we bail out), and then go back
  to (1).

After multiple tests, I was able to connect without delay on the
scenario described above, and was also able to connect in all other
types of scenarios.

I also implemented some hostname parsing functions (along with their
corresponding unit tests) which are used to help GDB and gdbserver to
parse hostname strings provided by the user.  These new functions are
living inside common/netstuff.[ch].  I've had to do that since IPv6
introduces a new URL scheme, which defines that square brackets can be
used to enclose the host part and differentiate it from the
port (e.g., "[::1]:1234" means "host ::1, port 1234").  I spent some
time thinking about a reasonable way to interpret what the user wants,
and I came up with the following:

  - If the user has provided a prefix that doesn't specify the protocol
    version (i.e., "tcp:" or "udp:"), or if the user has not provided
    any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when
    dealing with 'getaddrinfo') *unless* the host starts with "[" (in
    which case, assume it's an IPv6 host).

  - If the user has provided a prefix that does specify the protocol
    version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect
    that.

This method doesn't follow strictly what RFC 2732 proposes (that
literal IPv6 addresses should be provided enclosed in "[" and "]")
because IPv6 addresses still can be provided without square brackets
in our case, but since we have prefixes to specify protocol versions I
think this is not an issue.

Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST'
testcase parameter, which makes it possible to specify the
hostname (without the port) to be used when testing GDB and
gdbserver.  For example, to run IPv6 tests:

  $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]'

Or, to run IPv4 tests:

  $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1'

This required a few changes on the gdbserver-base.exp, and also a
minimal adjustment on gdb.server/run-without-local-binary.exp.

Finally, I've implemented a new testcase,
gdb.server/server-connect.exp, which is supposed to run on the native
host and perform various "smoke tests" using different connection
methods.

This patch has been regression-tested on BuildBot and locally, and
also built using a x86_64-w64-mingw32 GCC, and no problems were found.

gdb/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>
    Paul Fertser  <fercerpav@gmail.com>
    Tsutomu Seki  <sekiriki@gmail.com>
    Pedro Alves  <palves@redhat.com>

* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
'unittests/parse-connection-spec-selftests.c'.
(COMMON_SFILES): Add 'common/netstuff.c'.
(HFILES_NO_SRCDIR): Add 'common/netstuff.h'.
* NEWS (Changes since GDB 8.2): Mention IPv6 support.
* common/netstuff.c: New file.
* common/netstuff.h: New file.
* ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'.
(wait_for_connect): Update comment.  New parameter
'gdb::optional<int> sock' instead of 'struct serial *scb'.
Use 'sock' directly instead of 'scb->fd'.
(try_connect): New function, with code from 'net_open'.
(net_open): Rewrite main loop to deal with multiple
sockets/addresses.  Handle IPv6-style hostnames; implement
support for IPv6 connections.
* unittests/parse-connection-spec-selftests.c: New file.

gdb/gdbserver/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>
    Paul Fertser  <fercerpav@gmail.com>
    Tsutomu Seki  <sekiriki@gmail.com>

* Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'.
(OBS): Add 'common/netstuff.o'.
(GDBREPLAY_OBS): Likewise.
* gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'.
(remote_open): Implement support for IPv6
connections.
* remote-utils.c: Include 'netstuff.h', 'filestuff.h'
and 'wspiapi.h'.
(handle_accept_event): Accept connections from IPv6 sources.
(remote_prepare): Handle IPv6-style hostnames; implement
support for IPv6 connections.
(remote_open): Implement support for printing connections from
IPv6 sources.

gdb/testsuite/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>
    Paul Fertser  <fercerpav@gmail.com>
    Tsutomu Seki  <sekiriki@gmail.com>

* README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST'
parameter.
* boards/native-extended-gdbserver.exp: Do not set 'sockethost'
by default.
* boards/native-gdbserver.exp: Likewise.
* gdb.server/run-without-local-binary.exp: Improve regexp used
for detecting when a remote debugging connection succeeds.
* gdb.server/server-connect.exp: New file.
* lib/gdbserver-support.exp (gdbserver_default_get_comm_port):
Do not prefix the port number with ":".
(gdbserver_start): New global GDB_TEST_SOCKETHOST.  Implement
support for detecting and using it.  Add '$debughost_gdbserver'
to the list of arguments used to start gdbserver.  Handle case
when gdbserver cannot resolve a network name.

gdb/doc/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>
    Paul Fertser  <fercerpav@gmail.com>
    Tsutomu Seki  <sekiriki@gmail.com>

* gdb.texinfo (Remote Connection Commands): Add explanation
about new IPv6 support.  Add new connection prefixes.

6 years agoGDB: Work around D;PID handling bug in older GDBservers (PR gdb/23377)
Pedro Alves [Wed, 11 Jul 2018 22:31:44 +0000 (23:31 +0100)]
GDB: Work around D;PID handling bug in older GDBservers (PR gdb/23377)

This commit adds a GDB workaround for the GDBserver bug exposed by
commit f2ffa92bbce9 ("gdb: Eliminate the 'stop_pc' global"), so that
newer GDBs can continue working with older GDBservers.

gdb/ChangeLog:
2018-07-11  Pedro Alves  <palves@redhat.com>

PR gdb/23377
* remote.c (remote_target::remote_detach_pid): Call
set_current_process.

6 years agoGDBserver: Don't assume a current process in D;PID implementation (PR gdb/23377)
Pedro Alves [Wed, 11 Jul 2018 22:31:44 +0000 (23:31 +0100)]
GDBserver: Don't assume a current process in D;PID implementation (PR gdb/23377)

This fixes a gdb.base/multi-forks.exp regression with GDBserver.

Git commit f2ffa92bbce9 ("gdb: Eliminate the 'stop_pc' global") caused
the regression by exposing a latent bug in gdbserver.

The bug is that GDBserver's implementation of the D;PID packet
incorrectly assumes that the selected thread points to the process
being detached.  This happens via the any_persistent_commands call,
which calls current_process:

  (gdb) bt
  #0  0x000000000040a57e in internal_error(char const*, int, char const*, ...)
  (file=0x4a53c0 "src/gdb/gdbserver/inferiors.c", line=212, fmt=0x4a539e "%s:
  Assertion `%s' failed.") at src/gdb/gdbserver/../common/errors.c:54
  #1  0x0000000000420acf in current_process() () at
  src/gdb/gdbserver/inferiors.c:212
  #2  0x00000000004226a0 in any_persistent_commands() () at
  gdb/gdbserver/mem-break.c:308
  #3  0x000000000042cb43 in handle_detach(char*) (own_buf=0x6f0280 "D;62ea") at
  src/gdb/gdbserver/server.c:1210
  #4  0x0000000000433af3 in process_serial_event() () at
  src/gdb/gdbserver/server.c:4055
  #5  0x0000000000434878 in handle_serial_event(int, void*) (err=0,
  client_data=0x0)

The "eliminate stop_pc" commit exposes the problem because before that
commit, GDB's switch_to_thread always read the newly-selected thread's
PC, and that would end up forcing GDBserver's selected thread to
change accordingly as side effect.  After that commit, GDB no longer
reads the thread's PC, and GDBserver does not switch the thread.

Fix this by removing the assumption from GDBserver.

gdb/gdbserver/ChangeLog:
2018-07-11  Pedro Alves  <palves@redhat.com>

PR gdb/23377
* mem-break.c (any_persistent_commands): Add process_info
parameter and use it instead of relying on the current process.
Change return type to bool.
* mem-break.h (any_persistent_commands): Add process_info
parameter and change return type to bool.
* server.c (handle_detach): Remove require_running_or_return call.
Look up the process_info for the process we're about to detach.
If not found, return back error to GDB.  Adjust
any_persistent_commands call to pass down a process pointer.

6 years agogdb: Remove traces of h8300 ecoff support
Pedro Alves [Wed, 11 Jul 2018 19:39:12 +0000 (20:39 +0100)]
gdb: Remove traces of h8300 ecoff support

There's this little bit of ecoff support in the h8300 port that I ran
into that I think we could remove.  Grepping around BFD, I don't think
ECOFF is supported for h8300.

And if not, I'm failing to see why we'd support ECOFF debug info in
ELF for h8300 (.mdebug).  It kind of seems like someone just installed
the set_gdbarch_ecoff_reg_to_regnum hook at the same time the dwarf2
and stabs hooks were installed.

I'm removing this so that greps for ecoff stuff only lead to MIPS, as
ISTR that Linux/MIPS support still relies on some subset of ECOFF for
something.

gdb/ChangeLog:
2018-07-11  Pedro Alves  <palves@redhat.com>

* h8300-tdep.c (h8300_gdbarch_init): Remove
set_gdbarch_ecoff_reg_to_regnum calls.

6 years agoFix PR c++/23373: GDB hangs when printing a struct with a static member of itself
Sergio Durigan Junior [Sat, 7 Jul 2018 21:16:55 +0000 (17:16 -0400)]
Fix PR c++/23373: GDB hangs when printing a struct with a static member of itself

This patch fixes a failure that happens when a structure has a static
member whose type is the same as itself.  From the bug report:

  Example code:
  struct A
  {
      static A Empty;
      int a;
  };

  int main(void) {
      A a;
      return 0;
  }

  Output:
  (gdb) ptype/o A
  /* offset    |  size */  type = struct A {
     static struct A {
 static struct A {
     static struct A {
 static struct A {
     static struct A {
 static struct A {
     ... # infinite loop

The problem here is that GDB is not taking into account the fact that
static members inside a class/struct are not stored in the
class/struct, and therefore they should not be accounted for during
the display of the offsets/sizes.  The fix is simple: we just check if
the field we're dealing with (on
c-typeprint.c:c_type_print_base_struct_union) is static, and if it is
then we don't iterate over it.

This patch also adds a new test for this case, and doesn't introduce
any regressions.  I believe it is important enough to be included in
the 8.2 branch.

OK?

gdb/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>

PR c++/23373
* c-typeprint.c (c_type_print_base_struct_union): Don't print
offsets/sizes for static members of a class/struct.

gdb/testsuite/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>

PR c++/23373
* gdb.base/ptype-offsets.cc (struct static_member): New
struct.
(main) <stmember>: New variable.
* gdb.base/ptype-offsets.exp: Add test for printing a struct
with a static member in it.

6 years agoGDBserver: Fix "Cond. jump or move depends on uninit value" in x87 code
Pedro Alves [Wed, 11 Jul 2018 18:49:19 +0000 (19:49 +0100)]
GDBserver: Fix "Cond. jump or move depends on uninit value" in x87 code

Running gdbserver under Valgrind I get:

  ==26925== Conditional jump or move depends on uninitialised value(s)
  ==26925==    at 0x473E7F: i387_cache_to_xsave(regcache*, void*) (i387-fp.c:579)
  ==26925==    by 0x46E3ED: x86_fill_xstateregset(regcache*, void*) (linux-x86-low.c:418)
  ==26925==    by 0x45E747: regsets_store_inferior_registers(regsets_info*, regcache*) (linux-low.c:5456)
  ==26925==    by 0x45EEF8: linux_store_registers(regcache*, int) (linux-low.c:5731)
  ==26925==    by 0x426441: regcache_invalidate_thread(thread_info*) (regcache.c:89)
  ==26925==    by 0x45CCAF: linux_resume_one_lwp_throw(lwp_info*, int, int, siginfo_t*) (linux-low.c:4447)
  ==26925==    by 0x45CE2A: linux_resume_one_lwp(lwp_info*, int, int, siginfo_t*) (linux-low.c:4519)
  ==26925==    by 0x45E17C: proceed_one_lwp(thread_info*, lwp_info*) (linux-low.c:5216)
  ==26925==    by 0x45DC81: linux_resume_one_thread(thread_info*, bool) (linux-low.c:5031)
  ==26925==    by 0x45DD34: linux_resume(thread_resume*, unsigned long)::{lambda(thread_info*)#2}::operator()(thread_info*) const (linux-low.c:5095)
  ==26925==    by 0x462907: void for_each_thread<linux_resume(thread_resume*, unsigned long)::{lambda(thread_info*)#2}>(linux_resume(thread_resume*, unsigned long)::{lambda(thread_info*)#2}) (gdbthread.h:150)
  ==26925==    by 0x45DE62: linux_resume(thread_resume*, unsigned long) (linux-low.c:5093)
  ==26925==
  ==26925== Conditional jump or move depends on uninitialised value(s)
  ==26925==    at 0x473EBD: i387_cache_to_xsave(regcache*, void*) (i387-fp.c:586)
  ==26925==    by 0x46E3ED: x86_fill_xstateregset(regcache*, void*) (linux-x86-low.c:418)
  ==26925==    by 0x45E747: regsets_store_inferior_registers(regsets_info*, regcache*) (linux-low.c:5456)
  ==26925==    by 0x45EEF8: linux_store_registers(regcache*, int) (linux-low.c:5731)
  ==26925==    by 0x426441: regcache_invalidate_thread(thread_info*) (regcache.c:89)
  ==26925==    by 0x45CCAF: linux_resume_one_lwp_throw(lwp_info*, int, int, siginfo_t*) (linux-low.c:4447)
  ==26925==    by 0x45CE2A: linux_resume_one_lwp(lwp_info*, int, int, siginfo_t*) (linux-low.c:4519)
  ==26925==    by 0x45E17C: proceed_one_lwp(thread_info*, lwp_info*) (linux-low.c:5216)
  ==26925==    by 0x45DC81: linux_resume_one_thread(thread_info*, bool) (linux-low.c:5031)
  ==26925==    by 0x45DD34: linux_resume(thread_resume*, unsigned long)::{lambda(thread_info*)#2}::operator()(thread_info*) const (linux-low.c:5095)
  ==26925==    by 0x462907: void for_each_thread<linux_resume(thread_resume*, unsigned long)::{lambda(thread_info*)#2}>(linux_resume(thread_resume*, unsigned long)::{lambda(thread_info*)#2}) (gdbthread.h:150)
  ==26925==    by 0x45DE62: linux_resume(thread_resume*, unsigned long) (linux-low.c:5093)

The problem is a type/width mismatch in code like this, in
gdbserver/i387-fp.c:

  /* Some registers are 16-bit.  */
  collect_register_by_name (regcache, "fctrl", &val);
  fp->fctrl = val;

In the above code:

 #1 - 'val' is a 64-bit unsigned long.

 #2 - "fctrl" is 32-bit in the register cache, thus half of 'val' is
      left uninitialized by collect_register_by_name, which works with
      an untyped raw buffer output (i.e., void*).

 #3 - fp->fctrl is an unsigned short (16-bit).  For some such
      registers we're masking off the uninitialized bits with 0xffff,
      but not in all cases.

We end up in such a fragile situation because
collect_registers_by_name works with an untyped output buffer pointer,
making it easy to pass a pointer to a variable of the wrong size.

Fix this by using regcache_raw_get_unsigned instead (actually a new
regcache_raw_get_unsigned_by_name wrapper), which always returns a
zero-extended ULONGEST register value.  It ends up simplifying the
i387-tdep.c code a bit, even.

gdb/gdbserver/ChangeLog:
2018-07-11  Pedro Alves  <palves@redhat.com>

* i387-fp.c (i387_cache_to_fsave, cache_to_fxsave)
(i387_cache_to_xsave): Use regcache_raw_get_unsigned_by_name
instead of collect_register_by_name.
* regcache.c (regcache_raw_get_unsigned_by_name): New.
* regcache.h (regcache_raw_get_unsigned_by_name): New.

6 years agoAdds the speculation barrier instructions to the ARM assembler and disassembler.
Sudakshina Das [Wed, 11 Jul 2018 17:05:34 +0000 (18:05 +0100)]
Adds the speculation barrier instructions to the ARM assembler and disassembler.

See:
https://developer.arm.com/support/arm-security-updates/speculative-processor-vulnerability/download-the-whitepaper

opcodes * arm-dis.c (arm_opcodes): Add ssbb and pssbb and move
csdb together with them.
(thumb32_opcodes): Likewise.

gas * config/tc-arm.c (insns): Add new ssbb and pssbb instructions.
* testsuite/gas/arm/csdb.s: Add new tests for ssbb and pssbb.
* testsuite/gas/arm/csdb.d: Likewise
* testsuite/gas/arm/thumb2_it_bad.s: Likewise.
* testsuite/gas/arm/thumb2_it_bad.l: Likewise.
* testsuite/gas/arm/barrier.d: Update with ssbb.
* testsuite/gas/arm/barrier-thumb.d: Likewise.

6 years agoMIPS/BFD: Fix TLS relocation resolution for regular executables
Maciej W. Rozycki [Wed, 11 Jul 2018 16:44:45 +0000 (17:44 +0100)]
MIPS/BFD: Fix TLS relocation resolution for regular executables

Correct an issue with commit 0f20cc3522e7 ("TLS support for MIPS"),
<https://sourceware.org/ml/binutils/2005-02/msg00607.html>, where a
condition used to determine whether to use a dynamic symbol for GD, LD
and IE TLS dynamic relocations against a symbol that has been defined
locally has been incorrectly reversed.

It's executables rather than dynamic shared objects where no symbol is
required, because such symbols cannot be preempted and therefore their
values (thread pointer offsets) are fixed at the static link time as is
the associated module ID of the main executable, so the original
condition should have been `shared' instead of `!shared'.  This wrong
condition was then later converted from `!shared' to `!bfd_link_pic',
with commit 0e1862bb401f ("Add output_type to bfd_link_info").

Use the correct `bfd_link_dll' condition then, and adjust code for the
dynamic symbol index possibly being -1 as with symbols that have been
forced local, removing unnecessary dynamic relocations from dynamic
regular executables.  PIE executables are unaffected as the existing
condition excluded them by chance due to the conversion mentioned above.

Adjust test cases accordingly.

bfd/
* elfxx-mips.c (mips_tls_got_relocs): Use `bfd_link_dll' rather
than `!bfd_link_pic' in determining the dynamic symbol index.
Avoid the index of -1.
(mips_elf_initialize_tls_slots): Likewise.  Flatten code by
moving `dyn' to the beginning of the function block.

ld/
* testsuite/ld-mips-elf/tlsdyn-o32.d: Update test for dynamic
relocation removal.
* testsuite/ld-mips-elf/tlsdyn-o32.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-1.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-1.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-2.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-2.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-3.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-3.got: Likewise.

6 years agoPR ld/22570: MIPS/BFD: Fix TLS relocation resolution for PIE executables
Maciej W. Rozycki [Wed, 11 Jul 2018 16:44:45 +0000 (17:44 +0100)]
PR ld/22570: MIPS/BFD: Fix TLS relocation resolution for PIE executables

Correct a commit 0e1862bb401f ("Add output_type to bfd_link_info") issue
and use `bfd_link_dll' rather than `bfd_link_pic' in determining whether
to fully resolve GD, LD and IE TLS relocations referring to symbols
locally defined rather than deferring them to the load time by means of
dynamic relocations.

Such symbols cannot be preempted in PIE executables, which are
necessarily PIC, and therefore their values (thread pointer offsets) are
fixed at the static link time as is the associated module ID of the main
executable.

Given the `tlsbin-o32.s' and `tlsdyn-o32.s' sources from our test suite
this removes the absolute TLS relocations from the static:

DYNAMIC RELOCATION RECORDS
OFFSET   TYPE              VALUE
00000000 R_MIPS_NONE       *ABS*
1000002c R_MIPS_TLS_TPREL32  *ABS*
10000030 R_MIPS_TLS_DTPMOD32  *ABS*
10000038 R_MIPS_TLS_DTPMOD32  *ABS*

and the dynamic:

DYNAMIC RELOCATION RECORDS
OFFSET   TYPE              VALUE
00000000 R_MIPS_NONE       *ABS*
1000002c R_MIPS_TLS_TPREL32  *ABS*
10000038 R_MIPS_TLS_DTPMOD32  *ABS*
10000044 R_MIPS_TLS_DTPMOD32  *ABS*
10000030 R_MIPS_TLS_DTPMOD32  tlsvar_gd
10000034 R_MIPS_TLS_DTPREL32  tlsvar_gd
10000040 R_MIPS_TLS_TPREL32  tlsvar_ie

PIE executable respectively, as reported by `objdump -R', and fills the
corresponding GOT slots with the values expected, as recorded with the
test cases added.  The new output from `objdump -R' is:

DYNAMIC RELOCATION RECORDS (none)

and:

DYNAMIC RELOCATION RECORDS
OFFSET   TYPE              VALUE
00000000 R_MIPS_NONE       *ABS*
10000030 R_MIPS_TLS_DTPMOD32  tlsvar_gd
10000034 R_MIPS_TLS_DTPREL32  tlsvar_gd
10000040 R_MIPS_TLS_TPREL32  tlsvar_ie

for the static and the dynamic executable respectively.

2018-07-11  Maciej W. Rozycki  <macro@mips.com>
            Rich Felker  <bugdal@aerifal.cx>

bfd/
PR ld/22570
* elfxx-mips.c (mips_tls_got_relocs): Use `bfd_link_dll' rather
than `bfd_link_pic' to determine whether dynamic relocations are
to be produced.
(mips_elf_initialize_tls_slots): Likewise.

ld/
PR ld/22570
* testsuite/ld-mips-elf/tlsbin-pie-o32.d: New test.
* testsuite/ld-mips-elf/tlsbin-pie-o32.got: New test.
* testsuite/ld-mips-elf/tlsdyn-pie-o32.d: New test.
* testsuite/ld-mips-elf/tlsdyn-pie-o32.got: New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.

6 years agoFix printing the size of GOLD's memory areana on Cygwin based systems.
Franz Sirl [Wed, 24 Jan 2018 13:39:11 +0000 (13:39 +0000)]
Fix printing the size of GOLD's memory areana on Cygwin based systems.

I just stumbled over this with 2.29.1 while building a cross-toolchain, on Cygwin64, but it's still the same for 2.30. m.arena has size_t on Cygwin64 and thus errors out due to -Werror=format.

gold * main.cc: Print m.arena as long long.

6 years agoRename tdesc_register_size to tdesc_register_bitsize
Alan Hayward [Wed, 11 Jul 2018 07:34:50 +0000 (08:34 +0100)]
Rename tdesc_register_size to tdesc_register_bitsize

tdesc_register_size returns number of bits, not bytes.
Rename to make it clearer.

Also, fixed bug in aarch64_get_tdesc_vq which assumed bytes.

gdb/
* target-descriptions.c (tdesc_register_bitsize): Rename.
* target-descriptions.h (tdesc_register_bitsize): Likewise.
* rs6000-tdep.c (rs6000_gdbarch_init): Use new name.
* aarch64-tdep.c (aarch64_get_tdesc_vq): Convert size.

6 years agox86: adjust monitor/mwait templates
Jan Beulich [Wed, 11 Jul 2018 08:30:00 +0000 (10:30 +0200)]
x86: adjust monitor/mwait templates

Architecturally, MONITOR's and MONITORX'es memory operand is a 16- or
32-bit register outside of 64-bit mode, and a 64- or 32-bit register
inside 64-bit mode. The other register operands, including all of them
for MWAIT and MWAITX, are uniformly 32-bit, irrespective of mode. Retain
the original 64-bit MONITOR{,X} templates for compatibility only, and
fold the MWAIT{,X} ones.

6 years agox86: drop {,reg16_}inoutportreg variables
Jan Beulich [Wed, 11 Jul 2018 08:28:56 +0000 (10:28 +0200)]
x86: drop {,reg16_}inoutportreg variables

The checking against reg16_inoutportreg can be had with a simple test of
a bit, and the value setting from inoutportreg can be replaced by using
the actual register's reg_type field.

Note that the so far redundant 2nd instance of OPERAND_TYPE_INOUTPORTREG
is left in place, for its use in type_names[].

6 years agox86: simplify legacy prefix emission
Jan Beulich [Wed, 11 Jul 2018 08:28:16 +0000 (10:28 +0200)]
x86: simplify legacy prefix emission

The check_prefix label was bogus from the beginning: The special
checking is supposed to happen for PadLock insns only; no
3-opcode-byte insn should go this path.

6 years agox86/Intel: accept memory operand size specifiers for CET insns
Jan Beulich [Wed, 11 Jul 2018 08:25:40 +0000 (10:25 +0200)]
x86/Intel: accept memory operand size specifiers for CET insns

6 years agox86: replace off-by-one OTMax
Jan Beulich [Wed, 11 Jul 2018 08:24:44 +0000 (10:24 +0200)]
x86: replace off-by-one OTMax

With its name it should equal to the largest prior enumerator, which is
not very helpful as that will change every once in a while. Rename it to
OTNum instead to make name and value match, and correct use sites to no
longer use one too large a value.

6 years agox86: fix "REP RET" with -madd-bnd-prefix
Jan Beulich [Wed, 11 Jul 2018 08:23:48 +0000 (10:23 +0200)]
x86: fix "REP RET" with -madd-bnd-prefix

Just like any other branches, RET should gain a BND prefix also when
already prefixed in source by REP.

6 years agoRevise "ld testsuite use of notarget"
Alan Modra [Wed, 11 Jul 2018 04:23:20 +0000 (13:53 +0930)]
Revise "ld testsuite use of notarget"

git commit 624940689a wrongly changed fill.d and fill16.d notarget
entries to xfail, so revert that change and instead replace notarget
with skip.  The two tests are complementary.

This patch also modifies the pr20022 test to use .data, avoiding
xfails on targets that complain about dynamic relocations in .text.
This shows a bug in metag which discards section _foo in pr2022.so.

* testsuite/ld-elf/hash.d: Comment on mips xfail.
* testsuite/ld-gc/pr20022b.s: Use .data not .text.
* testsuite/ld-gc/pr20022.d: Remove xfails.
* testsuite/ld-scripts/fill.d: Revert most of last patch, but use
skip rather than notarget.
* testsuite/ld-scripts/fill16.d: Likewise.

6 years agoUse std::vector for moribund_locations
Tom Tromey [Tue, 5 Jun 2018 16:35:38 +0000 (10:35 -0600)]
Use std::vector for moribund_locations

This changes moribund_locations to use a std::vector rather than VEC.
I also noticed that moribund_locations is only used in breakpoint.c,
so now it is static as well.

It might be possible to make this code a bit simpler by using a
ref_ptr in moribund_locations; however, I have not done this.

Tested by the buildbot.

gdb/ChangeLog
2018-07-10  Tom Tromey  <tom@tromey.com>

* breakpoint.c (moribund_locations): Now static and a
std::vector.
(breakpoint_init_inferior, moribund_breakpoint_here_p)
(build_bpstat_chain, update_global_location_list)
(breakpoint_retire_moribund): Update.
* breakpoint.h (bp_location_p): Remove typedef.  Don't declare
VEC.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 11 Jul 2018 00:00:50 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoMIPS/ld/testsuite: Limit export class call reloc tests to DSO targets
Maciej W. Rozycki [Tue, 10 Jul 2018 23:56:46 +0000 (16:56 -0700)]
MIPS/ld/testsuite: Limit export class call reloc tests to DSO targets

Only run MIPS/LD export class call relocation tests with shared library
targets, avoiding:

.../ld/ld-new: -shared not supported

linker errors and removing:

FAIL: MIPS export class call relocation test (o32)

regressions with `mipsel-ps2-elf' and `mips64el-ps2-elf' targets.

ld/
* testsuite/ld-mips-elf/mips-elf.exp: Limit export class call
relocation tests to shared library targets.

6 years agoBFD/ELF: Correct a `remove' global shadowing error for pre-4.8 GCC
Maciej W. Rozycki [Tue, 10 Jul 2018 23:42:43 +0000 (00:42 +0100)]
BFD/ELF: Correct a `remove' global shadowing error for pre-4.8 GCC

Remove `-Wshadow' compilation errors:

cc1: warnings being treated as errors
.../bfd/elflink.c: In function 'bfd_elf_final_link':
.../bfd/elflink.c:11722: error: declaration of 'remove' shadows a global declaration
/usr/include/stdio.h:154: error: shadowed declaration is here

which for versions of GCC before 4.8 prevent support for ELF targets
from being built.  See also GCC PR c/53066.

bfd/
* elflink.c (bfd_elf_final_link): Rename `remove' local variable
to `remove_section'.

6 years agoxgate testsuite fixes
Alan Modra [Tue, 10 Jul 2018 02:39:28 +0000 (12:09 +0930)]
xgate testsuite fixes

binutils/
* testsuite/lib/binutils-common.exp (supports_gnu_unique): Return
zero for xgate.
ld/
* testsuite/lib/ld-lib.exp (check_gc_sections_available): Return 0
for xgate.
* testsuite/ld-elf/elf.exp: Add xgate to pr21703 xfails.
* testsuite/ld-elf/shared.exp: Add xgate to pr21703 xfails.
* testsuite/ld-discard/extern.d: xfail xgate.
* testsuite/ld-discard/start.d: Likewise.
* testsuite/ld-discard/static.d: Likewise.
* testsuite/ld-elf/attributes.d: Likewise.
* testsuite/ld-elf/compressed1d.d: Likewise.
* testsuite/ld-elf/group1.d: Likewise.
* testsuite/ld-elf/group3b.d: Likewise.
* testsuite/ld-elf/group8a.d: Likewise.
* testsuite/ld-elf/group8b.d: Likewise.
* testsuite/ld-elf/group9a.d: Likewise.
* testsuite/ld-elf/group9b.d: Likewise.
* testsuite/ld-elf/linkonce2.d: Likewise.
* testsuite/ld-elf/merge.d: Likewise.
* testsuite/ld-elf/merge2.d: Likewise.
* testsuite/ld-elf/merge3.d: Likewise.
* testsuite/ld-elf/orphan-10.d: Likewise.
* testsuite/ld-elf/orphan-9.d: Likewise.
* testsuite/ld-elf/orphan-region.d: Likewise.
* testsuite/ld-elf/orphan.d: Likewise.
* testsuite/ld-elf/orphan3.d: Likewise.
* testsuite/ld-elf/pr12851.d: Likewise.
* testsuite/ld-elf/pr12975.d: Likewise.
* testsuite/ld-elf/pr13177.d: Likewise.
* testsuite/ld-elf/pr13195.d: Likewise.
* testsuite/ld-elf/pr14156b.d: Likewise.
* testsuite/ld-elf/pr17550c.d: Likewise.
* testsuite/ld-elf/pr17550d.d: Likewise.
* testsuite/ld-elf/pr17615.d: Likewise.
* testsuite/ld-elf/pr20528a.d: Likewise.
* testsuite/ld-elf/pr20528b.d: Likewise.
* testsuite/ld-elf/pr21562a.d: Likewise.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562i.d: Likewise.
* testsuite/ld-elf/pr21562j.d: Likewise.
* testsuite/ld-elf/pr21562k.d: Likewise.
* testsuite/ld-elf/pr21562l.d: Likewise.
* testsuite/ld-elf/pr21562m.d: Likewise.
* testsuite/ld-elf/pr21562n.d: Likewise.
* testsuite/ld-elf/pr22677.d: Likewise.
* testsuite/ld-elf/pr22836-1a.d: Likewise.
* testsuite/ld-elf/pr22836-1b.d: Likewise.
* testsuite/ld-elf/pr349.d: Likewise.
* testsuite/ld-elf/warn1.d: Likewise.
* testsuite/ld-elf/warn2.d: Likewise.
* testsuite/ld-elf/warn3.d: Likewise.

6 years agoxgate cleanup
Alan Modra [Sat, 7 Jul 2018 11:53:53 +0000 (21:23 +0930)]
xgate cleanup

elf32-xgate.c contains many functions that are only stubs and
elf32-xgate.h contains unused declarations.  While this might be
reasonable for the initial commit of a port with subsequent work
fleshing out the stubs, xgate has only had two minor target specific
patches since the initial commit over six years ago.  The rest of the
changes have been general maintenance work applied to all ELF targets,
and some of this work could have been avoided if the stubs hadn't been
there.  So this patch removes all the stubs.

I've kept the functionality of the old elf32_xgate_add_symbol_hook,
implemented in elf32_xgate_backend_symbol_processing.  Presumably,
that's to set the symbol st_target_internal flag for use in
elf32-m68hc1x.c:elf32_m68hc11_relocate_section.

The empty elf32_xgate_relocate_section meant that xgate had no linker.
Or at least, no linker relocation processing.  Deleting the
elf_backend_relocate_section define means the target will now use the
generic linker reloc processing.  How good that is will depend on the
accuracy of the reloc howtos..

I haven't updated the ld testsuite to xfail tests expected to fail
for generic elf targets.

bfd/
* elf32-xgate.h: Delete.
* elf32-xgate.c: Delete unnecessary forward declarations, add two
that are now needed.
(xgate_elf_bfd_link_hash_table_create)
(xgate_elf_bfd_link_hash_table_free)
(xgate_elf_set_mach_from_flags, struct xgate_scan_param)
(stub_hash_newfunc, elf32_xgate_add_symbol_hook)
(elf32_xgate_setup_section_lists, elf32_xgate_size_stubs)
(elf32_xgate_build_stubs, elf32_xgate_check_relocs)
(elf32_xgate_relocate_section, _bfd_xgate_elf_set_private_flags)
(elf32_xgate_post_process_headers): Delete.
(elf32_xgate_backend_symbol_processing): New function.
(xgate_elf_ignore_reloc, xgate_elf_special_reloc)
(_bfd_xgate_elf_print_private_bfd_data): Make static.
(ELF_TARGET_ID, elf_info_to_howto, elf_backend_check_relocs)
(elf_backend_relocate_section, elf_backend_object_p)
(elf_backend_final_write_processing, elf_backend_can_gc_sections)
(elf_backend_post_process_headers, elf_backend_add_symbol_hook)
(bfd_elf32_bfd_link_hash_table_create)
(bfd_elf32_bfd_set_private_flags)
(xgate_stub_hash_lookup): Don't define.
(elf_backend_symbol_processing): Define.
* elf-bfd.h (elf_target_id): Delete XGATE_ELF_DATA.
ld/
* emulparams/xgateelf.sh (TEMPLATE_NAME) Set to generic.
(EXTRA_EM_FILE): Set to genelf.

6 years agold testsuite use of notarget
Alan Modra [Tue, 10 Jul 2018 13:43:10 +0000 (23:13 +0930)]
ld testsuite use of notarget

Much of the time it is better to use xfail rather than notarget to
hide a testsuite failure no one is planning on fixing.

1) When a target is fixed, an inappropriate xfail results in XPASS
   whereas notarget is silent.  Leaving in an inappropriate notarget
   entry risks the bug reappearing later, silently.
2) Tests might be used as a template for a new test, carrying over
   notarget and/or xfail.  Inappropriate notarget entries are silent.
3) An xfailed test that mysteriously XPASSes might actually indicate a
   bug.

* testsuite/ld-elf/attributes.d: Use xfail rather than notarget.
* testsuite/ld-elf/hash.d: Likewise.
* testsuite/ld-elf/orphan-10.d: Likewise.
* testsuite/ld-elf/overlay.d: Likewise.
* testsuite/ld-elf/pr14926.d: Likewise.
* testsuite/ld-elf/pr17550d.d: Likewise.
* testsuite/ld-elf/pr19539.d: Likewise.
* testsuite/ld-elf/pr22319.d: Likewise.
* testsuite/ld-misc/defsym1.d: Likewise.
* testsuite/ld-pe/pr19803.d: Likewise.
* testsuite/ld-scripts/assign-loc.d: Likewise.
* testsuite/ld-scripts/defined4.d: Likewise.
* testsuite/ld-scripts/empty-address-1.d: Likewise.
* testsuite/ld-scripts/empty-address-2a.d: Likewise.
* testsuite/ld-scripts/empty-address-2b.d: Likewise.
* testsuite/ld-scripts/fill.d: Likewise.
* testsuite/ld-scripts/fill16.d: Likewise.
* testsuite/ld-scripts/pr14962.d: Likewise.
* testsuite/ld-scripts/pr14962-2.d: Likewise.
* testsuite/ld-unique/pr21529.d: Likewise.
* testsuite/ld-elf/compress1a.d: Likewise, and adjust targets.
* testsuite/ld-elf/compressed1a.d: Likewise.
* testsuite/ld-elf/compressed1d.d: Likewise.
* testsuite/ld-elf/compressed1e.d: Likewise.
* testsuite/ld-elf/eh5.d: Likewise.
* testsuite/ld-elf/group8a.d: Likewise.
* testsuite/ld-elf/linkonce2.d: Likewise.
* testsuite/ld-elf/orphan-9.d: Likewise.
* testsuite/ld-elf/pr17550a.d: Likewise.
* testsuite/ld-elf/pr17550b.d: Likewise.
* testsuite/ld-elf/pr17550c.d: Likewise.
* testsuite/ld-elf/pr19162.d: Likewise.
* testsuite/ld-elf/pr21884.d: Likewise.
* testsuite/ld-gc/pr19167.d: Likewise.
* testsuite/ld-gc/pr20022.d: Likewise.
* testsuite/ld-gc/start.d: Likewise.
* testsuite/ld-elf/orphan-11.d: Delete notarget.
* testsuite/ld-elf/orphan-12.d: Likewise.
* testsuite/ld-gc/stop.d: Likewise.
* testsuite/ld-scripts/empty-address-3a.d: Likewise.
* testsuite/ld-scripts/empty-address-3b.d: Likewise.
* testsuite/ld-ifunc/pr17154-x86-64-now.d: Delete duplicate notarget.
* testsuite/ld-scripts/section-match-1.d: Comment fix.

6 years agogdb/testsuite: Run test with software and hardware watchpoints
Andrew Burgess [Tue, 10 Apr 2018 19:21:58 +0000 (20:21 +0100)]
gdb/testsuite: Run test with software and hardware watchpoints

Expand the gdb.base/watchpoint-reuse-slot.exp test to be run twice,
once with hardware watchpoints disabled (this is new) and then with
hardware watchpoints enabled (the old way).

Running with hardware watchpoints enabled is skipped if the board file
says that hardware watchpoints are not supported on this target.

gdb/testsuite/ChangeLog:

* gdb.base/watchpoint-reuse-slot.exp: Test with hardware
watchpoints enabled and disabled.

6 years agogdb/riscv: Fix assertion in inferior call code
Andrew Burgess [Sun, 8 Apr 2018 10:08:32 +0000 (11:08 +0100)]
gdb/riscv: Fix assertion in inferior call code

An assertion when setting up arguments for an inferior call checks the
size of the argument against xlen.  However, if xlen and flen are
different sizes, and the argument is being placed into a floating
pointer register then we should be comparing against flen not xlen.

This issue shows up as an assertion failure when running on an rv32g
target with a binary compiled using the rv32f abi and making an
inferior call involving large floating point arguments, for example
the test gdb.base/infcall-nested-structs.exp.

gdb/ChangeLog:

* riscv-tdep.c (riscv_is_fp_regno_p): New function.
(riscv_register_reggroup_p): Use new function, remove unneeded
parenthesis.
(riscv_push_dummy_call): Extend assert to compare against xlen or
flen based on register type.

6 years agogdb/riscv: Use TYPE_SAFE_NAME
Andrew Burgess [Sun, 8 Apr 2018 10:07:56 +0000 (11:07 +0100)]
gdb/riscv: Use TYPE_SAFE_NAME

In debug printing, use TYPE_SAFE_NAME instead of replicating the
functionality using TYPE_NAME and a null check.

gdb/ChangeLog:

* riscv-tdep.c (riscv_print_arg_location): Use TYPE_SAFE_NAME.

6 years agoMIPS/LD/testsuite: Make Linux dumps for n64 GOT relocation tests the default
Maciej W. Rozycki [Tue, 10 Jul 2018 00:28:46 +0000 (01:28 +0100)]
MIPS/LD/testsuite: Make Linux dumps for n64 GOT relocation tests the default

The current default dumps for n64 GOT relocation tests only work for
IRIX targets really, while the Linux dumps are suitable for non-Linux
targets as well.  Make the Linux dumps the default then and handle the
IRIX ones as a special case.

Define an `irix' variable as a shorthand for `[istarget *-*-irix*]' and
use it for these n64 GOT relocation tests as well as export class call
relocation tests.

ld/
* testsuite/ld-mips-elf/elf-rel-got-n64.d: Rename to...
* testsuite/ld-mips-elf/elf-rel-got-n64-irix.d: ... this.
* testsuite/ld-mips-elf/elf-rel-got-n64-linux.d: Rename to...
* testsuite/ld-mips-elf/elf-rel-got-n64.d: ... this.
* testsuite/ld-mips-elf/elf-rel-xgot-n64.d: Rename to...
* testsuite/ld-mips-elf/elf-rel-xgot-n64-irix.d: ... this.
* testsuite/ld-mips-elf/elf-rel-xgot-n64-linux.dd: Rename to...
* testsuite/ld-mips-elf/elf-rel-xgot-n64.d: ... this.
* testsuite/ld-mips-elf/mips-elf.exp: Update accordingly.
Define `irix' as a shorthand for `[istarget *-*-irix*]' and use
it throughout.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 10 Jul 2018 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix test for availability of emplace_back.
Cary Coutant [Mon, 9 Jul 2018 23:12:27 +0000 (16:12 -0700)]
Fix test for availability of emplace_back.

Testing for the GCC version 5 or later isn't right, since C++ 11 support
wasn't enabled by default until later.  This patch tests the C++ standard
support directly instead of inferring it from the GCC version.

gold/
* incremental.cc (Sized_incremental_binary::setup_readers): Use
emplace_back for C++ 11 or later.

6 years agoMIPS/LD/testsuite: Fix IRIX dumps for n64 GOT relocation tests
Maciej W. Rozycki [Mon, 9 Jul 2018 22:43:27 +0000 (23:43 +0100)]
MIPS/LD/testsuite: Fix IRIX dumps for n64 GOT relocation tests

Factor in the presence of a `.gnu.attributes' section at the end of the
respective dumps:

Disassembly of section .gnu.attributes:

0000000000000000 <.gnu.attributes>:
   0: 41000000  bc0f 4 <__dso_displacement+0x4>
   4: 0f676e75  jal d9db9d4 <__dso_displacement+0xd9db9d4>
   8: 00010000  sll zero,at,0x0
   c: 00070401  0x70401

and also ignore any trailing output with the IRIX variant of n64 GOT
relocation tests, like already done with the Linux and the embedded
ones, removing:

FAIL: MIPS ELF got reloc n64
FAIL: MIPS ELF xgot reloc n64

LD testsuite regressions with the `mips-sgi-irix6' target.

ld/
* testsuite/ld-mips-elf/elf-rel-got-n64.d: Add `#pass' at the
end.
* testsuite/ld-mips-elf/elf-rel-xgot-n64.d: Likewise.

6 years agoMIPS/BFD: Do not redirect to discarded lazy binding stubs
Maciej W. Rozycki [Mon, 9 Jul 2018 20:30:44 +0000 (21:30 +0100)]
MIPS/BFD: Do not redirect to discarded lazy binding stubs

Correct a MIPS/BFD linker issue with dynamic symbol and corresponding
GOT entry values being redirected to lazy binding stubs where the stubs
section has been discarded by assigning to the `/DISCARD/' output
section in the linker script used.  The issue manifests itself by the
values entered being relative to the absolute section, which is what any
discarded sections are internally assigned in the linker.

For the `stub-dynsym-2.s' piece of code included as a test case with
this change this issue results in the dynamic symbol table and the GOT
looking like:

Symbol table '.dynsym' contains 3 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000010     0 FUNC    GLOBAL DEFAULT  UND bar
     2: 00000000     0 FUNC    GLOBAL DEFAULT  UND foo

Primary GOT:
 Canonical gp value: 00097ff0

 Reserved entries:
   Address     Access  Initial Purpose
  00090000 -32752(gp) 00000000 Lazy resolver
  00090004 -32748(gp) 80000000 Module pointer (GNU extension)

 Global entries:
   Address     Access  Initial Sym.Val. Type    Ndx Name
  00090008 -32744(gp) 00000010 00000010 FUNC    UND bar
  0009000c -32740(gp) 00000000 00000000 FUNC    UND foo

if assembled to regular MIPS code, or:

Symbol table '.dynsym' contains 3 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000d     0 FUNC    GLOBAL DEFAULT  UND bar
     2: 00000001     0 FUNC    GLOBAL DEFAULT  UND foo

Primary GOT:
 Canonical gp value: 00097ff0

 Reserved entries:
   Address     Access  Initial Purpose
  00090000 -32752(gp) 00000000 Lazy resolver
  00090004 -32748(gp) 80000000 Module pointer (GNU extension)

 Global entries:
   Address     Access  Initial Sym.Val. Type    Ndx Name
  00090008 -32744(gp) 0000000d 0000000d FUNC    UND bar
  0009000c -32740(gp) 00000001 00000001 FUNC    UND foo

if assembled to microMIPS code.  Symbol values and GOT entries record
the offset into the inexistent stubs section and the ISA bit rather than
zero, which would be the case if a lazy binding stub was not used for
other reasons, such as the value of the symbol being taken for a purpose
other than making a function call (e.g. an R_MIPS_GOT16 relocation).

Correct the issue by refraining from redirecting symbols to lazy binding
stubs if the stubs section is going to be discarded.

bfd/
* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Don't set
`->needs_lazy_stub' if the stubs output section is the absolute
section.

ld/
* testsuite/ld-mips-elf/stub-dynsym-2.dd: New test.
* testsuite/ld-mips-elf/stub-dynsym-2.gd: New test.
* testsuite/ld-mips-elf/stub-dynsym-2.sd: New test.
* testsuite/ld-mips-elf/stub-dynsym-discard-2.gd: New test.
* testsuite/ld-mips-elf/stub-dynsym-discard-2.sd: New test.
* testsuite/ld-mips-elf/stub-dynsym-micromips-2.dd: New test.
* testsuite/ld-mips-elf/stub-dynsym-micromips-2.gd: New test.
* testsuite/ld-mips-elf/stub-dynsym-micromips-2.sd: New test.
* testsuite/ld-mips-elf/stub-dynsym-micromips-insn32-2.dd: New
test.
* testsuite/ld-mips-elf/stub-dynsym-micromips-insn32-2.gd: New
test.
* testsuite/ld-mips-elf/stub-dynsym-micromips-insn32-2.sd: New
test.
* testsuite/ld-mips-elf/stub-dynsym-2.ld: New test linker
script.
* testsuite/ld-mips-elf/stub-dynsym-discard-2.ld: New test
linker script.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.

6 years agogdb: Use add_setshow_zuinteger_unlimited_cmd in remote.c
Andrew Burgess [Mon, 2 Jul 2018 21:28:22 +0000 (22:28 +0100)]
gdb: Use add_setshow_zuinteger_unlimited_cmd in remote.c

Switch to use add_setshow_zuinteger_unlimited_cmd for some of the
control variables in remote.c.  The variables
hardware-watchpoint-limit, hardware-breakpoint-limit, and
hardware-watchpoint-length-limit are all changed.  For example, a user
will now see this:

    (gdb) show remote hardware-breakpoint-limit
    The maximum number of target hardware breakpoints is unlimited.

Instead of this:

    (gdb) show remote hardware-breakpoint-limit
    The maximum number of target hardware breakpoints is -1.

And can do this:

    (gdb) set remote hardware-breakpoint-limit unlimited

However, previously any negative value implied "unlimited", now only
-1, or the text "unlimited" can be used for unlimited.  Any other
negative value will give an error about invalid input.  This is a
small change in the user interface, but, hopefully, this will not
cause too many problems.

I've also added show functions for these three variables to allow for
internationalisation.

gdb/ChangeLog:

* remote.c (show_hardware_watchpoint_limit): New function.
(show_hardware_watchpoint_length_limit): New function.
(show_hardware_breakpoint_limit): New function.
(_initialize_remote): Use add_setshow_zuinteger_unlimited_cmd
where appropriate, update help text.

gdb/doc/ChangeLog:

* gdb.texinfo (Remote Configuration): Update descriptions for
set/show of hardware-watchpoint-limit, hardware-breakpoint-limit,
and hardware-watchpoint-length-limit variables.

6 years ago * testsuite/nds32/ji-jr.d: Fix name tag.
Jeff Law [Mon, 9 Jul 2018 16:35:12 +0000 (10:35 -0600)]
* testsuite/nds32/ji-jr.d: Fix name tag.

6 years agoLD/testsuite: run_dump_test: Report UNSUPPORTED for excluded targets
Maciej W. Rozycki [Mon, 9 Jul 2018 14:50:57 +0000 (15:50 +0100)]
LD/testsuite: run_dump_test: Report UNSUPPORTED for excluded targets

Bring the LD implementation of `run_dump_test' in line with its binutils
and GAS counterparts and report the UNSUPPORTED status for tests the run
of which has been prevented by means of one or more of `target',
`alltargets' and `notarget' tags.  Define `skip', `anyskip' and `noskip'
tags, which do not report anything for tests that are not run.

The rationale behind this is that we want to have unsupported tests
reported to ensure that they have actually been attempted and have not
been accidentally suppressed.  Then tests which have target-specific
variants that cannot be expressed with a single .d file can make use of
the newly added tags to silently suppress the uninteresting variants.

ld/
* testsuite/lib/ld-lib.exp (run_dump_test): Call `unsupported'
if the target being tested has been excluded by means of one or
more of `target', `alltargets' and `notarget' tags.  Add support
for `skip', `anyskip' and `noskip' tags.

6 years agoLD/testsuite: run_dump_test: Use the intended test name ASAP
Maciej W. Rozycki [Mon, 9 Jul 2018 14:50:57 +0000 (15:50 +0100)]
LD/testsuite: run_dump_test: Use the intended test name ASAP

Bring the LD implementation of `run_dump_test' in line with its binutils
and GAS counterparts and use the intended test name, from the `name' tag
if set, for test status reporting as soon as it is available.

ld/
* testsuite/lib/ld-lib.exp (run_dump_test): Move the setting of
`testname' earlier on and use it for test status reporting.

6 years agoS12Z/opcodes: Correct a `reg' global shadowing error for pre-4.8 GCC
Maciej W. Rozycki [Mon, 9 Jul 2018 14:50:57 +0000 (15:50 +0100)]
S12Z/opcodes: Correct a `reg' global shadowing error for pre-4.8 GCC

Remove `-Wshadow' compilation errors:

cc1: warnings being treated as errors
.../opcodes/s12z-dis.c: In function 'lea_reg_xys_opr':
.../opcodes/s12z-dis.c:814: error: declaration of 'reg' shadows a global declaration
.../opcodes/s12z-dis.c:783: error: shadowed declaration is here
.../opcodes/s12z-dis.c: In function 'lea_reg_xys':
.../opcodes/s12z-dis.c:843: error: declaration of 'reg' shadows a global declaration
.../opcodes/s12z-dis.c:783: error: shadowed declaration is here
.../opcodes/s12z-dis.c: In function 'print_insn_loop_primitive':
.../opcodes/s12z-dis.c:2206: error: declaration of 'reg' shadows a global declaration
.../opcodes/s12z-dis.c:783: error: shadowed declaration is here

which for versions of GCC before 4.8 prevent support for S12Z targets
from being built.  See also GCC PR c/53066.

opcodes/
* s12z-dis.c (lea_reg_xys_opr): Rename `reg' local variable to
`reg_xys'.
(lea_reg_xys): Likewise.
(print_insn_loop_primitive): Rename `reg' local variable to
`reg_dxy'.

6 years agogdb/testsuite: Allow for failure to read some memory addresses
Andrew Burgess [Fri, 2 Feb 2018 15:51:31 +0000 (15:51 +0000)]
gdb/testsuite: Allow for failure to read some memory addresses

In the gdb.base/examine-backward.exp test script, we check to see if
address zero is readable, and then read memory first forward from
address zero, and then backward from address zero.

The problem is, being able to read address zero does not guarantee
that you'll be able to read from the other end of the address space,
and the test probably shouldn't assume that is the case.

This patch updates the test script so that even if address zero is
known non-readable, we still run the tests, the tests in question are
mostly about, can GDB calculate the correct address to read from, we
can confirm this even if the final read ultimately fails.  We also no
longer assume that if address zero is readable, then the other end of
the address space will be readable.

One further change is that, when we examined the memory at address
zero, the regexp used to match the address expected that the zero
address would have two '0' digits as the least significant digits.  As
GDB strips leading zeros from addresses this was causing the test to
fail.  I've reduced the zero address to a single 0 digit.

gdb/testsuite/ChangeLog:

* gdb.base/examine-backward.exp: Still run tests around address
0x0, even if address 0x0 is not readable.  Update the pattern for
matching address 0x0 in expected output.

6 years agoDon't mention XM_CDEPS or NAT_CLIBS
Tom Tromey [Mon, 2 Jul 2018 13:36:04 +0000 (07:36 -0600)]
Don't mention XM_CDEPS or NAT_CLIBS

Neither XM_CDEPS nor NAT_CLIBS are defined anywhere, so remove the
uses.

gdb/ChangeLog
2018-07-09  Tom Tromey  <tom@tromey.com>

* Makefile.in (CDEPS): Don't mention XM_CDEPS.
(CLIBS): Don't mention NAT_CLIBS.

6 years agoRemove ADD_FILES and ADD_DEPS from Makefile.in
Tom Tromey [Mon, 2 Jul 2018 13:32:10 +0000 (07:32 -0600)]
Remove ADD_FILES and ADD_DEPS from Makefile.in

Nothing defines XM_ADD_FILES, TM_ADD_FILES, or NAT_ADD_FILES any more,
so consequently ADD_FILES and ADD_DEPS are no longer needed.  So, this
removes them.

gdb/ChangeLog
2018-07-09  Tom Tromey  <tom@tromey.com>

* Makefile.in (ADD_FILES, ADD_DEPS): Remove.
(LIBGDB_OBS, clean mostlyclean): Update.
(gdb$(EXEEXT), insight$(EXEEXT)): Update.