Commit Graph

90384 Commits

Author SHA1 Message Date
GDB Administrator 323449189c Automatic date update in version.in 2017-05-05 00:00:37 +00:00
Pedro Alves d512d31c39 Fix gdb.python/py-record-btrace-threads.exp with Python 3
Fix several instances of:

 ...
 python print not f1calls
   File "<string>", line 1
     print not f1calls
		     ^
 SyntaxError: Missing parentheses in call to 'print'
 Error while executing Python code.
 (gdb) FAIL: gdb.python/py-record-btrace-threads.exp: thread=1: checking thread 1: python print not f1calls
 ...

gdb/testsuite/ChangeLog:
2017-05-04  Pedro Alves  <palves@redhat.com>

	* gdb.python/py-record-btrace-threads.exp (check_insn_for_thread):
	Add parens to print call for Python 3.
2017-05-04 16:02:36 +01:00
Pedro Alves 5ed8105e02 RAII-fy make_cleanup_restore_current_thread & friends
After all the make_cleanup_restore_current_thread fixing, I thought
I'd convert that and its relatives (which are all cleanups) to RAII
classes.

scoped_restore_current_pspace_and_thread was put in a separate file to
avoid a circular dependency.

Tested on x86-64 Fedora 23, native and gdbserver.

gdb/ChangeLog:
2017-05-04  Pedro Alves  <palves@redhat.com>

	* Makefile.in (SFILES): Add progspace-and-thread.c.
	(HFILES_NO_SRCDIR): Add progspace-and-thread.h.
	(COMMON_OBS): Add progspace-and-thread.o.
	* breakpoint.c: Include "progspace-and-thread.h".
	(update_inserted_breakpoint_locations)
	(insert_breakpoint_locations, create_longjmp_master_breakpoint):
	Use scoped_restore_current_pspace_and_thread.
	(create_std_terminate_master_breakpoint): Use
	scoped_restore_current_program_space.
	(remove_breakpoint): Use scoped_restore_current_pspace_and_thread.
	(print_breakpoint_location): Use
	scoped_restore_current_program_space.
	(bp_loc_is_permanent): Use
	scoped_restore_current_pspace_and_thread.
	(resolve_sal_pc): Use scoped_restore_current_pspace_and_thread.
	(download_tracepoint_locations): Use
	scoped_restore_current_pspace_and_thread.
	(breakpoint_re_set): Use scoped_restore_current_pspace_and_thread.
	* exec.c (exec_close_1): Use scoped_restore_current_program_space.
	(enum step_over_calls_kind): Moved from inferior.h.
	(class scoped_restore_current_thread): New class.
	* gdbthread.h (make_cleanup_restore_current_thread): Delete
	declaration.
	(scoped_restore_current_thread): New class.
	* infcmd.c: Include "common/gdb_optional.h".
	(continue_1, proceed_after_attach): Use
	scoped_restore_current_thread.
	(notice_new_inferior): Use scoped_restore_current_thread.
	* inferior.c: Include "progspace-and-thread.h".
	(restore_inferior, save_current_inferior): Delete.
	(add_inferior_command, clone_inferior_command): Use
	scoped_restore_current_pspace_and_thread.
	* inferior.h (scoped_restore_current_inferior): New class.
	* infrun.c: Include "progspace-and-thread.h" and
	"common/gdb_optional.h".
	(follow_fork_inferior): Use
	scoped_restore_current_pspace_and_thread.
	(scoped_restore_exited_inferior): New class.
	(handle_vfork_child_exec_or_exit): Use
	scoped_restore_exited_inferior,
	scoped_restore_current_pspace_and_thread,
	scoped_restore_current_thread and scoped_restore.
	(fetch_inferior_event): Use scoped_restore_current_thread.
	* linespec.c (decode_line_full, decode_line_1): Use
	scoped_restore_current_program_space.
	* mi/mi-main.c: Include "progspace-and-thread.h".
	(exec_continue): Use scoped_restore_current_thread.
	(mi_cmd_exec_run): Use scoped_restore_current_pspace_and_thread.
	(mi_cmd_trace_frame_collected): Use scoped_restore_current_thread.
	* proc-service.c (ps_pglobal_lookup): Use
	scoped_restore_current_program_space.
	* progspace-and-thread.c: New file.
	* progspace-and-thread.h: New file.
	* progspace.c (release_program_space, clone_program_space): Use
	scoped_restore_current_program_space.
	(restore_program_space, save_current_program_space)
	(save_current_space_and_thread): Delete.
	(switch_to_program_space_and_thread): Moved to
	progspace-and-thread.c.
	* progspace.h (save_current_program_space)
	(save_current_space_and_thread): Delete declarations.
	(scoped_restore_current_program_space): New class.
	* remote.c (remote_btrace_maybe_reopen): Use
	scoped_restore_current_thread.
	* symtab.c: Include "progspace-and-thread.h".
	(skip_prologue_sal): Use scoped_restore_current_pspace_and_thread.
	* thread.c (print_thread_info_1): Use
	scoped_restore_current_thread.
	(struct current_thread_cleanup): Delete.
	(do_restore_current_thread_cleanup)
	(restore_current_thread_cleanup_dtor): Rename/convert both to ...
	(scoped_restore_current_thread::~scoped_restore_current_thread):
	... this new dtor.
	(make_cleanup_restore_current_thread): Rename/convert to ...
	(scoped_restore_current_thread::scoped_restore_current_thread):
	... this new ctor.
	(thread_apply_all_command): Use scoped_restore_current_thread.
	(thread_apply_command): Use scoped_restore_current_thread.
	* tracepoint.c (tdump_command): Use scoped_restore_current_thread.
	* varobj.c (value_of_root_1): Use scoped_restore_current_thread.
