source: rtems/c/src/librdbg/src/remdeb.x @ 48e40a3

Last change on this file since 48e40a3 was 981b99f, checked in by Joel Sherrill <joel.sherrill@…>, on 08/10/99 at 16:41:44

Patch from Eric Valette <valette@…> and Emmanuel Raguet
<raguet@…>:

  • the dec21140 driver code has been hardened (various bug fixed) Emmanuel,
  • bug in the mcp750 init code have been fixed (interrupt stack/initial stack initialization), BSS correctly cleared (Eric V)
  • remote debugging over TCP/IP is nearly complete (berakpoints, backtrace, variables,...) (Eric V),
  • exception handling code has also been improved in order to fully support RDBG requirements (Eric V),
  • Property mode set to 100644
File size: 15.2 KB
Line 
1/*
2 **********************************************************************
3 *
4 *  Component:  RDBG servers
5 *  Module:     remdeb.x
6 *
7 *  Synopsis:   XDR definitions for remote debug server RPC calls.
8 *              XDR definitions for RPCGEN to build remote debug server.
9 *
10 * $Id$
11 *
12 **********************************************************************
13 */
14
15#ifdef RPC_SVC
16%/*HEADER_START*/
17#endif
18
19%#define RTEMS_PORT 2071
20%#define RTEMS_BACK_PORT 2073
21
22#ifdef   RPC_HDR
23%#ifndef REMDEB_H
24%#define RPCGENSRVNAME(a)     a
25#endif
26
27enum rpc_type {
28        SUNRPC          = 0,
29        BADRPCTYPE      = 25
30};
31
32
33const NET_SAFE = 1400;  /* this is safe for UDP messages */
34
35struct UDP_MSG
36{                               /* format of UDP messages (should be in .h) */
37  unsigned char  type;          /* type of message (BMSG_xx) */
38  unsigned char  msg_num;       /* ringed number for resend detect */
39  unsigned short spec;          /* specific information for type */
40  long           pid;           /* process this affects */
41  unsigned long  context;       /* specific information to request */
42};
43
44  /* First we support the overhead structures and types needed for RPC
45        requests. Then, we have all RPC routines input/output args.     */
46
47%/*
48% * Sun request values for the remote ptrace system call
49% */
50%
51enum ptracereq
52{                               /* these match PTRACE_xxx numbers */
53  RPT_TRACEME = 0,              /* 0, by tracee to begin tracing */
54  RPT_CHILDDONE = 0,            /* 0, tracee is done with his half */
55  RPT_PEEKTEXT,                 /* 1, read word from text segment */
56  RPT_PEEKDATA,                 /* 2, read word from data segment */
57  RPT_PEEKUSER,                 /* 3, read word from user struct */
58  RPT_POKETEXT,                 /* 4, write word into text segment */
59  RPT_POKEDATA,                 /* 5, write word into data segment */
60  RPT_POKEUSER,                 /* 6, write word into user struct */
61  RPT_CONT,                     /* 7, continue process */
62  RPT_KILL,                     /* 8, terminate process */
63  RPT_SINGLESTEP,               /* 9, single step process */
64  RPT_ATTACH,                   /* 10, attach to an existing process (returns 2 if not primary)*/
65  RPT_DETACH,                   /* 11, detach from a process */
66  RPT_GETREGS,                  /* 12, get all registers */
67  RPT_SETREGS,                  /* 13, set all registers */
68  RPT_GETFPREGS,                /* 14, get all floating point regs */
69  RPT_SETFPREGS,                /* 15, set all floating point regs */
70  RPT_READDATA,                 /* 16, read data segment */
71  RPT_WRITEDATA,                /* 17, write data segment */
72  RPT_READTEXT,                 /* 18, read text segment */
73  RPT_WRITETEXT,                /* 19, write text segment */
74  RPT_GETFPAREGS,               /* 20, get all fpa regs */
75  RPT_SETFPAREGS,               /* 21, set all fpa regs */
76  RPT_22,                       /* 22, filler */
77  RPT_23,                       /* 23, filler */
78  RPT_SYSCALL,                  /* 24, trap next sys call */
79  RPT_DUMPCORE,                 /* 25, dump process core */
80  RPT_26,                       /* 26, filler */
81  RPT_27,                       /* 27, filler */
82  RPT_28,                       /* 28, filler */
83  RPT_GETUCODE,                 /* 29, get u.u_code */
84  /* Begin  specific ptrace options */
85  RPT_GETTARGETTHREAD = 50,     /* get PM target thread identifier */
86  RPT_SETTARGETTHREAD = 51,     /* set PM target thread identifier */
87  RPT_THREADSUSPEND   = 52,     /* suspend a thread */
88  RPT_THREADRESUME    = 53,     /* resume a thread */
89  RPT_THREADLIST      = 54,     /* get list of process's threads */
90  RPT_GETTHREADNAME   = 55,     /* get the name of the thread */
91  RPT_SETTHREADNAME   = 56,     /* set the name of the thread */
92  RPT_SETTHREADREGS   = 57,     /* set all registers for a specific thread*/
93  RPT_GETTHREADREGS   = 58,     /* get all registers for a specific thread*/
94  /* Begin extended ptrace options for remote debug server */
95  RPT_STEPRANGE       = 75,     /* step while in range (addr=start, data=len) */
96  RPT_CONTTO          = 76,     /* cont from PC to temp break in addr */
97  RPT_SETBREAK        = 77,     /* set a breakpoint (addr=break) */
98  RPT_CLRBREAK        = 78,     /* clear a breakpoint (data=handle or 0 for all) */
99  RPT_GETBREAK        = 79,     /* get breakpoint (data=handle, addr=buffer to
100                                   fill). Returns next break. If data=0,
101                                   returns number of breaks. */                 
102  RPT_GETNAME         = 80,     /* get name of process (data 0=name, 1=path
103                                   as started, 2=fullpath). Return in addr
104                                   as mem) */
105  RPT_STOP            = 81,     /* (C-actors) Stop the C-actor */
106  RPT_PGETREGS        = 82,     /* portable version */
107  RPT_PSETREGS        = 83,     /* portable version */
108  RPT_PSETTHREADREGS  = 84,     /* portable version */
109  RPT_PGETTHREADREGS  = 85      /* portable version */
110};
111
112#include FRONTEND
113
114const MAXDEBUGGEE= 150;
115const NAMEMAX = 17;   
116
117%  /*
118%   * Memory data for read/write text or data. The size is in data. The target
119%   * addr is in the addr field.
120%   * Be careful before modifying because this value goes into internal
121%   * pipes and is allocated on stack too. Pipes and/or the stack could
122%   * become too small if this value gets incremented.
123%   */
124
125const MEM_DATA_MAX      = 256;
126
127#ifndef RPC_XDR
128
129struct xdr_mem {
130        u_long          addr;
131        u_int           dataNb;
132        unsigned char   data[MEM_DATA_MAX];
133};
134
135#else
136/* manually define best XDR function for this */
137%bool_t xdr_xdr_mem(xdrs, objp)
138%       XDR *xdrs;
139%       struct xdr_mem *objp;
140%{
141%       if (!xdr_u_long(xdrs, &objp->addr)) {
142%               return (FALSE);
143%       }
144%       if (!xdr_u_int(xdrs, &objp->dataNb)) {
145%               return(FALSE);
146%       }
147%       return (xdr_opaque(xdrs, objp->data, objp->dataNb));
148%}
149
150#endif
151
152/* Breakpoint structure maps to same structure on host. Do not change one
153   without changing the other. */
154
155enum break_type
156{                               /* types of breakpoints */
157  BRKT_NONE,                    /* unused entry */
158  BRKT_INSTR,                   /* general instruction break */
159  BRKT_READ,                    /* read break */
160  BRKT_WRITE,                   /* write breakpoint */
161  BRKT_ACCESS,                  /* read-or-write break */
162  BRKT_EXEC,                    /* execution HW breakpoint */
163  BRKT_OS_CALL,                 /* break on OS call, addr is call number */
164  BRKT_OS_SWITCH,               /* dispatch breakpoint */
165  BRKT_STEPEMUL                 /* emulate hardware single-step */
166};
167const MAX_THRD_BRK = 4;         /* enough for 128 threads per process */
168struct xdr_break
169{                               /* one per process local breakpoint */
170  u_char        type;           /* BRKT_xxx type of break */
171  u_char        thread_spec;    /* 0=all, else count of threads it affects */
172  u_short       handle;         /* handle of breakpoint returned */
173  u_long        ee_loc;         /* address of start */
174  u_long        ee_type;        /* type/method of address */
175  u_short       length;         /* length of break if range, else 0 */
176  u_char        pass_count;     /* pass count to initialize to (0=none) */
177  u_char        curr_pass;      /* pass count current value */
178  u_long        thread_list[MAX_THRD_BRK]; /* bit map for thread list */
179};                              /* 20 bytes+4 per thread_list (4x4=16) = 36 */
180
181const UTHREAD_MAX     = 64;
182
183const THREADNAMEMAX =   16;
184typedef string thread_name <THREADNAMEMAX>;
185
186struct KernThread {
187        unsigned int threadLi;
188};
189
190#ifndef RPC_XDR
191
192#ifdef RPC_HDR
193%typedef KernThread *ptThreadList;
194#endif
195
196struct thread_list {
197        unsigned int nbThread;
198        ptThreadList threads;   
199};
200
201#else /* RPC_XDR */
202
203/* must write this function by hand */
204
205%bool_t xdr_thread_list(xdrs, objp)
206%       XDR *xdrs;
207%       struct thread_list *objp;
208%{
209%       return (xdr_array(xdrs, (char**)&objp->threads, &objp->nbThread,
210%                       UTHREAD_MAX, sizeof(KernThread), xdr_KernThread));
211%}
212
213#endif /* not RPC_XDR */
214
215
216union ptrace_addr_data_in switch (ptracereq req) {
217    /*
218     * due to rpcgen poor features, we cannot put RPC_SETREGS
219     * AND RPC_SETTHREADREGS in the case list. So we use a hack (FIX rpcgen).
220     */
221#ifndef RPC_HDR
222        case RPT_SETTHREADREGS :
223                                xdr_regs regs;
224#endif
225        case RPT_SETREGS:
226
227                                xdr_regs regs;
228
229#ifndef RPC_HDR
230        case RPT_PSETTHREADREGS:
231                                u_int pregs<>;
232#endif
233        case RPT_PSETREGS:
234                                u_int pregs<>;
235
236#ifdef LATER
237        case RPT_SETFPREGS:
238                                xdr_fp_status fpregs;
239#endif
240        case RPT_SETTHREADNAME:
241                                thread_name name;
242#ifndef RPC_HDR
243        case RPT_WRITETEXT:
244                                xdr_mem mem;
245#endif
246        case RPT_WRITEDATA:
247                                xdr_mem mem;
248        case RPT_SETBREAK:
249                                xdr_break breakp;
250        default:
251                                u_int address;
252};
253
254union ptrace_addr_data_out switch (ptracereq req) {
255        case RPT_GETREGS:
256                                xdr_regs regs;
257#ifndef RPC_HDR
258        case RPT_GETTHREADREGS:
259                                xdr_regs regs;
260#endif
261
262        case RPT_PGETREGS:
263                                u_int pregs<>;
264
265#ifndef RPC_HDR
266        case RPT_PGETTHREADREGS:
267                                u_int pregs<>;
268#endif
269
270#ifdef LATER
271        case RPT_GETFPREGS:
272                                xdr_fp_status fpregs;
273#endif
274        case RPT_THREADLIST:
275                                thread_list threads;
276        case RPT_GETTHREADNAME:
277                                thread_name name;                               
278#ifndef RPC_HDR
279        case RPT_READTEXT:
280                                xdr_mem mem;
281        case RPT_GETNAME:
282                                xdr_mem mem;
283#endif
284        case RPT_READDATA:
285                                xdr_mem mem;
286        case RPT_GETBREAK:
287                                xdr_break breakp;
288        default:
289                                u_int addr;
290};
291
292typedef opaque CHAR_DATA <NET_SAFE>;    /* variable sized data */
293
294const XRY_MAX_INST_BUFF = 128;
295const XRY_MAX_INSTANCES = 16;
296%#ifndef XRY_MAX_CMD_STR
297const XRY_MAX_CMD_STR = 320; /* XRY_MAX_INST_BUFF+(XRY_MAX_INSTANCES*12) */
298%#endif /* REMDEB_H */
299
300
301struct xry_inst
302{
303  unsigned char flags;          /* value2 interp, etc. INFL_xxx */
304  unsigned char type;           /* base type of data (str, val, etc) INST_xxx */
305  unsigned char sub_type;       /* specific type (task, res, etc). This is
306                                   set and defined by the user defined instance
307                                   processor and not the auto-processor */
308  unsigned char res_type;
309  u_long        value;          /* pointer to value or value itself */
310  u_long        value2;         /* second value (optional - based on flags) */ 
311};
312
313struct instance
314{
315  struct xry_inst instances[XRY_MAX_INSTANCES];
316  unsigned char buffer[XRY_MAX_INST_BUFF];
317};
318
319union instance_union switch (bool instances)
320{
321  case TRUE:
322        instance        inst;
323  case FALSE:
324        string          buffer <XRY_MAX_CMD_STR>;
325};
326
327typedef string  one_arg <NET_SAFE>;     
328
329const XRY_MAX_OBJ_NAME = 32;    /* objname in some commands */
330
331%  /* now open_connex() routine which establishes a connection to server */
332
333enum debug_type
334{                               /* type of connection requested */
335  DEBTYP_PROCESS = 0,           /* process connection */
336  DEBTYP_C_ACTOR = 1,           /* C-Actor connection */
337  DEBTYP_KERNEL = 2,            /* kernel debug connection */
338  DEBTYP_OTHER = 3              /* other subsystem */
339};
340
341%#define DEBUGGER_IS_GDB 0x2    /* */
342
343struct open_in
344{                               /* input args to open a connection */
345  u_char        back_port[16];  /* opaque NET address format */
346  u_short       debug_type;     /* type of process DEBTYP_xxx */
347  u_short       flags;          /* connection information OPNFLG_xxx */
348  u_char        destination[16];/* opaque address if to router */
349  one_arg       user_name;      /* name of user on host */
350};
351
352struct open_out
353{                               /* return from open_connex */
354  u_long        port;           /* connection number to server or -1 if error */
355  u_int         pad[4];         /* Planned to be KnIpcDest. Never used */
356  u_int         fp;             /* True if floating point processor. If error,
357                                   set to errno for open error.         */
358  u_char        cmd_table_num;  /* command table used */
359  u_char        cmd_table_vers; /* version of command table */
360  u_short       server_vers;    /* version number of server itself */
361};
362
363%  /* now close_connex() routine which detaches from server */
364
365enum close_control
366{                               /* choice of how to handle owned processes */
367  CLOSE_IGNORE = 0,             /* ignore all controlled pids on close */
368  CLOSE_KILL = 1,               /* kill all controlled pids on close */
369  CLOSE_DETACH = 2              /* detach free running all controlled pids */
370};
371
372struct close_in
373{                               /* arg to close connection */
374  close_control control;        /* shutdown of owned processes control */
375};
376
377%  /* now send_signal() routine which sends signals to processes like kill(2) */
378
379struct signal_in
380{                               /* input to send_signal */
381  int           pid;            /* process/actor to send signal to */
382  int           sig;            /* signal to send (from /usr/include/signal.h) */
383};
384
385struct signal_out
386{                               /* return from send_signal */
387  int           kill_return;    /* return code from kill(2) call */
388  int           errNo;          /* error code if failed */
389};
390
391
392%  /* now wait_info() routine which returns results of polling the wait status
393%       of a process/actor. It may return 0 if running, else pid or -1 */
394
395enum stop_code
396{                               /* stop code information */
397  STOP_ERROR = 0,               /* error, errno set */
398  STOP_NONE = 1,                /* not stopped */
399  STOP_UNKNOWN = 2,             /* unknown stop reason */
400  STOP_BREAK = 3,               /* stopped on breakpoint */
401  STOP_STEP = 4,                /* stopped on step */
402  STOP_SIGNAL = 5,              /* stopped on signal receieve */
403  STOP_TERM_EXIT = 6,           /* terminated normally */
404  STOP_TERM_SIG = 7,            /* terminated by signal */
405  STOP_DETACHED = 8,            /* detached from server */
406  STOP_KILLED = 9,              /* killed by ptrace KILL */
407  STOP_SPAWN_FAILED = 10        /* spawn failed in exec part, handle=errno */
408};
409
410struct wait_in
411{                               /* input arg to wait is process */
412  int           pid;            /* process/actor id */
413};
414
415struct wait_out
416{                               /* result of wait_info call */
417  int           wait_return;    /* -1=error,0=running,pid=stopped */
418  int           errNo;          /* error code if error */
419  int           status;         /* wait(2) status if stopped */
420  stop_code     reason;         /* reason in more abstracted terms */
421  int           handle;         /* handle of break if stopped on break,
422                                   or signal number or exit code  */
423  u_long        PC;             /* program counter if stopped */
424  u_long        SP;             /* stack pointer if stopped */
425  u_long        FP;             /* frame pointer if stopped */
426  u_long        thread;         /* thread that stopped if applies (else -1) */
427};
428
429%  /* now ptrace() routine. This matches the Sun UNIX ptrace as well as
430%       some additions */
431
432const PTRFLG_FORCE = 1;         /* when set and process running, forces process
433                                   to stop, make the request, then start again.
434                                   This is used for breakpoints and the like */
435const PTRFLG_NON_OWNER = 2;     /* do request even if not primary owner (will
436                                   notify all owners including caller if owns) */
437const PTRFLG_FREE = 4;          /* free pid_list after KILL/DETACH */
438
439const PTRDET_UNOWN = 0x100;     /* data value in RPT_DETACH just disconnects
440                                   caller as an owner of process.       */
441
442struct ptrace_in
443{                               /* input args matches ptrace but for XDR */
444  int           pid;            /* process to act on */
445  ptrace_addr_data_in addr;     /* mappings for addr and addr2 */
446  u_int         data;           /* simple data arg of ptrace */
447  u_int         flags;          /* mask of PTRFLG_xxx flags. */
448};
449
450struct ptrace_out
451{                               /* return information from ptrace */
452  ptrace_addr_data_out  addr;   /* return through addr/addr2 */
453  int                   result; /* result of ptrace call (return value) */
454  int                   errNo;  /* error code if error */
455};
456
457    /* Data for GET_GLOBAL_SYMBOLS */
458struct one_symbol {             /* Must match common/src/lib/ctx/ctx.h */
459    string symbolName<>;
460    long symbolValue;
461};
462
463typedef one_symbol all_symbols<>;
464
465struct get_global_symbols_out {
466    all_symbols symbols;
467};
468
469    /* Data for GET_TEXT_DATA */
470struct get_text_data_in {
471  int           pid;            /* process/actor id if non-zero */
472  string        actorName<16>;  /* actor name for system mode */
473};
474
475struct get_text_data_out {
476    int         result;
477    int         errNo;
478    u_long      textStart;
479    u_long      textSize;
480    u_long      dataStart;
481    u_long      dataSize;
482};
483
484    /* Data for GET_SIGNAL_NAMES */
485struct one_signal {
486    u_int       number;
487    string      name<>;
488};
489
490typedef one_signal all_signals<>;
491
492struct get_signal_names_out {
493    all_signals signals;
494};
495
496%  /* now define the actual calls we support */
497
498program REMOTEDEB {
499        version REMOTEVERS {
500
501                /* open a connection to server or router */
502                open_out
503                OPEN_CONNEX(open_in)            = 1;
504
505                /* send a signal to a process */
506                signal_out
507                SEND_SIGNAL(signal_in)          = 2;
508
509        /* all routines below require a connection first */
510
511                /* close the connection to the server */
512                void
513                CLOSE_CONNEX(close_in)          = 10;
514
515                /* process ptrace request */
516                ptrace_out
517                PTRACE(ptrace_in)               = 11;
518               
519                /* poll for status of process */
520                wait_out
521                WAIT_INFO(wait_in)              = 13;
522
523                get_signal_names_out
524                GET_SIGNAL_NAMES(void)          = 17;
525
526        } = 2;                  /* now version 2 */
527} = 0x20000fff;
528
529#ifdef RPC_HDR
530%#define REMDEB_H
531%#endif
532#endif
533
534#ifdef RPC_SVC
535
536%const char* names [] = {
537%    "NULLPROC", "OPEN_CONNEX", "SEND_SIGNAL", "name3",
538%    "name4", "name5", "name6", "name7",
539%    "name8", "name9", "CLOSE_CONNEX", "PTRACE",
540%    "name12", "WAIT_INFO", "name14", "name15",
541%    "name16", "GET_SIGNAL_NAMES", "name18"
542%};
543%
544
545%/*HEADER_END*/
546#endif
Note: See TracBrowser for help on using the repository browser.