rebuild target-delegates.c

target-delegates.c was out of date.  This patch rebuilds it.
Built and regtested on x86-64 Fedora 20.
Committed as obvious.

2014-07-16  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
reformat comment in target.h

A comment in target.h went past the column limit.  This patch
reformats it.  I'm pushing this as obvious.

2014-07-16  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_delete_record>: Reformat
	comment.
Add test for string evaluation with "debug expression" on

As Joel pointed out in...
https://sourceware.org/ml/gdb-patches/2014-07/msg00391.html
...it would be nice to add a test for that.

Tested on Linux x86_64 (Ubuntu 14.10).

gdb/testsuite/ChangeLog

2014-07-15  Simon Marchi  <simon.marchi@ericsson.com>

	* gdb.base/debug-expr.exp: Test string evaluation with
	"debug expression" on.
Properly match PLT entry against .got.plt relocation

Relocations against .got.plt section may not be in the same order as
entries in PLT section.  It is incorrect to assume that the Ith reloction
index against .got.plt section always maps to the (I + 1)th entry in PLT
section.  This patch matches the .got.plt relocation offset/index in PLT
entry against the index in .got.plt relocation table.  It only checks
R_*_JUMP_SLOT and R_*_IRELATIVE relocations.  It ignores R_*_TLS_DESC
and R_*_TLSDESC relocations since they have different PLT entries.

bfd/

	PR binutils/17154
	* elf32-i386.c (elf_i386_plt_sym_val): Only match R_*_JUMP_SLOT
	and R_*_IRELATIVE relocation offset with PLT entry.
	* elf64-x86-64.c (elf_x86_64_plt_sym_val): Likewise.
	(elf_x86_64_plt_sym_val_offset_plt_bnd): New.
	(elf_x86_64_get_synthetic_symtab): Use it.

ld/testsuite/

	PR binutils/17154
	* ld-ifunc/pr17154-i386.d: New file.
	* ld-ifunc/pr17154-x86-64.d: Likewise.
	* ld-ifunc/pr17154-x86.s: Likewise.
	* ld-x86-64/bnd-ifunc-2.d: Likewise.
	* ld-x86-64/bnd-ifunc-2.s: Likewise.
	* ld-x86-64/mpx.exp: Run bnd-ifunc-2.
	* ld-x86-64/tlsdesc-nacl.pd: Updated.
	* ld-x86-64/tlsdesc.pd: Likewise.
Match PLT entry only for ELFOSABI_GNU input

	* elf32-i386.c (elf_i386_plt_sym_val): Match PLT entry only for
	ELFOSABI_GNU input.
	* elf64-x86-64.c (elf_x86_64_plt_sym_val): Likewise.
	(elf_x86_64_plt_sym_val_offset_plt_bnd): Likewise.
gdb.trace/tfile.c: Remove Thumb bit in one more more, general cleanup

I noticed that the existing code casts a function's address to 'long',
but that doesn't work correctly on some ABIs, like Win64, where long
is 32-bit and while pointers are 64-bit:

  func_addr = (long) &write_basic_trace_file;

Fixing that showed there's actually another place in the file that
writes a function address to file, and therefore should clear the
Thumb bit.  This commit adds a macro+function pair to centralize the
Thumb bit handling, and uses it in both places.

