source: rtems/c/src/librdbg/src/rdbg.c @ 40cf43ea

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