source: rtems/c/src/librdbg/src/m68k/any/remdeb_svc.c @ cab2730

4.104.114.84.95
Last change on this file since cab2730 was cab2730, checked in by Joel Sherrill <joel.sherrill@…>, on 10/19/00 at 15:37:01

2000-10-19 Antti P Miettinen <anmietti@…>

  • src/m68k/any/remdeb.h, src/m68k/any/remdeb_xdr.c, src/m68k/any/remdeb_svc.c: New files missed in merger.
  • Property mode set to 100644
File size: 3.6 KB
Line 
1#include <rpc/types.h>
2#include <rpc/rpc.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <bsp.h>
7#include <rdbg/servrpc.h>
8#include <rdbg/remdeb.h>
9#define fprintf(a,b) printf(b)
10/*HEADER_START*/
11#define RTEMS_PORT 2071
12#define RTEMS_BACK_PORT 2073
13/*
14 * Sun request values for the remote ptrace system call
15 */
16
17  /*
18   * Memory data for read/write text or data. The size is in data. The target
19   * addr is in the addr field.
20   * Be careful before modifying because this value goes into internal
21   * pipes and is allocated on stack too. Pipes and/or the stack could
22   * become too small if this value gets incremented.
23   */
24#ifndef XRY_MAX_CMD_STR
25#endif  /* REMDEB_H */
26  /* now open_connex() routine which establishes a connection to server */
27#define DEBUGGER_IS_GDB 0x2    /* */
28  /* now close_connex() routine which detaches from server */
29  /* now send_signal() routine which sends signals to processes like kill(2) */
30  /* now wait_info() routine which returns results of polling the wait status
31        of a process/actor. It may return 0 if running, else pid or -1 */
32  /* now ptrace() routine. This matches the Sun UNIX ptrace as well as
33        some additions */
34  /* now define the actual calls we support */
35const char* names [] = {
36    "NULLPROC", "OPEN_CONNEX", "SEND_SIGNAL", "name3",
37    "name4", "name5", "name6", "name7",
38    "name8", "name9", "CLOSE_CONNEX", "PTRACE",
39    "name12", "WAIT_INFO", "name14", "name15",
40    "name16", "GET_SIGNAL_NAMES", "name18"
41};
42
43void
44remotedeb_2(struct svc_req *rqstp, register SVCXPRT *transp)
45{
46        union {
47                open_in open_connex_2_arg;
48                signal_in send_signal_2_arg;
49                close_in close_connex_2_arg;
50                ptrace_in ptrace_2_arg;
51                wait_in wait_info_2_arg;
52        } argument;
53        char *result;
54        xdrproc_t _xdr_argument, _xdr_result;
55        char *(*local)(char *, struct svc_req *);
56
57        DPRINTF (("remotedeb_2: %s (%d)\n",
58                (unsigned) rqstp->rq_proc <
59                (unsigned) (sizeof names / sizeof names[0]) ?
60                names [rqstp->rq_proc] : "???",
61                (int) rqstp->rq_proc));
62
63        switch (rqstp->rq_proc) {
64        case NULLPROC:
65                (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
66                return;
67
68        case OPEN_CONNEX:
69                _xdr_argument = (xdrproc_t) xdr_open_in;
70                _xdr_result = (xdrproc_t) xdr_open_out;
71                local = (char *(*)(char *, struct svc_req *)) open_connex_2_svc;
72                break;
73
74        case SEND_SIGNAL:
75                _xdr_argument = (xdrproc_t) xdr_signal_in;
76                _xdr_result = (xdrproc_t) xdr_signal_out;
77                local = (char *(*)(char *, struct svc_req *)) send_signal_2_svc;
78                break;
79
80        case CLOSE_CONNEX:
81                _xdr_argument = (xdrproc_t) xdr_close_in;
82                _xdr_result = (xdrproc_t) xdr_void;
83                local = (char *(*)(char *, struct svc_req *)) close_connex_2_svc;
84                break;
85
86        case PTRACE:
87                _xdr_argument = (xdrproc_t) xdr_ptrace_in;
88                _xdr_result = (xdrproc_t) xdr_ptrace_out;
89                local = (char *(*)(char *, struct svc_req *)) ptrace_2_svc;
90                break;
91
92        case WAIT_INFO:
93                _xdr_argument = (xdrproc_t) xdr_wait_in;
94                _xdr_result = (xdrproc_t) xdr_wait_out;
95                local = (char *(*)(char *, struct svc_req *)) wait_info_2_svc;
96                break;
97
98        case GET_SIGNAL_NAMES:
99                _xdr_argument = (xdrproc_t) xdr_void;
100                _xdr_result = (xdrproc_t) xdr_get_signal_names_out;
101                local = (char *(*)(char *, struct svc_req *)) get_signal_names_2_svc;
102                break;
103
104        default:
105                svcerr_noproc (transp);
106                return;
107        }
108        memset ((char *)&argument, 0, sizeof (argument));
109        if (!svc_getargs (transp, _xdr_argument, (caddr_t) &argument)) {
110                svcerr_decode (transp);
111                return;
112        }
113        result = (*local)((char *)&argument, rqstp);
114        if (result != NULL && !svc_sendreply(transp, _xdr_result, result)) {
115                svcerr_systemerr (transp);
116        }
117        if (!svc_freeargs (transp, _xdr_argument, (caddr_t) &argument)) {
118                fprintf (stderr, "unable to free arguments");
119                exit (1);
120        }
121        return;
122}
Note: See TracBrowser for help on using the repository browser.