The rest is just enough changes to make the file build without
warnings with "-Wall -Wextra" with x86_64-w64-mingw32-gcc and
i686-w64-mingw32-gcc cross compilers, and with -m32/-m64 on x86_64
GNU/Linux.  Currently with x86_64-w64-mingw32-gcc we get:

  $ x86_64-w64-mingw32-gcc tfile.c  -Wall -DTFILE_DIR=\"\"
  tfile.c: In function 'start_trace_file':
  tfile.c:51:23: error: 'S_IRGRP' undeclared (first use in this function)
	 S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
			 ^
  tfile.c:51:23: note: each undeclared identifier is reported only once for each function it appears in
  tfile.c:51:31: error: 'S_IROTH' undeclared (first use in this function)
	 S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
				 ^
  tfile.c: In function 'add_memory_block':
  tfile.c:79:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     ll_x = (unsigned long) addr;
	    ^
  tfile.c: In function 'write_basic_trace_file':
  tfile.c:113:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     func_addr = (long) &write_basic_trace_file;
		 ^
  tfile.c:137:3: warning: passing argument 1 of 'add_memory_block' from incompatible pointer type [enabled by default]
     add_memory_block (&testglob, sizeof (testglob));
     ^
  tfile.c:72:1: note: expected 'char *' but argument is of type 'int *'
   add_memory_block (char *addr, int size)
   ^
  tfile.c:139:3: warning: passing argument 1 of 'add_memory_block' from incompatible pointer type [enabled by default]
     add_memory_block (&testglob2, 1);
     ^
  tfile.c:72:1: note: expected 'char *' but argument is of type 'int *'
   add_memory_block (char *addr, int size)
   ^
  tfile.c: In function 'write_error_trace_file':
  tfile.c:185:3: warning: implicit declaration of function 'alloca' [-Wimplicit-function-declaration]
     char *hex = alloca (len * 2 + 1);
     ^
  tfile.c:185:15: warning: incompatible implicit declaration of built-in function 'alloca' [enabled by default]
     char *hex = alloca (len * 2 + 1);
		 ^
  tfile.c:211:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
	(long) &write_basic_trace_file);
      ^

Tested on x86_64 Fedora 20, -m64 and -m32.
Tested by Yao on arm targets.

gdb/testsuite/
2014-07-16  Pedro Alves  <palves@redhat.com>

	* gdb.trace/tfile.c: Include unistd.h and stdint.h.
	(start_trace_file): Guard S_IRGRP and S_IROTH uses behind #ifdef.
	(tfile_write_64, tfile_write_16, tfile_write_8, tfile_write_addr)
	(tfile_write_buf): New functions.
	(add_memory_block): Rewrite using the above.
	(adjust_function_address): New function.
	(FUNCTION_ADDRESS): New macro.
	(write_basic_trace_file): Remove short_x local, and use
	tfile_write_16. Change type of func_addr local to unsigned long
	long.  Use FUNCTION_ADDRESS instead of handling the Thumb bit
	here.  Cast argument of add_memory_block to char pointer.
	(write_error_trace_file): Avoid alloca.  Use FUNCTION_ADDRESS.
	(main): Remove parameters.
	* gdb.trace/tfile.exp: Remove nowarnings.
Linux: Use kill_lwp/tkill instead of kill when killing a process

Since we use tkill everywhere, using kill to try to kill each lwp
individually looks suspiciously odd.  We should really be using tgkill
everywhere, but at least while we don't get there this makes us
consistent.

gdb/gdbserver/
2014-07-16  Pedro Alves  <palves@redhat.com>

	* linux-low.c (linux_kill_one_lwp): Use kill_lwp, not kill.

gdb/
2014-07-16  Pedro Alves  <palves@redhat.com>

	* linux-nat.c (kill_callback): Use kill_lwp, not kill.
or1k: increase linux TEXT_START_ADDR to 0x2000

Override the default value of 0x0000 defined in
TEXT_START_ADDR to avoid linux executables to be mapped
at zero page.

ld/
	* emulparams/elf32or1k_linux.sh (TEXT_START_ADDR): Increase from
	0x0 to first page boundary at 0x2000.
daily update
Fix 17170.

	* maint.c (count_symtabs_and_blocks): Handle NULL
	current_program_space.
	(report_command_stats): Check global enabled flag in addition to
	recorded enabled flag.
	(make_command_stats_cleanup): Handle msg_type == 0, startup.

	testsuite/
	* gdb.base/maint.exp: Update testing of per-command stats.
Add reference to PR 17170 to previous entry.
PR 17170 - testcase for GDB global --statistics regression.

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

	PR gdb/17170
	* gdb.base/statistics.exp: New file.

Message-ID: <20140712174217.GA1478@host2.jankratochvil.net>
PR 17170 - testcase for GDB global --statistics regression - fix up.

Add missing file to previous entry.
Properly handle EVEX register aliases

gas/

	* config/tc-i386.c (parse_register): Set need_vrex.

gas/testsuite/

	* gas/i386/x86-64-equ.d: New.
	* gas/i386/x86-64-equ.s: New.
	* gas/i386/i386.exp: Run x86-64-equ.
