source: rtems/c/src/lib/librdbg/servutil.c @ 0bf2ff8

4.104.114.84.95
Last change on this file since 0bf2ff8 was 4721cf1, checked in by Joel Sherrill <joel.sherrill@…>, on 12/03/98 at 23:54:14

Patch from Emmanuel Raguet <raguet@…> to add remote debug server
and RPC support to RTEMS. Thanks. :) Email follows:

Hello,

For Xmas, here is the Remote Debugger on RTEMS !

Here are 2 patches for the Remote Debugger on RTEMS for pc386 from Linux
host :

  • one for RTEMS it self,
  • one for GDB-4.17.

1/ RTEMS patch
--------------

This patch adds 2 libraries :

  • a simplified SUN RPC library
  • the Remote Debugger library

The configuration command is the following :
../rtems4/configure --target=i386-rtemself --enable-rtemsbsp=pc386
--enable-rdbg

The SUN RPC library is built only if networking is set.
The RDBG library is built if networking and enable-rdbg are set.

The function used to initialize the debugger is :

rtems_rdbg_initialize ();

A special function has been created to force a task to be
in a "debug" state : enterRdbg().
The use of this function is not mandatory.

2/ GDB-4.17 patch
-----------------

This patch create a new RTEMS target for GDB-4.17.

The configuration command is the following :
./configure --enable-shared --target=i386RTEMS

To connect to a target, use :

target rtems [your_site_address]

Then, attach the target using : attach 1

And... Debug ;)

You can obtain the original GDB-4.17 on
ftp://ftp.debian.org/debian/dists/stable/main/source/devel/gdb_4.17.orig.tar.gz

This has been tested from a Debian 2.0.1 linux host.

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