OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [librdbg/] [src/] [remdeb.x] - Blame information for rev 1026

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 * remdeb.x,v 1.4 2002/02/01 17:00:01 joel Exp
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
 
27
enum rpc_type {
28
        SUNRPC          = 0,
29
        BADRPCTYPE      = 25
30
};
31
 
32
 
33
const NET_SAFE = 1400;  /* this is safe for UDP messages */
34
 
35
struct 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
%
51
enum 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
 
114
const MAXDEBUGGEE= 150;
115
const 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
 
125
const MEM_DATA_MAX      = 256;
126
 
127
#ifndef RPC_XDR
128
 
129
struct 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
 
155
enum 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
};
167
const MAX_THRD_BRK = 4;         /* enough for 128 threads per process */
168
struct 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
 
181
const UTHREAD_MAX     = 64;
182
 
183
const THREADNAMEMAX =   16;
184
typedef string thread_name ;
185
 
186
struct KernThread {
187
        unsigned int threadLi;
188
};
189
 
190
#ifndef RPC_XDR
191
 
192
#ifdef RPC_HDR
193
%typedef KernThread *ptThreadList;
194
#endif
195
 
196
struct 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
 
216
union 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
 
254
union 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
 
292
typedef opaque CHAR_DATA ;      /* variable sized data */
293
 
294
typedef string  one_arg ;
295
 
296
%  /* now open_connex() routine which establishes a connection to server */
297
 
298
enum debug_type
299
{                               /* type of connection requested */
300
  DEBTYP_PROCESS = 0,           /* process connection */
301
  DEBTYP_C_ACTOR = 1,           /* C-Actor connection */
302
  DEBTYP_KERNEL = 2,            /* kernel debug connection */
303
  DEBTYP_OTHER = 3              /* other subsystem */
304
};
305
 
306
%#define DEBUGGER_IS_GDB 0x2    /* */
307
 
308
struct open_in
309
{                               /* input args to open a connection */
310
  u_char        back_port[16];  /* opaque NET address format */
311
  u_short       debug_type;     /* type of process DEBTYP_xxx */
312
  u_short       flags;          /* connection information OPNFLG_xxx */
313
  u_char        destination[16];/* opaque address if to router */
314
  one_arg       user_name;      /* name of user on host */
315
};
316
 
317
struct open_out
318
{                               /* return from open_connex */
319
  u_long        port;           /* connection number to server or -1 if error */
320
  u_int         pad[4];         /* Planned to be KnIpcDest. Never used */
321
  u_int         fp;             /* True if floating point processor. If error,
322
                                   set to errno for open error.         */
323
  u_char        cmd_table_num;  /* command table used */
324
  u_char        cmd_table_vers; /* version of command table */
325
  u_short       server_vers;    /* version number of server itself */
326
};
327
 
328
%  /* now close_connex() routine which detaches from server */
329
 
330
enum close_control
331
{                               /* choice of how to handle owned processes */
332
  CLOSE_IGNORE = 0,             /* ignore all controlled pids on close */
333
  CLOSE_KILL = 1,               /* kill all controlled pids on close */
334
  CLOSE_DETACH = 2              /* detach free running all controlled pids */
335
};
336
 
337
struct close_in
338
{                               /* arg to close connection */
339
  close_control control;        /* shutdown of owned processes control */
340
};
341
 
342
%  /* now send_signal() routine which sends signals to processes like kill(2) */
343
 
344
struct signal_in
345
{                               /* input to send_signal */
346
  int           pid;            /* process/actor to send signal to */
347
  int           sig;            /* signal to send (from /usr/include/signal.h) */
348
};
349
 
350
struct signal_out
351
{                               /* return from send_signal */
352
  int           kill_return;    /* return code from kill(2) call */
353
  int           errNo;          /* error code if failed */
354
};
355
 
356
 
357
%  /* now wait_info() routine which returns results of polling the wait status
358
%       of a process/actor. It may return 0 if running, else pid or -1 */
359
 
360
enum stop_code
361
{                               /* stop code information */
362
  STOP_ERROR = 0,               /* error, errno set */
363
  STOP_NONE = 1,                /* not stopped */
364
  STOP_UNKNOWN = 2,             /* unknown stop reason */
365
  STOP_BREAK = 3,               /* stopped on breakpoint */
366
  STOP_STEP = 4,                /* stopped on step */
367
  STOP_SIGNAL = 5,              /* stopped on signal receieve */
368
  STOP_TERM_EXIT = 6,           /* terminated normally */
369
  STOP_TERM_SIG = 7,            /* terminated by signal */
370
  STOP_DETACHED = 8,            /* detached from server */
371
  STOP_KILLED = 9,              /* killed by ptrace KILL */
372
  STOP_SPAWN_FAILED = 10        /* spawn failed in exec part, handle=errno */
373
};
374
 
