source: rtems/c/src/librdbg/include/rdbg/servrpc.h @ 4721cf1

4.104.114.84.95
Last change on this file since 4721cf1 was 4721cf1, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 3, 1998 at 11:54:14 PM

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: 10.2 KB
Line 
1
2#ifndef SERVRPC_H
3#define SERVRPC_H
4
5
6#include <rtems/system.h>
7#include <rtems/score/cpu.h>
8
9#include <signal.h>            
10#include <stdio.h>              
11#include <stdlib.h>            
12#include <string.h>            
13
14#include <rpc/types.h>          
15#include <rdbg/remdeb.h>        
16#include <rpc/rpc.h>            
17#include <rpc/svc.h>            
18
19extern int CONN_LIST_INC;
20extern int PID_LIST_INC;
21extern int TSP_RETRIES;
22extern int BackPort;
23extern char ActName[];
24extern int getId();
25
26
27#ifdef DDEBUG
28int   rdb_debug;                /* True if env var RDB_DEBUG defined */
29extern const char* PtraceNames[]; /* list of ptrace requests for debug out */
30extern const char* BmsgNames[]; /* list of BMSG_xxx names */
31extern const char* PtraceName(int req);
32
33# define DPRINTF(a)     (rdb_debug ? printk ("%d >>> ", getId()), printk a : 0)
34#else
35# define DPRINTF(a)             /* suppress */
36#endif
37
38  /* Macros for analyzing/creating process status values. Presently do
39        not need to be separated per target. Could even use WIF... */
40
41#define STS_SIGNALLED(status)   (((status) & 0xFF) == 0x7F)
42#define STS_TERMONSIG(status)   (((status) & 0xFF) && !STS_SIGNALLED(status))
43#define STS_TERMGETSIG(status)  ((status) & 0x7F)
44#define STS_MAKESIG(sig)        (((sig) << 8) | 0x7f)
45#define STS_GETSIG(status)      ((status) >> 8)
46#define STS_GETCODE(status)     ((status) >> 8)
47
48
49/* now define base types */
50#ifndef UCHAR_DEFINED
51#define UCHAR_DEFINED           /* to handle duplicate typedes */
52typedef unsigned char   UCHAR;
53typedef unsigned char   UINT8;
54typedef char            INT8;
55typedef unsigned short  UINT16;
56typedef short           INT16;
57typedef unsigned long   UINT32;
58typedef long            INT32;
59#endif                          /* UCHAR_DEFINED */
60
61typedef long            PID;    /* generalized process id */
62
63#ifndef True
64# define True   1
65# define False  0
66typedef char Boolean;           
67#endif
68
69#define MAX_FILENAME    1024    /* largest filename with path */
70#define MAX_SEND        5       /* up to 5 pended outbound messages */
71
72#define SERVER_VERS     1
73
74typedef enum
75{                               /* message types */
76  BMSG_WARM=1,                  /* warm test for network connection */
77  BMSG_WAIT,                    /* wait change (stopped/started) */
78  BMSG_BREAK,                   /* breakpoint changed */
79  BMSG_EXEC_FAIL,               /* exec failed from spawn */
80  BMSG_DETACH,                  /* process detached from server */
81  BMSG_KILLED,                  /* killed by server */
82  BMSG_NOT_PRIM,                /* no longer the primary owner */
83  BMSG_NEW_PID                  /* the process was restart with new pid (in
84                                   context). Same ownership rules.   */
85} BACK_MSG;
86
87typedef struct 
88{                               /* this is the break_list[0] entry of pid */
89  UCHAR         clr_step;       /* true if step off break in last_break */
90  UCHAR         pad1;           /* Set if STEPEMUL breakpoints exist */
91  UINT16        last_break;     /* last breakpoint we stopped on (if break) */
92  UINT32        range_start;    /* start address of range */
93  UINT32        range_end;      /* end address inclusive */
94} BASE_BREAK;
95
96enum 
97{                               /* last start values */
98  LAST_NONE,                    /* stopped already */
99  LAST_STEP,                    /* did a step last - do not send to prim */
100  LAST_CONT,                    /* did a continue last */
101  LAST_RANGE,                   /* in the middle of step-in-range */
102  LAST_STEPOFF,                 /* stepped off break, now need to cont */
103  LAST_KILLED,                  /* was killed by ptrace */
104  LAST_DETACHED                 /* was detached by ptrace */
105};
106#define LAST_START 0x80         /* first execed. This is to handle MiX
107                                   bug where we need to start again */
108
109typedef struct 
110{                               /* one per open process */
111  PID           pid;            /* process id (or 0 if free) */
112  int           state;          /* status from last wait if stopped */
113  UCHAR         running;        /* True if running, else stopped/term */
114  /* now connection control over process */
115  UCHAR         owners;         /* count of owners for notify and term release */
116  UCHAR         primary_conn;   /* primary owner connection or 255=none */
117
118  UCHAR         filler;         /* Preserve alignment */
119
120  /* now break control and support */
121  UINT8         last_start;     /* LAST_xx start info for wait() */
122  UINT8         flags;          /* PIDFLG_xxx flags */
123  UINT16        break_alloc;    /* number of entries in break_list */
124  xdr_break     *break_list;    /* list of breakpoints ([0] is BASE_BREAK) */
125  /* now registers and other save information */
126  xdr_regs      regs;           /* saved registers when stopped */
127  int           is_step;        /* Was break or step (regs ambiguous often) */
128  int           stop_wanted;    /* Don't ignore next stop */
129  UINT32        thread;         /* current stopped thread or -1 if none */
130  char          *name;          /* full pathname or NULL if not known */
131  INT32         child;          /* child pid that manages the pid */
132  UINT32        textStart;      /* for relocating breakpoints at restart */
133} PID_LIST;
134PID_LIST        *pid_list;      /* array of processes being managed */
135int             pid_list_cnt;   /* number of entries allocated */
136UINT16          last_break;     /* unique handle generator for breaks */
137#define NO_PRIMARY ((UCHAR)-1)
138
139typedef union
140{                               /* an opaque net address */
141  unsigned long l[4];
142  unsigned char c[16];          /* corresponds to IP, enough for ChIPC */
143} NET_OPAQUE;
144
145typedef struct
146{                               /* one per connection */
147  UCHAR         in_use;         /* True if in use */
148  UCHAR         debug_type;     /* type of connection */
149  UINT16        flags;          /* flags for connection (CFLG_xxx) */
150  NET_OPAQUE    sender;         /* opaque address for transport compare */
151  NET_OPAQUE    back_port;      /* opaque address for transport event msgs */
152  NET_OPAQUE    route;          /* optional route address */
153  UINT32        pid_map[10];    /* map of pids owned relative to pid list */
154                                /* this allows up to 320 pids to be managed */
155  UCHAR         last_msg_num;   /* msg number used last to handle multi-send */
156  /* next field associated with UDP send messages */
157  UCHAR         retry;          /* count of retries. If 0, ok. If not 0, we
158                                   are in active wait for reply to an event */
159  UCHAR         send_idx;       /* current number of send's pended */
160  struct SEND_LIST
161  {                             /* holds pending msgs */
162    UCHAR       send_type;      /* BMSG_xxx type of message */
163    UCHAR       retry;          /* number of times to retry */
164    UINT16      spec;           /* spec field */
165    PID         pid;            /* pid if applies */
166    UINT32      context;        /* additional context if needed */
167  }             send_list[MAX_SEND]; /* pended list of messages being sent */
168  char          user_name[NAMEMAX]; /* name of user connecting in */
169  /* next fields are managed at runtime to handle lists, command upload, and
170     command download.                                                  */
171  enum {LST_NONE, LST_SPAWN, LST_INFO, LST_CMD_DOWN} list_type;
172  char          *list;          /* curr list we are sending/getting (malloced) */
173  UINT16        list_sz;        /* size of current list (string len) */
174  UINT16        list_num;       /* number of current list or position */
175  UINT16        list_alloc;     /* amount allocated so far */
176  UINT16        list_save;      /* used internally */
177} CONN_LIST;
178CONN_LIST       *conn_list;     /* an array of connections */
179int             conn_list_cnt;  /* number allocated */
180
181    /* Operations over the PID map. Each indexes into long and then bit */
182    /* 5 is log2 of 32, the number of bits in an int */
183#define PIDMAP_TEST(conn,idx) \
184    (conn_list [conn].pid_map [(idx) >> 5] & (1 << ((idx) & 31)))
185
186#define PIDMAP_SET(conn,idx) \
187    (conn_list [conn].pid_map [(idx) >> 5] |= 1 << ((idx) & 31))
188
189#define PIDMAP_CLEAR(conn,idx) \
190    (conn_list [conn].pid_map [(idx) >> 5] &= ~(1 << ((idx) &31)))
191
192#define PROC_TERMINATED(plst) \
193    (!(plst)->running && !STS_SIGNALLED ((plst)->state))
194
195
196/* first define the Connection routines exported from servcon.c */
197
198int ConnCreate  (struct svc_req *rqstp, open_in *in);
199void ConnDelete (int conn_idx, struct svc_req *rqstp, close_control control);
200
201void    TspInit (int rpc_io_channel);
202Boolean TspTranslateRpcAddr     (struct svc_req *rqstp, NET_OPAQUE *opaque);
203Boolean TspValidateAddr (NET_OPAQUE *opaque, NET_OPAQUE *sender);
204int     TspConnGetIndex (struct svc_req *rqstp);
205
206void    TspSendWaitChange  (int conn_idx, BACK_MSG msg, UINT16 spec, PID pid,
207                            UINT32 context, Boolean force);
208void    TspSendMessage     (int conn_idx, Boolean resend);
209void    TspMessageReceive  (int conn_idx, PID pid);
210char*   TspGetHostName     (int conn_idx);
211void    TgtCreateNew       (PID pid, int conn_idx, INT32 child,
212                            char *name, Boolean spawn);
213Boolean TgtAttach          (int conn_idx, PID pid);
214void    TgtNotifyWaitChange(PID pid, int status, Boolean exclude);
215void    TgtNotifyAll       (int pid_idx, BACK_MSG msg, UINT16 spec,
216                            UINT32 context, int exclude_conn, Boolean force);
217void    TgtDelete          (PID_LIST*, int conn_idx, BACK_MSG notify);
218int     TgtKillAndDelete   (PID_LIST *plst, struct svc_req *rqstp, Boolean term);
219void    TgtDetachCon       (int conn_idx, int pid_idx, Boolean delete);
220int     TgtThreadList      (PID_LIST*, unsigned* buf, unsigned int size);
221int     TgtGetThreadName   (PID_LIST*, unsigned thLi, char* name);
222int     TgtPtrace          (int req, PID pid, char *addr, int data, void *addr2);
223int     TgtRealPtrace      (int req, PID pid, char *addr, int data, void *addr2);
224Boolean TgtHandleChildChange(PID pid, int* status, int* unexp,
225                             CPU_Exception_frame *ctx);
226#ifdef DDEBUG
227  /* TgtDbgPtrace is a wrapper for RealPtrace() doing traces */
228int     TgtDbgPtrace       (int req, PID pid, char *addr, int data, void *addr2);
229#endif
230
231
232/* Information stored in "handle" */
233#define BKPT_INACTIVE   1       /* bkpt inactive for this execution */
234#define BKPT_ACTIVE     0       /* bkpt active for this execution */
235
236int     BreakOverwrite  (const PID_LIST* plst,const char* addr,
237                         unsigned int size);
238int     BreakSet        (PID_LIST*, int conn_idx, xdr_break*);
239int     BreakSetAt      (PID_LIST*, int conn_idx, unsigned long addr,break_type);
240int     BreakClear      (PID_LIST*, int conn_idx, int handle);
241int     BreakGetIndex   (PID_LIST*, void* addr);
242int     BreakGet        (const PID_LIST*, int data, xdr_break*);
243void    BreakHide       (const PID_LIST*, void*, int, void*);
244int     BreakStepOff    (const PID_LIST*, void** paddr2);
245void    BreakSteppedOff (PID_LIST*);
246int     BreakRespawn    (PID_LIST*);
247int     BreakIdentify   (PID_LIST*, int adjust, int thread);
248void    BreakPcChanged  (PID_LIST*);
249int     BreakStepRange  (PID_LIST*, void* addr, int len);
250void    BreaksDisable   (int pid);
251void    BreaksEnable    (int pid);
252
253int     TgtBreakRestoreOrig (int pid, void* addr, void* addr2);
254void    TgtBreakCancelStep  (PID_LIST* plst);
255
256Boolean ListAlloc       (char *buff, CONN_LIST *clst);
257int     FindPidEntry    (int pid);
258
259open_out*    RPCGENSRVNAME(open_connex_2_svc)    (open_in *in,
260                                                 struct svc_req *rqstp);
261signal_out*  RPCGENSRVNAME(send_signal_2_svc)    (signal_in *in,
262                                                 struct svc_req *rqstp);
263ptrace_out*  RPCGENSRVNAME(ptrace_2_svc)         (ptrace_in *in,
264                                                 struct svc_req *rqstp);
265wait_out*    RPCGENSRVNAME(wait_info_2_svc)      (wait_in *in,
266                                                 struct svc_req *rqstp);
267#endif /* !SERVRPC_H */
268
Note: See TracBrowser for help on using the repository browser.