aboutsummaryrefslogtreecommitdiff
path: root/gdb/spu-tdep.c
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2014-04-17 14:09:49 +0200
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2014-04-17 14:09:49 +0200
commit7ce16bd4c4d5e6f6a48ca7fcf532720fec0406bf (patch)
tree363fbc82309818891ffcec900bc9165648f9b1f8 /gdb/spu-tdep.c
parent2ed3c037cf8aac5f6dbee5b6c2a1239550a04202 (diff)
downloadgdb-7ce16bd4c4d5e6f6a48ca7fcf532720fec0406bf.zip
gdb-7ce16bd4c4d5e6f6a48ca7fcf532720fec0406bf.tar.gz
gdb-7ce16bd4c4d5e6f6a48ca7fcf532720fec0406bf.tar.bz2
Enable DWARF unwinders for SPU
This patch enables use of DWARF unwinders for the SPU target. In addition to appending the DWARF unwinders, we also need to install a spu_dwarf_reg_to_regnum that maps the raw stack pointer register to the cooked version (to avoid mismatches with gdbarch_sp_regnum). This also causes confusion with the AX collect handling, so we also install ax_pseudo_register routines to handle the cooked SP. gdb/ 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * spu-tdep.c: Include "dwarf2-frame.h" and "ax.h". (spu_ax_pseudo_register_collect): New function. (spu_ax_pseudo_register_push_stack): Likewise. (spu_dwarf_reg_to_regnum): Likewise. (spu_gdbarch_init): Install them. Append DWARF unwinders.
Diffstat (limited to 'gdb/spu-tdep.c')
-rw-r--r--gdb/spu-tdep.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 0f23b0f..4fc3ca5 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -44,6 +44,8 @@
#include "observer.h"
#include "infcall.h"
#include "dwarf2.h"
+#include "dwarf2-frame.h"
+#include "ax.h"
#include "exceptions.h"
#include "spu-tdep.h"
@@ -311,6 +313,51 @@ spu_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
}
}
+static int
+spu_ax_pseudo_register_collect (struct gdbarch *gdbarch,
+ struct agent_expr *ax, int regnum)
+{
+ switch (regnum)
+ {
+ case SPU_SP_REGNUM:
+ ax_reg_mask (ax, SPU_RAW_SP_REGNUM);
+ return 0;
+
+ case SPU_FPSCR_REGNUM:
+ case SPU_SRR0_REGNUM:
+ case SPU_LSLR_REGNUM:
+ case SPU_DECR_REGNUM:
+ case SPU_DECR_STATUS_REGNUM:
+ return -1;
+
+ default:
+ internal_error (__FILE__, __LINE__, _("invalid regnum"));
+ }
+}
+
+static int
+spu_ax_pseudo_register_push_stack (struct gdbarch *gdbarch,
+ struct agent_expr *ax, int regnum)
+{
+ switch (regnum)
+ {
+ case SPU_SP_REGNUM:
+ ax_reg (ax, SPU_RAW_SP_REGNUM);
+ return 0;
+
+ case SPU_FPSCR_REGNUM:
+ case SPU_SRR0_REGNUM:
+ case SPU_LSLR_REGNUM:
+ case SPU_DECR_REGNUM:
+ case SPU_DECR_STATUS_REGNUM:
+ return -1;
+
+ default:
+ internal_error (__FILE__, __LINE__, _("invalid regnum"));
+ }
+}
+
+
/* Value conversion -- access scalar values at the preferred slot. */
static struct value *
@@ -352,6 +399,15 @@ spu_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
return default_register_reggroup_p (gdbarch, regnum, group);
}
+/* DWARF-2 register numbers. */
+
+static int
+spu_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
+{
+ /* Use cooked instead of raw SP. */
+ return (reg == SPU_RAW_SP_REGNUM)? SPU_SP_REGNUM : reg;
+}
+
/* Address handling. */
@@ -2680,6 +2736,11 @@ spu_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_pseudo_register_write (gdbarch, spu_pseudo_register_write);
set_gdbarch_value_from_register (gdbarch, spu_value_from_register);
set_gdbarch_register_reggroup_p (gdbarch, spu_register_reggroup_p);
+ set_gdbarch_dwarf2_reg_to_regnum (gdbarch, spu_dwarf_reg_to_regnum);
+ set_gdbarch_ax_pseudo_register_collect
+ (gdbarch, spu_ax_pseudo_register_collect);
+ set_gdbarch_ax_pseudo_register_push_stack
+ (gdbarch, spu_ax_pseudo_register_push_stack);
/* Data types. */
set_gdbarch_char_signed (gdbarch, 0);
@@ -2718,6 +2779,7 @@ spu_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Frame handling. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
+ dwarf2_append_unwinders (gdbarch);
frame_unwind_append_unwinder (gdbarch, &spu_frame_unwind);
frame_base_set_default (gdbarch, &spu_frame_base);
set_gdbarch_unwind_pc (gdbarch, spu_unwind_pc);