RE: [RFC] New GDB Port CR16

Kaushik Phatak
2012-08-28T14:47:14Z

[-- Attachment #1: Type: text/plain, Size: 1633 bytes --]

Hi Mike,Yao,
Thanks for all your comments.

> might be nice if you were to split them up and commit them separately
I have attached an updated patch with purely sim port related changes.
The patch changes the following files in gdb-sim
/sim/common/gennltvals.sh
/sim/common/nltvals.def
/sim/cr16/cr16_sim.h
/sim/cr16/interp.c
/sim/cr16/simops.c

I have tried to address the other points as follows,

> but that should be "(void)". i imagine this sim port probably has
> a bunch of those bugs lurking though.
Yes, but I have not tinkered with this as yet.

> pretty sure the indentation here is incorrect.
My mistake. This was a switch inside a switch and my case statements were
aligned with the first level case statements. This is now fixed.

> please do not use C++ style comments
This is now fixed.

> this new local prototype makes no sense. just delete it.
OK. I will create separate binutils patch with these changes and submit it
to binutils at sourceware dot org as per Yao Qi's suggestion.

> The changes for top-level configure stuff should be submitted to
> gcc-patches with changelog entry.
Thanks Yao for these patch submission tips.

2012-08-28 Kaushik Phatak <kaushik.phatak@kpitcummins.com>

sim/common/
* gennltvals.sh: Use libgloss/syscall.h for cr16.
* nltvals.def: Regenerate.
sim/cr16/ChangeLog:
* interp.c (sim_complete_command): New stub function.
* cr16_sim.h : Add defines for TRAP handling.
* simops.c: Breakpoint handling code.

Thanks & Best Regards,
Kaushik
kaushik.phatak@kpitcummins.com
KPIT Cummins Infosystems Ltd
www.kpitcummins.com

[-- Attachment #2: cr16_sim.diff --]
[-- Type: application/octet-stream, Size: 4001 bytes --]

--- gdb_src.orig/sim/common/gennltvals.sh 2012-03-19 10:24:48.000000000 +0530
+++ ./gdb_src/sim/common/gennltvals.sh 2012-08-17 15:35:15.000000000 +0530
@@ -41,7 +41,7 @@ $shell ${srccom}/gentvals.sh $target sys
# OBSOLETE $shell ${srccom}/gentvals.sh $target sys ${srcroot}/$dir \
# OBSOLETE "syscall.h" 'SYS_[_[:alnum:]]*' "${cpp}"

-dir=libgloss target=cr16
+dir=libgloss/cr16/sys target=cr16
$shell ${srccom}/gentvals.sh $target sys ${srcroot}/$dir \
"syscall.h" 'SYS_[_[:alnum:]]*' "${cpp}"

--- gdb_src.orig/sim/common/nltvals.def 2011-05-26 23:50:13.000000000 +0530
+++ ./gdb_src/sim/common/nltvals.def 2012-08-17 15:36:39.000000000 +0530
@@ -218,30 +218,34 @@
#ifdef sys_defs
/* from syscall.h */
/* begin cr16 sys target macros */
- { "SYS_argc", 22 },
- { "SYS_argn", 24 },
- { "SYS_argnlen", 23 },
- { "SYS_argv", 13 },
- { "SYS_argvlen", 12 },
- { "SYS_chdir", 14 },
- { "SYS_chmod", 16 },
- { "SYS_close", 3 },
- { "SYS_exit", 1 },
- { "SYS_fstat", 10 },
- { "SYS_getpid", 8 },
- { "SYS_gettimeofday", 19 },
- { "SYS_kill", 9 },
- { "SYS_link", 21 },
- { "SYS_lseek", 6 },
- { "SYS_open", 2 },
- { "SYS_read", 4 },
- { "SYS_reconfig", 25 },
- { "SYS_stat", 15 },
- { "SYS_time", 18 },
- { "SYS_times", 20 },
- { "SYS_unlink", 7 },
- { "SYS_utime", 17 },
- { "SYS_write", 5 },
+ { "SYS_ARG", 24 },
+ { "SYS_chdir", 12 },
+ { "SYS_chmod", 15 },
+ { "SYS_chown", 16 },
+ { "SYS_close", 0x402 },
+ { "SYS_create", 8 },
+ { "SYS_execv", 11 },
+ { "SYS_execve", 59 },
+ { "SYS_exit", 0x410 },
+ { "SYS_fork", 2 },
+ { "SYS_fstat", 22 },
+ { "SYS_getpid", 20 },
+ { "SYS_isatty", 21 },
+ { "SYS_kill", 60 },
+ { "SYS_link", 9 },
+ { "SYS_lseek", 0x405 },
+ { "SYS_mknod", 14 },
+ { "SYS_open", 0x401 },
+ { "SYS_pipe", 42 },
+ { "SYS_read", 0x403 },
+ { "SYS_rename", 0x406 },
+ { "SYS_stat", 38 },
+ { "SYS_time", 0x300 },
+ { "SYS_unlink", 0x407 },
+ { "SYS_utime", 201 },
+ { "SYS_wait", 202 },
+ { "SYS_wait4", 7 },
+ { "SYS_write", 0x404 },
/* end cr16 sys target macros */
#endif
#endif
--- gdb_src.orig/sim/cr16/cr16_sim.h 2012-01-04 13:58:07.000000000 +0530
+++ ./gdb_src/sim/cr16/cr16_sim.h 2012-08-24 17:22:24.000000000 +0530
@@ -472,3 +472,9 @@ extern void write_longlong PARAMS ((uint
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
--- gdb_src.orig/sim/cr16/interp.c 2012-06-18 05:04:17.000000000 +0530
+++ ./gdb_src/sim/cr16/interp.c 2012-08-17 15:41:35.000000000 +0530
@@ -1192,7 +1192,11 @@ sim_resume (SIM_DESC sd, int step, int s
iaddr = imem_addr ((uint32)PC);
if (iaddr == State.mem.fault)
{
+#ifdef SIGBUS
State.exception = SIGBUS;
+#else
+ State.exception = SIGSEGV;
+#endif
break;
}

@@ -1548,6 +1552,11 @@ sim_store_register (sd, rn, memory, leng
return size;
}

+char **
+sim_complete_command (SIM_DESC sd, char *text, char *word)
+{
+ return NULL;
+}

void
sim_do_command (sd, cmd)
--- gdb_src.orig/sim/cr16/simops.c 2012-01-04 13:58:07.000000000 +0530
+++ ./gdb_src/sim/cr16/simops.c 2012-08-28 17:57:49.000000000 +0530
@@ -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