source: rtems/c/src/lib/librdbg/servcon.c @ 0bf2ff8

4.104.114.84.95
Last change on this file since 0bf2ff8 was 4721cf1, checked in by Joel Sherrill <joel.sherrill@…>, on 12/03/98 at 23:54:14

Patch from Emmanuel Raguet <raguet@…> 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.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 **************************************************************************
3 *
4 *  Component:  RDBG
5 *  Module:     servcon.c
6 *
7 *  Synopsis:   Management of RPC client connections.
8 *
9 **************************************************************************
10 */
11
12#include <sys/errno.h> 
13#include <rdbg/rdbg.h>         
14#include <rdbg/servrpc.h>       
15 
16    /*
17     *  ConnCreate - create a new connection entry for a client.
18     *
19     *  This function finds an empty entry in the connection array
20     *  or makes space. It fills in the fields that are passed to it.
21     *  It does not do any validation on net addresses nor does it
22     *  start a validation cycle on other clients. This is done by
23     *  the caller.
24     */
25
26    int
27ConnCreate (struct svc_req* rqstp, open_in* in)
28{
29    NET_OPAQUE  sender;
30    int         idx;
31    CONN_LIST*  clst;
32   
33    setErrno (0);
34
35    /* Convert to valid Net address */
36    if (! TspTranslateRpcAddr (rqstp, &sender)) {
37        DPRINTF (("ConnCreate: TspTranslateRpcAddr failed\n"));
38        return -1;
39    }
40    if (! TspValidateAddr ((NET_OPAQUE*) in->back_port, &sender)) {
41        DPRINTF (("ConnCreate: TspValidateAddr failed\n"));
42        return -1;                      /* errno now setup with error */
43    }
44
45        /* look for an empty connection entry */
46    for (idx = 0; idx < conn_list_cnt; idx++) {
47        if (!conn_list[idx].in_use)
48            break;                      /* an empty one found */
49    }
50
51    if (idx >= conn_list_cnt) {         /* no empties, create space */
52        CONN_LIST*      tmp_conn_list = conn_list;
53
54        conn_list_cnt += CONN_LIST_INC;
55        if (conn_list) {
56            conn_list = (CONN_LIST *) Realloc (conn_list,  /* extend */
57                conn_list_cnt * sizeof (CONN_LIST));
58        } else {
59            conn_list = (CONN_LIST *)Malloc(conn_list_cnt * sizeof(CONN_LIST));
60        }
61
62        if (!conn_list) {               /* unable to get space */
63            if ((conn_list_cnt -= CONN_LIST_INC)) {
64                    /* was realloc, restore space */
65                conn_list = tmp_conn_list;
66            }
67            return -1;          /* errno set by failed alloc */
68        }
69            /* clear newly created memory */
70        memset (conn_list + idx, 0, CONN_LIST_INC * sizeof (CONN_LIST));
71    } else {                    /* clear new entry */
72        memset (conn_list + idx, 0, sizeof (CONN_LIST));
73    }
74    clst = conn_list + idx;
75
76    clst->in_use = True; /* now in use */
77    clst->sender = sender;
78    memcpy (&clst->back_port, &in->back_port, sizeof (NET_OPAQUE));
79    memcpy (&clst->route, &in->destination, sizeof (NET_OPAQUE));
80    clst->debug_type = (UCHAR) in->debug_type;
81    clst->flags = in->flags;
82    strncpy (clst->user_name, in->user_name, NAMEMAX-1);
83    clst->user_name [NAMEMAX-1] = 0;
84
85    return idx;
86}
87
88    /*
89     *  ConnDelete - remove connection entry when shutdown.
90     *
91     */
92
93    void
94ConnDelete (int conn, struct svc_req* rqstp, close_control control)
95{
96    CONN_LIST*  clst = conn_list + conn;
97    int         idx;
98    Boolean     prim;
99
100    if (! clst->in_use) return; /* not active */
101
102    for (idx = 0; idx < pid_list_cnt; idx++) {
103        PID_LIST* plst = pid_list + idx;
104
105        if (! PIDMAP_TEST (conn, idx)) continue;
106
107            /* found a controlled pid */
108        prim = (plst->primary_conn == conn) ? True : False;
109        TgtDetachCon (conn, idx, True);
110
111            /* if still running or alive, we use close control on it */
112        if (! plst->pid)
113            continue;           /* entry gone */
114
115        if (prim && control == CLOSE_KILL) {
116                /* kill off process */
117            TgtKillAndDelete (plst, rqstp, True);
118        } else if (! plst->owners) {
119                /* no owners left */
120            if (control == CLOSE_DETACH) {
121                TgtKillAndDelete (plst, rqstp, False);
122            }
123            if (control == CLOSE_DETACH || PROC_TERMINATED (plst)) {
124                TgtDelete (plst, conn, (control==CLOSE_DETACH) ?
125                    BMSG_DETACH : 0);
126            }
127        }
128    }
129    if (clst->list) {
130        Free (clst->list);      /* free allocated memory */
131    }
132    DPRINTF (("ConnDelete: Connection closed for port %u\n",
133        HL_W(*((UINT16*) &clst->back_port.c[2]))));
134
135    clst->in_use = False;       /* free it back */
136}
Note: See TracBrowser for help on using the repository browser.