Add command support for Guile.
[deliverable/binutils-gdb.git] / gdb / aarch64-linux-tdep.c
index 52c5d97e92001ef7e5770a9d9bb0c1a03a6325f7..30ed73feb0c6e5d6d319cdeb27c460a4988ecc6d 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for GNU/Linux AArch64.
 
-   Copyright (C) 2009-2013 Free Software Foundation, Inc.
+   Copyright (C) 2009-2014 Free Software Foundation, Inc.
    Contributed by ARM Ltd.
 
    This file is part of GDB.
 
 /* Signal frame handling.
 
-      +----------+  ^
-      | saved lr |  |
-   +->| saved fp |--+
-   |  |          |
-   |  |          |
-   |  +----------+
-   |  | saved lr |
-   +--| saved fp |
-   ^  |          |
-   |  |          |
-   |  +----------+
-   ^  |          |
-   |  | signal   |
-   |  |          |
-   |  | saved lr |-->interrupted_function_pc
-   +--| saved fp |
-   |  +----------+
-   |  | saved lr |--> default_restorer (movz x8, NR_sys_rt_sigreturn; svc 0)
-   +--| saved fp |<- FP
-      |          |
-      |          |<- SP
-      +----------+
+      +------------+  ^
+      | saved lr   |  |
+   +->| saved fp   |--+
+   |  |            |
+   |  |            |
+   |  +------------+
+   |  | saved lr   |
+   +--| saved fp   |
+   ^  |            |
+   |  |            |
+   |  +------------+
+   ^  |            |
+   |  | signal     |
+   |  |            |        SIGTRAMP_FRAME (struct rt_sigframe)
+   |  | saved regs |
+   +--| saved sp   |--> interrupted_sp
+   |  | saved pc   |--> interrupted_pc
+   |  |            |
+   |  +------------+
+   |  | saved lr   |--> default_restorer (movz x8, NR_sys_rt_sigreturn; svc 0)
+   +--| saved fp   |<- FP
+      |            |         NORMAL_FRAME
+      |            |<- SP
+      +------------+
 
   On signal delivery, the kernel will create a signal handler stack
   frame and setup the return address in LR to point at restorer stub.
   d28015a8        movz    x8, #0xad
   d4000001        svc     #0x0
 
+  This is a system call sys_rt_sigreturn.
+
   We detect signal frames by snooping the return code for the restorer
   instruction sequence.
 
@@ -146,7 +150,6 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self,
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM);
-  CORE_ADDR fp = get_frame_register_unsigned (this_frame, AARCH64_FP_REGNUM);
   CORE_ADDR sigcontext_addr =
     sp
     + AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET
@@ -160,12 +163,14 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self,
                               sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET
                               + i * AARCH64_SIGCONTEXT_REG_SIZE);
     }
-
-  trad_frame_set_reg_addr (this_cache, AARCH64_FP_REGNUM, fp);
-  trad_frame_set_reg_addr (this_cache, AARCH64_LR_REGNUM, fp + 8);
-  trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM, fp + 8);
-
-  trad_frame_set_id (this_cache, frame_id_build (fp, func));
+  trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM,
+                          sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET
+                            + 31 * AARCH64_SIGCONTEXT_REG_SIZE);
+  trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM,
+                          sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET
+                            + 32 * AARCH64_SIGCONTEXT_REG_SIZE);
+
+  trad_frame_set_id (this_cache, frame_id_build (sp, func));
 }
 
 static const struct tramp_frame aarch64_linux_rt_sigframe =
@@ -240,6 +245,18 @@ supply_fpregset_from_core (const struct regset *regset,
   aarch64_linux_supply_fpregset (regcache, (const gdb_byte *) regbuf);
 }
 
+/* Register set definitions. */
+
+static const struct regset aarch64_linux_gregset =
+  {
+    NULL, supply_gregset_from_core, NULL
+  };
+
+static const struct regset aarch64_linux_fpregset =
+  {
+    NULL, supply_fpregset_from_core, NULL
+  };
+
 /* Implement the "regset_from_core_section" gdbarch method.  */
 
 static const struct regset *
@@ -247,25 +264,14 @@ aarch64_linux_regset_from_core_section (struct gdbarch *gdbarch,
                                        const char *sect_name,
                                        size_t sect_size)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-
   if (strcmp (sect_name, ".reg") == 0
       && sect_size == AARCH64_LINUX_SIZEOF_GREGSET)
-    {
-      if (tdep->gregset == NULL)
-       tdep->gregset = regset_alloc (gdbarch, supply_gregset_from_core,
-                                     NULL);
-      return tdep->gregset;
-    }
+    return &aarch64_linux_gregset;
 
   if (strcmp (sect_name, ".reg2") == 0
       && sect_size == AARCH64_LINUX_SIZEOF_FPREGSET)
-    {
-      if (tdep->fpregset == NULL)
-       tdep->fpregset = regset_alloc (gdbarch, supply_fpregset_from_core,
-                                      NULL);
-      return tdep->fpregset;
-    }
+    return &aarch64_linux_fpregset;
+
   return NULL;
 }
 
@@ -352,28 +358,28 @@ aarch64_stap_parse_special_token (struct gdbarch *gdbarch,
        return 0;
 
       /* The displacement.  */
-      write_exp_elt_opcode (OP_LONG);
-      write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
-      write_exp_elt_longcst (displacement);
-      write_exp_elt_opcode (OP_LONG);
+      write_exp_elt_opcode (&p->pstate, OP_LONG);
+      write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
+      write_exp_elt_longcst (&p->pstate, displacement);
+      write_exp_elt_opcode (&p->pstate, OP_LONG);
       if (got_minus)
-       write_exp_elt_opcode (UNOP_NEG);
+       write_exp_elt_opcode (&p->pstate, UNOP_NEG);
 
       /* The register name.  */
-      write_exp_elt_opcode (OP_REGISTER);
+      write_exp_elt_opcode (&p->pstate, OP_REGISTER);
       str.ptr = regname;
       str.length = len;
-      write_exp_string (str);
-      write_exp_elt_opcode (OP_REGISTER);
+      write_exp_string (&p->pstate, str);
+      write_exp_elt_opcode (&p->pstate, OP_REGISTER);
 
-      write_exp_elt_opcode (BINOP_ADD);
+      write_exp_elt_opcode (&p->pstate, BINOP_ADD);
 
       /* Casting to the expected type.  */
-      write_exp_elt_opcode (UNOP_CAST);
-      write_exp_elt_type (lookup_pointer_type (p->arg_type));
-      write_exp_elt_opcode (UNOP_CAST);
+      write_exp_elt_opcode (&p->pstate, UNOP_CAST);
+      write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type));
+      write_exp_elt_opcode (&p->pstate, UNOP_CAST);
 
-      write_exp_elt_opcode (UNOP_IND);
+      write_exp_elt_opcode (&p->pstate, UNOP_IND);
 
       p->arg = tmp;
     }
This page took 0.026159 seconds and 4 git commands to generate.