summaryrefslogtreecommitdiffstats
path: root/c/src/librdbg/src/i386/rdbg_f.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-12-03 23:54:14 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-12-03 23:54:14 +0000
commit4721cf1ecb949b37c98b6fce79163541711de2e5 (patch)
treea89f2bef604b2ddf22b262fe6115d9f75c952781 /c/src/librdbg/src/i386/rdbg_f.c
parentRemoved spaces. (diff)
downloadrtems-4721cf1ecb949b37c98b6fce79163541711de2e5.tar.bz2
Patch from Emmanuel Raguet <raguet@crf.canon.fr> to add remote debug server
and RPC support to RTEMS. Thanks. :) Email follows: Hello, For Xmas, here is the Remote Debugger on RTEMS ! Here are 2 patches for the Remote Debugger on RTEMS for pc386 from Linux host : - one for RTEMS it self, - one for GDB-4.17. 1/ RTEMS patch -------------- This patch adds 2 libraries : - a simplified SUN RPC library - the Remote Debugger library The configuration command is the following : ../rtems4/configure --target=i386-rtemself --enable-rtemsbsp=pc386 --enable-rdbg The SUN RPC library is built only if networking is set. The RDBG library is built if networking and enable-rdbg are set. The function used to initialize the debugger is : rtems_rdbg_initialize (); A special function has been created to force a task to be in a "debug" state : enterRdbg(). The use of this function is not mandatory. 2/ GDB-4.17 patch ----------------- This patch create a new RTEMS target for GDB-4.17. The configuration command is the following : ./configure --enable-shared --target=i386RTEMS To connect to a target, use : target rtems [your_site_address] Then, attach the target using : attach 1 And... Debug ;) You can obtain the original GDB-4.17 on ftp://ftp.debian.org/debian/dists/stable/main/source/devel/gdb_4.17.orig.tar.gz This has been tested from a Debian 2.0.1 linux host.
Diffstat (limited to 'c/src/librdbg/src/i386/rdbg_f.c')
-rw-r--r--c/src/librdbg/src/i386/rdbg_f.c130
1 files changed, 130 insertions, 0 deletions
diff --git a/c/src/librdbg/src/i386/rdbg_f.c b/c/src/librdbg/src/i386/rdbg_f.c
new file mode 100644
index 0000000000..aeb07fcbe8
--- /dev/null
+++ b/c/src/librdbg/src/i386/rdbg_f.c
@@ -0,0 +1,130 @@
+/*
+ **************************************************************************
+ *
+ * Component =
+ *
+ * Synopsis = rdbg/i386/rdbg_f.c
+ *
+ **************************************************************************
+ */
+
+#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>
+
+
+void
+CtxToRegs (const CPU_Exception_frame* ctx, xdr_regs* regs)
+{
+ regs->tabreg [GS] = 0;
+ regs->tabreg [FS] = 0;
+ regs->tabreg [ES] = 0;
+ regs->tabreg [DS] = 0;
+ regs->tabreg [EDI] = ctx->edi;
+ regs->tabreg [ESI] = ctx->esi;
+ regs->tabreg [EBP] = ctx->ebp;
+ regs->tabreg [ESP] = ctx->esp0;
+ regs->tabreg [EBX] = ctx->ebx;
+ regs->tabreg [EDX] = ctx->edx;
+ regs->tabreg [ECX] = ctx->ecx;
+ regs->tabreg [EAX] = ctx->eax;
+ regs->tabreg [TRAPNO] = ctx->idtIndex;
+ regs->tabreg [ERR] = ctx->faultCode;
+ regs->tabreg [EIP] = ctx->eip;
+ regs->tabreg [CS] = ctx->cs & 0xFFFF;
+ regs->tabreg [EFL] = ctx->eflags;
+}
+
+
+ void
+RegsToCtx (const xdr_regs* regs, CPU_Exception_frame* ctx)
+{
+ ctx->edi = regs->tabreg [EDI];
+ ctx->esi = regs->tabreg [ESI];
+ ctx->ebp = regs->tabreg [EBP];
+ ctx->esp0 = regs->tabreg [ESP];
+ ctx->ebx = regs->tabreg [EBX];
+ ctx->edx = regs->tabreg [EDX];
+ ctx->ecx = regs->tabreg [ECX];
+ ctx->eax = regs->tabreg [EAX];
+ ctx->idtIndex = regs->tabreg [TRAPNO];
+ ctx->faultCode = regs->tabreg [ERR];
+ ctx->eip = regs->tabreg [EIP];
+ ctx->cs = regs->tabreg [CS];
+ ctx->eflags = regs->tabreg [EFL];
+}
+
+void
+get_ctx_thread( Thread_Control *thread, CPU_Exception_frame* ctx)
+{
+ ctx->edi = thread->Registers.edi;
+ ctx->esi = thread->Registers.esi;
+ ctx->ebp = (unsigned32)(thread->Registers.ebp);
+ ctx->esp0 = (unsigned32)(thread->Registers.esp);
+ ctx->ebx = thread->Registers.ebx;
+ ctx->edx = 0;
+ ctx->ecx = 0;
+ ctx->eax = 0;
+ ctx->idtIndex = 0;
+ ctx->faultCode = 0;
+ ctx->eip = *(unsigned int*)(thread->Registers.esp);
+ ctx->cs = 0;
+ ctx->eflags = thread->Registers.eflags;
+}
+
+void
+set_ctx_thread( Thread_Control *thread, CPU_Exception_frame* ctx)
+{
+ thread->Registers.edi = ctx->edi;
+ thread->Registers.esi = ctx->esi;
+ thread->Registers.ebp = (void*)(ctx->ebp);
+ thread->Registers.esp = (void*)(ctx->esp0);
+ thread->Registers.ebx = ctx->ebx;
+ thread->Registers.eflags = ctx->eflags;
+}
+
+
+
+int
+Single_Step(CPU_Exception_frame* ctx)
+{
+ /* Check if not already set */
+ if ((ctx->eflags & EFLAGS_TF) != 0 || ExitForSingleStep != 0) {
+ /* Check coherency */
+ assert ((ctx->eflags & EFLAGS_TF) != 0);
+ assert (ExitForSingleStep != 0);
+ return 0;
+ }
+ ctx->eflags |= EFLAGS_TF; /* eflags */
+ ++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->eflags &= ~EFLAGS_TF;
+ ExitForSingleStep = 0;
+ return 1;
+ }
+ return 0;
+}
+
+void
+CancelSingleStep (CPU_Exception_frame* ctx)
+{
+ /* Cancel scheduled SS */
+ ctx->eflags &= ~EFLAGS_TF;
+ ExitForSingleStep-- ;
+}