summaryrefslogtreecommitdiffstats
path: root/c/src/librdbg/src
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-08-10 16:41:44 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-08-10 16:41:44 +0000
commit981b99faf208e2c7f6e2b83d73e1b89b669112ee (patch)
tree1f2e2b431853a81be77417c1026c75c53e04d5ea /c/src/librdbg/src
parentNew configuration files added by patch from (diff)
downloadrtems-981b99faf208e2c7f6e2b83d73e1b89b669112ee.tar.bz2
Patch from Eric Valette <valette@crf.canon.fr> and Emmanuel Raguet
<raguet@crf.canon.fr>: - the dec21140 driver code has been hardened (various bug fixed) Emmanuel, - bug in the mcp750 init code have been fixed (interrupt stack/initial stack initialization), BSS correctly cleared (Eric V) - remote debugging over TCP/IP is nearly complete (berakpoints, backtrace, variables,...) (Eric V), - exception handling code has also been improved in order to fully support RDBG requirements (Eric V),
Diffstat (limited to '')
-rw-r--r--c/src/librdbg/src/_servtgt.c63
-rw-r--r--c/src/librdbg/src/awk.svc4
-rw-r--r--c/src/librdbg/src/excep.c136
-rw-r--r--c/src/librdbg/src/i386/any/Makefile.in6
-rw-r--r--c/src/librdbg/src/i386/any/remdeb_f.x1
-rw-r--r--c/src/librdbg/src/i386/excep.c233
-rw-r--r--c/src/librdbg/src/i386/excep_f.c153
-rw-r--r--c/src/librdbg/src/i386/pc386/Makefile.in6
-rw-r--r--c/src/librdbg/src/i386/pc386/remdeb_f.x1
-rw-r--r--c/src/librdbg/src/i386/rdbg_cpu_asm.S4
-rw-r--r--c/src/librdbg/src/i386/rdbg_f.c25
-rw-r--r--c/src/librdbg/src/powerpc/Makefile.in25
-rw-r--r--c/src/librdbg/src/powerpc/excep_f.c167
-rw-r--r--c/src/librdbg/src/powerpc/mcp750/Makefile.in114
-rw-r--r--c/src/librdbg/src/powerpc/mcp750/remdeb_f.x76
-rw-r--r--c/src/librdbg/src/powerpc/new_exception_processing/remdeb_f.x76
-rw-r--r--c/src/librdbg/src/powerpc/rdbg_cpu_asm.S82
-rw-r--r--c/src/librdbg/src/powerpc/rdbg_f.c156
-rw-r--r--c/src/librdbg/src/ptrace.c10
-rw-r--r--c/src/librdbg/src/rdbg.c2
-rw-r--r--c/src/librdbg/src/remdeb.x2
-rw-r--r--c/src/librdbg/src/servbkpt.c2
-rw-r--r--c/src/librdbg/src/servcon.c2
-rw-r--r--c/src/librdbg/src/servrpc.c2
-rw-r--r--c/src/librdbg/src/servtgt.c2
-rw-r--r--c/src/librdbg/src/servtsp.c2
-rw-r--r--c/src/librdbg/src/servutil.c2
27 files changed, 1050 insertions, 304 deletions
diff --git a/c/src/librdbg/src/_servtgt.c b/c/src/librdbg/src/_servtgt.c
index 184415a1e2..b58ac0e676 100644
--- a/c/src/librdbg/src/_servtgt.c
+++ b/c/src/librdbg/src/_servtgt.c
@@ -1,6 +1,7 @@
/*
============================================================================
- _SERVTGT
+ _SERVTGT
+ $Id$
============================================================================
*/
@@ -17,9 +18,6 @@
#include <assert.h>
#include <rtems/score/cpu.h>
-extern void rtems_exception_prologue_50();
-
-
#ifdef DDEBUG
#define Ptrace TgtDbgPtrace
#else
@@ -34,8 +32,6 @@ rtems_id wakeupEventSemId;
CPU_Exception_frame Idle_frame;
-cpuExcHandlerType old_currentExcHandler;
-
/* -----------------------------------------------------------------
TgtRealPtrace - lowest level ptrace() wrapper
----------------------------------------------------------------- */
@@ -47,43 +43,6 @@ TgtRealPtrace(int req, PID aid, char* addr, int d, void* addr2)
}
-/* -----------------------------------------------------------------
- Maping of hardware exceptions into Unix-like signal numbers.
- It is identical to the one used by the PM and the AM.
- ----------------------------------------------------------------- */
-
- int
-ExcepToSig (int excep)
-{
- switch (excep) {
-
- case I386_EXCEPTION_MATH_COPROC_UNAVAIL:
- case I386_EXCEPTION_I386_COPROC_SEG_ERR:
- case I386_EXCEPTION_FLOAT_ERROR:
- case I386_EXCEPTION_BOUND:
- return SIGFPE;
-
- case I386_EXCEPTION_DEBUG:
- case I386_EXCEPTION_BREAKPOINT:
- case I386_EXCEPTION_ENTER_RDBG:
- return SIGTRAP;
-
- case I386_EXCEPTION_OVERFLOW:
- case I386_EXCEPTION_DIVIDE_BY_ZERO:
- case I386_EXCEPTION_ILLEGAL_INSTR:
- return SIGILL;
-
- case I386_EXCEPTION_SEGMENT_NOT_PRESENT:
- case I386_EXCEPTION_STACK_SEGMENT_FAULT:
- case I386_EXCEPTION_GENERAL_PROT_ERR:
- case I386_EXCEPTION_PAGE_FAULT:
- return SIGSEGV;
-
- default:
- break;
- }
- return SIGKILL;
-}
/* -----------------------------------------------------------------------
TgtChange() is called when the system stops.
@@ -128,7 +87,7 @@ rtems_task eventTask( rtems_task_argument pid)
CheckForSingleStep(ctx->ctx);
- TgtChange(pid, ctx->ctx,STS_MAKESIG(ExcepToSig(ctx->ctx->idtIndex)));
+ TgtChange(pid, ctx->ctx,STS_MAKESIG(ExcepToSig(ctx)));
}
}
@@ -162,9 +121,6 @@ Boolean TgtAttach(
rtems_name task_name;
rtems_status_code status;
rtems_id debugId;
- interrupt_gate_descriptor *currentIdtEntry;
- unsigned limit;
- unsigned level;
errno = 0;
@@ -177,19 +133,8 @@ Boolean TgtAttach(
TgtCreateNew(pid, conn_idx, 0, NULL, False);
- /*
- * Connect the Exception used to debug
- */
- i386_get_info_from_IDTR (&currentIdtEntry, &limit);
+ connect_rdbg_exception();
- _CPU_ISR_Disable(level);
- create_interrupt_gate_descriptor (&currentIdtEntry[50], rtems_exception_prologue_50);
- _CPU_ISR_Enable(level);
-
- old_currentExcHandler = _currentExcHandler;
- _currentExcHandler = BreakPointExcHdl ;
-
-
/*
* Create the attach debuger task
*/
diff --git a/c/src/librdbg/src/awk.svc b/c/src/librdbg/src/awk.svc
index 79e24a9d90..b9a88bdaca 100644
--- a/c/src/librdbg/src/awk.svc
+++ b/c/src/librdbg/src/awk.svc
@@ -7,7 +7,9 @@
# by rpcgen(1) into something suitable for RDB servers.
#
#########################################################################
-
+#
+# $Id$
+#
BEGIN {
headerstarted = 0
withinproc = 0
diff --git a/c/src/librdbg/src/excep.c b/c/src/librdbg/src/excep.c
new file mode 100644
index 0000000000..d3183e24e2
--- /dev/null
+++ b/c/src/librdbg/src/excep.c
@@ -0,0 +1,136 @@
+/*
+ **************************************************************************
+ *
+ * Component =
+ *
+ * Synopsis = rdbgexcep.c
+ *
+ * $Id$
+ *
+ **************************************************************************
+ */
+
+#include <rtems.h>
+#include <rtems/error.h>
+#include <assert.h>
+#include <errno.h>
+#include <rdbg/rdbg.h>
+#include <rdbg/servrpc.h>
+
+unsigned int NbExceptCtx;
+volatile unsigned int NbSerializedCtx;
+Exception_context *FirstCtx = NULL;
+Exception_context *LastCtx = NULL;
+
+CPU_Exception_frame SavedContext;
+
+
+/********* Save an exception context at the end of a list *****/
+
+int PushExceptCtx ( Objects_Id Id, Objects_Id semId, CPU_Exception_frame *ctx ) {
+
+ Exception_context *SaveCtx;
+
+ SaveCtx = (Exception_context *)malloc(sizeof(Exception_context));
+ if (SaveCtx == NULL)
+ rtems_panic("Can't allocate memory to save Exception context");
+
+ SaveCtx->id = Id;
+ SaveCtx->ctx = ctx;
+ SaveCtx->semaphoreId = semId;
+ SaveCtx->previous = NULL;
+ SaveCtx->next = NULL;
+
+ if (FirstCtx == NULL){ /* initialization */
+ FirstCtx = SaveCtx;
+ LastCtx = SaveCtx;
+ NbExceptCtx = 1;
+ }
+ else {
+ NbExceptCtx ++;
+ LastCtx->next = SaveCtx;
+ SaveCtx->previous = LastCtx;
+ LastCtx = SaveCtx;
+ }
+ return 0;
+}
+
+/********* Save an temporary exception context in a ******/
+/********* global variable ******/
+
+int PushSavedExceptCtx ( Objects_Id Id, CPU_Exception_frame *ctx ) {
+
+ memcpy (&(SavedContext), ctx, sizeof(CPU_Exception_frame));
+ return 0;
+}
+
+
+/****** Remove the context of the specified Id thread *********/
+/****** If Id = -1, then return the first context *********/
+
+
+int PopExceptCtx ( Objects_Id Id ) {
+
+ Exception_context *ExtractCtx;
+
+ if (FirstCtx == NULL) return -1;
+
+ if (Id == -1) {
+ ExtractCtx = LastCtx;
+ LastCtx = LastCtx->previous;
+ free(ExtractCtx);
+ NbExceptCtx --;
+ return 0;
+ }
+
+ ExtractCtx = LastCtx;
+
+ while (ExtractCtx->id != Id && ExtractCtx != NULL) {
+ ExtractCtx = ExtractCtx->previous;
+ }
+
+ if (ExtractCtx == NULL)
+ return -1;
+
+ if ( ExtractCtx->previous != NULL)
+ (ExtractCtx->previous)->next = ExtractCtx->next;
+
+ if ( ExtractCtx->next != NULL)
+ (ExtractCtx->next)->previous = ExtractCtx->previous;
+
+ if (ExtractCtx == FirstCtx)
+ FirstCtx = FirstCtx->next;
+ else
+ if (ExtractCtx == LastCtx)
+ LastCtx = LastCtx->previous;
+
+ free(ExtractCtx);
+ NbExceptCtx --;
+ return 0;
+}
+
+/****** Return the context of the specified Id thread *********/
+/****** If Id = -1, then return the first context *********/
+
+
+Exception_context *GetExceptCtx ( Objects_Id Id ) {
+
+ Exception_context *ExtractCtx;
+
+ if (FirstCtx == NULL) return NULL;
+
+ if (Id == -1) {
+ return LastCtx;
+ }
+
+ ExtractCtx = LastCtx;
+
+ while (ExtractCtx->id != Id && ExtractCtx != NULL) {
+ ExtractCtx = ExtractCtx->previous;
+ }
+
+ if (ExtractCtx == NULL)
+ return NULL;
+
+ return ExtractCtx;
+}
diff --git a/c/src/librdbg/src/i386/any/Makefile.in b/c/src/librdbg/src/i386/any/Makefile.in
index 9663082c39..aeaab6cb8a 100644
--- a/c/src/librdbg/src/i386/any/Makefile.in
+++ b/c/src/librdbg/src/i386/any/Makefile.in
@@ -17,8 +17,10 @@ LIBNAME = librdbg.a
LIB = ${ARCH}/${LIBNAME}
# C and C++ source names, if any, go here -- minus the .c or .cc
-C_PIECES = rdbg servcon servbkpt servrpc excep servtgt servtsp servutil \
- _servtgt rdbg_f ptrace
+C_PIECES = rdbg servcon servbkpt servrpc excep excep_f \
+ servtgt servtsp servutil _servtgt rdbg_f \
+ ptrace
+
C_FILES = $(C_PIECES:%=%.c)
C_O_FILES = $(C_PIECES:%=${ARCH}/%.o)
diff --git a/c/src/librdbg/src/i386/any/remdeb_f.x b/c/src/librdbg/src/i386/any/remdeb_f.x
index 0ff52d1307..01d899fe54 100644
--- a/c/src/librdbg/src/i386/any/remdeb_f.x
+++ b/c/src/librdbg/src/i386/any/remdeb_f.x
@@ -5,6 +5,7 @@
*
* Synopsis = remdeb_f.x
*
+ * $Id$
*
**************************************************************************
*/
diff --git a/c/src/librdbg/src/i386/excep.c b/c/src/librdbg/src/i386/excep.c
index 497c804e70..e69de29bb2 100644
--- a/c/src/librdbg/src/i386/excep.c
+++ b/c/src/librdbg/src/i386/excep.c
@@ -1,233 +0,0 @@
-/*
- **************************************************************************
- *
- * Component =
- *
- * Synopsis = rdbg/i386/excep.c
- *
- **************************************************************************
- */
-
-#include <rtems.h>
-#include <rtems/error.h>
-#include <rdbg/rdbg_f.h>
-#include <assert.h>
-#include <errno.h>
-#include <rdbg/rdbg.h>
-#include <rdbg/servrpc.h>
-
-
-extern rtems_id serializeSemId;
-extern rtems_id wakeupEventSemId;
-
-
-unsigned int NbExceptCtx;
-volatile unsigned int NbSerializedCtx;
-Exception_context *FirstCtx = NULL;
-Exception_context *LastCtx = NULL;
-
-CPU_Exception_frame SavedContext;
-
-
-/********* Save an exception context at the end of a list *****/
-
-int PushExceptCtx ( Objects_Id Id, Objects_Id semId, CPU_Exception_frame *ctx ) {
-
- Exception_context *SaveCtx;
-
- SaveCtx = (Exception_context *)malloc(sizeof(Exception_context));
- if (SaveCtx == NULL)
- rtems_panic("Can't allocate memory to save Exception context");
-
- SaveCtx->id = Id;
- SaveCtx->ctx = ctx;
- SaveCtx->semaphoreId = semId;
- SaveCtx->previous = NULL;
- SaveCtx->next = NULL;
-
- if (FirstCtx == NULL){ /* initialization */
- FirstCtx = SaveCtx;
- LastCtx = SaveCtx;
- NbExceptCtx = 1;
- }
- else {
- NbExceptCtx ++;
- LastCtx->next = SaveCtx;
- SaveCtx->previous = LastCtx;
- LastCtx = SaveCtx;
- }
- return 0;
-}
-
-/********* Save an temporary exception context in a ******/
-/********* global variable ******/
-
-int PushSavedExceptCtx ( Objects_Id Id, CPU_Exception_frame *ctx ) {
-
- memcpy (&(SavedContext), ctx, sizeof(CPU_Exception_frame));
- return 0;
-}
-
-
-/****** Remove the context of the specified Id thread *********/
-/****** If Id = -1, then return the first context *********/
-
-
-int PopExceptCtx ( Objects_Id Id ) {
-
- Exception_context *ExtractCtx;
-
- if (FirstCtx == NULL) return -1;
-
- if (Id == -1) {
- ExtractCtx = LastCtx;
- LastCtx = LastCtx->previous;
- free(ExtractCtx);
- NbExceptCtx --;
- return 0;
- }
-
- ExtractCtx = LastCtx;
-
- while (ExtractCtx->id != Id && ExtractCtx != NULL) {
- ExtractCtx = ExtractCtx->previous;
- }
-
- if (ExtractCtx == NULL)
- return -1;
-
- if ( ExtractCtx->previous != NULL)
- (ExtractCtx->previous)->next = ExtractCtx->next;
-
- if ( ExtractCtx->next != NULL)
- (ExtractCtx->next)->previous = ExtractCtx->previous;
-
- if (ExtractCtx == FirstCtx)
- FirstCtx = FirstCtx->next;
- else
- if (ExtractCtx == LastCtx)
- LastCtx = LastCtx->previous;
-
- free(ExtractCtx);
- NbExceptCtx --;
- return 0;
-}
-
-/****** Return the context of the specified Id thread *********/
-/****** If Id = -1, then return the first context *********/
-
-
-Exception_context *GetExceptCtx ( Objects_Id Id ) {
-
- Exception_context *ExtractCtx;
-
- if (FirstCtx == NULL) return NULL;
-
- if (Id == -1) {
- return LastCtx;
- }
-
- ExtractCtx = LastCtx;
-
- while (ExtractCtx->id != Id && ExtractCtx != NULL) {
- ExtractCtx = ExtractCtx->previous;
- }
-
- if (ExtractCtx == NULL)
- return NULL;
-
- return ExtractCtx;
-}
-
-/*----- Breakpoint Exception management -----*/
-
- /*
- * Handler for Breakpoint Exceptions :
- * software breakpoints.
- */
-
-void
-BreakPointExcHdl(CPU_Exception_frame *ctx)
-{
- rtems_status_code status;
- rtems_id continueSemId;
-
- if ( (justSaveContext) && (ctx->idtIndex == I386_EXCEPTION_ENTER_RDBG) ) {
- PushSavedExceptCtx (_Thread_Executing->Object.id, ctx);
- justSaveContext = 0;
- }
- else {
- if (ctx->idtIndex != I386_EXCEPTION_DEBUG){
- NbSerializedCtx++;
- rtems_semaphore_obtain(serializeSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
- NbSerializedCtx--;
- }
-
- currentTargetThread = _Thread_Executing->Object.id;
-
-#ifdef DDEBUG
- printk("----------------------------------------------------------\n");
- printk("Exception %d caught at PC %x by thread %d\n",
- ctx->idtIndex,
- ctx->eip,
- _Thread_Executing->Object.id);
- printk("----------------------------------------------------------\n");
- printk("Processor execution context at time of the fault was :\n");
- printk("----------------------------------------------------------\n");
- printk(" EAX = %x EBX = %x ECX = %x EDX = %x\n",
- ctx->eax, ctx->ebx, ctx->ecx, ctx->edx);
- printk(" ESI = %x EDI = %x EBP = %x ESP = %x\n",
- ctx->esi, ctx->edi, ctx->ebp, ctx->esp0);
- printk("----------------------------------------------------------\n");
- printk("Error code pushed by processor itself (if not 0) = %x\n",
- ctx->faultCode);
- printk("----------------------------------------------------------\n\n");
-#endif
-
- status = rtems_semaphore_create (rtems_build_name('D', 'B', 'G', 'c'),
- 0,
- RTEMS_FIFO |
- RTEMS_COUNTING_SEMAPHORE |
- RTEMS_NO_INHERIT_PRIORITY |
- RTEMS_NO_PRIORITY_CEILING |
- RTEMS_LOCAL,
- 0,
- &continueSemId);
- if (status != RTEMS_SUCCESSFUL)
- rtems_panic ("Can't create continue semaphore: `%s'\n",rtems_status_text(status));
-
- PushExceptCtx (_Thread_Executing->Object.id, continueSemId, ctx);
-
- switch (ctx->idtIndex){
- case I386_EXCEPTION_DEBUG:
- DPRINTF((" DEBUG EXCEPTION !!!\n"));
- ctx->eflags &= ~EFLAGS_TF;
- ExitForSingleStep-- ;
- rtems_semaphore_release( wakeupEventSemId );
- break;
-
- case I386_EXCEPTION_BREAKPOINT:
- DPRINTF((" BREAKPOINT EXCEPTION !!!\n"));
- rtems_semaphore_release( wakeupEventSemId );
- break;
-
- case I386_EXCEPTION_ENTER_RDBG:
- DPRINTF((" ENTER RDBG !!!\n"));
- rtems_semaphore_release( wakeupEventSemId );
- break;
-
- default:
- DPRINTF((" OTHER EXCEPTION !!!\n"));
- rtems_semaphore_release( wakeupEventSemId );
- break;
- }
-
- rtems_semaphore_obtain(continueSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
-
- PopExceptCtx (_Thread_Executing->Object.id);
- rtems_semaphore_delete(continueSemId);
- }
-}
-
-
-
diff --git a/c/src/librdbg/src/i386/excep_f.c b/c/src/librdbg/src/i386/excep_f.c
new file mode 100644
index 0000000000..100b0d79d6
--- /dev/null
+++ b/c/src/librdbg/src/i386/excep_f.c
@@ -0,0 +1,153 @@
+/*
+ **************************************************************************
+ *
+ * Component =
+ *
+ * Synopsis = rdbg/i386/excep.c
+ *
+ * $Id$
+ *
+ **************************************************************************
+ */
+
+#include <rtems.h>
+#include <rtems/error.h>
+#include <assert.h>
+#include <errno.h>
+#include <rdbg/rdbg.h>
+#include <rdbg/servrpc.h>
+
+/* -----------------------------------------------------------------
+ Maping of hardware exceptions into Unix-like signal numbers.
+ It is identical to the one used by the PM and the AM.
+ ----------------------------------------------------------------- */
+
+ int
+ExcepToSig (Exception_context *ctx)
+{
+ int excep = getExcNum (ctx);
+
+
+ switch (excep) {
+
+ case I386_EXCEPTION_MATH_COPROC_UNAVAIL:
+ case I386_EXCEPTION_I386_COPROC_SEG_ERR:
+ case I386_EXCEPTION_FLOAT_ERROR:
+ case I386_EXCEPTION_BOUND:
+ return SIGFPE;
+
+ case I386_EXCEPTION_DEBUG:
+ case I386_EXCEPTION_BREAKPOINT:
+ case I386_EXCEPTION_ENTER_RDBG:
+ return SIGTRAP;
+
+ case I386_EXCEPTION_OVERFLOW:
+ case I386_EXCEPTION_DIVIDE_BY_ZERO:
+ case I386_EXCEPTION_ILLEGAL_INSTR:
+ return SIGILL;
+
+ case I386_EXCEPTION_SEGMENT_NOT_PRESENT:
+ case I386_EXCEPTION_STACK_SEGMENT_FAULT:
+ case I386_EXCEPTION_GENERAL_PROT_ERR:
+ case I386_EXCEPTION_PAGE_FAULT:
+ return SIGSEGV;
+
+ default:
+ break;
+ }
+ return SIGKILL;
+}
+
+
+/*----- Breakpoint Exception management -----*/
+
+ /*
+ * Handler for Breakpoint Exceptions :
+ * software breakpoints.
+ */
+
+void
+BreakPointExcHdl(CPU_Exception_frame *ctx)
+{
+ rtems_status_code status;
+ rtems_id continueSemId;
+
+ if ( (justSaveContext) && (ctx->idtIndex == I386_EXCEPTION_ENTER_RDBG) ) {
+ PushSavedExceptCtx (_Thread_Executing->Object.id, ctx);
+ justSaveContext = 0;
+ }
+ else {
+ if (ctx->idtIndex != I386_EXCEPTION_DEBUG){
+ NbSerializedCtx++;
+ rtems_semaphore_obtain(serializeSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+ NbSerializedCtx--;
+ }
+
+ currentTargetThread = _Thread_Executing->Object.id;
+
+#ifdef DDEBUG
+ printk("----------------------------------------------------------\n");
+ printk("Exception %d caught at PC %x by thread %d\n",
+ ctx->idtIndex,
+ ctx->eip,
+ _Thread_Executing->Object.id);
+ printk("----------------------------------------------------------\n");
+ printk("Processor execution context at time of the fault was :\n");
+ printk("----------------------------------------------------------\n");
+ printk(" EAX = %x EBX = %x ECX = %x EDX = %x\n",
+ ctx->eax, ctx->ebx, ctx->ecx, ctx->edx);
+ printk(" ESI = %x EDI = %x EBP = %x ESP = %x\n",
+ ctx->esi, ctx->edi, ctx->ebp, ctx->esp0);
+ printk("----------------------------------------------------------\n");
+ printk("Error code pushed by processor itself (if not 0) = %x\n",
+ ctx->faultCode);
+ printk("----------------------------------------------------------\n\n");
+#endif
+
+ status = rtems_semaphore_create (rtems_build_name('D', 'B', 'G', 'c'),
+ 0,
+ RTEMS_FIFO |
+ RTEMS_COUNTING_SEMAPHORE |
+ RTEMS_NO_INHERIT_PRIORITY |
+ RTEMS_NO_PRIORITY_CEILING |
+ RTEMS_LOCAL,
+ 0,
+ &continueSemId);
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_panic ("Can't create continue semaphore: `%s'\n",rtems_status_text(status));
+
+ PushExceptCtx (_Thread_Executing->Object.id, continueSemId, ctx);
+
+ switch (ctx->idtIndex){
+ case I386_EXCEPTION_DEBUG:
+ DPRINTF((" DEBUG EXCEPTION !!!\n"));
+ ctx->eflags &= ~EFLAGS_TF;
+ ExitForSingleStep-- ;
+ rtems_semaphore_release( wakeupEventSemId );
+ break;
+
+ case I386_EXCEPTION_BREAKPOINT:
+ DPRINTF((" BREAKPOINT EXCEPTION !!!\n"));
+ rtems_semaphore_release( wakeupEventSemId );
+ break;
+
+ case I386_EXCEPTION_ENTER_RDBG:
+ DPRINTF((" ENTER RDBG !!!\n"));
+ rtems_semaphore_release( wakeupEventSemId );
+ break;
+
+ default:
+ DPRINTF((" OTHER EXCEPTION !!!\n"));
+ rtems_semaphore_release( wakeupEventSemId );
+ break;
+ }
+
+ rtems_semaphore_obtain(continueSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+
+ PopExceptCtx (_Thread_Executing->Object.id);
+ rtems_semaphore_delete(continueSemId);
+ }
+}
+
+
+
diff --git a/c/src/librdbg/src/i386/pc386/Makefile.in b/c/src/librdbg/src/i386/pc386/Makefile.in
index 9663082c39..aeaab6cb8a 100644
--- a/c/src/librdbg/src/i386/pc386/Makefile.in
+++ b/c/src/librdbg/src/i386/pc386/Makefile.in
@@ -17,8 +17,10 @@ LIBNAME = librdbg.a
LIB = ${ARCH}/${LIBNAME}
# C and C++ source names, if any, go here -- minus the .c or .cc
-C_PIECES = rdbg servcon servbkpt servrpc excep servtgt servtsp servutil \
- _servtgt rdbg_f ptrace
+C_PIECES = rdbg servcon servbkpt servrpc excep excep_f \
+ servtgt servtsp servutil _servtgt rdbg_f \
+ ptrace
+
C_FILES = $(C_PIECES:%=%.c)
C_O_FILES = $(C_PIECES:%=${ARCH}/%.o)
diff --git a/c/src/librdbg/src/i386/pc386/remdeb_f.x b/c/src/librdbg/src/i386/pc386/remdeb_f.x
index 0ff52d1307..01d899fe54 100644
--- a/c/src/librdbg/src/i386/pc386/remdeb_f.x
+++ b/c/src/librdbg/src/i386/pc386/remdeb_f.x
@@ -5,6 +5,7 @@
*
* Synopsis = remdeb_f.x
*
+ * $Id$
*
**************************************************************************
*/
diff --git a/c/src/librdbg/src/i386/rdbg_cpu_asm.S b/c/src/librdbg/src/i386/rdbg_cpu_asm.S
index f0942310ce..073262f864 100644
--- a/c/src/librdbg/src/i386/rdbg_cpu_asm.S
+++ b/c/src/librdbg/src/i386/rdbg_cpu_asm.S
@@ -3,6 +3,8 @@
* This file contains all assembly code for the Intel i386 implementation
* of RDBG.
*
+ * $Id$
+ *
*/
#include <asm.h>
@@ -10,7 +12,7 @@
BEGIN_CODE
/*
- * void copyback_data_cache_and_invalidate_instr_cache()
+ * void copyback_data_cache_and_invalidate_instr_cache(addr, size)
*
* This routine performs a copy of the data cache
* and invalidate the instruction cache
diff --git a/c/src/librdbg/src/i386/rdbg_f.c b/c/src/librdbg/src/i386/rdbg_f.c
index aeb07fcbe8..b339256e70 100644
--- a/c/src/librdbg/src/i386/rdbg_f.c
+++ b/c/src/librdbg/src/i386/rdbg_f.c
@@ -5,6 +5,8 @@
*
* Synopsis = rdbg/i386/rdbg_f.c
*
+ * $Id$
+ *
**************************************************************************
*/
@@ -128,3 +130,26 @@ CancelSingleStep (CPU_Exception_frame* ctx)
ctx->eflags &= ~EFLAGS_TF;
ExitForSingleStep-- ;
}
+
+cpuExcHandlerType old_currentExcHandler;
+extern void rtems_exception_prologue_50();
+
+void connect_rdbg_exception()
+{
+ interrupt_gate_descriptor *currentIdtEntry;
+ unsigned limit;
+ unsigned level;
+
+ /*
+ * Connect the Exception used to debug
+ */
+ i386_get_info_from_IDTR (&currentIdtEntry, &limit);
+
+ _CPU_ISR_Disable(level);
+ create_interrupt_gate_descriptor (&currentIdtEntry[50], rtems_exception_prologue_50);
+ _CPU_ISR_Enable(level);
+
+ old_currentExcHandler = _currentExcHandler;
+ _currentExcHandler = BreakPointExcHdl ;
+
+}
diff --git a/c/src/librdbg/src/powerpc/Makefile.in b/c/src/librdbg/src/powerpc/Makefile.in
new file mode 100644
index 0000000000..e65ded9381
--- /dev/null
+++ b/c/src/librdbg/src/powerpc/Makefile.in
@@ -0,0 +1,25 @@
+#
+# $Id$
+#
+
+@SET_MAKE@
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = ../..
+subdir = librdbg/powerpc
+
+RTEMS_ROOT = @RTEMS_ROOT@
+PROJECT_ROOT = @PROJECT_ROOT@
+
+VPATH = @srcdir@
+
+include $(RTEMS_ROOT)/make/custom/${RTEMS_BSP}.cfg
+include $(RTEMS_ROOT)/make/directory.cfg
+
+INSTALL_CHANGE = @INSTALL_CHANGE@
+
+SUB_DIRS = @RTEMS_BSP@
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
diff --git a/c/src/librdbg/src/powerpc/excep_f.c b/c/src/librdbg/src/powerpc/excep_f.c
new file mode 100644
index 0000000000..273a050d23
--- /dev/null
+++ b/c/src/librdbg/src/powerpc/excep_f.c
@@ -0,0 +1,167 @@
+/*
+ **************************************************************************
+ *
+ * Component =
+ *
+ * Synopsis = rdbg/powerpc/excep_f.c
+ *
+ * $Id$
+ *
+ **************************************************************************
+ */
+
+#include <rtems.h>
+#include <rtems/error.h>
+#include <assert.h>
+#include <errno.h>
+#include <rdbg/rdbg.h>
+#include <rdbg/servrpc.h>
+
+ int
+ExcepToSig (Exception_context *ctx)
+{
+ int excep = getExcNum (ctx);
+
+ switch (excep) {
+ case ASM_FLOAT_VECTOR : return SIGFPE;
+
+ case ASM_TRACE_VECTOR :
+ case ASM_SYS_VECTOR : return SIGTRAP;
+
+ case ASM_ISI_VECTOR : return SIGSEGV;
+
+ case ASM_PROG_VECTOR :
+ case ASM_RESET_VECTOR :
+ case ASM_MACH_VECTOR :
+ case ASM_EXT_VECTOR :
+ case ASM_ALIGN_VECTOR : return SIGILL;
+
+ default:
+ break;
+ }
+ return SIGKILL;
+}
+
+
+/*----- Breakpoint Exception management -----*/
+
+ /*
+ * Handler for Breakpoint Exceptions :
+ * software breakpoints.
+ */
+
+void
+BreakPointExcHdl(CPU_Exception_frame *ctx)
+{
+ rtems_status_code status;
+ rtems_id continueSemId;
+
+ if ( (justSaveContext) && (ctx->_EXC_number == ASM_SYS_VECTOR) ) {
+ PushSavedExceptCtx (_Thread_Executing->Object.id, ctx);
+ justSaveContext = 0;
+ }
+ else {
+ if (ctx->_EXC_number != ASM_TRACE_VECTOR){
+ NbSerializedCtx++;
+ rtems_semaphore_obtain(serializeSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+ NbSerializedCtx--;
+ }
+
+ currentTargetThread = _Thread_Executing->Object.id;
+
+#ifdef DDEBUG
+ printk("----------------------------------------------------------\n");
+ printk("Exception %d caught at PC %x by thread %d\n",
+ ctx->_EXC_number,
+ ctx->EXC_SRR0,
+ _Thread_Executing->Object.id);
+ printk("----------------------------------------------------------\n");
+ printk("Processor execution context at time of the fault was :\n");
+ printk("----------------------------------------------------------\n");
+ printk("\t R0 = %x\n", ctx->GPR0);
+ printk("\t R1 = %x\n", ctx->GPR1);
+ printk("\t R2 = %x\n", ctx->GPR2);
+ printk("\t R3 = %x\n", ctx->GPR3);
+ printk("\t R4 = %x\n", ctx->GPR4);
+ printk("\t R5 = %x\n", ctx->GPR5);
+ printk("\t R6 = %x\n", ctx->GPR6);
+ printk("\t R7 = %x\n", ctx->GPR7);
+ printk("\t R8 = %x\n", ctx->GPR8);
+ printk("\t R9 = %x\n", ctx->GPR9);
+ printk("\t R10 = %x\n", ctx->GPR10);
+ printk("\t R11 = %x\n", ctx->GPR11);
+ printk("\t R12 = %x\n", ctx->GPR12);
+ printk("\t R13 = %x\n", ctx->GPR13);
+ printk("\t R14 = %x\n", ctx->GPR14);
+ printk("\t R15 = %x\n", ctx->GPR15);
+ printk("\t R16 = %x\n", ctx->GPR16);
+ printk("\t R17 = %x\n", ctx->GPR17);
+ printk("\t R18 = %x\n", ctx->GPR18);
+ printk("\t R19 = %x\n", ctx->GPR19);
+ printk("\t R20 = %x\n", ctx->GPR20);
+ printk("\t R21 = %x\n", ctx->GPR21);
+ printk("\t R22 = %x\n", ctx->GPR22);
+ printk("\t R23 = %x\n", ctx->GPR23);
+ printk("\t R24 = %x\n", ctx->GPR24);
+ printk("\t R25 = %x\n", ctx->GPR25);
+ printk("\t R26 = %x\n", ctx->GPR26);
+ printk("\t R27 = %x\n", ctx->GPR27);
+ printk("\t R28 = %x\n", ctx->GPR28);
+ printk("\t R29 = %x\n", ctx->GPR29);
+ printk("\t R30 = %x\n", ctx->GPR30);
+ printk("\t R31 = %x\n", ctx->GPR31);
+ printk("\t CR = %x\n", ctx->EXC_CR);
+ printk("\t CTR = %x\n", ctx->EXC_CTR);
+ printk("\t XER = %x\n", ctx->EXC_XER);
+ printk("\t LR = %x\n", ctx->EXC_LR);
+ printk("\t MSR = %x\n", ctx->EXC_MSR);
+#endif
+
+ status = rtems_semaphore_create (rtems_build_name('D', 'B', 'G', 'c'),
+ 0,
+ RTEMS_FIFO |
+ RTEMS_COUNTING_SEMAPHORE |
+ RTEMS_NO_INHERIT_PRIORITY |
+ RTEMS_NO_PRIORITY_CEILING |
+ RTEMS_LOCAL,
+ 0,
+ &continueSemId);
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_panic ("Can't create continue semaphore: `%s'\n",rtems_status_text(status));
+
+ PushExceptCtx (_Thread_Executing->Object.id, continueSemId, ctx);
+
+ switch (ctx->_EXC_number){
+ case ASM_TRACE_VECTOR :
+ DPRINTF((" TRACE EXCEPTION !!!\n"));
+ ctx->EXC_SRR1 &= ~MSR_SE;
+ ExitForSingleStep-- ;
+ rtems_semaphore_release( wakeupEventSemId );
+ break;
+
+ case ASM_PROG_VECTOR :
+ DPRINTF((" BREAKPOINT EXCEPTION !!!\n"));
+ rtems_semaphore_release( wakeupEventSemId );
+ break;
+
+ case ASM_SYS_VECTOR :
+ DPRINTF((" ENTER RDBG !!!\n"));
+ rtems_semaphore_release( wakeupEventSemId );
+ break;
+
+ default:
+ DPRINTF((" OTHER EXCEPTION !!!\n"));
+ rtems_semaphore_release( wakeupEventSemId );
+ break;
+ }
+
+ rtems_semaphore_obtain(continueSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+
+ PopExceptCtx (_Thread_Executing->Object.id);
+ rtems_semaphore_delete(continueSemId);
+ }
+
+}
+
+
+
diff --git a/c/src/librdbg/src/powerpc/mcp750/Makefile.in b/c/src/librdbg/src/powerpc/mcp750/Makefile.in
new file mode 100644
index 0000000000..3ede15a1b7
--- /dev/null
+++ b/c/src/librdbg/src/powerpc/mcp750/Makefile.in
@@ -0,0 +1,114 @@
+#
+# $Id$
+#
+
+@SET_MAKE@
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = ../../..
+subdir = librdbg/powerpc/mcp750
+
+RTEMS_ROOT = @RTEMS_ROOT@
+PROJECT_ROOT = @PROJECT_ROOT@
+
+VPATH = @srcdir@:@srcdir@/..:@srcdir@/../..
+
+LIBNAME = librdbg.a
+LIB = ${ARCH}/${LIBNAME}
+
+# C and C++ source names, if any, go here -- minus the .c or .cc
+C_PIECES = rdbg servcon servbkpt servrpc excep excep_f \
+ servtgt servtsp servutil _servtgt rdbg_f \
+ ptrace
+C_FILES = $(C_PIECES:%=%.c)
+C_O_FILES = $(C_PIECES:%=${ARCH}/%.o)
+
+# Asm source names, if any, go here -- minus the .s
+S_PIECES = rdbg_cpu_asm
+S_FILES = $(ASM_PIECES:%=%.S)
+S_O_FILES = $(ASM_PIECES:%=${ARCH}/%.o)
+
+# Generated C source names, if any, go here -- minus the .c
+GEN_C_PIECES= remdeb_xdr remdeb_svc
+GEN_C_FILES = $(GEN_C_PIECES:%=%.c)
+GEN_C_O_FILES = $(GEN_C_PIECES:%=${ARCH}/%.o)
+
+# H source names, if any, go here -- minus the .h
+H_PIECES = remdeb
+H_FILES = $(H_PIECES:%=%.h)
+
+# X source names
+X_FILES = remdeb.x remdeb_f.x
+
+SRCS= $(C_FILES) $(S_FILES) $(GEN_C_FILES) $(H_FILES)
+OBJS = $(GEN_C_O_FILES) $(C_O_FILES) $(S_O_FILES)
+
+RPCGEN = @RPCGEN@
+AWK = @AWK@
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(RTEMS_ROOT)/make/lib.cfg
+
+INSTALL_CHANGE = @INSTALL_CHANGE@
+mkinstalldirs = $(SHELL) $(top_srcdir)/@RTEMS_TOPdir@/mkinstalldirs
+
+INSTALLDIRS = $(PROJECT_INCLUDE)/rdbg
+
+$(INSTALLDIRS):
+ @$(mkinstalldirs) $(INSTALLDIRS)
+
+#
+# Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS +=
+#
+# Enable traces in RDBG
+#
+#CFLAGS += -DDDEBUG
+#
+CFLAGS +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS += $(LIB) $(H_FILES) $(GEN_C_FILES)
+CLOBBER_ADDITIONS +=
+
+FRONTEND = \"$(RTEMS_CPU)/@RTEMS_BSP@/remdeb_f.x\"
+
+all: ${ARCH} $(LIB)
+ @$(INSTALL_VARIANT) -m 644 $(LIB) $(PROJECT_RELEASE)/lib
+
+$(LIB): $(SRCS) ${OBJS}
+ $(make-library)
+
+remdeb.h: $(X_FILES)
+ @rm -f $@
+ ( pwd=`pwd`; cd $(srcdir)/../..; \
+ $(RPCGEN) -h -DFRONTEND=$(FRONTEND) \
+ -o $$pwd/$@ remdeb.x )
+ @$(INSTALL_CHANGE) -m 755 $@ $(PROJECT_INCLUDE)/rdbg
+
+remdeb_xdr.c: $(X_FILES)
+ @rm -f $@
+ ( pwd=`pwd`; cd $(srcdir)/../..; \
+ $(RPCGEN) -c -DFRONTEND=$(FRONTEND) \
+ -o $$pwd/$@ remdeb.x )
+
+remdeb_svc.c: $(X_FILES)
+ @rm -f $@ tmpSvc.c
+ ( pwd=`pwd`; cd $(srcdir)/../..; \
+ $(RPCGEN) -s udp -DFRONTEND=$(FRONTEND) \
+ -o $$pwd/tmpSvc.c remdeb.x )
+ $(AWK) -f $(srcdir)/../../awk.svc THEPROG="remdeb.h" tmpSvc.c >$@
+ @rm -f tmpSvc.c
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
diff --git a/c/src/librdbg/src/powerpc/mcp750/remdeb_f.x b/c/src/librdbg/src/powerpc/mcp750/remdeb_f.x
new file mode 100644
index 0000000000..10cf8dd540
--- /dev/null
+++ b/c/src/librdbg/src/powerpc/mcp750/remdeb_f.x
@@ -0,0 +1,76 @@
+/*
+ **************************************************************************
+ *
+ * Component = rdblib
+ * Synopsis = remdeb_f.x
+ *
+ **************************************************************************
+ * $Id$
+ **************************************************************************
+ */
+
+struct xdr_regs
+{
+ unsigned int tabreg[40];
+};
+
+#ifdef RPC_HDR
+
+%/* now define register macros to apply to xdr_regs struct */
+%
+%#define R_PC 0
+%#define R_MSR 1
+%#define R_EXCEPNB 2
+%#define R_R0 3
+%#define R_R1 (R_R0 + 1)
+%#define R_R2 (R_R0 + 2)
+%#define R_R3 (R_R0 + 3)
+%#define R_R4 (R_R0 + 4)
+%#define R_R5 (R_R0 + 5)
+%#define R_R6 (R_R0 + 6)
+%#define R_R7 (R_R0 + 7)
+%#define R_R8 (R_R0 + 8)
+%#define R_R9 (R_R0 + 9)
+%#define R_R10 (R_R0 + 10)
+%#define R_R11 (R_R0 + 11)
+%#define R_R12 (R_R0 + 12)
+%#define R_R13 (R_R0 + 13)
+%#define R_R14 (R_R0 + 14)
+%#define R_R15 (R_R0 + 15)
+%#define R_R16 (R_R0 + 16)
+%#define R_R17 (R_R0 + 17)
+%#define R_R18 (R_R0 + 18)
+%#define R_R19 (R_R0 + 19)
+%#define R_R20 (R_R0 + 20)
+%#define R_R21 (R_R0 + 21)
+%#define R_R22 (R_R0 + 22)
+%#define R_R23 (R_R0 + 23)
+%#define R_R24 (R_R0 + 24)
+%#define R_R25 (R_R0 + 25)
+%#define R_R26 (R_R0 + 26)
+%#define R_R27 (R_R0 + 27)
+%#define R_R28 (R_R0 + 28)
+%#define R_R29 (R_R0 + 29)
+%#define R_R30 (R_R0 + 30)
+%#define R_R31 (R_R0 + 31)
+%#define R_CR 35
+%#define R_CTR 36
+%#define R_XER 37
+%#define R_LR 38
+%#define R_MQ 39
+%
+%#include <libcpu/raw_exception.h>
+%
+%#define REG_PC tabreg[R_PC] /* PC register offset */
+%#define REG_SP tabreg[R_R1] /* SP register offset */
+%#define REG_FP tabreg[R_R1] /* SP register offset (no FP on PPC) */
+%#define BREAK_SIZE 4 /* Breakpoint occupies 4 bytes */
+%#define BREAK_ADJ 0 /* Nothing to subtract from address after bp */
+%#define IS_BREAK(l) ((l) == 0x7d8d6808)
+%#define SET_BREAK(l) (0x7d8d6808)
+%#define ORG_BREAK(c,p) (p)
+%#define IS_STEP(regs) (regs.tabreg[R_EXCEPNB] == ASM_TRACE_VECTOR) /* Was step and not break */
+%#define TARGET_PROC_TYPE 3
+
+#endif
+
diff --git a/c/src/librdbg/src/powerpc/new_exception_processing/remdeb_f.x b/c/src/librdbg/src/powerpc/new_exception_processing/remdeb_f.x
new file mode 100644
index 0000000000..10cf8dd540
--- /dev/null
+++ b/c/src/librdbg/src/powerpc/new_exception_processing/remdeb_f.x
@@ -0,0 +1,76 @@
+/*
+ **************************************************************************
+ *
+ * Component = rdblib
+ * Synopsis = remdeb_f.x
+ *
+ **************************************************************************
+ * $Id$
+ **************************************************************************
+ */
+
+struct xdr_regs
+{
+ unsigned int tabreg[40];
+};
+
+#ifdef RPC_HDR
+
+%/* now define register macros to apply to xdr_regs struct */
+%
+%#define R_PC 0
+%#define R_MSR 1
+%#define R_EXCEPNB 2
+%#define R_R0 3
+%#define R_R1 (R_R0 + 1)
+%#define R_R2 (R_R0 + 2)
+%#define R_R3 (R_R0 + 3)
+%#define R_R4 (R_R0 + 4)
+%#define R_R5 (R_R0 + 5)
+%#define R_R6 (R_R0 + 6)
+%#define R_R7 (R_R0 + 7)
+%#define R_R8 (R_R0 + 8)
+%#define R_R9 (R_R0 + 9)
+%#define R_R10 (R_R0 + 10)
+%#define R_R11 (R_R0 + 11)
+%#define R_R12 (R_R0 + 12)
+%#define R_R13 (R_R0 + 13)
+%#define R_R14 (R_R0 + 14)
+%#define R_R15 (R_R0 + 15)
+%#define R_R16 (R_R0 + 16)
+%#define R_R17 (R_R0 + 17)
+%#define R_R18 (R_R0 + 18)
+%#define R_R19 (R_R0 + 19)
+%#define R_R20 (R_R0 + 20)
+%#define R_R21 (R_R0 + 21)
+%#define R_R22 (R_R0 + 22)
+%#define R_R23 (R_R0 + 23)
+%#define R_R24 (R_R0 + 24)
+%#define R_R25 (R_R0 + 25)
+%#define R_R26 (R_R0 + 26)
+%#define R_R27 (R_R0 + 27)
+%#define R_R28 (R_R0 + 28)
+%#define R_R29 (R_R0 + 29)
+%#define R_R30 (R_R0 + 30)
+%#define R_R31 (R_R0 + 31)
+%#define R_CR 35
+%#define R_CTR 36
+%#define R_XER 37
+%#define R_LR 38
+%#define R_MQ 39
+%
+%#include <libcpu/raw_exception.h>
+%
+%#define REG_PC tabreg[R_PC] /* PC register offset */
+%#define REG_SP tabreg[R_R1] /* SP register offset */
+%#define REG_FP tabreg[R_R1] /* SP register offset (no FP on PPC) */
+%#define BREAK_SIZE 4 /* Breakpoint occupies 4 bytes */
+%#define BREAK_ADJ 0 /* Nothing to subtract from address after bp */
+%#define IS_BREAK(l) ((l) == 0x7d8d6808)
+%#define SET_BREAK(l) (0x7d8d6808)
+%#define ORG_BREAK(c,p) (p)
+%#define IS_STEP(regs) (regs.tabreg[R_EXCEPNB] == ASM_TRACE_VECTOR) /* Was step and not break */
+%#define TARGET_PROC_TYPE 3
+
+#endif
+
diff --git a/c/src/librdbg/src/powerpc/rdbg_cpu_asm.S b/c/src/librdbg/src/powerpc/rdbg_cpu_asm.S
new file mode 100644
index 0000000000..ef1a43385d
--- /dev/null
+++ b/c/src/librdbg/src/powerpc/rdbg_cpu_asm.S
@@ -0,0 +1,82 @@
+/* cpu_asm.s
+ *
+ * This file contains all assembly code for the Intel i386 implementation
+ * of RDBG.
+ *
+ * $Id$
+ *
+ */
+
+#include <libcpu/cpu.h>
+#include <libcpu/io.h>
+#include <rtems/score/targopts.h>
+#include <asm.h>
+
+ BEGIN_CODE
+
+/*
+ * void copyback_data_cache_and_invalidate_instr_cache(addr, size)
+ *
+ * This routine performs a copy of the data cache
+ * and invalidate the instruction cache
+ */
+
+ .p2align 5
+ PUBLIC_VAR (copyback_data_cache_and_invalidate_instr_cache)
+
+SYM (copyback_data_cache_and_invalidate_instr_cache):
+ /* r3 address to handle, r4 length in bytes */
+ addi r6, r0, PPC_CACHE_ALIGNMENT
+ /* r5 = last address to handle */
+ add r5,r3,r4
+ /* r3 = cache_align(r3, PPC_CACHE_ALIGNMENT)
+ subi r0,r6,1
+ andc r3,r3,r0
+ /* R4 = R3 = copy of first address */
+ mr r4,r3
+ /*
+ * Copyback data cache
+ */
+1: cmplw r4,r5 /* r4 >= r5 then done */
+ dcbst 0,r4 /* flush (data cache bloc store) */
+ add r4,r4,r6 /* r4 = next cache line addr */
+ blt 1b /* end r4 >= r5 then done */
+ sync /* Wait for all dcbst to complete on bus */
+ /*
+ * invalidate instruction cache
+ */
+ /* R4 = fisrt address */
+ mr r4,r3
+2: cmplw r4,r5 /* r4 >= r5 then done */
+ icbi 0,r4 /* invalidate (instruction cache bloc invalidate) */
+ add r4,r4,r6 /* r4 = next cache line addr */
+ blt 2b /* end r4 >= r5 then done */
+ sync /* Wait for all icbi to complete on bus */
+ isync
+ blr
+
+
+/*
+ * void enterRdbg(void)
+ *
+ * This function perform a call to the exception SYSTEM call
+ * It is used :
+ * 1 - in the user code, to simulate a Breakpoint.
+ * (with justSaveContext = 0)
+ * 2 - in the RDBG code, to push a ctx in the list.
+ * (with justSaveContext = 1)
+ *
+ * In most of case, it will be use as described in 1.
+ * The 2nd possibility will be used by RDBG to obtain
+ * its own ctx
+ */
+
+ PUBLIC_VAR (enterRdbg)
+
+SYM (enterRdbg):
+ sc
+ blr
+
+END_CODE
+
+END
diff --git a/c/src/librdbg/src/powerpc/rdbg_f.c b/c/src/librdbg/src/powerpc/rdbg_f.c
new file mode 100644
index 0000000000..6149b5d426
--- /dev/null
+++ b/c/src/librdbg/src/powerpc/rdbg_f.c
@@ -0,0 +1,156 @@
+/*
+ **************************************************************************
+ *
+ * Component =
+ *
+ * Synopsis = rdbg/powerpc/rdbg_f.c
+ *
+ * $Id$
+ *
+ **************************************************************************
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <rdbg/reg.h>
+#include <rdbg/remdeb.h>
+#include <rdbg/rdbg.h>
+#include <rtems/score/cpu.h>
+#include <rtems/score/thread.h>
+#include <libcpu/cpu.h>
+
+void
+CtxToRegs (const CPU_Exception_frame* ctx, xdr_regs* regs)
+{
+ * ((CPU_Exception_frame*) regs) = *ctx;
+}
+
+
+ void
+RegsToCtx (const xdr_regs* regs, CPU_Exception_frame* ctx)
+{
+ *ctx = * ((CPU_Exception_frame*) regs);
+}
+
+void
+get_ctx_thread( Thread_Control *thread, CPU_Exception_frame* ctx)
+{
+ unsigned int *ptr;
+ unsigned int i;
+
+ ctx->EXC_SRR0 = thread->Registers.pc;
+ ctx->EXC_SRR1 = thread->Registers.msr;
+ ctx->_EXC_number = 0xdeadbeef;
+
+ ctx->GPR1 = thread->Registers.gpr1;
+ ctx->GPR2 = thread->Registers.gpr2;
+ /*
+ * Fill with dummy values...
+ */
+ ptr = &ctx->GPR3;
+ for (i = 0; i < 10; i++)
+ ptr [i] = 0xdeadbeef;
+
+ ctx->GPR13 = thread->Registers.gpr13;
+ ctx->GPR14 = thread->Registers.gpr14;
+ ctx->GPR15 = thread->Registers.gpr15;
+ ctx->GPR16 = thread->Registers.gpr16;
+ ctx->GPR17 = thread->Registers.gpr17;
+ ctx->GPR18 = thread->Registers.gpr18;
+ ctx->GPR19 = thread->Registers.gpr19;
+ ctx->GPR20 = thread->Registers.gpr20;
+ ctx->GPR21 = thread->Registers.gpr21;
+ ctx->GPR22 = thread->Registers.gpr22;
+ ctx->GPR23 = thread->Registers.gpr23;
+ ctx->GPR24 = thread->Registers.gpr24;
+ ctx->GPR25 = thread->Registers.gpr25;
+ ctx->GPR26 = thread->Registers.gpr26;
+ ctx->GPR27 = thread->Registers.gpr27;
+ ctx->GPR28 = thread->Registers.gpr28;
+ ctx->GPR29 = thread->Registers.gpr29;
+ ctx->GPR30 = thread->Registers.gpr30;
+ ctx->GPR31 = thread->Registers.gpr31;
+ ctx->EXC_CR = thread->Registers.cr;
+ ctx->EXC_CTR = 0xdeadbeef;
+ ctx->EXC_XER = 0xdeadbeef;
+ ctx->EXC_LR = 0xdeadbeef;
+ ctx->EXC_MSR = 0xdeadbeef;
+ ctx->EXC_DAR = 0xdeadbeef;
+}
+
+void
+set_ctx_thread( Thread_Control *thread, CPU_Exception_frame* ctx)
+{
+ thread->Registers.gpr1 = ctx->GPR1;
+ thread->Registers.gpr2 = ctx->GPR2;
+
+ thread->Registers.gpr13 = ctx->GPR13;
+ thread->Registers.gpr14 = ctx->GPR14;
+ thread->Registers.gpr15 = ctx->GPR15;
+ thread->Registers.gpr16 = ctx->GPR16;
+ thread->Registers.gpr17 = ctx->GPR17;
+ thread->Registers.gpr18 = ctx->GPR18;
+ thread->Registers.gpr19 = ctx->GPR19;
+ thread->Registers.gpr20 = ctx->GPR20;
+ thread->Registers.gpr21 = ctx->GPR21;
+ thread->Registers.gpr22 = ctx->GPR22;
+ thread->Registers.gpr23 = ctx->GPR23;
+ thread->Registers.gpr24 = ctx->GPR24;
+ thread->Registers.gpr25 = ctx->GPR25;
+ thread->Registers.gpr26 = ctx->GPR26;
+ thread->Registers.gpr27 = ctx->GPR27;
+ thread->Registers.gpr28 = ctx->GPR28;
+ thread->Registers.gpr29 = ctx->GPR29;
+ thread->Registers.gpr30 = ctx->GPR30;
+ thread->Registers.gpr31 = ctx->GPR31;
+ thread->Registers.cr = ctx->EXC_CR;
+ thread->Registers.pc = ctx->EXC_SRR0;
+ thread->Registers.msr = ctx->EXC_SRR1;
+}
+
+
+
+int
+Single_Step(CPU_Exception_frame* ctx)
+{
+ if ((ctx->EXC_SRR1 & MSR_SE) != 0 || ExitForSingleStep != 0) {
+ /* Check coherency */
+ assert ((ctx->EXC_SRR1 & MSR_SE) != 0);
+ assert (ExitForSingleStep != 0);
+ return 0;
+ }
+ ctx->EXC_SRR1 |= MSR_SE;
+ ++ExitForSingleStep;
+ return 0;
+}
+
+ int
+CheckForSingleStep (CPU_Exception_frame* ctx)
+{
+ if (ExitForSingleStep) {
+ /*
+ * This functions can be called both from
+ * INT1 and INT3 handlers. In case it is
+ * called from INT3, need to clear TF.
+ */
+ ctx->EXC_SRR1 &= ~MSR_SE;
+ ExitForSingleStep = 0;
+ return 1;
+ }
+ return 0;
+}
+
+void
+CancelSingleStep (CPU_Exception_frame* ctx)
+{
+ /* Cancel scheduled SS */
+ ctx->EXC_SRR1 &= ~MSR_SE;
+ ExitForSingleStep-- ;
+}
+cpuExcHandlerType oldExcHandler;
+
+void connect_rdbg_exception()
+{
+ oldExcHandler = globalExceptHdl;
+ globalExceptHdl = BreakPointExcHdl ;
+}
diff --git a/c/src/librdbg/src/ptrace.c b/c/src/librdbg/src/ptrace.c
index 158bd57cbb..91772bb2bd 100644
--- a/c/src/librdbg/src/ptrace.c
+++ b/c/src/librdbg/src/ptrace.c
@@ -5,6 +5,8 @@
*
* Synopsis = rkdb/rkdb.c
*
+ * $Id$
+ *
**************************************************************************
*/
@@ -142,7 +144,7 @@ ptrace (int request, int pid, char* addr, int data, char* addr2)
*/
if (diag == 0) {
- copyback_data_cache_and_invalidate_instr_cache();
+ copyback_data_cache_and_invalidate_instr_cache(addr, sizeof data);
return 0;
}
goto mem_error;
@@ -162,11 +164,7 @@ ptrace (int request, int pid, char* addr, int data, char* addr2)
ctx = GetExceptCtx (currentTargetThread);
- if (
- ctx->ctx->idtIndex != I386_EXCEPTION_DEBUG &&
- ctx->ctx->idtIndex != I386_EXCEPTION_BREAKPOINT &&
- ctx->ctx->idtIndex != I386_EXCEPTION_ENTER_RDBG
- ) {
+ if (!isRdbgException(ctx)) {
CannotRestart = 1;
setErrno (EIO);
return -1;
diff --git a/c/src/librdbg/src/rdbg.c b/c/src/librdbg/src/rdbg.c
index 1f04119e8e..a7288550a4 100644
--- a/c/src/librdbg/src/rdbg.c
+++ b/c/src/librdbg/src/rdbg.c
@@ -5,6 +5,8 @@
*
* Synopsis = rkdb/rkdb.c
*
+ * $Id$
+ *
**************************************************************************
*/
diff --git a/c/src/librdbg/src/remdeb.x b/c/src/librdbg/src/remdeb.x
index 86ce9efb37..b36ee3dcbb 100644
--- a/c/src/librdbg/src/remdeb.x
+++ b/c/src/librdbg/src/remdeb.x
@@ -7,6 +7,8 @@
* Synopsis: XDR definitions for remote debug server RPC calls.
* XDR definitions for RPCGEN to build remote debug server.
*
+ * $Id$
+ *
**********************************************************************
*/
diff --git a/c/src/librdbg/src/servbkpt.c b/c/src/librdbg/src/servbkpt.c
index 8d986751a2..f6c76bb494 100644
--- a/c/src/librdbg/src/servbkpt.c
+++ b/c/src/librdbg/src/servbkpt.c
@@ -6,6 +6,8 @@
*
* Synopsis: Management of breakpoints
*
+ * $Id$
+ *
**********************************************************************
*/
diff --git a/c/src/librdbg/src/servcon.c b/c/src/librdbg/src/servcon.c
index a26bfd2c7b..30570760db 100644
--- a/c/src/librdbg/src/servcon.c
+++ b/c/src/librdbg/src/servcon.c
@@ -6,6 +6,8 @@
*
* Synopsis: Management of RPC client connections.
*
+ * $Id$
+ *
**************************************************************************
*/
diff --git a/c/src/librdbg/src/servrpc.c b/c/src/librdbg/src/servrpc.c
index f62a2ecbb8..310f3bb6c4 100644
--- a/c/src/librdbg/src/servrpc.c
+++ b/c/src/librdbg/src/servrpc.c
@@ -7,6 +7,8 @@
* Synopsis: support routines for RPC dispatch for remote debug server.
* Main server dispatch routines from RPC to support remote debug.
*
+ * $Id$
+ *
**********************************************************************
*/
diff --git a/c/src/librdbg/src/servtgt.c b/c/src/librdbg/src/servtgt.c
index 7a8471e3e2..de41abc1a6 100644
--- a/c/src/librdbg/src/servtgt.c
+++ b/c/src/librdbg/src/servtgt.c
@@ -4,6 +4,8 @@
* Component: RDB servers
* Module: servtgt.c
*
+ * $Id$
+ *
**************************************************************************
*/
diff --git a/c/src/librdbg/src/servtsp.c b/c/src/librdbg/src/servtsp.c
index 6a83c6caf5..db342d58f9 100644
--- a/c/src/librdbg/src/servtsp.c
+++ b/c/src/librdbg/src/servtsp.c
@@ -6,6 +6,8 @@
*
* Synopsis: Transport management for remote debug server.
*
+ * $Id$
+ *
**************************************************************************
*/
diff --git a/c/src/librdbg/src/servutil.c b/c/src/librdbg/src/servutil.c
index 40187faead..1417fa5236 100644
--- a/c/src/librdbg/src/servutil.c
+++ b/c/src/librdbg/src/servutil.c
@@ -6,6 +6,8 @@
*
* Synopsis: Various utility routines
*
+ * $Id$
+ *
**********************************************************************
*/