This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfa] rda / samples: Allow multiple connections.


Allocate gdbserv_target only once, so that gdb can disconnect and reconnect.

2004-07-09  Michael Snyder  <msnyder@redhat.com>

	* samples/demo-target.c (demo_target): Call malloc only once,
	so that gdb can detach and re-attach repeatedly.

Index: demo-target.c
===================================================================
RCS file: /cvs/cvsfiles/devo/rda/samples/demo-target.c,v
retrieving revision 1.19
diff -p -r1.19 demo-target.c
*** demo-target.c	21 Aug 2002 22:43:14 -0000	1.19
--- demo-target.c	9 Jul 2004 19:54:04 -0000
*************** static struct gdbserv* sole_connection =
*** 136,142 ****
  struct gdbserv_target *
  demo_target (struct gdbserv *serv, void *context)
  {
!   struct gdbserv_target *target;
  
    if (sole_connection != NULL)
      {
--- 161,167 ----
  struct gdbserv_target *
  demo_target (struct gdbserv *serv, void *context)
  {
!   static struct gdbserv_target *target = NULL;
  
    if (sole_connection != NULL)
      {
*************** demo_target (struct gdbserv *serv, void 
*** 147,153 ****
    fprintf (stderr, "Accepted gdb connection.\n");
    sole_connection = serv;
  
!   target = malloc (sizeof (struct gdbserv_target));
    memset (target, sizeof (*target), 0);
  
    /* Callback structure for function pointers that handle processed
--- 172,179 ----
    fprintf (stderr, "Accepted gdb connection.\n");
    sole_connection = serv;
  
!   if (target == NULL)
!     target = malloc (sizeof (struct gdbserv_target));
    memset (target, sizeof (*target), 0);
  
    /* Callback structure for function pointers that handle processed

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]