source: rtems/c/src/lib/librdbg/rdbg.c @ 196094eb

4.104.114.84.95
Last change on this file since 196094eb was 4721cf1, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 3, 1998 at 11:54:14 PM

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: 2.9 KB
Line 
1/*
2 **************************************************************************
3 *
4 * Component =   
5 *
6 * Synopsis  =   rkdb/rkdb.c
7 *
8 **************************************************************************
9 */
10
11#include <assert.h>
12#include <errno.h>
13#include <rtems.h>
14#include <rtems/error.h>
15#include <rdbg/rdbg.h>
16#include <rdbg/servrpc.h>
17
18u_short  rtemsPort = RTEMS_PORT;
19int      BackPort = RTEMS_BACK_PORT;
20int      rtemsActive = 0;
21SVCXPRT* rtemsXprt;
22int      rtemsSock;
23char     ActName[] = "RTEMS";
24volatile int            ExitForSingleStep = 0 ;
25volatile int            Continue;
26volatile int            justSaveContext;
27volatile Objects_Id     currentTargetThread;
28volatile int            CannotRestart = 0;
29volatile int            TotalReboot = 0;
30int CONN_LIST_INC = 3;
31int PID_LIST_INC  = 1;
32int TSP_RETRIES   = 10;
33
34
35    int
36getId()
37{
38  rtems_id id;
39 
40  rtems_task_ident(RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &id);
41    return (int)(id) ;
42}
43
44    static int
45rdbgInit (void)
46{
47    int sock;
48    struct sockaddr_in addr;
49
50    sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
51    if (sock == -1) {
52        printf("%s: rkdbInit: cannot allocate socket\n", ActName);
53        return -1;
54    }
55
56    bzero( (void *)&addr, sizeof(struct sockaddr_in));
57    addr.sin_port = htons(rtemsPort);
58    if ((bind(sock, (struct sockaddr*) &addr, sizeof(addr))) == -1) {
59        printf("%s: rkdbInit: cannot bind socket\n", ActName);
60        return -2;
61    }
62    rtemsXprt = svcudp_create(sock);
63    if (svcudp_enablecache(rtemsXprt, 1) == 0) {
64        printf("%s: rkdbInit: cannot enable rpc cache\n", ActName);
65        return -3;
66    }
67    rtemsSock = sock;
68    return 0;
69}
70
71    rtems_task
72rdbgDaemon (rtems_task_argument argument)
73{
74  for (;;){
75
76    if (TotalReboot == 1){
77      rtemsReboot();
78    }
79
80    svc_processrequest( rtemsXprt, REMOTEDEB, REMOTEVERS, remotedeb_2);
81  }
82}
83
84    void
85rtems_rdbg_initialize (void)
86{
87  rtems_name        task_name;
88  rtems_id          tid;
89  rtems_status_code status;
90
91#ifdef DDEBUG
92        rdb_debug = 1;           /* DPRINTF now will display */
93#endif
94
95    DPRINTF (("%s init starting\n", ActName));
96
97    /* Print version string */
98#ifdef DDEBUG
99    printk ("RDBG v.%d built on [%s %s]\n", SERVER_VERS, __DATE__, __TIME__);
100#else
101    printk ("RDBG v.%d\n", SERVER_VERS);
102#endif
103
104    /* Create socket and init UDP RPC server */
105    if (rdbgInit() != 0) goto error;
106
107    Continue = 1;
108    justSaveContext = 0;
109    currentTargetThread = 0;
110   
111    task_name = rtems_build_name( 'R', 'D', 'B', 'G' );
112    if ((status = rtems_task_create( task_name, 5, 24576,
113                                     RTEMS_INTERRUPT_LEVEL(0),
114                                     RTEMS_DEFAULT_ATTRIBUTES | RTEMS_SYSTEM_TASK
115                                     , &tid ))
116        != RTEMS_SUCCESSFUL){
117      printf("status = %d\n",status);
118      rtems_panic ("Can't create task.\n");
119    }
120
121    status = rtems_task_start(tid, rdbgDaemon, 0);
122
123    return;
124
125error:
126    printf ("initialization failed.\n");
127}
128
129    void
130setErrno (int error)
131{
132    errno = error;
133}
134
135    int
136getErrno()
137{
138    return errno;
139}
Note: See TracBrowser for help on using the repository browser.