[4/4] Implement get_syscall_trapinfo for arm-linux

Message ID 1466158585-21833-5-git-send-email-yao.qi@linaro.org
State New, archived
Headers

Commit Message

Yao Qi June 17, 2016, 10:16 a.m. UTC
  gdb/gdbserver:

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

	* linux-arm-low.c (arm_get_syscall_trapinfo): New function.
	(the_low_target): Install arm_get_syscall_trapinfo.
---
 gdb/gdbserver/linux-arm-low.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 2ffda87..67d1bbf 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -951,6 +951,36 @@  arm_supports_hardware_single_step (void)
   return 0;
 }
 
+/* Implementation of linux_target_ops method "get_syscall_trapinfo".  */
+
+static void
+arm_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
+{
+  if (arm_is_thumb_mode ())
+    collect_register_by_name (regcache, "r7", sysno);
+  else
+    {
+      unsigned long pc;
+      unsigned long insn;
+      unsigned long svc_operand;
+
+      collect_register_by_name (regcache, "pc", &pc);
+      (*the_target->read_memory) (pc - 4, (unsigned char *) &insn, 4);
+      svc_operand = (0x00ffffff & insn);
+
+      if (svc_operand)
+	{
+	  /* OABI */
+	  *sysno = svc_operand - 0x900000;
+	}
+      else
+	{
+	  /* EABI */
+	  collect_register_by_name (regcache, "r7", sysno);
+	}
+    }
+}
+
 /* Register sets without using PTRACE_GETREGSET.  */
 
 static struct regset_info arm_regsets[] = {
@@ -1031,7 +1061,8 @@  struct linux_target_ops the_low_target = {
   NULL, /* get_min_fast_tracepoint_insn_len */
   NULL, /* supports_range_stepping */
   arm_breakpoint_kind_from_current_state,
-  arm_supports_hardware_single_step
+  arm_supports_hardware_single_step,
+  arm_get_syscall_trapinfo,
 };
 
 void