daily update
move exec_make_note_section earlier

This patch moves exec_make_note_section a bit earlier in exec.c.  This
lets us remove an otherwise unnecessary forward declaration and it
also makes the file a bit more in line with other code, as now
_initialize_exec is the final function in the file.

Tested by rebuilding.
I'm committing this as obvious.

2014-07-18  Tom Tromey  <tromey@redhat.com>

	* exec.c (exec_make_note_section): Move earlier.
clean up some target delegation cases

This patch cleans up some minor inconsistencies in target delegation.
It's primary purpose is to avoid confusion in the code.  A few spots
were checking the "beneath" target; however this can only be NULL for
the dummy target, so such tests are not needed.  Some other spots were
iterating over the beneath targets, looking for a method
implementation.  This is not needed for methods handled by
make-target-delegates, as there is always an implementation.

2014-07-18  Tom Tromey  <tromey@redhat.com>

	PR gdb/17130:
	* spu-multiarch.c (spu_region_ok_for_hw_watchpoint)
	(spu_fetch_registers, spu_store_registers, spu_xfer_partial)
	(spu_search_memory, spu_mourn_inferior): Simplify delegation.
	* linux-thread-db.c (thread_db_pid_to_str): Always delegate.
	* windows-nat.c (windows_xfer_partial): Always delegate.
	* record-btrace.c (record_btrace_xfer_partial): Simplify
	delegation.
	(record_btrace_fetch_registers, record_btrace_store_registers)
	(record_btrace_prepare_to_store, record_btrace_resume)
	(record_btrace_wait, record_btrace_find_new_threads)
	(record_btrace_thread_alive): Likewise.
	* procfs.c (procfs_xfer_partial): Always delegate.
	* corelow.c (core_xfer_partial): Always delegate.
	* sol-thread.c (sol_find_new_threads): Simplify delegation.
fix PR gdb/17130

This fixes PR gdb/17130.

The bug is that some code in utils.c was not updated during the target
delegation change:

  if (job_control
      /* If there is no terminal switching for this target, then we can't
         possibly get screwed by the lack of job control.  */
      || current_target.to_terminal_ours == NULL)
    fatal ("Quit");
  else
    fatal ("Quit (expect signal SIGINT when the program is resumed)");

After the delegation change, to_terminal_ours will never be NULL.

I think this bug can be seen before the target delegation change by
enabling target debugging -- this would also cause to_terminal_ours to
be non-NULL.

The fix is to introduce a new target_supports_terminal_ours function,
that properly checks the target stack.  This is not perhaps ideal, but
I think is a reasonable-enough approach, and in keeping with some
other existing code of the same form.

This patch also fixes a similar bug in target_supports_delete_record.

2014-07-18  Tom Tromey  <tromey@redhat.com>

	PR gdb/17130:
	* utils.c (quit): Use target_supports_terminal_ours.
	* target.h (target_supports_terminal_ours): Declare.
	* target.c (target_supports_delete_record): Don't check
	to_delete_record against NULL.
	(target_supports_terminal_ours): New function.
fix calls to find_target_beneath

A long time ago Pedro pointed out that there are some calls to
find_target_beneath that pass in an explicit target_ops; but which
should instead use the ops provided to the method in question.  See:

    https://sourceware.org/ml/gdb-patches/2014-01/msg00429.html

This patch is just a minor cleanup to fix all such calls.  There were
only three.

2014-07-18  Tom Tromey  <tromey@redhat.com>

	* spu-multiarch.c (spu_region_ok_for_hw_watchpoint): Pass "self"
	to find_target_beneath.
	* ravenscar-thread.c (ravenscar_prepare_to_store): Pass "ops" to
	find_target_beneath.
	(ravenscar_mourn_inferior): Pass "self" to find_target_beneath.
make exec_ops static

While working on some target stack changes, I noticed that exec_ops is
only used from exec.c.  This patch makes it "static".  This is cleaner
and makes it simpler to reason about the use of the target.

Tested by rebuilding.
I'm checking this in as obvious.

2014-07-18  Tom Tromey  <tromey@redhat.com>

	* exec.c (exec_ops): Now static.
	* exec.h (exec_ops): Don't declare.