2017-05-04 15:18:44 +01:00
Pedro Alves f6223dbb50 make_cleanup_restore_current_thread: Look up thread earlier
The unconditional is_stopped call already asserts that the thread exists.

gdb/ChangeLog:
2017-05-04  Pedro Alves  <palves@redhat.com>

	* thread.c (make_cleanup_restore_current_thread): Move
	find_thread_ptid call before the is_stopped call.  Assert that the
	thread is found.  Replace is_stopped call by checking the thread's
	state directly.  Remove unnecessary NULL-thread check.
2017-05-04 15:17:38 +01:00
Pedro Alves 3c3ae77e68 Fix get_core_register_section leak, introduce thread_section_name
This plugs a leak introduced in the previous change to
get_core_register_section, which removed an xfree call that is
actually necessary because the 'section_name' local is static.

From [1] it looks like the reason the variable was made static to
begin with, was just "laziness" to avoid having to think about freeing
it on every function return path:

 https://sourceware.org/ml/gdb-patches/2005-03/msg00237.html

The easiest to fix that nowadays is to use a std::string.

I don't see a need to xstrdup the section name in the single-threaded
case though, and also there's more than one place that computes a
multi-threaded section name in the same way.  So put the section name
computation in a wrapper class with state.

gdb/ChangeLog:
2017-05-04  Pedro Alves  <palves@redhat.com>

	* corelow.c (thread_section_name): New class.
	(get_core_register_section, get_core_siginfo): Use it.
2017-05-04 15:14:37 +01:00
Kito Cheng f91d48deb2 RISC-V: Fix disassemble for c.li, c.andi and c.addiw
ChangeLog

2017-05-03  Kito Cheng  <kito.cheng@gmail.com>

        * riscv-dis.c (print_insn_args): Handle 'Co' operands.
2017-05-04 03:20:30 -07:00
Andreas Arnez 45eba0ab7d Remove some superfluous code in corelow.c
In corelow.c I stumbled upon an extra semicolon and an xfree of a NULL
pointer.  Remove them.

gdb/ChangeLog:

	* corelow.c (sniff_core_bfd): Remove extra semicolon.
	(get_core_register_section): Remove xfree of NULL pointer.
2017-05-04 11:06:10 +02:00
Senthil Kumar Selvaraj b660e9eb7a Fix PR21404 - assertion fail when calculating symbol size
Fix a host of problems related to adjustment of
symbol values and sizes when relaxing for avr.

1. Adjust symbol size first before adjusting symbol
value. Otherwise, a symbol whose value just got adjusted to the
relaxed address also ends up getting resized. See pr21404-1.s.

2. Reduce symbol sizes only if their span is below an
alignment boundary. Otherwise, the size gets decremented once when the
actual instruction is relaxed and padding bytes are added, and again
when the padding bytes are deleted (if padding ends up being unnecessary).
pr21404-2.s addresses that, and this bug is really the root cause of PR21404.

3. Adjust all symbol values before an alignment boundary.
Previous code did not adjust symbol values if they fell in the
would-be padded area, resulting in incorrect symbol values in some
cases (see pr21404-3.s).

4. Increase symbol sizes if alignment directives require so.
As pr21404-4.s shows
.global nonzero_sym
L1:
    jmp  L1
nonzero_sym:
    nop
    nop
    .p2align 2
.size nonzero_sym, .-nonzero_sym

The two nops satisfy the 4 byte alignment at assembly time and
therefore the size of nonzero_sym is 4. Relaxation shortens
the 4 byte jmp to a 2 byte rjmp, and to satisfy 4 byte alignment
the code places 2 extra padding bytes after the nops, increasing
nonzero_sym's size by 2. This wasn't handled before.

If the assembly code does not have any align directives, then the
boundary is the section size, and symbol values and sizes == boundary
should also get adjusted. To handle that case, add a did_pad variable
and use that to determine whether it should use < boundary or <= boundary.

Also get rid of reloc_toaddr, which is now redundant.  toaddr is now not
adjusted to handle the above case - the newly added
did_pad variable does the job.