375
struct wait_in
376
{                               /* input arg to wait is process */
377
  int           pid;            /* process/actor id */
378
};
379
 
380
struct wait_out
381
{                               /* result of wait_info call */
382
  int           wait_return;    /* -1=error,0=running,pid=stopped */
383
  int           errNo;          /* error code if error */
384
  int           status;         /* wait(2) status if stopped */
385
  stop_code     reason;         /* reason in more abstracted terms */
386
  int           handle;         /* handle of break if stopped on break,
387
                                   or signal number or exit code  */
388
  u_long        PC;             /* program counter if stopped */
389
  u_long        SP;             /* stack pointer if stopped */
390
  u_long        FP;             /* frame pointer if stopped */
391
  u_long        thread;         /* thread that stopped if applies (else -1) */
392
};
393
 
394
%  /* now ptrace() routine. This matches the Sun UNIX ptrace as well as
395
%       some additions */
396
 
397
const PTRFLG_FORCE = 1;         /* when set and process running, forces process
398
                                   to stop, make the request, then start again.
399
                                   This is used for breakpoints and the like */
400
const PTRFLG_NON_OWNER = 2;     /* do request even if not primary owner (will
401
                                   notify all owners including caller if owns) */
402
const PTRFLG_FREE = 4;          /* free pid_list after KILL/DETACH */
403
 
404
const PTRDET_UNOWN = 0x100;     /* data value in RPT_DETACH just disconnects
405
                                   caller as an owner of process.       */
406
 
407
struct ptrace_in
408
{                               /* input args matches ptrace but for XDR */
409
  int           pid;            /* process to act on */
410
  ptrace_addr_data_in addr;     /* mappings for addr and addr2 */
411
  u_int         data;           /* simple data arg of ptrace */
412
  u_int         flags;          /* mask of PTRFLG_xxx flags. */
413
};
414
 
415
struct ptrace_out
416
{                               /* return information from ptrace */
417
  ptrace_addr_data_out  addr;   /* return through addr/addr2 */
418
  int                   result; /* result of ptrace call (return value) */
419
  int                   errNo;  /* error code if error */
420
};
421
 
422
    /* Data for GET_GLOBAL_SYMBOLS */
423
struct one_symbol {             /* Must match common/src/lib/ctx/ctx.h */
424
    string symbolName<>;
425
    long symbolValue;
426
};
427
 
428
typedef one_symbol all_symbols<>;
429
 
430
struct get_global_symbols_out {
431
    all_symbols symbols;
432
};
433
 
434
    /* Data for GET_TEXT_DATA */
435
struct get_text_data_in {
436
  int           pid;            /* process/actor id if non-zero */
437
  string        actorName<16>;      /* actor name for system mode */
438
};
439
 
440
struct get_text_data_out {
441
    int         result;
442
    int         errNo;
443
    u_long      textStart;
444
    u_long      textSize;
445
    u_long      dataStart;
446
    u_long      dataSize;
447
};
448
 
449
    /* Data for GET_SIGNAL_NAMES */
450
struct one_signal {
451
    u_int       number;
452
    string      name<>;
453
};
454
 
455
typedef one_signal all_signals<>;
456
 
457
struct get_signal_names_out {
458
    all_signals signals;
459
};
460
 
461
%  /* now define the actual calls we support */
462
 
463
program REMOTEDEB {
464
        version REMOTEVERS {
465
 
466
                /* open a connection to server or router */
467
                open_out
468
                OPEN_CONNEX(open_in)            = 1;
469
 
470
                /* send a signal to a process */
471
                signal_out
472
                SEND_SIGNAL(signal_in)          = 2;
473
 
474
        /* all routines below require a connection first */
475
 
476
                /* close the connection to the server */
477
                void
478
                CLOSE_CONNEX(close_in)          = 10;
479
 
480
                /* process ptrace request */
481
                ptrace_out
482
                PTRACE(ptrace_in)               = 11;
483
 
484
                /* poll for status of process */
485
                wait_out
486
                WAIT_INFO(wait_in)              = 13;
487
 
488
                get_signal_names_out
489
                GET_SIGNAL_NAMES(void)          = 17;
490
 
491
        } = 2;                  /* now version 2 */
492
} = 0x20000fff;
493
 
494
#ifdef RPC_HDR
495
%#define REMDEB_H
496
%#endif
497
#endif
498
 
499
#ifdef RPC_SVC
500
 
501
%const char* names [] = {
502
%    "NULLPROC", "OPEN_CONNEX", "SEND_SIGNAL", "name3",
503
%    "name4", "name5", "name6", "name7",
504
%    "name8", "name9", "CLOSE_CONNEX", "PTRACE",
505
%    "name12", "WAIT_INFO", "name14", "name15",
506
%    "name16", "GET_SIGNAL_NAMES", "name18"
507
%};
508
%
509
 
510
%/*HEADER_END*/
511
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.