source: rtems/c/src/librdbg/src/servutil.c @ 7a97f26

4.104.114.84.95
Last change on this file since 7a97f26 was 40cf43ea, checked in by Joel Sherrill <joel.sherrill@…>, on 02/01/02 at 17:00:01
  • So many patches have been posted recently on the mailing list and because we were unable to find correct solution to compile on various linux distros (due to rpcgen incompatibilities), and because the coding style of rdbg was rather inconsistant among various pieces of code, I decided to:

1) make some cleaning regarding global coding style (using

indent + manual edits),

2) incorporate/review the paches send by various people

(S. Holford, T. Strauman),

3) Fix the bug due to varying rpcgen code generation

in remdeb_svc.c,

4) Remove some dead code,
5) Apply a patches enabling to call enterRdbg imediately

after rdbg initialization is done,

NB : the paches is huge but it is mainly due to coding styke chnages.
Only few lines of codes have been really changed and they do not impact
rdbg functionnality (AFAIKT).

  • include/rdbg/servrpc.h, include/rdbg/i386/rdbg_f.h, include/rdbg/m68k/rdbg_f.h, include/rdbg/powerpc/rdbg_f.h, src/_servtgt.c, src/awk.svc, src/excep.c, src/ptrace.c, src/rdbg.c, src/remdeb.x, src/servbkpt.c, src/servcon.c, src/servrpc.c, src/servtgt.c, src/servtsp.c, src/servutil.c, src/i386/excep_f.c, src/i386/rdbg_f.c, src/i386/any/Makefile.am, src/i386/any/remdeb.h, src/i386/any/remdeb_svc.c, src/i386/any/remdeb_xdr.c, src/m68k/excep_f.c, src/m68k/rdbg_f.c, src/m68k/any/Makefile.am, src/m68k/any/remdeb.h, src/m68k/any/remdeb_svc.c, src/m68k/any/remdeb_xdr.c, src/powerpc/excep_f.c, src/powerpc/rdbg_f.c, src/powerpc/new_exception_processing/Makefile.am, src/powerpc/new_exception_processing/remdeb.h, src/powerpc/new_exception_processing/remdeb_svc.c, src/powerpc/new_exception_processing/remdeb_xdr.c: Modified.
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 **********************************************************************
3 *
4 *  Component:  RDB
5 *  Module:     servutil.c
6 *
7 *  Synopsis:   Various utility routines
8 *
9 * $Id$
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
29ListAlloc (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
63FindPidEntry (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
88const 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 *
118PtraceName (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
129const char *BmsgNames[] = {
130  "?", "WARM", "WAIT", "BREAK",
131  "EXEC_FAIL", "DETACH", "KILLED", "NOT_PRIM",
132  "NEW_PID"
133};
134
135#endif /* DDEBUG */
Note: See TracBrowser for help on using the repository browser.