summaryrefslogtreecommitdiffstats
path: root/c/src/librdbg/src/rdbg.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/rdbg.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/rdbg.c')
-rw-r--r--c/src/librdbg/src/rdbg.c139
1 files changed, 139 insertions, 0 deletions
diff --git a/c/src/librdbg/src/rdbg.c b/c/src/librdbg/src/rdbg.c
new file mode 100644
index 0000000000..1f04119e8e
--- /dev/null
+++ b/c/src/librdbg/src/rdbg.c
@@ -0,0 +1,139 @@
+/*
+ **************************************************************************
+ *
+ * Component =
+ *
+ * Synopsis = rkdb/rkdb.c
+ *
+ **************************************************************************
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <rtems.h>
+#include <rtems/error.h>
+#include <rdbg/rdbg.h>
+#include <rdbg/servrpc.h>
+
+u_short rtemsPort = RTEMS_PORT;
+int BackPort = RTEMS_BACK_PORT;
+int rtemsActive = 0;
+SVCXPRT* rtemsXprt;
+int rtemsSock;
+char ActName[] = "RTEMS";
+volatile int ExitForSingleStep = 0 ;
+volatile int Continue;
+volatile int justSaveContext;
+volatile Objects_Id currentTargetThread;
+volatile int CannotRestart = 0;
+volatile int TotalReboot = 0;
+int CONN_LIST_INC = 3;
+int PID_LIST_INC = 1;
+int TSP_RETRIES = 10;
+
+
+ int
+getId()
+{
+ rtems_id id;
+
+ rtems_task_ident(RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &id);
+ return (int)(id) ;
+}
+
+ static int
+rdbgInit (void)
+{
+ int sock;
+ struct sockaddr_in addr;
+
+ sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (sock == -1) {
+ printf("%s: rkdbInit: cannot allocate socket\n", ActName);
+ return -1;
+ }
+
+ bzero( (void *)&addr, sizeof(struct sockaddr_in));
+ addr.sin_port = htons(rtemsPort);
+ if ((bind(sock, (struct sockaddr*) &addr, sizeof(addr))) == -1) {
+ printf("%s: rkdbInit: cannot bind socket\n", ActName);
+ return -2;
+ }
+ rtemsXprt = svcudp_create(sock);
+ if (svcudp_enablecache(rtemsXprt, 1) == 0) {
+ printf("%s: rkdbInit: cannot enable rpc cache\n", ActName);
+ return -3;
+ }
+ rtemsSock = sock;
+ return 0;
+}
+
+ rtems_task
+rdbgDaemon (rtems_task_argument argument)
+{
+ for (;;){
+
+ if (TotalReboot == 1){
+ rtemsReboot();
+ }
+
+ svc_processrequest( rtemsXprt, REMOTEDEB, REMOTEVERS, remotedeb_2);
+ }
+}
+
+ void
+rtems_rdbg_initialize (void)
+{
+ rtems_name task_name;
+ rtems_id tid;
+ rtems_status_code status;
+
+#ifdef DDEBUG
+ rdb_debug = 1; /* DPRINTF now will display */
+#endif
+
+ DPRINTF (("%s init starting\n", ActName));
+
+ /* Print version string */
+#ifdef DDEBUG
+ printk ("RDBG v.%d built on [%s %s]\n", SERVER_VERS, __DATE__, __TIME__);
+#else
+ printk ("RDBG v.%d\n", SERVER_VERS);
+#endif
+
+ /* Create socket and init UDP RPC server */
+ if (rdbgInit() != 0) goto error;
+
+ Continue = 1;
+ justSaveContext = 0;
+ currentTargetThread = 0;
+
+ task_name = rtems_build_name( 'R', 'D', 'B', 'G' );
+ if ((status = rtems_task_create( task_name, 5, 24576,
+ RTEMS_INTERRUPT_LEVEL(0),
+ RTEMS_DEFAULT_ATTRIBUTES | RTEMS_SYSTEM_TASK
+ , &tid ))
+ != RTEMS_SUCCESSFUL){
+ printf("status = %d\n",status);
+ rtems_panic ("Can't create task.\n");
+ }
+
+ status = rtems_task_start(tid, rdbgDaemon, 0);
+
+ return;
+
+error:
+ printf ("initialization failed.\n");
+}
+
+ void
+setErrno (int error)
+{
+ errno = error;
+}
+
+ int
+getErrno()
+{
+ return errno;
+}