1. 28 Jun, 2016 4 commits
    • Yao Qi's avatar
      [AArch64] Use int64_t for address offset · 2ac09a5b
      Yao Qi authored
      In AArch64 displaced stepping and fast tracepoint, GDB/GDBserver needs
      to check whether the offset can fit in the range.  We are using int32_t
      for offset, it is sufficient to get an offset from an instruction, but
      it is not enough to get an offset from two addresses.  For example,
      we have a BL in shared lib which is at 0x0000002000040774, and the
      scratch pad for displaced stepping is at 0x400698.  The offset can't
      fit in 28 bit imm.  However, since we are using int32_t for offset, GDB
      thinks the offset can fit it, and generate the B instruction with wrong
      offset.
      
      It fixes the following fail,
      
      -FAIL: gdb.base/dso2dso.exp: next over call to sub2
      
      gdb:
      
      2016-06-28  Yao Qi  <yao.qi@linaro.org>
      
      	* aarch64-tdep.c (aarch64_displaced_step_b): Use int64_t for
      	variable new_offset.
      
      gdb/gdbserver:
      
      2016-06-28  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-aarch64-low.c (aarch64_ftrace_insn_reloc_b): Use int64_t
      	for variable new_offset.
      	(aarch64_ftrace_insn_reloc_b_cond): Likewise.
      	(aarch64_ftrace_insn_reloc_cb): Likewise.
      	(aarch64_ftrace_insn_reloc_tb): Likewise.
      	(aarch64_install_fast_tracepoint_jump_pad): Likewise.  Use
      	PRIx64 instead of PRIx32.
      2ac09a5b
    • Yao Qi's avatar
      Implement get_syscall_trapinfo for arm-linux · 79e7fd4f
      Yao Qi authored
      gdb/gdbserver:
      
      2016-06-28  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-arm-low.c (arm_get_syscall_trapinfo): New function.
      	(the_low_target): Install arm_get_syscall_trapinfo.
      79e7fd4f
    • Yao Qi's avatar
      Implement get_syscall_trapinfo for aarch64-linux · 061fc021
      Yao Qi authored
      gdb/gdbserver:
      
      2016-06-28  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-aarch64-low.c (aarch64_get_syscall_trapinfo): New
      	function.
      	(the_low_target): Install aarch64_get_syscall_trapinfo.
      061fc021
    • Yao Qi's avatar
      Remove parameter sysret from linux_target_ops.get_syscall_trapinfo · 4cc32bec
      Yao Qi authored
      When I implement linux_target_ops.get_syscall_trapinfo for aarch64 and arm,
      I find the second parameter sysret isn't used at all.  In RSP, we don't
      need syscall return value either, because GDB can figure out the return
      value from registers content got by 'g' packet.
      
      This patch is to remove them.
      
      gdb/gdbserver:
      
      2016-06-28  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-low.c (get_syscall_trapinfo): Remove parameter sysret.
      	Callers updated.
      	* linux-low.h (struct linux_target_ops) <get_syscall_trapinfo>:
      	Remove parameter sysno.
      	* linux-x86-low.c (x86_get_syscall_trapinfo): Remove parameter
      	sysret.
      4cc32bec
  2. 21 Jun, 2016 1 commit
    • Andreas Arnez's avatar
      S390 gdbserver: Mark local funcs/vars as static · 782c1122
      Andreas Arnez authored
      Compiling with '-Wmissing-declarations' yields warnings in
      linux-s390-low.c.  To fix this, mark appropriate functions as static.
      
      gdb/gdbserver/ChangeLog:
      
      	* linux-s390-low.c (s390_emit_eq_goto): Mark function static.
      	(s390_emit_ne_goto): Likewise.
      	(s390_emit_lt_goto): Likewise.
      	(s390_emit_le_goto): Likewise.
      	(s390_emit_gt_goto): Likewise.
      	(s390_emit_ge_goto): Likewise.
      	(s390x_emit_eq_goto): Likewise.
      	(s390x_emit_ne_goto): Likewise.
      	(s390x_emit_lt_goto): Likewise.
      	(s390x_emit_le_goto): Likewise.
      	(s390x_emit_gt_goto): Likewise.
      	(s390x_emit_ge_goto): Likewise.
      	(s390_emit_ops_impl): Mark variable static.
      	(s390x_emit_ops): Likewise.
      782c1122
  3. 17 Jun, 2016 5 commits
    • Yao Qi's avatar
      Handle reinsert breakpoints for vforked child · 2e7b624b
      Yao Qi authored
      When a thread is doing step-over with reinsert breakpoint, and the
      instruction executed is a syscall doing vfork, both parent and child
      share the memory, so the reinsert breakpoint in the space is visible
      to both of them.  Also, removing the reinsert breakpoints from the
      child will effectively remove them from the parent.  We should
      carefully manipulate reinsert breakpoints for both processes.
      
      What we are doing here is that
      
       - uninsert reinsert breakpoints from the parent before cloning the
         breakpoint list.  We use "uninsert" instead of "remove", because
         we need to "reinsert" them back after vfork is done.  In fact,
         "uninsert" removes them from both child and parent process space.
       - reinsert breakpoints in parent process are still copied to child's
         breakpoint list,
       - remove them from child's breakpoint list as what we did for fork,
         at this point, reinsert breakpoints are removed from the child and
         the parent, but they are still tracked by the parent's breakpoint
         list,
       - once vfork is done, "reinsert" them back to the parent,
      
      gdb/gdbserver:
      
      2016-06-17  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-low.c (handle_extended_wait): Call
      	uninsert_reinsert_breakpoints for the parent process.  Remove
      	reinsert breakpoints from the child process.  Reinsert them to
      	the parent process when vfork is done.
      	* mem-break.c (uninsert_reinsert_breakpoints): New function.
      	(reinsert_reinsert_breakpoints): New function.
      	* mem-break.h (uninsert_reinsert_breakpoints): Declare
      	(reinsert_reinsert_breakpoints): Declare.
      2e7b624b
    • Yao Qi's avatar
      Delete reinsert breakpoints from forked child · 8a81c5d7
      Yao Qi authored
      When a thread is stepping over a syscall instruction with software
      single step, GDBserver inserts reinsert breakpoints at the next pcs.
      If the syscall call is fork, the forked child has reinsert breakpoint
      in its space, and GDBserver clones parent's breakpoint list to child's.
      When GDBserver resumes the child, its bp_reinsert is zero, but has
      reinsert breakpoints, so the following assert is triggered if I apply
      the patch extending step-over-syscall.exp.
      
      gdb/gdbserver/linux-low.c:4292: A problem internal to GDBserver has been detected.^M
      void linux_resume_one_lwp_throw(lwp_info*, int, int, siginfo_t*): Assertion `!has_reinsert_breakpoints (proc)' failed.
      
      gdb/gdbserver:
      
      2016-06-17  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-low.c (handle_extended_wait): If the parent is doing
      	step-over, remove the reinsert breakpoints from the forked child.
      8a81c5d7
    • Yao Qi's avatar
      Step over exit with reinsert breakpoints · f50bf8e5
      Yao Qi authored
      This patch fixes a GDBserver crash when one thread is stepping over
      a syscall instruction which is exit.  Step-over isn't finished due
      to the exit, but GDBserver doesn't clean up the state of step-over,
      so in the wait next time, GDBserver will wait on step_over_bkpt,
      which is already exited, and GDBserver crashes because
      'requested_child' is NULL.  See gdbserver logs below,
      
      Need step over [LWP 14858]? yes, found breakpoint at 0x2aaaaad91307^M
      proceed_all_lwps: found thread 14858 needing a step-over^M
      Starting step-over on LWP 14858.  Stopping all threads^M
      >>>> entering void stop_all_lwps(int, lwp_info*)
      ....
      <<<< exiting void stop_all_lwps(int, lwp_info*)^M
      Done stopping all threads for step-over.^M
      pc is 0x2aaaaad91307^M
      Writing 0f to 0x2aaaaad91307 in process 14858^M
      Could not find fast tracepoint jump at 0x2aaaaad91307 in list (uninserting).^M
        pending reinsert at 0x2aaaaad91307^M
        step from pc 0x2aaaaad91307^M
      Resuming lwp 14858 (step, signal 0, stop not expected)^M
      
       # Start step-over for LWP 14858
      
      >>>> entering ptid_t linux_wait_1(ptid_t, target_waitstatus*, int)
      ....
      LLFE: 14858 exited.
      ...
      <<<< exiting ptid_t linux_wait_1(ptid_t, target_waitstatus*, int)
      
        # LWP 14858 exited
      .....
      >>>> entering ptid_t linux_wait_1(ptid_t, target_waitstatus*, int)^M
      linux_wait_1: [<all threads>]^M
      step_over_bkpt set [LWP 14858.14858], doing a blocking wait
      
        # but step_over_bkpt is still LWP 14858, which is wrong
      
      The fix is to finish step-over if it is ongoing, and unsuspend other
      threads.  Without the fix in linux-low.c, GDBserver will crash in
      with running gdb.base/step-over-exit.exp.
      
      gdb/gdbserver:
      
      2016-06-17  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-low.c (unsuspend_all_lwps): Declare.
      	(linux_low_filter_event): If thread exited, call finish_step_over.
      	If step-over is finished, unsuspend other threads.
      
      gdb/testsuite:
      
      2016-06-17  Yao Qi  <yao.qi@linaro.org>
      
      	* gdb.base/step-over-exit.c: New.
      	* gdb.base/step-over-exit.exp: New.
      f50bf8e5
    • Yao Qi's avatar
      More assert checks on reinsert breakpoint · 8376a3cb
      Yao Qi authored
      This patch adds more asserts, so the incorrect or sub-optimal
      reinsert breakpoints manipulations (from the tests in the following
      patches) can trigger them.
      
      gdb/gdbserver:
      
      2016-06-17  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-low.c (linux_resume_one_lwp_throw): Assert
      	has_reinsert_breakpoints returns false.
      	* mem-break.c (delete_disabled_breakpoints): Assert
      	bp type isn't reinsert_breakpoint.
      8376a3cb
    • Yao Qi's avatar
      Switch to current thread in finish_step_over · f79b145d
      Yao Qi authored
      This patch adds some sanity check that reinsert breakpoints must be
      there when doing step-over on software single step target.  The check
      triggers an assert when running forking-threads-plus-breakpoint.exp
      on arm-linux target,
      
       gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M
       int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed.
      
      the error happens when GDBserver has already resumed a thread of
      process A for step-over (and wait for it hitting reinsert breakpoint),
      but receives detach request for process B from GDB, which is shown in
      the backtrace below,
      
       (gdb) bt
       #2  0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703
       #3  0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749
       #4  complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760
       #5  linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503
       #6  0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974
       #7  handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347
       #8  0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429
       #9  0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184
       #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547
       #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719
       #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804
      
      the sanity check tries to find the reinsert breakpoint from process B,
      but nothing is found.  It is wrong, we need to search in process A,
      since we started step-over of a thread of process A.
      
       (gdb) p lwp->thread->entry.id
       $3 = {pid = 25120, lwp = 25131, tid = 0}
       (gdb) p current_thread->entry.id
       $4 = {pid = 25228, lwp = 25228, tid = 0}
      
      This patch switched current_thread to the thread we are doing step-over
      in finish_step_over.
      
      gdb/gdbserver:
      
      2016-06-17  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-low.c (maybe_hw_step): New function.
      	(linux_resume_one_lwp_throw): Call maybe_hw_step.
      	(finish_step_over): Switch current_thread to lwp temporarily,
      	and assert has_reinsert_breakpoints returns true.
      	(proceed_one_lwp): Call maybe_hw_step.
      	* mem-break.c (has_reinsert_breakpoints): New function.
      	* mem-break.h (has_reinsert_breakpoints): Declare.
      f79b145d
  4. 03 Jun, 2016 1 commit
    • Jon Turney's avatar
      Fix C++ build for Cygwin · 0ae534d2
      Jon Turney authored
      gdb/ChangeLog:
      
      2016-06-02  Jon Turney  <jon.turney@dronecode.org.uk>
      
      	* windows-nat.c (handle_output_debug_string): Return type of
      	gdb_signal_from_host() is gdb_signal, not an int.
      	(windows_get_exec_module_filename): Add pointer casts for C++.
      
      gdb/gdbserver/ChangeLog:
      
      2016-06-02  Jon Turney  <jon.turney@dronecode.org.uk>
      
      	* win32-low.c (win32_create_inferior): Add pointer casts for C++.
      0ae534d2
  5. 17 May, 2016 1 commit
    • Yao Qi's avatar
      Use unsuspend_all_lwps · fcdad592
      Yao Qi authored
      This patch is to replace find_inferior (&all_threads, unsuspend_one_lwp, NULL)
      with unsuspend_all_lwps (NULL), which is shorter.  They are equivalent
      to each other.
      
      gdb/gdbserver:
      
      2016-05-17  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-low.c (linux_stabilize_threads): Call unsuspend_all_lwps
      	instead of find_inferior.
      fcdad592
  6. 05 May, 2016 3 commits
    • Simon Marchi's avatar
      Fix ChangeLog entry format · cbe14bcf
      Simon Marchi authored
      cbe14bcf
    • Yao Qi's avatar
      Initialize res in get_next_pcs_read_memory_unsigned_integer · 9e784964
      Yao Qi authored
      This patch initialize res to zero, otherwise, it may have some garbage
      bits after the *the_target->read_memory call.
      
      gdb/gdbserver:
      
      2016-05-05  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-arm-low.c (get_next_pcs_read_memory_unsigned_integer):
      	Initialize res to zero.
      9e784964
    • Yao Qi's avatar
      Change type of cpsr in arm_sigreturn_next_pc · cf2ebb6e
      Yao Qi authored
      Variable cpsr holds the value of cpsr register, which is 32-bit.  It
      is better to explicitly use uint32_t.
      
      gdb/gdbserver:
      
      2016-05-05  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-arm-low.c (arm_sigreturn_next_pc): Change type of cpsr
      	to uint32_t.
      cf2ebb6e
  7. 04 May, 2016 1 commit
    • Ulrich Weigand's avatar
      [spu] Fix C++ build problems · c1aebf87
      Ulrich Weigand authored
      ChangeLog:
      
      	* spu-linux-nat.c (spu_bfd_iovec_pread): Add pointer cast for C++.
      	(spu_bfd_open): Likewise.
      
      gdbserver/ChangeLog:
      
      	* spu-low.c (fetch_ppc_register): Cast PowerPC-Linux-specific value
      	used as first ptrace argument to PTRACE_TYPE_ARG1 for C++.
      	(fetch_ppc_memory_1, store_ppc_memory_1): Likewise.
      c1aebf87
  8. 28 Apr, 2016 1 commit
    • Par Olsson's avatar
      Fix write endianness/size problem for fast tracepoint enabled flag · 35fd2deb
      Par Olsson authored
      I am sending this fix on behalf of Par Olsson, as a follow-up of this
      one:
      
      https://www.sourceware.org/ml/gdb-patches/2015-10/msg00196.html
      
      This problem is exposed when enabling/disabling fast tracepoints on big
      endian machines.  The flag is defined as an int8_t, but is written from
      gdbserver as an integer (usually 32 bits).  When the agent code reads it
      as an int8_t, it only considers the most significant byte, which is
      always 0.
      
      Also, we were writing 32 bits in an 8 bits field, so the write would
      overflow, but since the following bytes are padding (the next field is
      an uint64_t), it luckily didn't cause any issue on little endian
      systems.
      
      The fix was originally tested on ARM big endian systems, but I don't
      have access to such a system.  However, thanks to Marcin's PowerPC fast
      tracepoint patches and gcc110 (big endian Power7) on the gcc compile
      farm, I was able to reproduce the problem, test the fix and write a
      test (the following patch).
      
      gdb/gdbserver/ChangeLog:
      
      YYYY-MM-DD  Par Olsson  <par.olsson@windriver.com>
      
      	* tracepoint.c (write_inferior_int8): New function.
      	(cmd_qtenable_disable): Write enable flag using
      	write_inferior_int8.
      35fd2deb
  9. 25 Apr, 2016 2 commits
    • Yao Qi's avatar
      Resume the inferior with signal rather than stepping over · 484b3c32
      Yao Qi authored
      When GDBserver steps over a breakpoint using software single step, it
      enqueues the signal, single step and deliver the signal in the next
      resume if step over is not needed.  In this way, the program won't
      receive the signal if the conditional breakpoint is set a branch to
      self instruction, because the step over is always needed.
      
      This patch removes the restriction that don't deliver the signal to
      the inferior if we are trying to reinsert a breakpoint for software
      single step and change the decision on resume vs. step-over when the
      LWP has pending signals to deliver.
      
      gdb/gdbserver:
      
      2016-04-25  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-low.c (lwp_signal_can_be_delivered): Adjust.
      	(need_step_over_p): Return zero if the LWP has pending signals
      	can be delivered on software single step target.
      484b3c32
    • Yao Qi's avatar
      [GDBserver] Don't error in reinsert_raw_breakpoint if bp->inserted · 85ba7d86
      Yao Qi authored
      GDBserver steps over a breakpoint while the single step breakpoint
      is inserted at the same address, there are two breakpoint objects
      using single raw breakpoint, which is inserted (for single step).
      When step over is finished, GDBserver reinsert the breakpoint, but
      it finds the raw breakpoint is already inserted, and error out
      "Breakpoint already inserted at reinsert time."  Even if I change the
      order to delete reinsert breakpoints first (which only decreases the
      refcount, but leave inserted flag unchanged), the error is still
      there.
      
      The fix is to remove the error and return instead.
      
      gdb/gdbserver:
      
      2016-04-25  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-low.c (reinsert_raw_breakpoint): If bp->inserted is true
      	return instead of error.
      85ba7d86
  10. 22 Apr, 2016 2 commits
    • Yao Qi's avatar
      [ARM] Clear reserved bits in CPSR · 3539aa13
      Yao Qi authored
      Bits 20 ~ 23 of CPSR are reserved (RAZ, read as zero), but they are not
      zero if the arm program runs on aarch64-linux.  AArch64 tracer gets PSTATE
      from arm 32-bit tracee as CPSR, but bits 20 ~ 23 are used in PSTATE.  I
      think kernel should clear these bits when it is read through ptrace, but
      the fix in user space is still needed.
      
      This patch fixes these two fails,
      
      -FAIL: gdb.reverse/insn-reverse.exp: ext_reg_push_pop: compare registers on insn 0:vldr	d7, [r11, #-12]
      -FAIL: gdb.reverse/insn-reverse.exp: ext_reg_push_pop: compare registers on insn 0:vldr	d7, [r7]
      
      gdb:
      
      2016-04-22  Yao Qi  <yao.qi@linaro.org>
      
      	* aarch32-linux-nat.c (aarch32_gp_regcache_supply): Clear CPSR
      	bits 20 to 23.
      
      gdb/gdbserver:
      
      2016-04-22  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-aarch32-low.c (arm_store_gregset): Clear CPSR bits 20
      	to 23.
      3539aa13
    • Yao Qi's avatar
      Deliver signal in hardware single step · 5b061e98
      Yao Qi authored
      GDBserver doesn't deliver signal when stepping over a breakpoint even
      hardware single step is used.  When GDBserver started to step over
      (thread creation) breakpoint for mutlit-threaded debugging in 2002 [1],
      GDBserver behaves this way.
      
      This behavior gets trouble on conditional breakpoints on branch to
      self instruction like this,
      
         0x00000000004005b6 <+29>:	jmp    0x4005b6 <main+29>
      
      and I set breakpoint
      
      $(gdb) break branch-to-self.c:43 if counter > 3
      
      and the variable counter will be set to 5 in SIGALRM signal handler.
      Since GDBserver keeps stepping over breakpoint, the SIGALRM can never
      be dequeued and delivered to the inferior, so the program can't stop.
      The test can be found in gdb.base/branch-to-self.exp.
      
      GDBserver didn't deliver signal when stepping over a breakpoint because
      a tracepoint is collected twice if GDBserver does so in the following
      scenario, which can be reproduced by gdb.trace/signal.exp.
      
       - program stops at tracepoint, and tracepoint is collected,
       - gdbserver starts a step-over,
       - a signal arrives, step-over is canceled, and signal should be passed,
       - gdbserver starts a new step-over again, pass the signal as well,
       - program stops at the entry of signal handler, step-over finished,
       - gdbserver proceeds,
       - program returns from the signal handler, again to the tracepoint,
         and thus is collected again.
      
      The spurious collection isn't that harmful, IMO, so it should be OK
      to let GDBserver deliver signal when stepping over a breakpoint.
      
      gdb/gdbserver:
      
      2016-04-22  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-low.c (lwp_signal_can_be_delivered): Don't deliver
      	signal when stepping over breakpoint with software single
      	step.
      
      gdb/testsuite:
      
      2016-04-22  Yao Qi  <yao.qi@linaro.org>
      
      	* gdb.trace/signal.exp: Also pass if
      	$tracepoint_hits($i) > $iterations.
      5b061e98
  11. 21 Apr, 2016 1 commit
    • Pedro Alves's avatar
      Fix s390 GNU/Linux gdb and gdbserver builds · 3451269c
      Pedro Alves authored
      Now that gdb/gdbserver compile as C++ programs by default, the s390
      GNU/Linux build started failing with:
      
       In file included from ../../src/gdb/common/common-defs.h:64:0,
      		  from ../../src/gdb/defs.h:28,
      		  from ../../src/gdb/s390-linux-nat.c:22:
       ../../src/gdb/s390-linux-nat.c: In function ‘void fetch_regset(regcache*, int, int, int, const regset*)’:
       ../../src/gdb/../include/libiberty.h:711:38: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
        # define alloca(x) __builtin_alloca(x)
      				       ^
       ../../src/gdb/s390-linux-nat.c:297:19: note: in expansion of macro ‘alloca’
          gdb_byte *buf = alloca (regsize);
      		    ^
      
      etc.
      
      gdb/ChangeLog:
      2016-04-21  Pedro Alves  <palves@redhat.com>
      
      	* s390-linux-nat.c (fetch_regset, store_regset, check_regset): Use
      	void * instead of gdb_byte *.
      
      gdb/gdbserver/ChangeLog:
      2016-04-21  Pedro Alves  <palves@redhat.com>
      
      	* linux-s390-low.c (s390_collect_ptrace_register)
      	(s390_supply_ptrace_register, s390_get_hwcap): Use gdb_byte * and
      	add casts.
      	(s390_check_regset): Use void * instead of gdb_byte *.
      3451269c
  12. 20 Apr, 2016 2 commits
    • Pedro Alves's avatar
      Build GDB as a C++ program by default · a2358508
      Pedro Alves authored
      This makes --enable-build-with-cxx be "yes" by default.
      
      One must now configure with --enable-build-with-cxx=no in order to
      build with a C compiler.
      
      gdb/ChangeLog:
      2016-04-20  Pedro Alves  <palves@redhat.com>
      
      	* build-with-cxx.m4 (GDB_AC_BUILD_WITH_CXX): Default to yes.
      	* configure: Renegerate.
      
      gdb/gdbserver/ChangeLog:
      2016-04-20  Pedro Alves  <palves@redhat.com>
      
      	* configure: Renegerate.
      a2358508
    • Yao Qi's avatar
      Move ARM_CPSR_GREGNUM to arch/arm-linux.h · 6885166d
      Yao Qi authored
      This patch moves macro ARM_CPSR_GREGNUM to arch/arm-linux.h so that it
      can be used in GDBserver side.
      
      gdb:
      
      2016-04-20  Yao Qi  <yao.qi@linaro.org>
      
      	* arm-linux-tdep.h (ARM_CPSR_GREGNUM): Move it to ...
      	* arch/arm-linux.h: ... here.
      
      gdb/gdbserver:
      
      2016-04-20  Yao Qi  <yao.qi@linaro.org>
      
      	* linux-aarch32-low.c: Include "arch/arm-linux.h".
      	(arm_fill_gregset): Use ARM_CPSR_GREGNUM rather than magic
      	number 16.
      	(arm_store_gregset): Likewise.
      6885166d
  13. 19 Apr, 2016 1 commit
    • Walfred Tedeschi's avatar
      Add target descriptions for AVX + MPX · 2b863f51
      Walfred Tedeschi authored
      The current MPX target descriptions assume that MPX is always combined
      with AVX, however that's not correct.  We can have machines with MPX
      and without AVX; or machines with AVX and without MPX.
      
      This patch adds new target descriptions for machines that support
      both MPX and AVX, as duplicates of the existing MPX descriptions.
      
      The following commit will remove AVX from the MPX-only descriptions.
      
      
      2016-04-16  Walfred Tedeschi  <walfred.tedeschi@intel.com>
      
      gdb/ChangeLog:
      
      	* amd64-linux-tdep.c (features/i386/amd64-avx-mpx-linux.c):
      	New include.
      	(amd64_linux_core_read_description): Add case for
      	 X86_XSTATE_AVX_MPX_MASK.
      	(_initialize_amd64_linux_tdep): Call initialize_tdesc_amd64_avx_mpx_linux.
      	* amd64-linux-tdep.h (tdesc_amd64_avx_mpx_linux): New definition.
      	* amd64-tdep.c (features/i386/amd64-avx-mpx.c): New include.
      	(amd64_target_description): Add case for  X86_XSTATE_AVX_MPX_MASK.
      	(_initialize_amd64_tdep): Call initialize_tdesc_amd64_avx_mpx.
      	* common/x86-xstate.h (X86_XSTATE_MPX_MASK): Remove AVX bits.
      	(X86_XSTATE_AVX_MPX_MASK): New case.
      	* features/Makefile (i386/i386-avx-mpx, i386/i386-avx-mpx-linux)
      	(i386/amd64-avx-mpx, i386/amd64-avx-mpx-linux): New rules.
      	(i386/i386-avx-mpx-expedite, i386/i386-avx-mpx-linux-expedite)
      	(i386/amd64-avx-mpx-expedite, i386/amd64-avx-mpx-linux-expedite):
      	New expedites.
      	* i386-linux-tdep.c (features/i386/i386-avx-mpx-linux.c): New
      	include.
      	(i386_linux_core_read_description): Add case
      	X86_XSTATE_AVX_MPX_MASK.
      	(_initialize_i386_linux_tdep): Call
      	initialize_tdesc_i386_avx_mpx_linux.
      	* i386-linux-tdep.h (tdesc_i386_avx_mpx_linux): New include.
      	* i386-tdep.c (features/i386/i386-avx-mpx.c): New include.
      	(i386_target_description): Add case for X86_XSTATE_AVX_MPX_MASK.
      	* x86-linux-nat.c (x86_linux_read_description): Add case for
      	X86_XSTATE_AVX_MPX_MASK.
      	* features/i386/amd64-avx-mpx-linux.xml: New file.
      	* features/i386/i386-avx-mpx-linux.xml: New file.
      	* features/i386/i386-avx-mpx.xml: New file.
      	* features/i386/amd64-avx-mpx.xml: New file.
      	* features/i386/amd64-avx-mpx-linux.c: Generated.
      	* features/i386/amd64-avx-mpx.c: Generated.
      	* features/i386/i386-avx-mpx-linux.c: Generated.
      	* features/i386/i386-avx-mpx.c: Generated.
      	* regformats/i386/amd64-avx-mpx-linux.dat: Generated.
      	* regformats/i386/amd64-avx-mpx.dat: Generated.
      	* regformats/i386/i386-avx-mpx-linux.dat: Generated.
      	* regformats/i386/i386-avx-mpx.dat: Generated.
      
      gdb/gdbserver/ChangeLog:
      
      	* Makefile.in (clean): Add removal for i386-avx-mpx.c,
      	i386-avx-mpx-linux.c, amd64-avx-mpx.c and amd64-avx-mpx-linux.c.
      	(i386-avx-mpx.c, i386-avx-mpx-linux.c, amd64-avx-mpx.c)
      	(amd64-avx-mpx-linux.c): New rules.
      	(amd64-avx-mpx-linux-ipa.o, i386-avx-mpx-linux-ipa.o): New rule.
      	* configure.srv (srv_i386_regobj): Add i386-avx-mpx.o.
      	(srv_i386_linux_regobj): Add i386-avx-mpx-linux.o.
      	(srv_amd64_regobj): Add amd64-avx-mpx.o.
      	(srv_amd64_linux_regobj): Add amd64-avx-mpx-linux.o.
      	(srv_i386_xmlfiles): Add i386/i386-avx-mpx.xml.
      	(srv_amd64_xmlfiles): Add i386/amd64-avx-mpx.xml.
      	(srv_i386_linux_xmlfiles): Add i386/i386-avx-mpx-linux.xml.
      	(srv_amd64_linux_xmlfiles): Add i386/amd64-avx-mpx-linux.xml.
      	(ipa_i386_linux_regobj): Add i386-avx-mpx-linux-ipa.o.
      	(ipa_amd64_linux_regobj): Add amd64-avx-mpx-linux-ipa.o.
      	* linux-x86-low.c (x86_linux_read_description): Add case for
      	X86_XSTATE_AVX_MPX_MASK.
      	(x86_get_ipa_tdesc_idx): Add cases for avx_mpx.
      	(initialize_low_arch): Call init_registers_amd64_avx_mpx_linux and
      	init_registers_i386_avx_mpx_linux.
      	* linux-i386-ipa.c (get_ipa_tdesc): Add case for avx_mpx.
      	(initialize_low_tracepoint): Call
      	init_registers_i386_avx_mpx_linux.
      	* linux-amd64-ipa.c (get_ipa_tdesc):  Add case for avx_mpx.
      	(initialize_low_tracepoint): Call
      	init_registers_amd64_avx_mpx_linux.
      	* linux-x86-tdesc.h (X86_TDESC_AVX_MPX): New enum value.
      	(init_registers_amd64_avx_mpx_linux, tdesc_amd64_avx_mpx_linux)
      	(init_registers_i386_avx_mpx_linux, tdesc_i386_avx_mpx_linux): New
      	declarations.
      2b863f51
  14. 18 Apr, 2016 1 commit
    • Pedro Alves's avatar
      Fix PR gdb/19250: ptrace prototype is not detected properly in C++ mode · 9b30624b
      Pedro Alves authored
      The ptrace args/return types detection doesn't work properly in C++
      mode, on non-GNU/Linux hosts.  For example, on gcc70 (NetBSD 5.1),
      where the prototype is:
      
       int ptrace(int, __pid_t, void*, int);
      
      configure misdetects it as:
      
       $ grep PTRACE_TYPE config.h
       #define PTRACE_TYPE_ARG1 int
       #define PTRACE_TYPE_ARG3 int *
       #define PTRACE_TYPE_ARG4 int
       /* #undef PTRACE_TYPE_ARG5 */
       #define PTRACE_TYPE_RET int
      
      resulting in:
      
       ../../src/gdb/amd64bsd-nat.c: In function 'void amd64bsd_fetch_inferior_registers(target_ops*, regcache*, int)':
       ../../src/gdb/amd64bsd-nat.c:56: warning: dereferencing type-punned pointer will break strict-aliasing rules
       ../../src/gdb/amd64bsd-nat.c: In function 'void amd64bsd_store_inferior_registers(target_ops*, regcache*, int)':
       ../../src/gdb/amd64bsd-nat.c:104: warning: dereferencing type-punned pointer will break strict-aliasing rules
       ../../src/gdb/amd64bsd-nat.c:110: warning: dereferencing type-punned pointer will break strict-aliasing rules
      
      We could address this [1], however despite ptrace.m4's claim:
      
       # Needs to be tested in C++ mode, to detect whether we need to cast
       # the first argument to enum __ptrace_request.
      
      it appears that there's actually no need to test in C++ mode.  Always
      running the ptrace tests in C mode works just the same on GNU/Linux.
      
      I remember experimenting with several different ways to handle the
      original issue back then, and maybe that was needed in some other
      attempt and then I didn't realize it ended up not really necessary.
      
      Confirmed that this fixes the NetBSD 5.1 C++ build, and confirmed that
      C and C++ builds on Fedora 23 are unaffected.
      
      [1] - https://sourceware.org/ml/gdb-patches/2016-04/msg00374.html
      
      gdb/ChangeLog:
      2016-04-18  Pedro Alves  <palves@redhat.com>
      
      	* ptrace.m4 (GDB_AC_PTRACE): Don't run tests in C++ mode.
      	* configure: Regenerate.
      
      gdb/gdbserver/ChangeLog:
      2016-04-18  Pedro Alves  <palves@redhat.com>
      
      	* configure: Regenerate.
      9b30624b
  15. 13 Apr, 2016 1 commit
    • Antoine Tremblay's avatar
      Fix aarch64 ftrace JIT condition testcase · 45e3745e
      Antoine Tremblay authored
      This patch fixes the following failure:
      FAIL: gdb.trace/trace-condition.exp: ftrace: -(21 << 1) == -42: check 10
      frames were collected.
      
      This was due to aarch64_emit_sub using the wrong order in its operands, so the
      operation would end up being 42 - 0 rather than 0 - 42.
      
      This patch also fixes the order of aarch64_emit_add for clarity.
      
      The test case for emit_sub is fixed so that the proper order of
      the operands is needed for the test to pass.
      
      Tested on aarch64-native-extended-gdbserver.
      
      Note: trace-condition.exp was broken a bit so I had to modify it to run
      the test. A fix is coming for that in another patch.
      
      gdb/gdbserver/ChangeLog:
      
      	* linux-aarch64-low.c (aarch64_emit_add): Switch x1 and x0.
      	(aarch64_emit_sub): Likewise.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.trace/trace-condition.exp (foreach): Fix emit_sub testcase.
      45e3745e
  16. 12 Apr, 2016 1 commit
    • Pedro Alves's avatar
      Eliminate prepare_to_throw_exception · 2afc13ff
      Pedro Alves authored
      No longer necessary.
      
      gdb/ChangeLog:
      2016-04-12  Pedro Alves  <palves@redhat.com>
      
      	* common/common-exceptions.c (exception_rethrow): Remove
      	prepare_to_throw_exception call.
      	* common/common-exceptions.h (prepare_to_throw_exception): Delete
      	declaration.
      	* exceptions.c (prepare_to_throw_exception): Delete.
      
      gdb/gdbserver/ChangeLog:
      2016-04-12  Pedro Alves  <palves@redhat.com>
      
      	* utils.c (prepare_to_throw_exception): Delete.
      2afc13ff
  17. 05 Apr, 2016 2 commits
    • Simon Marchi's avatar
      Make ftrace tests work with remote targets · 6e774b13
      Simon Marchi authored
      When we build a shared library for testing, it is built differently
      whether it is meant for the local system or a remote one.  When it is
      for the local system, the library is built with no SONAME.  So when the
      executable is built, roughly in this way:
      
        $ gcc testfile.c /path/to/library.so
      
      the executable will contain an absolute reference to the library.  For
      example:
      
        $ readelf -a testsuite/gdb.python/py-shared | grep NEEDED
         0x0000000000000001 (NEEDED)             Shared library: [/home/emaisin/build/binutils-gdb/gdb/testsuite/gdb.python/py-shared-sl.sl]
      
      When testing is done remotely, the absolute path obviously doesn't work.
      Therefore, we build the library with an SONAME:
      
        $ readelf -a testsuite/gdb.python/py-shared-sl.sl | grep SONAME
         0x000000000000000e (SONAME)             Library soname: [py-shared-sl.sl]
      
      which ends up in the executable's NEEDED field:
      
        $ readelf -a testsuite/gdb.python/py-shared | grep NEEDED
         0x0000000000000001 (NEEDED)             Shared library: [py-shared-sl.sl]
      
      The executable and the library are then uploaded side-by-side on the
      remote system.  To allow the dynamic linker to find the shared library,
      we have to add the special RPATH value $ORIGIN, which tells it to search
      in the executable's directory:
      
        $ readelf -a testsuite/gdb.python/py-shared | grep ORIGIN
         0x000000000000000f (RPATH)              Library rpath: [$ORIGIN]
      
      The problem with the IPA library is that it doesn't have an SONAME,
      making it very difficult to do testing on a remote board.  When a
      test executable is linked with it, it contains an absolute reference to
      the library path.  Therefore, unless the paths on the target are the
      same as on the build system, it won't work.
      
      To make it possible for tests using the IPA library to run test on
      remote boards, I suggest adding an SONAME to libinproctrace.so.  I don't
      think it should be a big problem for users.  All the libraries installed
      on my system have an SONAME, so it should be fine if libinproctrace.so
      does too.
      
      As a consequence, native testing does not work anymore, since
      executables do not contain the absolute path to the library anymore.  To
      keep them working, we can have gdb_load_shlibs copy the library to the
      test directory when testing natively.  That's done by modifying
      gdb_load_shlibs.  We also have to add RPATH=$ORIGIN to executables, even
      when testing natively.
      
      I think it's a good change in general, as it reduces the differences
      between testing a native and a remote target.  To further reduce those
      differences, we can also always build test shared libraries with an
      SONAME.
      
      ftrace.exp and ftrace-lock.exp need to be modified slightly.  The code
      checks that the IPA library is loaded using the absolute path on the
      build machine.  That obviously doesn't work if the test is done
      remotely, as the path will be different.  I changed the tests to only
      search for the library basename (e.g. libinproctrace.so).
      
      gdb/gdbserver/ChangeLog:
      
      	* Makefile.in ($(IPA_LIB)): Set SONAME of the IPA lib.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.trace/ftrace-lock.exp: Check for IPA basename instead of
      	absolute.
      	* gdb.trace/ftrace.exp: Likewise.
      	* lib/gdb.exp (gdb_compile): Set rpath $ORIGIN for non-remote
      	targets as well.
      	(gdb_compile_shlib): Set SONAME for non-remote targets as well.
      	(gdb_load_shlibs): Copy libraries to test directory when testing
      	natively.  Only set solib-search-path if testing remotely.
      	* lib/mi-support.exp (mi_load_shlibs): Likewise.
      6e774b13
    • Marcin Kościelnicki's avatar
      IPA: Move getauxval out of #ifndef IN_PROCESS_AGENT · 4dca19f8
      Marcin Kościelnicki authored
      The getauxval code was wrongly included in code area only compiled for
      gdbserver.  Move it to a #ifdef IN_PROCESS_AGENT area that already
      contains lots of IPA-only code.
      
      gdb/gdbserver/ChangeLog:
      
      	* tracepoint.c (getauxval): Move to #ifdef IN_PROCESS_AGENT.
      4dca19f8
  18. 03 Apr, 2016 1 commit
    • Marcin Kościelnicki's avatar
      IPA: Fix build problem on !HAVE_GETAUXVAL · d0a9981f
      Marcin Kościelnicki authored
      These files need AT_PHDR, which is defined in elf.h.  If HAVE_GETAUXVAL
      is set, it's implicitely included by sys/auxv.h.  Include it manually
      for the opposite case.
      
      gdb/gdbserver/ChangeLog:
      
      	* linux-aarch64-ipa.c: Add <elf.h> include.
      	* linux-ppc-ipa.c: Add <elf.h> include.
      	* linux-s390-ipa.c: Add <elf.h> include.
      d0a9981f
  19. 31 Mar, 2016 4 commits
    • Marcin Kościelnicki's avatar
      gdbserver: Fix C++ build errors in tracepoint.c · 252db07e
      Marcin Kościelnicki authored
      These were introduced by 1cda1512
      and a13c4696 .  One is a simple
      missing cast, the other is const usage on global function pointers
      exported from IPA: in C++, consts are static, and thus won't be
      exported from the DSO (the build error was because of non-applicable
      visibility("default")).
      
      gdb/gdbserver/ChangeLog:
      
      	* tracepoint.c (gdb_collect_ptr): Remove const qualifier.
      	(get_raw_reg_ptr): Likewise.
      	(get_trace_state_variable_value_ptr): Likewise.
      	(set_trace_state_variable_value_ptr): Likewise.
      	(initialize_tracepoint): Cast alloc_jump_pad_buffer result to
      	char *.
      252db07e
    • Marcin Kościelnicki's avatar
      gdbserver: Add emit_ops for powerpc. · 14e2b6d9
      Marcin Kościelnicki authored
      gdb/gdbserver/ChangeLog:
      
      2016-03-31  Wei-cheng Wang  <cole945@gmail.com>
      	    Marcin Kościelnicki  <koriakin@0x04.net>
      
      	PR/17221
      	* linux-ppc-low.c (emit_insns): New function.
      	(__EMIT_ASM, _EMIT_ASM, EMIT_ASM): New macros.
      	(ppc_emit_prologue): New function.
      	(ppc_emit_epilogue): New function.
      	(ppc_emit_add): New function.
      	(ppc_emit_sub): New function.
      	(ppc_emit_mul): New function.
      	(ppc_emit_lsh): New function.
      	(ppc_emit_rsh_signed): New function.
      	(ppc_emit_rsh_unsigned): New function.
      	(ppc_emit_ext): New function.
      	(ppc_emit_zero_ext): New function.
      	(ppc_emit_log_not): New function.
      	(ppc_emit_bit_and): New function.
      	(ppc_emit_bit_or): New function.
      	(ppc_emit_bit_xor): New function.
      	(ppc_emit_bit_not): New function.
      	(ppc_emit_equal): New function.
      	(ppc_emit_less_signed): New function.
      	(ppc_emit_less_unsigned): New function.
      	(ppc_emit_ref): New function.
      	(ppc_emit_const): New function.
      	(ppc_emit_reg): New function.
      	(ppc_emit_pop): New function.
      	(ppc_emit_stack_flush): New function.
      	(ppc_emit_swap): New function.
      	(ppc_emit_stack_adjust): New function.
      	(ppc_emit_call): New function.
      	(ppc_emit_int_call_1): New function.
      	(ppc_emit_void_call_2): New function.
      	(ppc_emit_if_goto): New function.
      	(ppc_emit_goto): New function.
      	(ppc_emit_eq_goto): New function.
      	(ppc_emit_ne_goto): New function.
      	(ppc_emit_lt_goto): New function.
      	(ppc_emit_le_goto): New function.
      	(ppc_emit_gt_goto): New function.
      	(ppc_emit_ge_goto): New function.
      	(ppc_write_goto_address): New function.
      	(ppc_emit_ops_impl): New static variable.
      	(ppc64v1_emit_prologue): New function.
      	(ppc64v2_emit_prologue): New function.
      	(ppc64_emit_epilogue): New function.
      	(ppc64_emit_add): New function.
      	(ppc64_emit_sub): New function.
      	(ppc64_emit_mul): New function.
      	(ppc64_emit_lsh): New function.
      	(ppc64_emit_rsh_signed): New function.
      	(ppc64_emit_rsh_unsigned): New function.
      	(ppc64_emit_ext): New function.
      	(ppc64_emit_zero_ext): New function.
      	(ppc64_emit_log_not): New function.
      	(ppc64_emit_bit_and): New function.
      	(ppc64_emit_bit_or): New function.
      	(ppc64_emit_bit_xor): New function.
      	(ppc64_emit_bit_not): New function.
      	(ppc64_emit_equal): New function.
      	(ppc64_emit_less_signed): New function.
      	(ppc64_emit_less_unsigned): New function.
      	(ppc64_emit_ref): New function.
      	(ppc64_emit_const): New function.
      	(ppc64v1_emit_reg): New function.
      	(ppc64v2_emit_reg): New function.
      	(ppc64_emit_pop): New function.
      	(ppc64_emit_stack_flush): New function.
      	(ppc64_emit_swap): New function.
      	(ppc64v1_emit_call): New function.
      	(ppc64v2_emit_call): New function.
      	(ppc64v1_emit_int_call_1): New function.
      	(ppc64v2_emit_int_call_1): New function.
      	(ppc64v1_emit_void_call_2): New function.
      	(ppc64v2_emit_void_call_2): New function.
      	(ppc64_emit_if_goto): New function.
      	(ppc64_emit_eq_goto): New function.
      	(ppc64_emit_ne_goto): New function.
      	(ppc64_emit_lt_goto): New function.
      	(ppc64_emit_le_goto): New function.
      	(ppc64_emit_gt_goto): New function.
      	(ppc64_emit_ge_goto): New function.
      	(ppc64v1_emit_ops_impl): New static variable.
      	(ppc64v2_emit_ops_impl): New static variable.
      	(ppc_emit_ops): New function.
      	(linux_low_target): Wire in ppc_emit_ops.
      14e2b6d9
    • Marcin Kościelnicki's avatar
      gdbserver: Add powerpc fast tracepoint support. · a2174ba4
      Marcin Kościelnicki authored
      gdb/gdbserver/ChangeLog:
      
      2016-03-31  Wei-cheng Wang  <cole945@gmail.com>
      	    Marcin Kościelnicki  <koriakin@0x04.net>
      
      	PR/17221
      	* Makefile.in: Add powerpc-*-ipa.o
      	* configure.srv: Add ipa_obj for powerpc*-linux.
      	* linux-ppc-ipa.c: New file.
      	* linux-ppc-low.c: Added linux-ppc-tdesc.h, ax.h, tracepoint.h
      	includes.
      	(PPC_FIELD): New macro.
      	(PPC_SEXT): New macro.
      	(PPC_OP6): New macro.
      	(PPC_BO): New macro.
      	(PPC_LI): New macro.
      	(PPC_BD): New macro.
      	(init_registers_*): Move prototype to linux-ppc-tdesc.h.
      	(tdesc_*): Move declaration to linux-ppc-tdesc.h.
      	(ppc_get_hwcap): Rename to ppc_get_auxv and add type parameter.
      	(ppc_get_thread_area): New function.
      	(is_elfv2_inferior): New function.
      	(gen_ds_form): New function.
      	(GEN_STD): New macro.
      	(GEN_STDU): New macro.
      	(GEN_LD): New macro.
      	(GEN_LDU): New macro.
      	(gen_d_form): New function.
      	(GEN_ADDI): New macro.
      	(GEN_ADDIS): New macro.
      	(GEN_LI): New macro.
      	(GEN_LIS): New macro.
      	(GEN_ORI): New macro.
      	(GEN_ORIS): New macro.
      	(GEN_LWZ): New macro.
      	(GEN_STW): New macro.
      	(GEN_STWU): New macro.
      	(gen_xfx_form): New function.
      	(GEN_MFSPR): New macro.
      	(GEN_MTSPR): New macro.
      	(GEN_MFCR): New macro.
      	(GEN_MTCR): New macro.
      	(GEN_SYNC): New macro.
      	(GEN_LWSYNC): New macro.
      	(gen_x_form): New function.
      	(GEN_OR): New macro.
      	(GEN_MR): New macro.
      	(GEN_LWARX): New macro.
      	(GEN_STWCX): New macro.
      	(GEN_CMPW): New macro.
      	(gen_md_form): New function.
      	(GEN_RLDICL): New macro.
      	(GEN_RLDICR): New macro.
      	(gen_i_form): New function.
      	(GEN_B): New macro.
      	(GEN_BL): New macro.
      	(gen_b_form): New function.
      	(GEN_BNE): New macro.
      	(GEN_LOAD): New macro.
      	(GEN_STORE): New macro.
      	(gen_limm): New function.
      	(gen_atomic_xchg): New function.
      	(gen_call): New function.
      	(ppc_relocate_instruction): New function.
      	(ppc_install_fast_tracepoint_jump_pad): New function.
      	(ppc_get_min_fast_tracepoint_insn_len): New function.
      	(ppc_get_ipa_tdesc_idx): New function.
      	(the_low_target): Wire in the new functions.
      	(initialize_low_arch) [!__powerpc64__]: Don'it initialize 64-bit
      	tdescs.
      	* linux-ppc-tdesc.h: New file.
      a2174ba4
    • Marcin Kościelnicki's avatar
      IPA: Add alloc_jump_pad_buffer target hook. · a13c4696
      Marcin Kościelnicki authored
      Targets may have various requirements on the required location of the jump
      pad area.  Currently IPA allocates it at the lowest possible address,
      so that it is reachable by branches from the executable.  However, this
      fails on powerpc, which has executable link address (0x10000000) much
      larger than branch reach (+/- 32MiB).
      
      This makes jump pad buffer allocation a target hook instead.  The current
      implementations are as follows:
      
      - i386 and s390: Branches can reach anywhere, so just mmap it.  This
        avoids the linear search dance.
      - x86_64: Branches have +/-2GiB of reach, and executable is loaded low,
        so just call mmap with MAP_32BIT.  Likewise avoids the linear search.
      - aarch64: Branches have +-128MiB of reach, executable loaded at 4MiB.
        Do a linear search from 4MiB-size downwards to page_size.
      - s390x: Branches have +-4GiB of reach, executable loaded at 2GiB.
        Do like on aarch64.
      
      gdb/gdbserver/ChangeLog:
      
      	* linux-aarch64-ipa.c: Add <sys/mman.h> and <sys/auxv.h> includes.
      	(alloc_jump_pad_buffer): New function.
      	* linux-amd64-ipa.c: Add <sys/mman.h> include.
      	(alloc_jump_pad_buffer): New function.
      	* linux-i386-ipa.c (alloc_jump_pad_buffer): New function.
      	* linux-s390-ipa.c: Add <sys/mman.h> and <sys/auxv.h> includes.
      	(alloc_jump_pad_buffer): New function.
      	* tracepoint.c (getauxval) [!HAVE_GETAUXVAL]: New function.
      	(initialize_tracepoint): Delegate to alloc_jump_pad_buffer.
      	* tracepoint.h (alloc_jump_pad_buffer): New prototype.
      	(getauxval) [!HAVE_GETAUXVAL]: New prototype.
      a13c4696
  20. 30 Mar, 2016 2 commits
    • Marcin Kościelnicki's avatar
      gdbserver/IPA: Export some functions via global function pointers. · 1cda1512
      Marcin Kościelnicki authored
      On powerpc64, qSymbol for a function returns the function code address,
      and not the descriptor address.  Since we emit code calling gdb_collect
      and some other functions, we need the descriptor (no way to know the
      proper TOC address without it).  To get the descriptor address, make
      global function pointer variables in the IPA pointing to the relevant
      functions and read them instead of asking for them directly via qSymbol.
      
      gdb/gdbserver/ChangeLog:
      
      	* linux-aarch64-ipa.c: Rename gdb_agent_get_raw_reg to get_raw_reg.
      	* linux-amd64-ipa.c: Likewise.
      	* linux-i386-ipa.c: Likewise.
      	* linux-s390-ipa.c: Likewise.
      	* tracepoint.c: IPA-export gdb_collect_ptr instead of gdb_collect,
      	ditto for get_raw_reg_ptr, get_trace_state_variable_value_ptr,
      	set_trace_state_variable_value_ptr.
      	(struct ipa_sym_addresses): Likewise.
      	(symbol_list): Likewise.
      	(install_fast_tracepoint): Dereference gdb_collect_ptr instead of
      	accessing gdb_collect directly.
      	(gdb_collect_ptr_type): New typedef.
      	(get_raw_reg_ptr_type): New typedef.
      	(get_trace_state_variable_value_ptr_type): New typedef.
      	(set_trace_state_variable_value_ptr_type): New typedef.
      	(gdb_collect_ptr): New global.
      	(get_raw_reg_ptr): New global.
      	(get_trace_state_variable_value_ptr): New global.
      	(set_trace_state_variable_value_ptr): New global.
      	(get_raw_reg_func_addr): Dereference get_raw_reg_ptr instead of
      	accessing get_raw_reg directly.
      	(get_get_tsv_func_addr): Likewise for
      	get_trace_state_variable_value_ptr.
      	(get_set_tsv_func_addr): Likewise for
      	set_trace_state_variable_value_ptr.
      	* tracepoint.h: Rename gdb_agent_get_raw_reg to get_raw_reg.
      1cda1512
    • Simon Marchi's avatar
      gdbserver/tracepoint.c: Remove whitespace · 72fb5488
      Simon Marchi authored
      gdb/gdbserver/ChangeLog:
      
      	* tracepoint.c (cmd_qtenable_disable): Remove whitespace.
      72fb5488
  21. 29 Mar, 2016 3 commits
    • Marcin Kościelnicki's avatar
      gdbserver: Handle 'v' packet while processing qSymbol. · 28170b88
      Marcin Kościelnicki authored
      On powerpc64, qSymbol query may require gdb to read a function
      descriptor, sending a vFile packet to gdbserver.  Thus, we need
      to handle 'v' packet in look_up_one_symbol.
      
      vFile replies may be quite long, and require reallocating own_buf.
      Since handle_v_requests assumes the buffer is the static global own_buf
      from server.c and reallocates it, we need to make own_buf global and
      use it from look_up_one_symbol instead of using our own auto variable.
      I've also done the same change in relocate_instruction, just in case.
      
      On gdb side, in remote_check_symbols, rs->buf may be clobbered by vFile
      handling, yet we need its contents for the reply (the symbol name is
      stored there).  Allocate a new buffer instead.
      
      This broke fast tracepoints on powerpc64, due to errors in reading IPA
      symbols.
      
      gdb/ChangeLog:
      
      	* remote.c (remote_check_symbols): Allocate own buffer for reply.
      
      gdbserver/ChangeLog:
      
      	* remote-utils.c (look_up_one_symbol): Remove own_buf, handle 'v'
      	packets.
      	(relocate_instruction): Remove own_buf.
      	* server.c (own_buf): Make global.
      	(handle_v_requests): Make global.
      	* server.h (own_buf): New declaration.
      	(handle_v_requests): New prototype.
      28170b88
    • Marcin Kościelnicki's avatar
      gdbserver/s390: Add support for compiled agent expressions. · f39e8743
      Marcin Kościelnicki authored
      These sequences assume a z900+ CPU, like the rest of fast tracepoint
      support.
      
      gdb/gdbserver/ChangeLog:
      
      	PR 18377
      	* linux-s390-low.c (add_insns): New function.
      	(s390_emit_prologue): New function.
      	(s390_emit_epilogue): New function.
      	(s390_emit_add): New function.
      	(s390_emit_sub): New function.
      	(s390_emit_mul): New function.
      	(s390_emit_lsh): New function.
      	(s390_emit_rsh_signed): New function.
      	(s390_emit_rsh_unsigned): New function.
      	(s390_emit_ext): New function.
      	(s390_emit_log_not): New function.
      	(s390_emit_bit_and): New function.
      	(s390_emit_bit_or): New function.
      	(s390_emit_bit_xor): New function.
      	(s390_emit_bit_not): New function.
      	(s390_emit_equal): New function.
      	(s390_emit_less_signed): New function.
      	(s390_emit_less_unsigned): New function.
      	(s390_emit_ref): New function.
      	(s390_emit_if_goto): New function.
      	(s390_emit_goto): New function.
      	(s390_write_goto_address): New function.
      	(s390_emit_litpool): New function.
      	(s390_emit_const): New function.
      	(s390_emit_call): New function.
      	(s390_emit_reg): New function.
      	(s390_emit_pop): New function.
      	(s390_emit_stack_flush): New function.
      	(s390_emit_zero_ext): New function.
      	(s390_emit_swap): New function.
      	(s390_emit_stack_adjust): New function.
      	(s390_emit_set_r2): New function.
      	(s390_emit_int_call_1): New function.
      	(s390_emit_void_call_2): New function.
      	(s390_emit_eq_goto): New function.
      	(s390_emit_ne_goto): New function.
      	(s390_emit_lt_goto): New function.
      	(s390_emit_le_goto): New function.
      	(s390_emit_gt_goto): New function.
      	(s390_emit_ge_goto): New function.
      	(s390x_emit_prologue): New function.
      	(s390x_emit_epilogue): New function.
      	(s390x_emit_add): New function.
      	(s390x_emit_sub): New function.
      	(s390x_emit_mul): New function.
      	(s390x_emit_lsh): New function.
      	(s390x_emit_rsh_signed): New function.
      	(s390x_emit_rsh_unsigned): New function.
      	(s390x_emit_ext): New function.
      	(s390x_emit_log_not): New function.
      	(s390x_emit_bit_and): New function.
      	(s390x_emit_bit_or): New function.
      	(s390x_emit_bit_xor): New function.
      	(s390x_emit_bit_not): New function.
      	(s390x_emit_equal): New function.
      	(s390x_emit_less_signed): New function.
      	(s390x_emit_less_unsigned): New function.
      	(s390x_emit_ref): New function.
      	(s390x_emit_if_goto): New function.
      	(s390x_emit_const): New function.
      	(s390x_emit_call): New function.
      	(s390x_emit_reg): New function.
      	(s390x_emit_pop): New function.
      	(s390x_emit_stack_flush): New function.
      	(s390x_emit_zero_ext): New function.
      	(s390x_emit_swap): New function.
      	(s390x_emit_stack_adjust): New function.
      	(s390x_emit_int_call_1): New function.
      	(s390x_emit_void_call_2): New function.
      	(s390x_emit_eq_goto): New function.
      	(s390x_emit_ne_goto): New function.
      	(s390x_emit_lt_goto): New function.
      	(s390x_emit_le_goto): New function.
      	(s390x_emit_gt_goto): New function.
      	(s390x_emit_ge_goto): New function.
      	(s390_emit_ops): New function.
      	(struct linux_target_ops): Fill in emit_ops hook.
      f39e8743
    • Marcin Kościelnicki's avatar
      gdbserver/s390: Add fast tracepoint support. · abd9baf9
      Marcin Kościelnicki authored
      Fast tracepoints will only work on 6-byte intructions, and assume at least
      a z900 CPU.  s390 also has 4-byte jump instructions, which also work on
      pre-z900, but their range is limitted to +-64kiB, which is not very useful
      (and wouldn't work at all with current jump pad allocation).
      
      There's a little problem with s390_relocate_instruction function: it
      converts BRAS/BRASL instructions to LARL of the return address + JG
      to the target address.  On 31-bit, this sets the high bit of the target
      register to 0, while BRAS/BRASL would set it to 1.  While this is not
      a problem when the result is only used to address memory, it could
      possibly break something that expects to compare such addresses for
      equality without first masking the bit off.  In particular, I'm not sure
      whether leaving the return address high bit unset is ABI-compliant
      (could confuse some unwinder?).  If that's a problem, it could be fixed
      by handling it in the jump pad (since at that point we can just modify
      the GPRs in the save area without having to worry about preserving
      CCs and only having that one GPR to work with - I'm not sure if it's
      even possible to set the high bit with such constraints).
      
      gdb/gdbserver/ChangeLog:
      
      	PR 18377
      	* Makefile.in: Add s390 IPA files.
      	* configure.srv: Build IPA for s390.
      	* linux-s390-ipa.c: New file.
      	* linux-s390-low.c: New includes - inttypes.h and linux-s390-tdesc.h.
      	(init_registers_s390_linux32): Move declaration to linux-s390-tdesc.h.
      	(tdesc_s390_linux32): Likewise.
      	(init_registers_s390_linux32v1): Likewise.
      	(tdesc_s390_linux32v1): Likewise.
      	(init_registers_s390_linux32v2): Likewise.
      	(tdesc_s390_linux32v2): Likewise.
      	(init_registers_s390_linux64): Likewise.
      	(tdesc_s390_linux64): Likewise.
      	(init_registers_s390_linux64v1): Likewise.
      	(tdesc_s390_linux64v1): Likewise.
      	(init_registers_s390_linux64v2): Likewise.
      	(tdesc_s390_linux64v2): Likewise.
      	(init_registers_s390_te_linux64): Likewise.
      	(tdesc_s390_te_linux64): Likewise.
      	(init_registers_s390_vx_linux64): Likewise.
      	(tdesc_s390_vx_linux64): Likewise.
      	(init_registers_s390_tevx_linux64): Likewise.
      	(tdesc_s390_tevx_linux64): Likewise.
      	(init_registers_s390x_linux64): Likewise.
      	(tdesc_s390x_linux64): Likewise.
      	(init_registers_s390x_linux64v1): Likewise.
      	(tdesc_s390x_linux64v1): Likewise.
      	(init_registers_s390x_linux64v2): Likewise.
      	(tdesc_s390x_linux64v2): Likewise.
      	(init_registers_s390x_te_linux64): Likewise.
      	(tdesc_s390x_te_linux64): Likewise.
      	(init_registers_s390x_vx_linux64): Likewise.
      	(tdesc_s390x_vx_linux64): Likewise.
      	(init_registers_s390x_tevx_linux64): Likewise.
      	(tdesc_s390x_tevx_linux64): Likewise.
      	(have_hwcap_s390_vx): New static variable.
      	(s390_arch_setup): Fill have_hwcap_s390_vx.
      	(s390_get_thread_area): New function.
      	(s390_ft_entry_gpr_esa): New const.
      	(s390_ft_entry_gpr_zarch): New const.
      	(s390_ft_entry_misc): New const.
      	(s390_ft_entry_fr): New const.
      	(s390_ft_entry_vr): New const.
      	(s390_ft_main_31): New const.
      	(s390_ft_main_64): New const.
      	(s390_ft_exit_fr): New const.
      	(s390_ft_exit_vr): New const.
      	(s390_ft_exit_misc): New const.
      	(s390_ft_exit_gpr_esa): New const.
      	(s390_ft_exit_gpr_zarch): New const.
      	(append_insns): New function.
      	(s390_relocate_instruction): New function.
      	(s390_install_fast_tracepoint_jump_pad): New function.
      	(s390_get_min_fast_tracepoint_insn_len): New function.
      	(s390_get_ipa_tdesc_idx): New function.
      	(struct linux_target_ops): Wire in the above functions.
      	(initialize_low_arch) [!__s390x__]: Don't initialize s390x tdescs.
      	* linux-s390-tdesc.h: New file.
      abd9baf9