pr21404-{5,6,7,8} are the same testcases written for local symbols, as
the code handles them slightly differently.
2017-05-04 10:34:29 +05:30
GDB Administrator 8293e73636 Automatic date update in version.in 2017-05-04 00:00:55 +00:00
Maciej W. Rozycki 8507b6e797 MIPS16/GAS: Relax 32-bit non-PIC PC-relative synthetic instructions
Implement the relaxation of MIPS16 PC-relative synthetic LA, DLA, LW and
LD instructions to an equivalent sequence of instructions produced where
the address operand requested is out of range, absolute or requires
linker relocation, for ABIs that use 32-bit addressing and non-PIC code.

The sequence generated uses the register specified for the destination
operand as a temporary and begins with LI to load the high 16-bit part
of the address, then continues with SLL by 16 bits to move that part
into place and finally completes with a suitable operation corresponding
to the synthetic instruction used, one of: 2-argument ADDIU, 2-argument
DADDIU, absolute LW, and absolute LD respectively, providing the low
16-bit part of the address.  All instructions use the extended encoding.
As a special exception accept absolute addresses for relaxation even in
PIC code.

For example:

	la	$2, 0x12345678

produces code as:

	li	$2, 0x1234
	sll	$2, $2, 16
	addiu	$2, 0x5678

would.

Where linker relocation is required emit an R_MIPS16_HI16 relocation on
the initial LI instruction and an R_MIPS16_LO16 relocation on the final
operation.

