summaryrefslogtreecommitdiffstats
path: root/c/src/librdbg/src/rdbg.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2002-02-01 17:00:01 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2002-02-01 17:00:01 +0000
commit40cf43eab4e4121a92ec95bc1366cc5b3bad4e27 (patch)
tree5aef0f81416b68a9f035ac5d14ba9278f0787c1c /c/src/librdbg/src/rdbg.c
parent2001-02-01 Mike Siers <mikes@poliac.com> (diff)
downloadrtems-40cf43eab4e4121a92ec95bc1366cc5b3bad4e27.tar.bz2
* So many patches have been posted recently on the mailing list and
because we were unable to find correct solution to compile on various linux distros (due to rpcgen incompatibilities), and because the coding style of rdbg was rather inconsistant among various pieces of code, I decided to: 1) make some cleaning regarding global coding style (using indent + manual edits), 2) incorporate/review the paches send by various people (S. Holford, T. Strauman), 3) Fix the bug due to varying rpcgen code generation in remdeb_svc.c, 4) Remove some dead code, 5) Apply a patches enabling to call enterRdbg imediately after rdbg initialization is done, NB : the paches is huge but it is mainly due to coding styke chnages. Only few lines of codes have been really changed and they do not impact rdbg functionnality (AFAIKT). * include/rdbg/servrpc.h, include/rdbg/i386/rdbg_f.h, include/rdbg/m68k/rdbg_f.h, include/rdbg/powerpc/rdbg_f.h, src/_servtgt.c, src/awk.svc, src/excep.c, src/ptrace.c, src/rdbg.c, src/remdeb.x, src/servbkpt.c, src/servcon.c, src/servrpc.c, src/servtgt.c, src/servtsp.c, src/servutil.c, src/i386/excep_f.c, src/i386/rdbg_f.c, src/i386/any/Makefile.am, src/i386/any/remdeb.h, src/i386/any/remdeb_svc.c, src/i386/any/remdeb_xdr.c, src/m68k/excep_f.c, src/m68k/rdbg_f.c, src/m68k/any/Makefile.am, src/m68k/any/remdeb.h, src/m68k/any/remdeb_svc.c, src/m68k/any/remdeb_xdr.c, src/powerpc/excep_f.c, src/powerpc/rdbg_f.c, src/powerpc/new_exception_processing/Makefile.am, src/powerpc/new_exception_processing/remdeb.h, src/powerpc/new_exception_processing/remdeb_svc.c, src/powerpc/new_exception_processing/remdeb_xdr.c: Modified.
Diffstat (limited to 'c/src/librdbg/src/rdbg.c')
-rw-r--r--c/src/librdbg/src/rdbg.c175
1 files changed, 86 insertions, 89 deletions
diff --git a/c/src/librdbg/src/rdbg.c b/c/src/librdbg/src/rdbg.c
index 5f08e99f5c..3dd9a52e10 100644
--- a/c/src/librdbg/src/rdbg.c
+++ b/c/src/librdbg/src/rdbg.c
@@ -3,7 +3,7 @@
*
* Component =
*
- * Synopsis = rkdb/rkdb.c
+ * Synopsis = rdbg.c
*
* $Id$
*
@@ -21,131 +21,128 @@
#include <sys/socket.h>
#include <netinet/in.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;
+u_short rtemsPort = RTEMS_PORT;
+int BackPort = RTEMS_BACK_PORT;
+int rtemsActive = 0;
+SVCXPRT *rtemsXprt;
+int rtemsSock;
+char taskName[] = "RTEMS rdbg daemon";
+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 PID_LIST_INC = 1;
+int TSP_RETRIES = 10;
-
-int
-getId()
+ int
+getId ()
{
rtems_id id;
-
- rtems_task_ident(RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &id);
- return (int)(id) ;
-}
-static void
-remotedeb_2_hook(struct svc_req *rqstp, register SVCXPRT *transp)
-{
- connect_rdbg_exception(); /* monitor stub changes trace vector */
- remotedeb_2(rqstp, transp);
- connect_rdbg_exception();
+ rtems_task_ident (RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &id);
+ return (int) (id);
}
-static int
+ 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;
- if (!svc_register(rtemsXprt, REMOTEDEB, REMOTEVERS, remotedeb_2, 0)) {
- printf(stderr, "unable to register (REMOTEDEB, REMOTEVERS, udp).");
- return -4;
- }
-
- return 0;
+ int sock;
+ struct sockaddr_in addr;
+
+ sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (sock == -1) {
+ printf ("%s: rdbgInit: cannot allocate socket\n", taskName);
+ 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: rdbgInit: cannot bind socket\n", taskName);
+ return -2;
+ }
+ rtemsXprt = svcudp_create (sock);
+ if (svcudp_enablecache (rtemsXprt, 1) == 0) {
+ printf ("%s: rdbgInit: cannot enable rpc cache\n", taskName);
+ return -3;
+ }
+ rtemsSock = sock;
+ if (!svc_register (rtemsXprt, REMOTEDEB, REMOTEVERS, remotedeb_2, 0)) {
+ printf (stderr, "unable to register (REMOTEDEB, REMOTEVERS, udp).");
+ return -4;
+ }
+ connect_rdbg_exception ();
+
+ return 0;
}
-rtems_task
+ rtems_task
rdbgDaemon (rtems_task_argument argument)
{
- svc_run();
+ svc_run ();
}
-void
+ void
rtems_rdbg_initialize (void)
{
- rtems_name task_name;
- rtems_id tid;
+ rtems_name task_name;
+ rtems_id tid;
rtems_status_code status;
#ifdef DDEBUG
- rdb_debug = 1; /* DPRINTF now will display */
+ rdb_debug = 1; /* DPRINTF now will display */
#endif
- DPRINTF (("%s init starting\n", ActName));
+ DPRINTF (("%s init starting\n", taskName));
- /* Print version string */
+ /*
+ * Print version string
+ */
#ifdef DDEBUG
- printk ("RDBG v.%d built on [%s %s]\n", SERVER_VERS, __DATE__, __TIME__);
+ printk ("RDBG v.%d built on [%s %s]\n", SERVER_VERS, __DATE__, __TIME__);
#else
- printk ("RDBG v.%d\n", SERVER_VERS);
+ printk ("RDBG v.%d\n", SERVER_VERS);
#endif
- /* Create socket and init UDP RPC server */
- if (rdbgInit() != 0) goto error;
+ /*
+ * Create socket and init UDP RPC server
+ */
+ if (rdbgInit () != 0)
+ goto error;
+
+ Continue = 1;
+ justSaveContext = 0;
+ currentTargetThread = 0;
- 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");
- }
+ 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);
+ status = rtems_task_start (tid, rdbgDaemon, 0);
- return;
+ return;
error:
- printf ("initialization failed.\n");
+ printf ("initialization failed.\n");
}
-void
+ void
setErrno (int error)
{
- errno = error;
+ errno = error;
}
-int
-getErrno()
+ int
+getErrno ()
{
- return errno;
+ return errno;
}