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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [librdbg/] [src/] [servutil.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 **********************************************************************
3
 *
4
 *  Component:  RDB
5
 *  Module:     servutil.c
6
 *
7
 *  Synopsis:   Various utility routines
8
 *
9
 * servutil.c,v 1.3 2002/02/01 17:00:01 joel 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
    /*
42
     * need more space
43
     */
44
    name = (char *) Realloc (clst->list, len = new_len + MAX_FILENAME);
45
    if (name == NULL) {
46
      return (False);           /* failed, no space */
47
    }
48
    clst->list_alloc = len;
49
    clst->list = name;
50
  }
51
  strcpy (clst->list + clst->list_sz, buff);
52
  clst->list_sz += tmp;
53
  return (True);
54
}
55
 
56
/*----- Management of processes -----*/
57
 
58
    /*
59
     *  FindPidEntry - locate pid_list entry from pid
60
     */
61
 
62
  int
63
FindPidEntry (int pid) /* pid = process identifier */
64
{
65
  int idx;
66
 
67
  /*
68
   * pid 0 is invalid, and signals a free slot
69
   */
70
  if (pid_list == NULL || pid == 0) {
71
    return -1;
72
  }
73
  for (idx = 0; idx < pid_list_cnt; idx++) {
74
    if (pid_list[idx].pid == pid)
75
      return idx;
76
  }
77
  return -1;
78
}
79
 
80
/*----- Debug suport -----*/
81
 
82
#ifdef DDEBUG
83
 
84
    /*
85
     *  Names of debug primitives
86
     */
87
 
88
const char *PtraceNames[] = {
89
 
90
  "RPT_TRACEME", "RPT_PEEKTEXT", "RPT_PEEKDATA", "RPT_PEEKUSER",
91
  "RPT_POKETEXT", "RPT_POKEDATA", "RPT_POKEUSER", "RPT_CONT",
92
  "RPT_KILL", "RPT_SINGLESTEP", "RPT_ATTACH", "RPT_DETACH",
93
  "RPT_GETREGS", "RPT_SETREGS", "RPT_GETFPREGS", "RPT_SETFPREGS",
94
  "RPT_READDATA", "RPT_WRITEDATA", "RPT_READTEXT", "RPT_WRITETEXT",
95
  "RPT_GETFPAREGS", "RPT_SETFPAREGS", "RPT_22", "RPT_23",
96
  "RPT_SYSCALL", "RPT_DUMPCORE", "RPT_26", "RPT_27",
97
  "RPT_28", "RPT_GETUCODE", "RPT_30", "RPT_31",
98
  "RPT_32", "RPT_33", "RPT_34", "RPT_35",
99
  "RPT_36", "RPT_37", "RPT_38", "RPT_39",
100
  "RPT_40", "RPT_41", "RPT_42", "RPT_43",
101
  "RPT_44", "RPT_45", "RPT_46", "RPT_47",
102
  "RPT_48", "RPT_49", "RPT_GETTARGETTHREAD", "RPT_SETTARGETTHREAD",
103
  "RPT_THREADSUSPEND", "RPT_THREADRESUME", "RPT_THREADLIST",
104
    "RPT_GETTHREADNAME",
105
  "RPT_SETTHREADNAME", "RPT_SETTHREADREGS", "RPT_GETTHREADREGS",
106
  "RPT_59",
107
  "RPT_60", "RPT_61", "RPT_62", "RPT_63",
108
  "RPT_64", "RPT_65", "RPT_66", "RPT_67",
109
  "RPT_68", "RPT_69", "RPT_70", "RPT_71",
110
  "RPT_72", "RPT_73", "RPT_74", "RPT_STEPRANGE",
111
  "RPT_CONTTO", "RPT_SETBREAK", "RPT_CLRBREAK", "RPT_GETBREAK",
112
  "RPT_GETNAME", "RPT_STOP",
113
  "RPT_PGETREGS", "RPT_PSETREGS",
114
  "RPT_PSETTHREADREGS", "RPT_PGETTHREADREGS"
115
};
116
 
117
  const char *
118
PtraceName (int req)
119
{
120
  static char bufret[40];
121
 
122
  if ((req < 0) || (req >= sizeof (PtraceNames) / sizeof (char *))) {
123
    sprintf (bufret, "BAD_REQ_%d", req);
124
    return bufret;
125
  }
126
  return PtraceNames[req];
127
}
128
 
129
const char *BmsgNames[] = {
130
  "?", "WARM", "WAIT", "BREAK",
131
  "EXEC_FAIL", "DETACH", "KILLED", "NOT_PRIM",
132
  "NEW_PID"
133
};
134
 
135
#endif /* DDEBUG */

powered by: WebSVN 2.1.0

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