For example (where `foo' is not local):

	lw	$3, foo

produces code as:

	li	$3, %hi(foo)
	sll	$3, $3, 16
	lw	$3, %lo(foo)($3)

would.

Emit assembly warnings as appropriate where this new relaxation triggers
in the `nomacro' mode or for an instruction manually placed in a branch
delay slot in the `noreorder' mode.  Refrain from relaxation where an
explicit instruction size suffix has been used and in the `noautoextend'
mode.

	gas/
	* config/tc-mips.c (RELAX_MIPS16_ENCODE): Add `pic', `sym32' and
	`nomacro' flags.
	(RELAX_MIPS16_PIC, RELAX_MIPS16_SYM32, RELAX_MIPS16_NOMACRO):
	New macros.
	(RELAX_MIPS16_USER_SMALL, RELAX_MIPS16_USER_EXT)
	(RELAX_MIPS16_DSLOT, RELAX_MIPS16_JAL_DSLOT)
	(RELAX_MIPS16_EXTENDED, RELAX_MIPS16_MARK_EXTENDED)
	(RELAX_MIPS16_CLEAR_EXTENDED, RELAX_MIPS16_ALWAYS_EXTENDED)
	(RELAX_MIPS16_MARK_ALWAYS_EXTENDED)
	(RELAX_MIPS16_CLEAR_ALWAYS_EXTENDED): Shift bits.
	(RELAX_MIPS16_MACRO, RELAX_MIPS16_MARK_MACRO)
	(RELAX_MIPS16_CLEAR_MACRO): New macros.
	(append_insn): Pass `mips_pic', HAVE_32BIT_SYMBOLS and
	`mips_opts.warn_about_macros' settings to RELAX_MIPS16_ENCODE.
	(mips16_macro_frag): New function.
	(md_estimate_size_before_relax): Handle HI16/LO16 relaxation.
	(mips_relax_frag): Likewise.
	(md_convert_frag): Likewise.

	* testsuite/gas/mips/mips16@relax-swap3.d: Remove error output,
	add dump patterns.
	* testsuite/gas/mips/mips16e@relax-swap3.d: New test
	subarchitecture.
	* testsuite/gas/mips/micromips@relax-swap3.d: Remove trailing
	NOP padding.
	* testsuite/gas/mips/mips16-pcrel-reloc-2.d: Remove error
	output, add dump patterns.
	* testsuite/gas/mips/mips16-pcrel-reloc-3.d: Remove error
	output, add dump patterns.
	* testsuite/gas/mips/mips16-pcrel-reloc-6.d: Remove error
	output, add dump patterns.
	* testsuite/gas/mips/mips16-pcrel-reloc-7.d: Remove error
	output, add dump patterns.
	* testsuite/gas/mips/mips16-pcrel-addend-2.d: Remove error
	output, add dump patterns.
	* testsuite/gas/mips/mips16-pcrel-addend-3.d: Remove error
	output, add dump patterns.
	* testsuite/gas/mips/mips16-pcrel-absolute.d: Remove error
	output, add dump patterns.
	* testsuite/gas/mips/mips16-pcrel-absolute-1.d: Remove error
	output, add dump patterns.
	* testsuite/gas/mips/mips16@relax-swap3.l: Remove file.
	* testsuite/gas/mips/mips16-pcrel-reloc-2.l: Remove file.
	* testsuite/gas/mips/mips16-pcrel-reloc-3.l: Remove file.
	* testsuite/gas/mips/mips16-pcrel-reloc-6.l: Remove file.
	* testsuite/gas/mips/mips16-pcrel-reloc-7.l: Remove file.
	* testsuite/gas/mips/mips16-pcrel-addend-2.l: Remove file.
	* testsuite/gas/mips/mips16-pcrel-addend-3.l: Remove file.
	* testsuite/gas/mips/mips16-pcrel-absolute.l: Remove file.
	* testsuite/gas/mips/mips16-pcrel-absolute-1.l: Remove file.
	* testsuite/gas/mips/relax-swap3.s: Adjust trailing padding.

	* testsuite/gas/mips/mips16-pcrel-0.d: New test.
	* testsuite/gas/mips/mips16-pcrel-1.d: New test.
	* testsuite/gas/mips/mips16-pcrel-2.d: New test.
	* testsuite/gas/mips/mips16-pcrel-3.d: New test.
	* testsuite/gas/mips/mips16-pcrel-4.d: New test.
	* testsuite/gas/mips/mips16-pcrel-5.d: New test.
	* testsuite/gas/mips/mips16-pcrel-pic-0.d: New test.
	* testsuite/gas/mips/mips16-pcrel-pic-1.d: New test.
	* testsuite/gas/mips/mips16-pcrel-n32-0.d: New test.
	* testsuite/gas/mips/mips16-pcrel-n32-1.d: New test.
	* testsuite/gas/mips/mips16-pcrel-n64-sym32-0.d: New test.
	* testsuite/gas/mips/mips16-pcrel-n64-sym32-1.d: New test.
	* testsuite/gas/mips/mips16-pcrel-n64-0.d: New test.
	* testsuite/gas/mips/mips16-pcrel-n64-1.d: New test.
	* testsuite/gas/mips/mips16-pcrel-delay-0.d: New test.
	* testsuite/gas/mips/mips16-pcrel-delay-1.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-4.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-5.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-6.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-7.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-8.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-9.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-pic-8.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-pic-9.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-n32-8.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-n32-9.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-n64-sym32-8.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-n64-sym32-9.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-n64-8.d: New test.
	* testsuite/gas/mips/mips16-pcrel-addend-n64-9.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-2.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-3.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-4.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-5.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-6.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-7.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-pic-4.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-pic-6.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-n32-4.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-n32-6.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-n64-4.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-n64-6.d: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-n64-sym32-4.d: New
	test.
	* testsuite/gas/mips/mips16-pcrel-absolute-n64-sym32-6.d: New
	test.
	* testsuite/gas/mips/mips16-pcrel-absolute-pic-n32-4.d: New
	test.
	* testsuite/gas/mips/mips16-pcrel-absolute-pic-n32-6.d: New
	test.
	* testsuite/gas/mips/mips16-pcrel-absolute-pic-n64-4.d: New
	test.
	* testsuite/gas/mips/mips16-pcrel-absolute-pic-n64-6.d: New
	test.
	* testsuite/gas/mips/mips16-pcrel-absolute-pic-n64-sym32-4.d:
	New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-pic-n64-sym32-6.d:
	New test.
	* testsuite/gas/mips/mips16-pcrel-0.l: New stderr output.
	* testsuite/gas/mips/mips16-pcrel-1.l: New stderr output.
	* testsuite/gas/mips/mips16-pcrel-2.l: New stderr output.
	* testsuite/gas/mips/mips16-pcrel-3.l: New stderr output.
	* testsuite/gas/mips/mips16-pcrel-4.l: New stderr output.
	* testsuite/gas/mips/mips16-pcrel-5.l: New stderr output.
	* testsuite/gas/mips/mips16-pcrel-delay-0.l: New stderr output.
	* testsuite/gas/mips/mips16-pcrel-delay-1.l: New stderr output.
	* testsuite/gas/mips/mips16-pcrel-addend-8.l: New stderr output.
	* testsuite/gas/mips/mips16-pcrel-addend-9.l: New stderr output.
	* testsuite/gas/mips/mips16-pcrel-absolute-4.l: New stderr
	output.
	* testsuite/gas/mips/mips16-pcrel-absolute-6.l: New stderr
	output.
	* testsuite/gas/mips/mips16-pcrel-0.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-1.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-2.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-3.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-4.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-5.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-delay-0.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-delay-1.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-addend-4.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-addend-5.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-addend-6.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-addend-7.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-addend-8.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-addend-9.s: New test source.
	* testsuite/gas/mips/mips16-pcrel-absolute-2.s: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-3.s: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-4.s: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-5.s: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-6.s: New test.
	* testsuite/gas/mips/mips16-pcrel-absolute-7.s: New test.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* testsuite/ld-mips-elf/mips16-pcrel-0.d: New test.
	* testsuite/ld-mips-elf/mips16-pcrel-1.d: New test.
	* testsuite/ld-mips-elf/mips16-pcrel-addend-2.d: New test.
	* testsuite/ld-mips-elf/mips16-pcrel-addend-6.d: New test.
	* testsuite/ld-mips-elf/mips16-pcrel-n32-0.d: New test.
	* testsuite/ld-mips-elf/mips16-pcrel-n32-1.d: New test.
	* testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-0.d: New test.
	* testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-1.d: New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2017-05-03 20:47:40 +01:00
Keith Seitz 90cef2edd2 Make sure malloc is linked into gdb.cp/oranking.cc.
On some platforms, e.g., arm-eabi-none, we need to make certain that
malloc is linked into the program because the test suite uses function
calls requiring malloc:

(gdb) p foo101("abc")
evaluation of this expression requires the program to have a function "malloc".

gdb/testsuite/ChangeLog

	* gdb.cp/oranking.cc (dummy): New function to grab malloc.
	(main): Call it.
2017-05-03 12:41:09 -07:00
H.J. Lu b22908217d Adjust testsuite/ld-elf/pr21384.d
Adjust testsuite/ld-elf/pr21384.d to accommodate additional dynamic
symbols on some targets.

	* testsuite/ld-elf/pr21384.d: Adjusted to accommodate
	additional dynamic symbols on some targets.
2017-05-03 07:43:50 -07:00
Alan Hayward f81fdd350e Remove MAX_REGISTER_SIZE from frv-linux-tdep.c
gdb/
	* frv-linux-tdep.c (frv_linux_supply_gregset): Use raw_supply_zeroed.
	* regcache.c (regcache::raw_supply_zeroed): New function.
	* regcache.h (regcache::raw_supply_zeroed): New declaration.
2017-05-03 14:51:40 +01:00
Simon Marchi 35837774a7 gdbarch.sh: Remove commented out TARGET_CHAR_BIT definition
As Pedro commented on the patch "Change field separator in gdbarch.sh",
this commented out definition is probably not useful and should be
removed.  It has been commented out for basically forever, and it
probably serves the same intent as addressable_memory_unit_size.

gdb/ChangeLog:

	* gdbarch.sh: Remove commented out definition of
	TARGET_CHAR_BIT.
	* gdbarch.h: Re-generate.
2017-05-03 09:21:27 -04:00
Sergio Durigan Junior c94fee56f5 Regenerate gdb/{,gdbserver/}configure (for commit be628ab814)
On commit be628ab814, both
common/common.m4 was modified in order to check for the presence of
'termios.h', 'termio.h' and 'sgtty.h'.  However, I forgot to
regenerate both gdb/configure and gdb/gdbserver/configure.  This
commit does that.

gdb/ChangeLog:
2017-05-03  Sergio Durigan Junior  <sergiodj@redhat.com>

	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2017-05-03  Sergio Durigan Junior  <sergiodj@redhat.com>

	* configure: Regenerate.
2017-05-03 09:17:12 -04:00
Nick Clifton e78bb25cb6 Prevent a seg-fault in the assembler when provided with a bogus input source file.
PR gas/20941
	* symbols.c (snapshot_symbol): Handle the case where
	resolve_expression returns a local symbol.
2017-05-03 09:52:01 +01:00
GDB Administrator 35387fdec5 Automatic date update in version.in 2017-05-03 00:00:41 +00:00
Maciej W. Rozycki 82d808edbc MIPS16/GAS: Fix absolute references with PC-relative synthetic instructions
Complement commit 88a7ef1689 ("MIPS16/GAS: Restore unsupported
relocation diagnostics") and also propagate constant expressions, either
already reduced from absolute symbol references or created from literals
in the first place, used as a PC-relative operand with the MIPS16 LA,
LW, DLA and LD synthetic instructions to relaxation, matching the way
forward absolute symbol references have been handled as from the commit
referred and letting relaxation produce any necessary relocations, if
possible, for the absolute value requested to be reproduced at the run
time.

Call `symbol_append' for any expression symbol created for the purpose
of MIPS16 relaxation as with constant expressions now propagated from
earlier on such symbols may make it through and have R_MIPS16_PC16_S1
relocations emitted against, and therefore need to appear in the symbol
table produced.

	gas/
	* config/tc-mips.c (append_insn): Call `symbol_append' for any
	expression symbol created for MIPS16 relaxation.
	(match_mips16_insn): Don't encode a constant value as an
	immediate with a PC-relative operand.

	* testsuite/gas/mips/mips16-pcrel-absolute-1.d: New test.
	* testsuite/gas/mips/mips16-branch-absolute-1.d: New test.
	* testsuite/gas/mips/mips16-branch-absolute-2.d: New test.
	* testsuite/gas/mips/mips16-branch-absolute-addend-1.d: New
	test.
	* testsuite/gas/mips/mips16-branch-absolute-n32-1.d: New test.
	* testsuite/gas/mips/mips16-branch-absolute-n32-2.d: New test.
	* testsuite/gas/mips/mips16-branch-absolute-addend-n32-1.d: New
	test.
	* testsuite/gas/mips/mips16-branch-absolute-n64-1.d: New test.
	* testsuite/gas/mips/mips16-branch-absolute-n64-2.d: New test.
	* testsuite/gas/mips/mips16-branch-absolute-addend-n64-1.d: New
	test.
	* testsuite/gas/mips/mips16-pcrel-absolute-1.l: New stderr
	output.
	* testsuite/gas/mips/mips16-pcrel-absolute-1.s: New test source.
	* testsuite/gas/mips/mips16-branch-absolute-1.s: New test
	source.
	* testsuite/gas/mips/mips16-branch-absolute-2.s: New test
	source.
	* testsuite/gas/mips/mips16-branch-absolute-addend-1.s: New test
	source.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* testsuite/ld-mips-elf/mips16-branch-absolute-1.d: New test.
	* testsuite/ld-mips-elf/mips16-branch-absolute-2.d: New test.
	* testsuite/ld-mips-elf/mips16-branch-absolute-addend-1.d: New
	test.
	* testsuite/ld-mips-elf/mips16-branch-absolute-n32-1.d: New
	test.
	* testsuite/ld-mips-elf/mips16-branch-absolute-n32-2.d: New
	test.
	* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n32-1.d:
	New test.
	* testsuite/ld-mips-elf/mips16-branch-absolute-n64-1.d: New
	test.
	* testsuite/ld-mips-elf/mips16-branch-absolute-n64-2.d: New
	test.
	* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n64-1.d:
	New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2017-05-03 00:15:56 +01:00
H.J. Lu 3d8505928a x86: Add -Wl,--no-as-needed to some TLS tests
* testsuite/ld-i386/tls.exp: Add -Wl,--no-as-needed to
	"TLS without PLT (1)" and "TLS without PLT (3)".
	* testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to
	to "TLS without PLT (3)".
2017-05-02 16:01:39 -07:00
Michael Clark 43e379d74c RISC-V: Change CALL macro to use ra as the temporary address register
e.g.

    1:  auipc ra, %pcrel_hi(symbol)
        jalr  ra, %pcrel_lo(1b)(ra)

The use of ra instead of t1 for address construction provides an
opportunity for a microarchitecture to elide the write of the
destination address, and instead read the target address as an
immediate spread across the fused auipc+jalr pair. The link
register ra in the jalr overwrites the target address temporary.

2017-05-01  Michael Clark  <michaeljclark@mac.com>

	* riscv-opc.c (riscv_opcodes) <call>: Use RA not T1 as a temporary
	register.
2017-05-02 15:19:07 -07:00
Palmer Dabbelt 763a5fa4f3 RISC-V: Allow 32-bit BFD to handle 64-bit objects
We've been telling people that the riscv32-* and riscv64-* toolchains
are exactly the same, but it turns out we were lying: the riscv32-* BFD
doesn't handle 64-bit objects.  This fixes that difference, so the ports
are actually the same.

bfd/ChangeLog

2017-05-01  Palmer Dabbelt  <palmer@dabbelt.com>

        * config.bfd (riscv32-*): Enable rv64.
2017-05-02 15:19:05 -07:00
H.J. Lu 640226f048 Add a test for PR ld/21384
PR ld/21384
	* testsuite/ld-elf/pr21384.d: New file.
	* testsuite/ld-elf/pr21384.dl: Likewise.
	* testsuite/ld-elf/pr21384.ld: Likewise.
	* testsuite/ld-elf/pr21384.s: Likewise.
2017-05-02 13:54:22 -07:00
H.J. Lu 2ecf0cc317 Cast relcount to unsigned long when comparing with sec->reloc_count
The type of relcount is long and the type of sec->reloc_count is
unsigned int.  On 32-bit hosts, GCC issues an error:

objcopy.c:2144:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
       if (relcount > sec->reloc_count)

Cast relcount to unsigned long to silence GCC.

	* objcopy.c (merge_gnu_build_notes): Cast relcount to unsigned
	long when comparing with sec->reloc_count.
2017-05-02 12:16:26 -07:00
Simon Marchi d17f7b365c solib-target: Remove local variables
Now that we use std::vector, these local variables are not very useful.
They're not much shorter than the expressions they stand for.

gdb/ChangeLog:

	* solib-target.c (solib_target_relocate_section_addresses):
	Remove num_section_bases, num_bases, segment_bases variables.
2017-05-02 14:25:43 -04:00
Simon Marchi b560ebd660 Remove definition of VEC (CORE_ADDR)
gdb/ChangeLog:

	* common/gdb_vecs.h (DEF_VEC_I (CORE_ADDR)): Remove.
2017-05-02 13:30:09 -04:00
Simon Marchi f2f46dfcda Use std::vector in lm_info_target
Replace the two VEC fields with std::vector.

gdb/ChangeLog:

	* solib-target.c: Include <vector>
	(struct lm_info_target) <~lm_info_target>: Remove.
	<segment_bases, section_bases>: Change type to
	std::vector<CORE_ADDR>.
	(library_list_start_segment, library_list_start_section,
	library_list_end_library,
	solib_target_relocate_section_addresses): Adjust.
2017-05-02 13:30:08 -04:00
Simon Marchi a0ff9e1ad2 Change return type of gdbarch_software_single_step to vector<CORE_ADDR>
This is a relatively straightforward patch that changes
gdbarch_software_single_step so it returns an std::vector<CORE_ADDR>
instead of a VEC (CORE_ADDR).

gdb/ChangeLog:

	* gdbarch.sh (software_single_step): Change return type to
	std::vector<CORE_ADDR>.
	* gdbarch.c, gdbarch.h: Re-generate.
	* arch/arm-get-next-pcs.c (thumb_deal_with_atomic_sequence_raw):
	Adjust.
	(arm_deal_with_atomic_sequence_raw): Adjust.
	(thumb_get_next_pcs_raw): Adjust.
	(arm_get_next_pcs_raw): Adjust.
	(arm_get_next_pcs): Adjust.
	* arch/arm-get-next-pcs.h (arm_get_next_pcs): Adjust.
	* aarch64-tdep.c (aarch64_software_single_step): Adjust.
	* alpha-tdep.c (alpha_deal_with_atomic_sequence): Adjust.
	(alpha_software_single_step): Adjust.
	* alpha-tdep.h (alpha_software_single_step): Adjust.
	* arm-linux-tdep.c (arm_linux_software_single_step): Adjust.
	* arm-tdep.c (arm_software_single_step): Adjust.
	(arm_breakpoint_kind_from_current_state): Adjust.
	* arm-tdep.h (arm_software_single_step): Adjust.
	* breakpoint.c (insert_single_step_breakpoint): Adjust.
	* cris-tdep.c (cris_software_single_step): Adjust.
	* mips-tdep.c (mips_deal_with_atomic_sequence): Adjust.
	(micromips_deal_with_atomic_sequence): Adjust.
	(deal_with_atomic_sequence): Adjust.
	(mips_software_single_step): Adjust.
	* mips-tdep.h (mips_software_single_step): Adjust.
	* moxie-tdep.c (moxie_software_single_step): Adjust.
	* nios2-tdep.c (nios2_software_single_step): Adjust.
	* ppc-tdep.h (ppc_deal_with_atomic_sequence): Adjust.
	* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
	* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
	* s390-linux-tdep.c (s390_software_single_step): Adjust.
	* sparc-tdep.c (sparc_software_single_step): Adjust.
	* spu-tdep.c (spu_software_single_step): Adjust.
	* tic6x-tdep.c (tic6x_software_single_step): Adjust.

gdb/gdbserver/ChangeLog:

	* linux-arm-low.c (arm_gdbserver_get_next_pcs): Adjust to
	software_single_step change of return type to
	std::vector<CORE_ADDR>.
	* linux-low.c (install_software_single_step_breakpoints):
	Likewise.
	* linux-low.h (install_software_single_step_breakpoints):
	Likewise.
2017-05-02 13:30:07 -04:00
Simon Marchi ea480a306d Change field separator in gdbarch.sh
The fields in the description of the gdbarch interface are separated
using colons.  That becomes a problem if we want to use things like
std::vector in it. This patch changes the field separator to use
semicolons instead.

I think there's very little chance we'll ever want to use a semicolon in
one of the fields, but if you think another character would be more
appropriate, let me know.

gdb/ChangeLog:

	* gdbarch.sh: Use semi-colon as field separator instead of colon.
	* gdbarch.h: Re-generate.
2017-05-02 13:30:07 -04:00
Nick Clifton 1395c6ce47 Don't merge notes when the relocs associated with them cannot be reliably deleted.
* objcopy.c (merge_gnu_build_notes): Disable merge if there are
	more internal relocs than external relocs.
2017-05-02 16:55:31 +01:00
Alan Modra 73ec947d59 PR 21384, --dynamic-list regression with f02cb058
The commit to "Always descend into output section statements in
lang_do_assignments" meant that linker script symbols were not
bfd_link_hash_new when ld called bfd_elf_record_link_assignment.
This patch corrects that problem by testing h->non_elf instead.

	PR 21384
	* elflink.c (bfd_elf_link_mark_dynamic_symbol): Test h->non_elf
	rather than h->root.type == bfd_link_hash_new.
	(bfd_elf_record_link_assignment): Similarly, call
	bfd_elf_link_mark_dynamic_symbol when h->non_elf.
2017-05-03 00:51:06 +09:30
Maciej W. Rozycki a4ddc54ec1 MIPS16/opcodes: Keep the LSB of PC-relative offsets in disassembly
Correct the disassembly of the PC-relative immediate argument of the
MIPS16 synthetic LA, LW, DLA and LD instructions and do not mask the
LSB, which in this case is a part of the data address rather than the
ISA bit and has to be fully presented.

	opcodes/
	* mips-dis.c (print_insn_arg): Only clear the ISA bit for jumps
	and branches and not synthetic data instructions.

	binutils/
	* testsuite/binutils-all/mips/mips16-undecoded.d: Adjust the
	disassembly of PC-relative LA and LW synthetic instructions.
2017-05-02 11:58:44 +01:00
Nick Clifton 39ff1b79f6 Prevent memory exhaustion from a corrupt PE binary with an overlarge number of relocs.
PR 21440
	* objdump.c (dump_relocs_in_section): Check for an excessive
	number of relocs before attempting to dump them.
2017-05-02 11:54:53 +01:00
Tim Wiederhake d050f7d7f4 Python: Introduce gdb.Instruction class
This adds a generic instruction class to Python and has gdb.RecordInstruction
inherit from it.
2017-05-02 11:35:54 +02:00
Tim Wiederhake 14f819c8c5 Python: Move and rename gdb.BtraceFunction
Remove gdb.BtraceFunctionCall and replace by gdb.FunctionSegment.  Additionally,
rename prev_segment and next_segment to prev and next.
2017-05-02 11:35:54 +02:00
Tim Wiederhake 0ed5da759e Python: Move and rename gdb.BtraceInstruction
Remove gdb.BtraceInstruction and replace by gdb.RecordInstruction.
2017-05-02 11:35:54 +02:00
Tim Wiederhake 913aeadd9d Python: Introduce gdb.RecordGap class
As discussed here: https://sourceware.org/ml/gdb-patches/2017-04/msg00157.html

A gap is not an instruction and it should not pretend to be one.
gdb.Record.instruction_history is now a list of gdb.RecordInstruction and
gdb.RecordGap objects.  This allows the user to deal with Gaps in the record
in a more sane way.
2017-05-02 11:35:54 +02:00
Tim Wiederhake a3be24ad59 Python: Remove ptid from gdb.Record interface
As discussed here: https://sourceware.org/ml/gdb-patches/2017-04/msg00166.html
2017-05-02 11:35:54 +02:00
Tim Wiederhake ae20e79ae8 Python: Use correct ptid in btrace recording
The user would always get the instruction_history and function_call_history
objects of the current thread, not the thread for which the gdb.Record object
was created.

The attached testcase fails without this patch and passes with the patch.
2017-05-02 11:35:54 +02:00
Tim Wiederhake 8d0050ea19 Python: Fix indentation in py-record-btrace.c 2017-05-02 11:35:54 +02:00
Bernd Edlinger fe50e98c9a Fix value in comment of disassembled ARM type A opcodes.
* arm-dis.c (print_insn_thumb32): Fix value_in_comment.
2017-05-02 10:28:09 +01:00
GDB Administrator 122a483d4f Automatic date update in version.in 2017-05-02 00:00:39 +00:00
H.J. Lu 0aae7e72a2 x86: Run GNU2 TLS tests with working GNU2 TLS support
Check if GNU2 TLS really works before running GNU2 TLS tests.

	* testsuite/ld-i386/tls.exp: Run GNU2 TLS tests only if there
	is working GNU2 TLS support.
	* testsuite/ld-x86-64/tls.exp: Likewise.
	* testsuite/lib/ld-lib.exp (check_gnu2_tls_available): New proc.
2017-05-01 11:02:55 -07:00
Joel Brobecker 3f380b5027 gdb/MAINTAINERS: Move Daniel J and Mark to the Past Maintainers section.
gdb/ChangeLog:

        * MAINTAINERS: Move Daniel Jacobowitz and Mark Kettenis to
        the past maintainers section.
2017-05-01 10:02:51 -07:00
Alan Modra ee7e95efb9 merge_gnu_build_notes reloc deletion
If moving relocs, the next reloc to look at is at the same location.

	* objcopy.c (merge_gnu_build_notes): Correct code deleting
	relocs.
2017-05-01 14:13:31 +09:30
GDB Administrator 6224c85813 Automatic date update in version.in 2017-05-01 00:00:35 +00:00
GDB Administrator 020bf56c8e Automatic date update in version.in 2017-04-30 00:00:31 +00:00
Alan Modra a941291cab PR21432, buffer overflow in perform_relocation
The existing reloc offset range tests didn't catch small negative
offsets less than the size of the reloc field.

	PR 21432
	* reloc.c (reloc_offset_in_range): New function.
	(bfd_perform_relocation, bfd_install_relocation): Use it.
	(_bfd_final_link_relocate): Likewise.
2017-04-29 18:59:37 +09:30
Sergio Durigan Junior 45ce1b47e4 Make environ.exp run on all platforms (and create info-program.exp)
This has been on my TODO list for a while.  There's a really old bug
about this (PR testsuite/8595), and there was no reason for
environ.exp to be specific for hppa* targets.  So this patch removes
this constraint, modernizes the testcase, and cleans up some things.
Most of the tests remained, and some were rewritten (especially the
one that checks if "show environment" works, which is something kind
of hard to do).

As a bonus, I'm adding a separated info-program.exp file containing
all the tests related to "info program" that were present on
environ.exp.

Tested locally, everything still passes.

gdb/testsuite/ChangeLog:
2017-04-28  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR testsuite/8595
	* gdb.base/environ.exp: Make test available in all architectures.
	Move bits related to "info program" testing to
	gdb.base/info-program.exp.  Rewrite tests to use the two new
	procedures mentione below.
	(test_set_show_env_var) New procedure.
	(test_set_show_env_var_equal): Likewise.
	* gdb.base/info-program.exp: New file.
2017-04-28 20:29:20 -04:00
GDB Administrator a93866c8bf Automatic date update in version.in 2017-04-29 00:00:38 +00:00
Yao Qi 0749542484 Remove cleanup in get_return_value
With regcache ctor, we can use it to create local object in
get_return_value (), so that the cleanup can be removed.

gdb:

2017-04-28  Yao Qi  <yao.qi@linaro.org>

	* infcmd.c (get_return_value): Use regcache ctor, and remove
	cleanup.
2017-04-28 22:48:42 +01:00