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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [librdbg/] [src/] [i386/] [any/] [remdeb_svc.c] - Blame information for rev 1780

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

Line No. Rev Author Line
1 1026 ivang
#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 printf(c)
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
 /* now open_connex() routine which establishes a connection to server */
25
#define DEBUGGER_IS_GDB 0x2 /* */
26
 /* now close_connex() routine which detaches from server */
27
 /* now send_signal() routine which sends signals to processes like kill(2) */
28
 /* now wait_info() routine which returns results of polling the wait status
29
        of a process/actor. It may return 0 if running, else pid or -1 */
30
 /* now ptrace() routine. This matches the Sun UNIX ptrace as well as
31
        some additions */
32
 /* now define the actual calls we support */
33
const char* names [] = {
34
 "NULLPROC", "OPEN_CONNEX", "SEND_SIGNAL", "name3",
35
 "name4", "name5", "name6", "name7",
36
 "name8", "name9", "CLOSE_CONNEX", "PTRACE",
37
 "name12", "WAIT_INFO", "name14", "name15",
38
 "name16", "GET_SIGNAL_NAMES", "name18"
39
};
40
 
41
void
42
remotedeb_2(struct svc_req *rqstp, register SVCXPRT *transp)
43
{
44
        union {
45
                open_in open_connex_2_arg;
46
                signal_in send_signal_2_arg;
47
                close_in close_connex_2_arg;
48
                ptrace_in ptrace_2_arg;
49
                wait_in wait_info_2_arg;
50
        } argument;
51
        char *result;
52
        xdrproc_t _xdr_argument, _xdr_result;
53
        char *(*local)(char *, struct svc_req *);
54
 
55
        DPRINTF (("remotedeb_2: %s (%d)\n",
56
                (unsigned) rqstp->rq_proc <
57
                (unsigned) (sizeof names / sizeof names[0]) ?
58
                names [rqstp->rq_proc] : "???",
59
                (int) rqstp->rq_proc));
60
 
61
        switch (rqstp->rq_proc) {
62
        case NULLPROC:
63
                (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
64
                return;
65
 
66
        case OPEN_CONNEX:
67
                _xdr_argument = (xdrproc_t) xdr_open_in;
68
                _xdr_result = (xdrproc_t) xdr_open_out;
69
                local = (char *(*)(char *, struct svc_req *)) open_connex_2_svc;
70
                break;
71
 
72
        case SEND_SIGNAL:
73
                _xdr_argument = (xdrproc_t) xdr_signal_in;
74
                _xdr_result = (xdrproc_t) xdr_signal_out;
75
                local = (char *(*)(char *, struct svc_req *)) send_signal_2_svc;
76
                break;
77
 
78
        case CLOSE_CONNEX:
79
                _xdr_argument = (xdrproc_t) xdr_close_in;
80
                _xdr_result = (xdrproc_t) xdr_void;
81
                local = (char *(*)(char *, struct svc_req *)) close_connex_2_svc;
82
                break;
83
 
84
        case PTRACE:
85
                _xdr_argument = (xdrproc_t) xdr_ptrace_in;
86
                _xdr_result = (xdrproc_t) xdr_ptrace_out;
87
                local = (char *(*)(char *, struct svc_req *)) ptrace_2_svc;
88
                break;
89
 
90
        case WAIT_INFO:
91
                _xdr_argument = (xdrproc_t) xdr_wait_in;
92
                _xdr_result = (xdrproc_t) xdr_wait_out;
93
                local = (char *(*)(char *, struct svc_req *)) wait_info_2_svc;
94
                break;
95
 
96
        case GET_SIGNAL_NAMES:
97
                _xdr_argument = (xdrproc_t) xdr_void;
98
                _xdr_result = (xdrproc_t) xdr_get_signal_names_out;
99
                local = (char *(*)(char *, struct svc_req *)) get_signal_names_2_svc;
100
                break;
101
 
102
        default:
103
                svcerr_noproc (transp);
104
                return;
105
        }
106
        memset ((char *)&argument, 0, sizeof (argument));
107
        if (!svc_getargs (transp, _xdr_argument, (caddr_t) &argument)) {
108
                svcerr_decode (transp);
109
                return;
110
        }
111
        result = (*local)((char *)&argument, rqstp);
112
        if (result != NULL && !svc_sendreply(transp, _xdr_result, result)) {
113
                svcerr_systemerr (transp);
114
        }
115
        if (!svc_freeargs (transp, _xdr_argument, (caddr_t) &argument)) {
116
                printf( "unable to free arguments");
117
                exit (1);
118
        }
119
        return;
120
}

powered by: WebSVN 2.1.0

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