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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [librdbg/] [src/] [servutil.c] - Blame information for rev 385

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

Line No. Rev Author Line
1 30 unneback
/*
2
 **********************************************************************
3
 *
4
 *  Component:  RDB
5
 *  Module:     servutil.c
6
 *
7
 *  Synopsis:   Various utility routines
8
 *
9
 * $Id: servutil.c,v 1.2 2001-09-27 12:02:01 chris Exp $
10
 *
11
 **********************************************************************
12
 */
13
 
14
#include <string.h>
15
#include <rdbg/rdbg.h>
16
#include <rdbg/servrpc.h>
17
 
18
/*----- Management of per-process list ----*/
19
 
20
    /*
21
     *  ListAlloc - build up list entry.
22
     *
23
     *  Notes:
24
     *  - this is a generic routine to build up entries in the per-connection
25
     *    list. The fields list, list_sz and list_alloc are affected.
26
     */
27
 
28
    Boolean
29
ListAlloc(buff, clst)
30
     char *buff;
31
     CONN_LIST *clst;           /* place to copy it */
32
{
33
    int         tmp;
34
    char*       name;
35
    int         new_len;
36
    int         len;
37
 
38
    tmp = strlen(buff);
39
    new_len = (int)clst->list_sz + 1 + tmp;
40
    if (clst->list_alloc < (unsigned)new_len) {
41
            /* need more space */
42
        name = (char *)Realloc(clst->list, len = new_len + MAX_FILENAME);
43
        if (name == NULL) {
44
            return(False);              /* failed, no space */
45
        }
46
        clst->list_alloc = len;
47
        clst->list = name;
48
    }
49
    strcpy(clst->list + clst->list_sz, buff);
50
    clst->list_sz += tmp;
51
    return(True);
52
}
53
 
54
/*----- Management of processes -----*/
55
 
56
    /*
57
     *  FindPidEntry - locate pid_list entry from pid
58
     */
59
 
60
    int
61
FindPidEntry (pid)
62
    int pid;                    /* process identifier */
63
{
64
    int idx;
65
 
66
        /* pid 0 is invalid, and signals a free slot */
67
    if (pid_list == NULL  ||  pid == 0) {
68
        return -1;
69
    }
70
    for (idx = 0; idx < pid_list_cnt; idx++) {
71
        if (pid_list [idx].pid == pid )
72
            return idx;
73
    }
74
    return -1;
75
}
76
 
77
/*----- Debug suport -----*/
78
 
79
#ifdef DDEBUG
80
 
81
    /*
82
     *  Names of debug primitives
83
     */
84
 
85
const char* PtraceNames [] = {
86
 
87
"RPT_TRACEME", "RPT_PEEKTEXT", "RPT_PEEKDATA", "RPT_PEEKUSER",
88
"RPT_POKETEXT", "RPT_POKEDATA", "RPT_POKEUSER", "RPT_CONT",
89
"RPT_KILL", "RPT_SINGLESTEP", "RPT_ATTACH", "RPT_DETACH",
90
"RPT_GETREGS", "RPT_SETREGS", "RPT_GETFPREGS", "RPT_SETFPREGS",
91
"RPT_READDATA", "RPT_WRITEDATA", "RPT_READTEXT", "RPT_WRITETEXT",
92
"RPT_GETFPAREGS", "RPT_SETFPAREGS", "RPT_22", "RPT_23",
93
"RPT_SYSCALL", "RPT_DUMPCORE", "RPT_26", "RPT_27",
94
"RPT_28", "RPT_GETUCODE", "RPT_30", "RPT_31",
95
"RPT_32", "RPT_33", "RPT_34", "RPT_35",
96
"RPT_36", "RPT_37", "RPT_38", "RPT_39",
97
"RPT_40", "RPT_41", "RPT_42", "RPT_43",
98
"RPT_44", "RPT_45", "RPT_46", "RPT_47",
99
"RPT_48", "RPT_49", "RPT_GETTARGETTHREAD", "RPT_SETTARGETTHREAD",
100
"RPT_THREADSUSPEND", "RPT_THREADRESUME", "RPT_THREADLIST", "RPT_GETTHREADNAME",
101
"RPT_SETTHREADNAME", "RPT_SETTHREADREGS", "RPT_GETTHREADREGS",
102
        "RPT_59",
103
"RPT_60", "RPT_61", "RPT_62", "RPT_63",
104
"RPT_64", "RPT_65", "RPT_66", "RPT_67",
105
"RPT_68", "RPT_69", "RPT_70", "RPT_71",
106
"RPT_72", "RPT_73", "RPT_74", "RPT_STEPRANGE",
107
"RPT_CONTTO", "RPT_SETBREAK", "RPT_CLRBREAK", "RPT_GETBREAK",
108
"RPT_GETNAME", "RPT_STOP",
109
"RPT_PGETREGS", "RPT_PSETREGS",
110
"RPT_PSETTHREADREGS", "RPT_PGETTHREADREGS"
111
};
112
 
113
const char*
114
PtraceName(req)
115
    int req;
116
{
117
    static char bufret[40];
118
 
119
    if ((req < 0) || (req >= sizeof(PtraceNames)/sizeof(char*))) {
120
        sprintf(bufret, "BAD_REQ_%d", req);
121
        return bufret;
122
    }
123
    return PtraceNames[req];
124
}
125
 
126
const char* BmsgNames [] = {
127
    "?",         "WARM",   "WAIT",   "BREAK",
128
    "EXEC_FAIL", "DETACH", "KILLED", "NOT_PRIM",
129
    "NEW_PID"
130
};
131
 
132
#endif /* DDEBUG */

powered by: WebSVN 2.1.0

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