aboutsummaryrefslogtreecommitdiff
path: root/sim/cr16
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2012-08-30 06:10:28 +0000
committerMike Frysinger <vapier@gentoo.org>2012-08-30 06:10:28 +0000
commit5a06d7c470e4dfd5f66ba9b6a93d9a77d4910e07 (patch)
tree42c53ad4bd9a45129ab069a279615065547c9110 /sim/cr16
parent4881a75b8b097924cac2f6ee2d22de879111127a (diff)
downloadgdb-5a06d7c470e4dfd5f66ba9b6a93d9a77d4910e07.zip
gdb-5a06d7c470e4dfd5f66ba9b6a93d9a77d4910e07.tar.gz
gdb-5a06d7c470e4dfd5f66ba9b6a93d9a77d4910e07.tar.bz2
sim: cr16: improve trap handling
Diffstat (limited to 'sim/cr16')
-rw-r--r--sim/cr16/ChangeLog2
-rw-r--r--sim/cr16/cr16_sim.h6
-rw-r--r--sim/cr16/interp.c4
-rw-r--r--sim/cr16/simops.c21
4 files changed, 31 insertions, 2 deletions
diff --git a/sim/cr16/ChangeLog b/sim/cr16/ChangeLog
index 094d54c..f0c62c3 100644
--- a/sim/cr16/ChangeLog
+++ b/sim/cr16/ChangeLog
@@ -1,6 +1,8 @@
2012-08-28 Kaushik Phatak <kaushik.phatak@kpitcummins.com>
+ * cr16_sim.h: Add defines for TRAP handling.
* interp.c (sim_complete_command): New stub function.
+ * simops.c: Breakpoint handling code.
2012-06-17 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/cr16/cr16_sim.h b/sim/cr16/cr16_sim.h
index c7783ba..7252b14 100644
--- a/sim/cr16/cr16_sim.h
+++ b/sim/cr16/cr16_sim.h
@@ -472,3 +472,9 @@ extern void write_longlong PARAMS ((uint8 *addr, int64 data));
PSR is masked for zero bits. */
extern creg_t move_to_cr (int cr, creg_t mask, creg_t val, int psw_hw_p);
+
+#ifndef SIGTRAP
+#define SIGTRAP 5
+#endif
+/* Special purpose trap */
+#define TRAP_BREAKPOINT 8
diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c
index 1207906..36f848e 100644
--- a/sim/cr16/interp.c
+++ b/sim/cr16/interp.c
@@ -1192,7 +1192,11 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
iaddr = imem_addr ((uint32)PC);
if (iaddr == State.mem.fault)
{
+#ifdef SIGBUS
State.exception = SIGBUS;
+#else
+ State.exception = SIGSEGV;
+#endif
break;
}
diff --git a/sim/cr16/simops.c b/sim/cr16/simops.c
index f8fee8a..2e5e9eb 100644
--- a/sim/cr16/simops.c
+++ b/sim/cr16/simops.c
@@ -5059,6 +5059,8 @@ OP_14C_14 ()
void
OP_C_C ()
{
+ uint32 tmp;
+ uint16 a;
trace_input ("excp", OP_CONSTANT4, OP_VOID, OP_VOID);
switch (OP[0])
{
@@ -5465,9 +5467,24 @@ OP_C_C ()
#endif
default:
- cr16_callback->error (cr16_callback, "Unknown syscall %d", FUNC);
+ a = OP[0];
+ switch (a)
+ {
+ case TRAP_BREAKPOINT:
+ State.exception = SIGTRAP;
+ tmp = (PC);
+ JMP(tmp);
+ trace_output_void ();
+ break;
+ case SIGTRAP: /* supervisor call ? */
+ State.exception = SIG_CR16_EXIT;
+ trace_output_void ();
+ break;
+ default:
+ cr16_callback->error (cr16_callback, "Unknown syscall %d", FUNC);
+ break;
+ }
}
-
if ((uint16) result == (uint16) -1)
RETERR (cr16_callback->get_errno(cr16_callback));
else