This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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]

[ob/commit] wince.c whitespace tweaks


2005-01-13  Michael Snyder  <msnyder@redhat.com>

	* wince.c: Whitespace tweaks.

Index: wince.c
===================================================================
RCS file: /cvs/src/src/gdb/wince.c,v
retrieving revision 1.37
diff -p -r1.37 wince.c
*** wince.c	12 Jan 2005 18:31:34 -0000	1.37
--- wince.c	14 Jan 2005 04:31:50 -0000
***************
*** 27,37 ****
  
  #ifdef SHx
  #undef SH4
! #define SH4			/* Just to get all of the CONTEXT defines. */
  #endif
  
  #include "defs.h"
! #include "frame.h"		/* required by inferior.h */
  #include "inferior.h"
  #include "target.h"
  #include "exceptions.h"
--- 27,37 ----
  
  #ifdef SHx
  #undef SH4
! #define SH4		/* Just to get all of the CONTEXT defines.  */
  #endif
  
  #include "defs.h"
! #include "frame.h"	/* required by inferior.h */
  #include "inferior.h"
  #include "target.h"
  #include "exceptions.h"
***************
*** 64,70 ****
  
  /* If we're not using the old Cygwin header file set, define the
     following which never should have been in the generic Win32 API
!    headers in the first place since they were our own invention... */
  #ifndef _GNU_H_WINDOWS_H
  #define FLAG_TRACE_BIT 0x100
  #ifdef CONTEXT_FLOATING_POINT
--- 64,70 ----
  
  /* If we're not using the old Cygwin header file set, define the
     following which never should have been in the generic Win32 API
!    headers in the first place since they were our own invention...  */
  #ifndef _GNU_H_WINDOWS_H
  #define FLAG_TRACE_BIT 0x100
  #ifdef CONTEXT_FLOATING_POINT
***************
*** 80,86 ****
  #define CONTEXT_DEBUGGER CONTEXT_DEBUGGER0
  #endif
  /* The string sent by cygwin when it processes a signal.
!    FIXME: This should be in a cygwin include file. */
  #define CYGWIN_SIGNAL_STRING "cygwin: signal"
  
  #define CHECK(x)	check (x, __FILE__,__LINE__)
--- 80,86 ----
  #define CONTEXT_DEBUGGER CONTEXT_DEBUGGER0
  #endif
  /* The string sent by cygwin when it processes a signal.
!    FIXME: This should be in a cygwin include file.  */
  #define CYGWIN_SIGNAL_STRING "cygwin: signal"
  
  #define CHECK(x)	check (x, __FILE__,__LINE__)
***************
*** 89,100 ****
  #define DEBUG_MEM(x)	if (debug_memory)	printf x
  #define DEBUG_EXCEPT(x)	if (debug_exceptions)	printf x
  
! static int connection_initialized = 0;	/* True if we've initialized a RAPI session. */
  
! /* The directory where the stub and executable files are uploaded. */
  static const char *remote_directory = "\\gdb";
  
! /* The types automatic upload available. */
  static enum
    {
      UPLOAD_ALWAYS = 0,
--- 89,101 ----
  #define DEBUG_MEM(x)	if (debug_memory)	printf x
  #define DEBUG_EXCEPT(x)	if (debug_exceptions)	printf x
  
! static int connection_initialized = 0;	/* True if we've initialized a
! 					   RAPI session.  */
  
! /* The directory where the stub and executable files are uploaded.  */
  static const char *remote_directory = "\\gdb";
  
! /* The types automatic upload available.  */
  static enum
    {
      UPLOAD_ALWAYS = 0,
*************** static enum
*** 104,110 ****
  upload_when = UPLOAD_NEWER;
  
  /* Valid options for 'set remoteupload'.  Note that options
!    must track upload_when enum. */
  static struct opts
    {
      const char *name;
--- 105,111 ----
  upload_when = UPLOAD_NEWER;
  
  /* Valid options for 'set remoteupload'.  Note that options
!    must track upload_when enum.  */
  static struct opts
    {
      const char *name;
*************** upload_options[3] =
*** 125,141 ****
    }
  };
  
! static char *remote_upload = NULL;	/* Set by set remoteupload */
  static int remote_add_host = 0;
  
  static int win32_child_thread_alive (ptid_t);
  void child_kill_inferior (void);
  
! static int last_sig = 0;	/* Set if a signal was received from the
! 				   debugged process */
  
  /* Thread information structure used to track information that is
!    not available in gdb's thread structure. */
  typedef struct thread_info_struct
    {
      struct thread_info_struct *next;
--- 126,142 ----
    }
  };
  
! static char *remote_upload = NULL;	/* Set by set remoteupload.  */
  static int remote_add_host = 0;
  
  static int win32_child_thread_alive (ptid_t);
  void child_kill_inferior (void);
  
! static int last_sig = 0;	/* Set if a signal was received from
! 				   the debugged process.  */
  
  /* Thread information structure used to track information that is
!    not available in gdb's thread structure.  */
  typedef struct thread_info_struct
    {
      struct thread_info_struct *next;
*************** typedef struct thread_info_struct
*** 143,149 ****
      HANDLE h;
      char *name;
      int suspend_count;
!     int stepped;		/* True if stepped. */
      CORE_ADDR step_pc;
      unsigned long step_prev;
      CONTEXT context;
--- 144,150 ----
      HANDLE h;
      char *name;
      int suspend_count;
!     int stepped;		/* True if stepped.  */
      CORE_ADDR step_pc;
      unsigned long step_prev;
      CONTEXT context;
*************** static thread_info thread_head =
*** 154,176 ****
  {NULL};
  static thread_info * thread_rec (DWORD id, int get_context);
  
! /* The process and thread handles for the above context. */
  
  static DEBUG_EVENT current_event;	/* The current debug event from
! 					   WaitForDebugEvent */
! static HANDLE current_process_handle;	/* Currently executing process */
! static thread_info *current_thread;	/* Info on currently selected thread */
! static thread_info *this_thread;	/* Info on thread returned by wait_for_debug_event */
! static DWORD main_thread_id;	/* Thread ID of the main thread */
  
! /* Counts of things. */
  static int exception_count = 0;
  static int event_count = 0;
  
! /* User options. */
! static int debug_exec = 0;	/* show execution */
! static int debug_events = 0;	/* show events from kernel */
! static int debug_memory = 0;	/* show target memory accesses */
  static int debug_exceptions = 0;	/* show target exceptions */
  
  /* An array of offset mappings into a Win32 Context structure.
--- 155,179 ----
  {NULL};
  static thread_info * thread_rec (DWORD id, int get_context);
  
! /* The process and thread handles for the above context.  */
  
  static DEBUG_EVENT current_event;	/* The current debug event from
! 					   WaitForDebugEvent.  */
! static HANDLE current_process_handle;	/* Currently executing process.  */
! static thread_info *current_thread;	/* Info on currently selected
! 					   thread.  */
! static thread_info *this_thread;	/* Info on thread returned by
! 					   wait_for_debug_event.  */
! static DWORD main_thread_id;		/* Thread ID of the main thread.  */
  
! /* Counts of things.  */
  static int exception_count = 0;
  static int event_count = 0;
  
! /* User options.  */
! static int debug_exec = 0;		/* show execution */
! static int debug_events = 0;		/* show events from kernel */
! static int debug_memory = 0;		/* show target memory accesses */
  static int debug_exceptions = 0;	/* show target exceptions */
  
  /* An array of offset mappings into a Win32 Context structure.
*************** static int debug_exceptions = 0;	/* show
*** 181,187 ****
     register in it's CONTEXT structure.  regptr will return zero for this
     register.
  
!    This is used by the regptr function. */
  #define context_offset(x) ((int)&(((PCONTEXT)NULL)->x))
  static const int mappings[NUM_REGS + 1] =
  {
--- 184,190 ----
     register in it's CONTEXT structure.  regptr will return zero for this
     register.
  
!    This is used by the regptr function.  */
  #define context_offset(x) ((int)&(((PCONTEXT)NULL)->x))
  static const int mappings[NUM_REGS + 1] =
  {
*************** regptr (LPCONTEXT c, int r)
*** 405,417 ****
     byte 1-2:    length
     byte 3-n:    arbitrary memory.
  
!    The interface is deterministic, i.e., if the stub expects a DWORD then
!    the gdb server should send a DWORD.
   */
  
! /* Note:  In the functions below, the `huh' parameter is a string passed from the
!    function containing a descriptive string concerning the current operation.
!    This is used for error reporting.
  
     The 'what' parameter is a command id as found in wince-stub.h.
  
--- 408,420 ----
     byte 1-2:    length
     byte 3-n:    arbitrary memory.
  
!    The interface is deterministic, i.e., if the stub expects a DWORD
!    then the gdb server should send a DWORD.
   */
  
! /* Note: In the functions below, the `huh' parameter is a string
!    passed from the function containing a descriptive string concerning
!    the current operation.  This is used for error reporting.
  
     The 'what' parameter is a command id as found in wince-stub.h.
  
*************** static int s;			/* communication socket 
*** 422,428 ****
  
  /* v-style interface for handling varying argyment list error messages.
     Displays the error message in a dialog box and exits when user clicks
!    on OK. */
  static void
  vstub_error (LPCSTR fmt, va_list * args)
  {
--- 425,431 ----
  
  /* v-style interface for handling varying argyment list error messages.
     Displays the error message in a dialog box and exits when user clicks
!    on OK.  */
  static void
  vstub_error (LPCSTR fmt, va_list * args)
  {
*************** vstub_error (LPCSTR fmt, va_list * args)
*** 432,438 ****
    error ("%s", buf);
  }
  
! /* The standard way to display an error message and exit. */
  static void
  stub_error (LPCSTR fmt,...)
  {
--- 435,441 ----
    error ("%s", buf);
  }
  
! /* The standard way to display an error message and exit.  */
  static void
  stub_error (LPCSTR fmt,...)
  {
*************** stub_error (LPCSTR fmt,...)
*** 441,455 ****
    vstub_error (fmt, args);
  }
  
! /* Standard "oh well" can't communicate error.  Someday this might attempt
!    synchronization. */
  static void
  attempt_resync (LPCSTR huh, int s)
  {
    stub_error ("lost synchronization with target attempting %s", huh);
  }
  
! /* Read arbitrary stuff from a socket. */
  static int
  sockread (LPCSTR huh, int s, void *str, size_t n)
  {
--- 444,458 ----
    vstub_error (fmt, args);
  }
  
! /* Standard "oh well" can't communicate error.  Someday this might
!    attempt synchronization.  */
  static void
  attempt_resync (LPCSTR huh, int s)
  {
    stub_error ("lost synchronization with target attempting %s", huh);
  }
  
! /* Read arbitrary stuff from a socket.  */
  static int
  sockread (LPCSTR huh, int s, void *str, size_t n)
  {
*************** sockread (LPCSTR huh, int s, void *str, 
*** 461,467 ****
      }
  }
  
! /* Write arbitrary stuff to a socket. */
  static int
  sockwrite (LPCSTR huh, const void *str, size_t n)
  {
--- 464,470 ----
      }
  }
  
! /* Write arbitrary stuff to a socket.  */
  static int
  sockwrite (LPCSTR huh, const void *str, size_t n)
  {
*************** sockwrite (LPCSTR huh, const void *str, 
*** 473,479 ****
      }
  }
  
! /* Output an id/dword to the host */
  static void
  putdword (LPCSTR huh, gdb_wince_id what, DWORD n)
  {
--- 476,482 ----
      }
  }
  
! /* Output an id/dword to the host.  */
  static void
  putdword (LPCSTR huh, gdb_wince_id what, DWORD n)
  {
*************** putdword (LPCSTR huh, gdb_wince_id what,
*** 483,489 ****
      stub_error ("error writing %s to host.", huh);
  }
  
! /* Output an id/word to the host */
  static void
  putword (LPCSTR huh, gdb_wince_id what, WORD n)
  {
--- 486,492 ----
      stub_error ("error writing %s to host.", huh);
  }
  
! /* Output an id/word to the host.  */
  static void
  putword (LPCSTR huh, gdb_wince_id what, WORD n)
  {
*************** putword (LPCSTR huh, gdb_wince_id what, 
*** 493,515 ****
      stub_error ("error writing %s host.", huh);
  }
  
! /* Convenience define for outputting a "gdb_wince_len" type. */
  #define putlen(huh, what, n) putword((huh), (what), (gdb_wince_len) (n))
  
  /* Put an arbitrary block of memory to the gdb host.  This comes in
!    two chunks an id/dword representing the length and the stream of memory
!    itself. */
  static void
! putmemory (LPCSTR huh, gdb_wince_id what, const void *mem, gdb_wince_len len)
  {
    putlen (huh, what, len);
    if (((short) len > 0) && sockwrite (huh, mem, len) != len)
      stub_error ("error writing %s to host.", huh);
  }
  
! /* Output the result of an operation to the host.  If res != 0, sends a block of
!    memory starting at mem of len bytes.  If res == 0, sends -GetLastError () and
!    avoids sending the mem. */
  static DWORD
  getdword (LPCSTR huh, gdb_wince_id what_this)
  {
--- 496,519 ----
      stub_error ("error writing %s host.", huh);
  }
  
! /* Convenience define for outputting a "gdb_wince_len" type.  */
  #define putlen(huh, what, n) putword((huh), (what), (gdb_wince_len) (n))
  
  /* Put an arbitrary block of memory to the gdb host.  This comes in
!    two chunks an id/dword representing the length and the stream of
!    memory itself.  */
  static void
! putmemory (LPCSTR huh, gdb_wince_id what, 
! 	   const void *mem, gdb_wince_len len)
  {
    putlen (huh, what, len);
    if (((short) len > 0) && sockwrite (huh, mem, len) != len)
      stub_error ("error writing %s to host.", huh);
  }
  
! /* Output the result of an operation to the host.  If res != 0, sends
!    a block of memory starting at mem of len bytes.  If res == 0, sends
!    -GetLastError () and avoids sending the mem.  */
  static DWORD
  getdword (LPCSTR huh, gdb_wince_id what_this)
  {
*************** getdword (LPCSTR huh, gdb_wince_id what_
*** 528,534 ****
  
  /* Get a an ID (possibly) and a WORD from the host gdb.
     Don't bother with the id if the main loop has already
!    read it. */
  static WORD
  getword (LPCSTR huh, gdb_wince_id what_this)
  {
--- 532,538 ----
  
  /* Get a an ID (possibly) and a WORD from the host gdb.
     Don't bother with the id if the main loop has already
!    read it.  */
  static WORD
  getword (LPCSTR huh, gdb_wince_id what_this)
  {
*************** getword (LPCSTR huh, gdb_wince_id what_t
*** 545,563 ****
    return n;
  }
  
! /* Handy defines for getting/putting various types of values. */
  #define gethandle(huh, what) (HANDLE) getdword ((huh), (what))
  #define getpvoid(huh, what) (LPVOID) getdword ((huh), (what))
  #define getlen(huh, what) (gdb_wince_len) getword ((huh), (what))
  #define puthandle(huh, what, h) putdword ((huh), (what), (DWORD) (h))
  #define putpvoid(huh, what, p) putdword ((huh), (what), (DWORD) (p))
  
! /* Retrieve the result of an operation from the stub.  If nbytes < 0) then nbytes
!    is actually an error and nothing else follows.  Use SetLastError to remember this.
!    if nbytes > 0, retrieve a block of *nbytes into buf.
   */
  int
! getresult (LPCSTR huh, gdb_wince_id what, LPVOID buf, gdb_wince_len * nbytes)
  {
    gdb_wince_len dummy;
    if (nbytes == NULL)
--- 549,569 ----
    return n;
  }
  
! /* Handy defines for getting/putting various types of values.  */
  #define gethandle(huh, what) (HANDLE) getdword ((huh), (what))
  #define getpvoid(huh, what) (LPVOID) getdword ((huh), (what))
  #define getlen(huh, what) (gdb_wince_len) getword ((huh), (what))
  #define puthandle(huh, what, h) putdword ((huh), (what), (DWORD) (h))
  #define putpvoid(huh, what, p) putdword ((huh), (what), (DWORD) (p))
  
! /* Retrieve the result of an operation from the stub.  If nbytes < 0)
!    then nbytes is actually an error and nothing else follows.  Use
!    SetLastError to remember this.  if nbytes > 0, retrieve a block of
!    *nbytes into buf.
   */
  int
! getresult (LPCSTR huh, gdb_wince_id what, LPVOID buf, 
! 	   gdb_wince_len * nbytes)
  {
    gdb_wince_len dummy;
    if (nbytes == NULL)
*************** towide (const char *s, gdb_wince_len * o
*** 586,608 ****
  {
    static int n = -1;
    static LPWSTR outs[8] =
!   {NULL /*, NULL, etc. */ };
    gdb_wince_len dummy;
  
    if (!out_len)
      out_len = &dummy;
  
!   /* First determine the length required to hold the converted string. */
!   *out_len = sizeof (WCHAR) * MultiByteToWideChar (CP_ACP, 0, s, -1, NULL, 0);
    if (!*out_len)
!     return NULL;		/* The conversion failed */
  
    if (++n >= (sizeof (outs) / sizeof (outs[0])))
      n = 0;			/* wrap */
  
!   /* Allocate space for the converted string, reusing any previously allocated
!      space, if applicable. Note that if outs[n] is NULL, xrealloc will act as
!      a malloc (under cygwin, at least).
     */
    outs[n] = (LPWSTR) xrealloc (outs[n], *out_len);
    memset (outs[n], 0, *out_len);
--- 592,615 ----
  {
    static int n = -1;
    static LPWSTR outs[8] =
!   {NULL /*, NULL, etc.  */ };
    gdb_wince_len dummy;
  
    if (!out_len)
      out_len = &dummy;
  
!   /* First determine the length required to hold the converted string.  */
!   *out_len = sizeof (WCHAR) * MultiByteToWideChar (CP_ACP, 0, s, 
! 						   -1, NULL, 0);
    if (!*out_len)
!     return NULL;		/* The conversion failed.  */
  
    if (++n >= (sizeof (outs) / sizeof (outs[0])))
      n = 0;			/* wrap */
  
!   /* Allocate space for the converted string, reusing any previously
!      allocated space, if applicable. Note that if outs[n] is NULL,
!      xrealloc will act as a malloc (under cygwin, at least).
     */
    outs[n] = (LPWSTR) xrealloc (outs[n], *out_len);
    memset (outs[n], 0, *out_len);
*************** towide (const char *s, gdb_wince_len * o
*** 612,632 ****
  
  /******************** Emulation routines start here. ********************
  
!   The functions below are modelled after their Win32 counterparts.  They are named
!   similarly to Win32 and take exactly the same arguments except where otherwise noted.
!   They communicate with the stub on the hand-held device by sending their arguments
!   over the socket and waiting for results from the socket.
! 
!   There is one universal change.  In cases where a length is expected to be returned
!   in a DWORD, we use a gdb_wince_len type instead.  Currently this is an unsigned short
!   which is smaller than the standard Win32 DWORD.  This is done to minimize unnecessary
!   traffic since the connection to Windows CE can be slow.  To change this, modify the
!   typedef in wince-stub.h and change the putlen/getlen macros in this file and in
!   the stub.
  */
  
  static int
! create_process (LPSTR exec_file, LPSTR args, DWORD flags, PROCESS_INFORMATION * pi)
  {
    gdb_wince_len len;
    LPWSTR buf;
--- 619,642 ----
  
  /******************** Emulation routines start here. ********************
  
!   The functions below are modelled after their Win32 counterparts.
!   They are named similarly to Win32 and take exactly the same
!   arguments except where otherwise noted.  They communicate with the
!   stub on the hand-held device by sending their arguments over the
!   socket and waiting for results from the socket.
! 
!   There is one universal change.  In cases where a length is expected
!   to be returned in a DWORD, we use a gdb_wince_len type instead.
!   Currently this is an unsigned short which is smaller than the
!   standard Win32 DWORD.  This is done to minimize unnecessary traffic
!   since the connection to Windows CE can be slow.  To change this,
!   modify the typedef in wince-stub.h and change the putlen/getlen
!   macros in this file and in the stub.
  */
  
  static int
! create_process (LPSTR exec_file, LPSTR args, DWORD flags, 
! 		PROCESS_INFORMATION * pi)
  {
    gdb_wince_len len;
    LPWSTR buf;
*************** create_process (LPSTR exec_file, LPSTR a
*** 639,646 ****
    return getresult ("CreateProcess result", GDB_CREATEPROCESS, pi, NULL);
  }
  
! /* Emulate TerminateProcess.  Don't bother with the second argument since CE
!    ignores it.
   */
  static int
  terminate_process (HANDLE h)
--- 649,656 ----
    return getresult ("CreateProcess result", GDB_CREATEPROCESS, pi, NULL);
  }
  
! /* Emulate TerminateProcess.  
!    Don't bother with the second argument since CE ignores it.
   */
  static int
  terminate_process (HANDLE h)
*************** terminate_process (HANDLE h)
*** 649,655 ****
    if (s < 0)
      return 1;
    puthandle ("TerminateProcess handle", GDB_TERMINATEPROCESS, h);
!   return getresult ("TerminateProcess result", GDB_TERMINATEPROCESS, &res, NULL);
  }
  
  static int
--- 659,667 ----
    if (s < 0)
      return 1;
    puthandle ("TerminateProcess handle", GDB_TERMINATEPROCESS, h);
! 
!   return getresult ("TerminateProcess result", 
! 		    GDB_TERMINATEPROCESS, &res, NULL);
  }
  
  static int
*************** wait_for_debug_event (DEBUG_EVENT * ev, 
*** 658,664 ****
    if (s < 0)
      return 1;
    putdword ("WaitForDebugEvent ms", GDB_WAITFORDEBUGEVENT, ms);
!   return getresult ("WaitForDebugEvent event", GDB_WAITFORDEBUGEVENT, ev, NULL);
  }
  
  static int
--- 670,678 ----
    if (s < 0)
      return 1;
    putdword ("WaitForDebugEvent ms", GDB_WAITFORDEBUGEVENT, ms);
! 
!   return getresult ("WaitForDebugEvent event", 
! 		    GDB_WAITFORDEBUGEVENT, ev, NULL);
  }
  
  static int
*************** get_thread_context (HANDLE h, CONTEXT * 
*** 667,674 ****
    if (s < 0)
      return 1;
    puthandle ("GetThreadContext handle", GDB_GETTHREADCONTEXT, h);
!   putdword ("GetThreadContext flags", GDB_GETTHREADCONTEXT, c->ContextFlags);
!   return getresult ("GetThreadContext context", GDB_GETTHREADCONTEXT, c, NULL);
  }
  
  static int
--- 681,691 ----
    if (s < 0)
      return 1;
    puthandle ("GetThreadContext handle", GDB_GETTHREADCONTEXT, h);
!   putdword ("GetThreadContext flags", GDB_GETTHREADCONTEXT, 
! 	    c->ContextFlags);
! 
!   return getresult ("GetThreadContext context", 
! 		    GDB_GETTHREADCONTEXT, c, NULL);
  }
  
  static int
*************** set_thread_context (HANDLE h, CONTEXT * 
*** 678,689 ****
    if (s < 0)
      return 1;
    puthandle ("SetThreadContext handle", GDB_SETTHREADCONTEXT, h);
!   putmemory ("SetThreadContext context", GDB_SETTHREADCONTEXT, c, sizeof (*c));
!   return getresult ("SetThreadContext context", GDB_SETTHREADCONTEXT, &res, NULL);
  }
  
  static int
! read_process_memory (HANDLE h, LPCVOID where, LPVOID buf, gdb_wince_len len, gdb_wince_len * nbytes)
  {
    if (s < 0)
      return 1;
--- 695,711 ----
    if (s < 0)
      return 1;
    puthandle ("SetThreadContext handle", GDB_SETTHREADCONTEXT, h);
!   putmemory ("SetThreadContext context", GDB_SETTHREADCONTEXT, 
! 	     c, sizeof (*c));
! 
!   return getresult ("SetThreadContext context", 
! 		    GDB_SETTHREADCONTEXT, &res, NULL);
  }
  
  static int
! read_process_memory (HANDLE h, LPCVOID where, 
! 		     LPVOID buf, gdb_wince_len len, 
! 		     gdb_wince_len * nbytes)
  {
    if (s < 0)
      return 1;
*************** read_process_memory (HANDLE h, LPCVOID w
*** 691,701 ****
    putpvoid ("ReadProcessMemory location", GDB_READPROCESSMEMORY, where);
    putlen ("ReadProcessMemory size", GDB_READPROCESSMEMORY, len);
  
!   return getresult ("ReadProcessMemory buf", GDB_READPROCESSMEMORY, buf, nbytes);
  }
  
  static int
! write_process_memory (HANDLE h, LPCVOID where, LPCVOID buf, gdb_wince_len len, gdb_wince_len * nbytes)
  {
    if (s < 0)
      return 1;
--- 713,726 ----
    putpvoid ("ReadProcessMemory location", GDB_READPROCESSMEMORY, where);
    putlen ("ReadProcessMemory size", GDB_READPROCESSMEMORY, len);
  
!   return getresult ("ReadProcessMemory buf", 
! 		    GDB_READPROCESSMEMORY, buf, nbytes);
  }
  
  static int
! write_process_memory (HANDLE h, LPCVOID where, 
! 		      LPCVOID buf, gdb_wince_len len, 
! 		      gdb_wince_len * nbytes)
  {
    if (s < 0)
      return 1;
*************** write_process_memory (HANDLE h, LPCVOID 
*** 703,717 ****
    putpvoid ("WriteProcessMemory location", GDB_WRITEPROCESSMEMORY, where);
    putmemory ("WriteProcProcessMemory buf", GDB_WRITEPROCESSMEMORY, buf, len);
  
!   return getresult ("WriteProcessMemory result", GDB_WRITEPROCESSMEMORY, nbytes, NULL);
  }
  
  static int
  remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
  {
    gdb_wince_len nbytes;
!   if (!read_process_memory (current_process_handle, (LPCVOID) memaddr,
! 			    (LPVOID) myaddr, len, &nbytes))
      return -1;
    return nbytes;
  }
--- 728,745 ----
    putpvoid ("WriteProcessMemory location", GDB_WRITEPROCESSMEMORY, where);
    putmemory ("WriteProcProcessMemory buf", GDB_WRITEPROCESSMEMORY, buf, len);
  
!   return getresult ("WriteProcessMemory result", 
! 		    GDB_WRITEPROCESSMEMORY, nbytes, NULL);
  }
  
  static int
  remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
  {
    gdb_wince_len nbytes;
!   if (!read_process_memory (current_process_handle, 
! 			    (LPCVOID) memaddr,
! 			    (LPVOID) myaddr, 
! 			    len, &nbytes))
      return -1;
    return nbytes;
  }
*************** static int
*** 720,733 ****
  remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
  {
    gdb_wince_len nbytes;
!   if (!write_process_memory (current_process_handle, (LPCVOID) memaddr,
! 			     (LPCVOID) myaddr, len, &nbytes))
      return -1;
    return nbytes;
  }
  
! /* This is not a standard Win32 function.  It instructs the stub to return TRUE
!    if the thread referenced by HANDLE h is alive.
   */
  static int
  thread_alive (HANDLE h)
--- 748,763 ----
  remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
  {
    gdb_wince_len nbytes;
!   if (!write_process_memory (current_process_handle, 
! 			     (LPCVOID) memaddr, 
! 			     (LPCVOID) myaddr, 
! 			     len, &nbytes))
      return -1;
    return nbytes;
  }
  
! /* This is not a standard Win32 function.  It instructs the stub to
!    return TRUE if the thread referenced by HANDLE h is alive.
   */
  static int
  thread_alive (HANDLE h)
*************** continue_debug_event (DWORD pid, DWORD t
*** 766,772 ****
    putdword ("ContinueDebugEvent pid", GDB_CONTINUEDEBUGEVENT, pid);
    putdword ("ContinueDebugEvent tid", GDB_CONTINUEDEBUGEVENT, tid);
    putdword ("ContinueDebugEvent status", GDB_CONTINUEDEBUGEVENT, status);
!   return getresult ("ContinueDebugEvent result", GDB_CONTINUEDEBUGEVENT, &res, NULL);
  }
  
  static int
--- 796,803 ----
    putdword ("ContinueDebugEvent pid", GDB_CONTINUEDEBUGEVENT, pid);
    putdword ("ContinueDebugEvent tid", GDB_CONTINUEDEBUGEVENT, tid);
    putdword ("ContinueDebugEvent status", GDB_CONTINUEDEBUGEVENT, status);
!   return getresult ("ContinueDebugEvent result", 
! 		    GDB_CONTINUEDEBUGEVENT, &res, NULL);
  }
  
  static int
*************** close_handle (HANDLE h)
*** 776,786 ****
    if (s < 0)
      return 1;
    puthandle ("CloseHandle handle", GDB_CLOSEHANDLE, h);
!   return (int) getresult ("CloseHandle result", GDB_CLOSEHANDLE, &res, NULL);
  }
  
! /* This is not a standard Win32 interface.  This function tells the stub
!    to terminate.
   */
  static void
  stop_stub (void)
--- 807,818 ----
    if (s < 0)
      return 1;
    puthandle ("CloseHandle handle", GDB_CLOSEHANDLE, h);
!   return (int) getresult ("CloseHandle result", 
! 			  GDB_CLOSEHANDLE, &res, NULL);
  }
  
! /* This is not a standard Win32 interface.  This function tells the
!    stub to terminate.
   */
  static void
  stop_stub (void)
*************** wince_software_single_step (enum target_
*** 812,818 ****
  			    int insert_breakpoints_p)
  {
    unsigned long pc;
!   thread_info *th = current_thread;	/* Info on currently selected thread */
    CORE_ADDR mips_next_pc (CORE_ADDR pc);
  
    if (!insert_breakpoints_p)
--- 844,851 ----
  			    int insert_breakpoints_p)
  {
    unsigned long pc;
!   /* Info on currently selected thread.  */
!   thread_info *th = current_thread;
    CORE_ADDR mips_next_pc (CORE_ADDR pc);
  
    if (!insert_breakpoints_p)
*************** void
*** 952,958 ****
  wince_software_single_step (enum target_signal ignore,
  			    int insert_breakpoints_p)
  {
!   thread_info *th = current_thread;	/* Info on currently selected thread */
  
    if (!insert_breakpoints_p)
      {
--- 985,992 ----
  wince_software_single_step (enum target_signal ignore,
  			    int insert_breakpoints_p)
  {
!   /* Info on currently selected thread.  */
!   thread_info *th = current_thread;
  
    if (!insert_breakpoints_p)
      {
*************** wince_software_single_step (enum target_
*** 1000,1006 ****
  			    int insert_breakpoints_p)
  {
    unsigned long pc;
!   thread_info *th = current_thread;	/* Info on currently selected thread */
    CORE_ADDR mips_next_pc (CORE_ADDR pc);
  
    if (!insert_breakpoints_p)
--- 1034,1041 ----
  			    int insert_breakpoints_p)
  {
    unsigned long pc;
!   /* Info on currently selected thread.  */
!   thread_info *th = current_thread;
    CORE_ADDR mips_next_pc (CORE_ADDR pc);
  
    if (!insert_breakpoints_p)
*************** wince_software_single_step (enum target_
*** 1019,1026 ****
  #endif
  
  /* Find a thread record given a thread id.
!    If get_context then also retrieve the context for this
!    thread. */
  static thread_info *
  thread_rec (DWORD id, int get_context)
  {
--- 1054,1061 ----
  #endif
  
  /* Find a thread record given a thread id.
!    If get_context then also retrieve the context for this thread.  */
! 
  static thread_info *
  thread_rec (DWORD id, int get_context)
  {
*************** thread_rec (DWORD id, int get_context)
*** 1041,1051 ****
  	  }
  	return th;
        }
- 
    return NULL;
  }
  
! /* Add a thread to the thread list */
  static thread_info *
  child_add_thread (DWORD id, HANDLE h)
  {
--- 1076,1085 ----
  	  }
  	return th;
        }
    return NULL;
  }
  
! /* Add a thread to the thread list.  */
  static thread_info *
  child_add_thread (DWORD id, HANDLE h)
  {
*************** child_add_thread (DWORD id, HANDLE h)
*** 1065,1071 ****
  }
  
  /* Clear out any old thread list and reintialize it to a
!    pristine state. */
  static void
  child_init_thread_list (void)
  {
--- 1099,1105 ----
  }
  
  /* Clear out any old thread list and reintialize it to a
!    pristine state.  */
  static void
  child_init_thread_list (void)
  {
*************** child_init_thread_list (void)
*** 1082,1088 ****
      }
  }
  
! /* Delete a thread from the list of threads */
  static void
  child_delete_thread (DWORD id)
  {
--- 1116,1122 ----
      }
  }
  
! /* Delete a thread from the list of threads.  */
  static void
  child_delete_thread (DWORD id)
  {
*************** static void
*** 1110,1116 ****
  check (BOOL ok, const char *file, int line)
  {
    if (!ok)
!     printf_filtered ("error return %s:%d was %d\n", file, line, GetLastError ());
  }
  
  static void
--- 1144,1151 ----
  check (BOOL ok, const char *file, int line)
  {
    if (!ok)
!     printf_filtered ("error return %s:%d was %d\n", 
! 		     file, line, GetLastError ());
  }
  
  static void
*************** do_child_store_inferior_registers (int r
*** 1147,1153 ****
      }
  }
  
! /* Store a new register value into the current thread context */
  static void
  child_store_inferior_registers (int r)
  {
--- 1182,1188 ----
      }
  }
  
! /* Store a new register value into the current thread context.  */
  static void
  child_store_inferior_registers (int r)
  {
*************** out:
*** 1207,1220 ****
    if (!event->fUnicode)
      memcpy (dll_name, dll_buf, len);
    else
!     WideCharToMultiByte (CP_ACP, 0, (LPCWSTR) dll_buf, len,
! 			 dll_name, len, 0, 0);
  
    while ((p = strchr (dll_name, '\\')))
      *p = '/';
  
!   /* FIXME!! It would be nice to define one symbol which pointed to the
!      front of the dll if we can't find any symbols. */
  
    if (!(dll_basename = strrchr (dll_name, '/')))
      dll_basename = dll_name;
--- 1242,1255 ----
    if (!event->fUnicode)
      memcpy (dll_name, dll_buf, len);
    else
!     WideCharToMultiByte (CP_ACP, 0, (LPCWSTR) dll_buf,
! 			 len, dll_name, len, 0, 0);
  
    while ((p = strchr (dll_name, '\\')))
      *p = '/';
  
!   /* FIXME!! It would be nice to define one symbol which pointed to
!      the front of the dll if we can't find any symbols.  */
  
    if (!(dll_basename = strrchr (dll_name, '/')))
      dll_basename = dll_name;
*************** out:
*** 1233,1239 ****
    return 1;
  }
  
! /* Handle DEBUG_STRING output from child process. */
  static void
  handle_output_debug_string (struct target_waitstatus *ourstatus)
  {
--- 1268,1274 ----
    return 1;
  }
  
! /* Handle DEBUG_STRING output from child process.  */
  static void
  handle_output_debug_string (struct target_waitstatus *ourstatus)
  {
*************** handle_output_debug_string (struct targe
*** 1254,1261 ****
      return;
  
    memset (s, 0, sizeof (s));
!   WideCharToMultiByte (CP_ACP, 0, (LPCWSTR) p, (int) nbytes_read, s,
! 		       sizeof (s) - 1, NULL, NULL);
    q = strchr (s, '\n');
    if (q != NULL)
      {
--- 1289,1296 ----
      return;
  
    memset (s, 0, sizeof (s));
!   WideCharToMultiByte (CP_ACP, 0, (LPCWSTR) p, (int) nbytes_read,
! 		       s, sizeof (s) - 1, NULL, NULL);
    q = strchr (s, '\n');
    if (q != NULL)
      {
*************** handle_output_debug_string (struct targe
*** 1269,1275 ****
    return;
  }
  
! /* Handle target exceptions. */
  static int
  handle_exception (struct target_waitstatus *ourstatus)
  {
--- 1304,1310 ----
    return;
  }
  
! /* Handle target exceptions.  */
  static int
  handle_exception (struct target_waitstatus *ourstatus)
  {
*************** handle_exception (struct target_waitstat
*** 1301,1308 ****
        DEBUG_EXCEPT (("gdb: Target exception CONTROL_C at 0x%08x\n",
  		     (unsigned) current_event.u.Exception.ExceptionRecord.ExceptionAddress));
        ourstatus->value.sig = TARGET_SIGNAL_INT;
!       /* User typed CTRL-C.  Continue with this status */
!       last_sig = SIGINT;	/* FIXME - should check pass state */
        break;
      case EXCEPTION_SINGLE_STEP:
        DEBUG_EXCEPT (("gdb: Target exception SINGLE_STEP at 0x%08x\n",
--- 1336,1343 ----
        DEBUG_EXCEPT (("gdb: Target exception CONTROL_C at 0x%08x\n",
  		     (unsigned) current_event.u.Exception.ExceptionRecord.ExceptionAddress));
        ourstatus->value.sig = TARGET_SIGNAL_INT;
!       /* User typed CTRL-C.  Continue with this status.  */
!       last_sig = SIGINT;	/* FIXME - should check pass state.  */
        break;
      case EXCEPTION_SINGLE_STEP:
        DEBUG_EXCEPT (("gdb: Target exception SINGLE_STEP at 0x%08x\n",
*************** handle_exception (struct target_waitstat
*** 1311,1327 ****
        break;
      case EXCEPTION_ILLEGAL_INSTRUCTION:
        DEBUG_EXCEPT (("gdb: Target exception SINGLE_ILL at 0x%08x\n",
! 	       current_event.u.Exception.ExceptionRecord.ExceptionAddress));
!       ourstatus->value.sig = check_for_step (&current_event, TARGET_SIGNAL_ILL);
        break;
      default:
        /* This may be a structured exception handling exception.  In
  	 that case, we want to let the program try to handle it, and
  	 only break if we see the exception a second time.  */
  
!       printf_unfiltered ("gdb: unknown target exception 0x%08x at 0x%08x\n",
! 		    current_event.u.Exception.ExceptionRecord.ExceptionCode,
! 		current_event.u.Exception.ExceptionRecord.ExceptionAddress);
        ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
        break;
      }
--- 1346,1364 ----
        break;
      case EXCEPTION_ILLEGAL_INSTRUCTION:
        DEBUG_EXCEPT (("gdb: Target exception SINGLE_ILL at 0x%08x\n",
! 		     /* (unsigned)? */ current_event.u.Exception.ExceptionRecord.ExceptionAddress));
!       ourstatus->value.sig = check_for_step (&current_event, 
! 					     TARGET_SIGNAL_ILL);
        break;
      default:
        /* This may be a structured exception handling exception.  In
  	 that case, we want to let the program try to handle it, and
  	 only break if we see the exception a second time.  */
  
!       printf_unfiltered 
! 	("gdb: unknown target exception 0x%08x at 0x%08x\n",
! 	 current_event.u.Exception.ExceptionRecord.ExceptionCode,
! 	 current_event.u.Exception.ExceptionRecord.ExceptionAddress);
        ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
        break;
      }
*************** handle_exception (struct target_waitstat
*** 1330,1336 ****
  }
  
  /* Resume all artificially suspended threads if we are continuing
!    execution */
  static BOOL
  child_continue (DWORD continue_status, int id)
  {
--- 1367,1373 ----
  }
  
  /* Resume all artificially suspended threads if we are continuing
!    execution.  */
  static BOOL
  child_continue (DWORD continue_status, int id)
  {
*************** child_continue (DWORD continue_status, i
*** 1339,1345 ****
    BOOL res;
  
    DEBUG_EVENTS (("ContinueDebugEvent (cpid=%d, ctid=%d, DBG_CONTINUE);\n",
! 		 (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId));
    res = continue_debug_event (current_event.dwProcessId,
  			      current_event.dwThreadId,
  			      continue_status);
--- 1376,1383 ----
    BOOL res;
  
    DEBUG_EVENTS (("ContinueDebugEvent (cpid=%d, ctid=%d, DBG_CONTINUE);\n",
! 		 (unsigned) current_event.dwProcessId, 
! 		 (unsigned) current_event.dwThreadId));
    res = continue_debug_event (current_event.dwProcessId,
  			      current_event.dwThreadId,
  			      continue_status);
*************** get_child_debug_event (int pid, struct t
*** 1436,1442 ****
  		     (unsigned) current_event.dwProcessId,
  		     (unsigned) current_event.dwThreadId,
  		     "LOAD_DLL_DEBUG_EVENT"));
!       catch_errors (handle_load_dll, NULL, (char *) "", RETURN_MASK_ALL);
        registers_changed ();	/* mark all regs invalid */
        break;
  
--- 1474,1481 ----
  		     (unsigned) current_event.dwProcessId,
  		     (unsigned) current_event.dwThreadId,
  		     "LOAD_DLL_DEBUG_EVENT"));
!       catch_errors (handle_load_dll, NULL, 
! 		    (char *) "", RETURN_MASK_ALL);
        registers_changed ();	/* mark all regs invalid */
        break;
  
*************** get_child_debug_event (int pid, struct t
*** 1478,1484 ****
      }
  
    if (breakout)
!     this_thread = current_thread = th ?: thread_rec (current_event.dwThreadId, TRUE);
    else
      CHECK (child_continue (continue_status, -1));
  
--- 1517,1524 ----
      }
  
    if (breakout)
!     this_thread = current_thread = th ?: thread_rec (current_event.dwThreadId,
! 						     TRUE);
    else
      CHECK (child_continue (continue_status, -1));
  
*************** out:
*** 1486,1492 ****
    return breakout;
  }
  
! /* Wait for interesting events to occur in the target process. */
  static ptid_t
  child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
  {
--- 1526,1532 ----
    return breakout;
  }
  
! /* Wait for interesting events to occur in the target process.  */
  static ptid_t
  child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
  {
*************** child_wait (ptid_t ptid, struct target_w
*** 1498,1507 ****
       with a SPURIOUS because resume can try and step or modify things,
       which needs a current_thread->h.  But some of these exceptions mark
       the birth or death of threads, which mean that the current thread
!      isn't necessarily what you think it is. */
  
    while (1)
!     if (get_child_debug_event (pid, ourstatus, EXCEPTION_DEBUG_EVENT, &retval))
        return pid_to_ptid (retval);
      else
        {
--- 1538,1548 ----
       with a SPURIOUS because resume can try and step or modify things,
       which needs a current_thread->h.  But some of these exceptions mark
       the birth or death of threads, which mean that the current thread
!      isn't necessarily what you think it is.  */
  
    while (1)
!     if (get_child_debug_event (pid, ourstatus, 
! 			       EXCEPTION_DEBUG_EVENT, &retval))
        return pid_to_ptid (retval);
      else
        {
*************** child_open (char *arg, int from_tty)
*** 1533,1539 ****
  #define FACTOR (0x19db1ded53ea710LL)
  #define NSPERSEC 10000000
  
! /* Convert a Win32 time to "UNIX" format. */
  long
  to_time_t (FILETIME * ptr)
  {
--- 1574,1580 ----
  #define FACTOR (0x19db1ded53ea710LL)
  #define NSPERSEC 10000000
  
! /* Convert a Win32 time to "UNIX" format.  */
  long
  to_time_t (FILETIME * ptr)
  {
*************** to_time_t (FILETIME * ptr)
*** 1543,1558 ****
  
    long rem;
    long long x = ((long long) ptr->dwHighDateTime << 32) + ((unsigned) ptr->dwLowDateTime);
!   x -= FACTOR;			/* number of 100ns between 1601 and 1970 */
    rem = x % ((long long) NSPERSEC);
    rem += (NSPERSEC / 2);
!   x /= (long long) NSPERSEC;	/* number of 100ns in a second */
    x += (long long) (rem / NSPERSEC);
    return x;
  }
  
  /* Upload a file to the remote device depending on the user's
!    'set remoteupload' specification. */
  char *
  upload_to_device (const char *to, const char *from)
  {
--- 1584,1599 ----
  
    long rem;
    long long x = ((long long) ptr->dwHighDateTime << 32) + ((unsigned) ptr->dwLowDateTime);
!   x -= FACTOR;			/* Number of 100ns between 1601 and 1970.  */
    rem = x % ((long long) NSPERSEC);
    rem += (NSPERSEC / 2);
!   x /= (long long) NSPERSEC;	/* Number of 100ns in a second.  */
    x += (long long) (rem / NSPERSEC);
    return x;
  }
  
  /* Upload a file to the remote device depending on the user's
!    'set remoteupload' specification.  */
  char *
  upload_to_device (const char *to, const char *from)
  {
*************** upload_to_device (const char *to, const 
*** 1569,1575 ****
    struct stat st;
    int fd;
  
!   /* Look for a path separator and only use trailing part. */
    while ((p = strpbrk (to, "/\\")) != NULL)
      to = p + 1;
  
--- 1610,1616 ----
    struct stat st;
    int fd;
  
!   /* Look for a path separator and only use trailing part.  */
    while ((p = strpbrk (to, "/\\")) != NULL)
      to = p + 1;
  
*************** upload_to_device (const char *to, const 
*** 1583,1609 ****
    strcat (remotefile, to);
  
    if (upload_when == UPLOAD_NEVER)
!     return remotefile;		/* Don't bother uploading. */
  
!   /* Open the source. */
!   if ((fd = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, (char *) from, O_RDONLY,
! 		   0, NULL)) < 0)
      error ("couldn't open %s", from);
  
!   /* Get the time for later comparison. */
    if (fstat (fd, &st))
      st.st_mtime = (time_t) - 1;
  
!   /* Always attempt to create the directory on the remote system. */
    wstr = towide (dir, NULL);
    (void) CeCreateDirectory (wstr, NULL);
  
!   /* Attempt to open the remote file, creating it if it doesn't exist. */
    wstr = towide (remotefile, NULL);
    h = CeCreateFile (wstr, GENERIC_READ | GENERIC_WRITE, 0, NULL,
  		    OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  
!   /* Some kind of problem? */
    err = CeGetLastError ();
    if (h == NULL || h == INVALID_HANDLE_VALUE)
      error ("error opening file \"%s\".  Windows error %d.",
--- 1624,1650 ----
    strcat (remotefile, to);
  
    if (upload_when == UPLOAD_NEVER)
!     return remotefile;		/* Don't bother uploading.  */
  
!   /* Open the source.  */
!   if ((fd = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, (char *) from,
! 		   O_RDONLY, 0, NULL)) < 0)
      error ("couldn't open %s", from);
  
!   /* Get the time for later comparison.  */
    if (fstat (fd, &st))
      st.st_mtime = (time_t) - 1;
  
!   /* Always attempt to create the directory on the remote system.  */
    wstr = towide (dir, NULL);
    (void) CeCreateDirectory (wstr, NULL);
  
!   /* Attempt to open the remote file, creating it if it doesn't exist.  */
    wstr = towide (remotefile, NULL);
    h = CeCreateFile (wstr, GENERIC_READ | GENERIC_WRITE, 0, NULL,
  		    OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  
!   /* Some kind of problem?  */
    err = CeGetLastError ();
    if (h == NULL || h == INVALID_HANDLE_VALUE)
      error ("error opening file \"%s\".  Windows error %d.",
*************** upload_to_device (const char *to, const 
*** 1619,1625 ****
        printf ("%s < %s\n", buf, ctime(&st.st_mtime));
      }
  #endif
!   /* See if we need to upload the file. */
    if (upload_when == UPLOAD_ALWAYS ||
        err != ERROR_ALREADY_EXISTS ||
        !CeGetFileTime (h, &crtime, &actime, &wrtime) ||
--- 1660,1666 ----
        printf ("%s < %s\n", buf, ctime(&st.st_mtime));
      }
  #endif
!   /* See if we need to upload the file.  */
    if (upload_when == UPLOAD_ALWAYS ||
        err != ERROR_ALREADY_EXISTS ||
        !CeGetFileTime (h, &crtime, &actime, &wrtime) ||
*************** upload_to_device (const char *to, const 
*** 1629,1635 ****
        char buf[4096];
        int n;
  
!       /* Upload the file. */
        while ((n = read (fd, buf, sizeof (buf))) > 0)
  	if (!CeWriteFile (h, buf, (DWORD) n, &nbytes, NULL))
  	  error ("error writing to remote device - %d.",
--- 1670,1676 ----
        char buf[4096];
        int n;
  
!       /* Upload the file.  */
        while ((n = read (fd, buf, sizeof (buf))) > 0)
  	if (!CeWriteFile (h, buf, (DWORD) n, &nbytes, NULL))
  	  error ("error writing to remote device - %d.",
*************** upload_to_device (const char *to, const 
*** 1643,1649 ****
    return remotefile;
  }
  
! /* Initialize the connection to the remote device. */
  static void
  wince_initialize (void)
  {
--- 1684,1690 ----
    return remotefile;
  }
  
! /* Initialize the connection to the remote device.  */
  static void
  wince_initialize (void)
  {
*************** wince_initialize (void)
*** 1667,1673 ****
  	break;
        }
  
!   /* Upload the stub to the handheld device. */
    stub_file_name = upload_to_device ("wince-stub.exe", WINCE_STUB);
    strcpy (args, stub_file_name);
  
--- 1708,1714 ----
  	break;
        }
  
!   /* Upload the stub to the handheld device.  */
    stub_file_name = upload_to_device ("wince-stub.exe", WINCE_STUB);
    strcpy (args, stub_file_name);
  
*************** wince_initialize (void)
*** 1679,1697 ****
  	error ("couldn't get hostname of this system.");
      }
  
!   /* Get a socket. */
    if ((s0 = socket (AF_INET, SOCK_STREAM, 0)) < 0)
      stub_error ("Couldn't connect to host system.");
  
!   /* Allow rapid reuse of the port. */
    tmp = 1;
!   (void) setsockopt (s0, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp));
  
  
!   /* Set up the information for connecting to the host gdb process. */
    memset (&sin, 0, sizeof (sin));
    sin.sin_family = AF_INET;
!   sin.sin_port = htons (7000);	/* FIXME: This should be configurable */
  
    if (bind (s0, (struct sockaddr *) &sin, sizeof (sin)))
      error ("couldn't bind socket");
--- 1720,1739 ----
  	error ("couldn't get hostname of this system.");
      }
  
!   /* Get a socket.  */
    if ((s0 = socket (AF_INET, SOCK_STREAM, 0)) < 0)
      stub_error ("Couldn't connect to host system.");
  
!   /* Allow rapid reuse of the port.  */
    tmp = 1;
!   (void) setsockopt (s0, SOL_SOCKET, SO_REUSEADDR, 
! 		     (char *) &tmp, sizeof (tmp));
  
  
!   /* Set up the information for connecting to the host gdb process.  */
    memset (&sin, 0, sizeof (sin));
    sin.sin_family = AF_INET;
!   sin.sin_port = htons (7000);	/* FIXME: This should be configurable.  */
  
    if (bind (s0, (struct sockaddr *) &sin, sizeof (sin)))
      error ("couldn't bind socket");
*************** wince_initialize (void)
*** 1699,1707 ****
    if (listen (s0, 1))
      error ("Couldn't open socket for listening.\n");
  
!   /* Start up the stub on the remote device. */
!   if (!CeCreateProcess (towide (stub_file_name, NULL), towide (args, NULL),
! 			NULL, NULL, 0, 0, NULL, NULL, NULL, &pi))
      error ("Unable to start remote stub '%s'.  Windows CE error %d.",
  	   stub_file_name, CeGetLastError ());
  
--- 1741,1751 ----
    if (listen (s0, 1))
      error ("Couldn't open socket for listening.\n");
  
!   /* Start up the stub on the remote device.  */
!   if (!CeCreateProcess (towide (stub_file_name, NULL), 
! 			towide (args, NULL),
! 			NULL, NULL, 0, 0, 
! 			NULL, NULL, NULL, &pi))
      error ("Unable to start remote stub '%s'.  Windows CE error %d.",
  	   stub_file_name, CeGetLastError ());
  
*************** wince_initialize (void)
*** 1716,1722 ****
  /* Start an inferior win32 child process and sets inferior_ptid to its pid.
     EXEC_FILE is the file to run.
     ALLARGS is a string containing the arguments to the program.
!    ENV is the environment vector to pass.  Errors reported with error().  */
  static void
  child_create_inferior (char *exec_file, char *args, char **env,
  		       int from_tty)
--- 1760,1767 ----
  /* Start an inferior win32 child process and sets inferior_ptid to its pid.
     EXEC_FILE is the file to run.
     ALLARGS is a string containing the arguments to the program.
!    ENV is the environment vector to pass.  
!    Errors reported with error().  */
  static void
  child_create_inferior (char *exec_file, char *args, char **env,
  		       int from_tty)
*************** child_create_inferior (char *exec_file, 
*** 1732,1738 ****
  
    flags = DEBUG_PROCESS;
  
!   wince_initialize ();		/* Make sure we've got a connection. */
  
    exec_file = upload_to_device (exec_file, exec_file);
  
--- 1777,1783 ----
  
    flags = DEBUG_PROCESS;
  
!   wince_initialize ();		/* Make sure we've got a connection.  */
  
    exec_file = upload_to_device (exec_file, exec_file);
  
*************** child_create_inferior (char *exec_file, 
*** 1752,1760 ****
      }
  
    memset (&pi, 0, sizeof (pi));
!   /* Execute the process */
    if (!create_process (exec_file, exec_and_args, flags, &pi))
!     error ("Error creating process %s, (error %d)\n", exec_file, GetLastError ());
  
    exception_count = 0;
    event_count = 0;
--- 1797,1806 ----
      }
  
    memset (&pi, 0, sizeof (pi));
!   /* Execute the process.  */
    if (!create_process (exec_file, exec_and_args, flags, &pi))
!     error ("Error creating process %s, (error %d)\n", 
! 	   exec_file, GetLastError ());
  
    exception_count = 0;
    event_count = 0;
*************** child_create_inferior (char *exec_file, 
*** 1780,1786 ****
    proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
  }
  
! /* Chile has gone bye-bye. */
  static void
  child_mourn_inferior (void)
  {
--- 1826,1832 ----
    proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
  }
  
! /* Chile has gone bye-bye.  */
  static void
  child_mourn_inferior (void)
  {
*************** child_mourn_inferior (void)
*** 1792,1800 ****
    generic_mourn_inferior ();
  }
  
! /* Move memory from child to/from gdb. */
  int
! child_xfer_memory (CORE_ADDR memaddr, char *our, int len, int write,
  		   struct mem_attrib *attrib,
  		   struct target_ops *target)
  {
--- 1838,1847 ----
    generic_mourn_inferior ();
  }
  
! /* Move memory from child to/from gdb.  */
  int
! child_xfer_memory (CORE_ADDR memaddr, char *our, 
! 		   int len, int write,
  		   struct mem_attrib *attrib,
  		   struct target_ops *target)
  {
*************** child_xfer_memory (CORE_ADDR memaddr, ch
*** 1809,1815 ****
    return res;
  }
  
! /* Terminate the process and wait for child to tell us it has completed. */
  void
  child_kill_inferior (void)
  {
--- 1856,1863 ----
    return res;
  }
  
! /* Terminate the process and wait for child to tell us it has
!    completed.  */
  void
  child_kill_inferior (void)
  {
*************** child_kill_inferior (void)
*** 1827,1842 ****
  
    CHECK (close_handle (current_process_handle));
    close_handle (current_thread->h);
!   target_mourn_inferior ();	/* or just child_mourn_inferior? */
  }
  
! /* Resume the child after an exception. */
  void
  child_resume (ptid_t ptid, int step, enum target_signal sig)
  {
    thread_info *th;
    DWORD continue_status = last_sig > 0 && last_sig < NSIG ?
!   DBG_EXCEPTION_NOT_HANDLED : DBG_CONTINUE;
    int pid = PIDGET (ptid);
  
    DEBUG_EXEC (("gdb: child_resume (pid=%d, step=%d, sig=%d);\n",
--- 1875,1890 ----
  
    CHECK (close_handle (current_process_handle));
    close_handle (current_thread->h);
!   target_mourn_inferior ();	/* or just child_mourn_inferior?  */
  }
  
! /* Resume the child after an exception.  */
  void
  child_resume (ptid_t ptid, int step, enum target_signal sig)
  {
    thread_info *th;
    DWORD continue_status = last_sig > 0 && last_sig < NSIG ?
!     DBG_EXCEPTION_NOT_HANDLED : DBG_CONTINUE;
    int pid = PIDGET (ptid);
  
    DEBUG_EXEC (("gdb: child_resume (pid=%d, step=%d, sig=%d);\n",
*************** child_resume (ptid_t ptid, int step, enu
*** 1852,1860 ****
      }
  
    /* Allow continuing with the same signal that interrupted us.
!      Otherwise complain. */
    if (sig && sig != last_sig)
!     fprintf_unfiltered (gdb_stderr, "Can't send signals to the child.  signal %d\n", sig);
  
    last_sig = 0;
    child_continue (continue_status, pid);
--- 1900,1910 ----
      }
  
    /* Allow continuing with the same signal that interrupted us.
!      Otherwise complain.  */
    if (sig && sig != last_sig)
!     fprintf_unfiltered (gdb_stderr, 
! 			"Can't send signals to the child.  signal %d\n", 
! 			sig);
  
    last_sig = 0;
    child_continue (continue_status, pid);
*************** static void
*** 1876,1882 ****
  child_close (void)
  {
    DEBUG_EVENTS (("gdb: child_close, inferior_ptid=%d\n",
!                 PIDGET (inferior_ptid)));
  }
  
  /* Explicitly upload file to remotedir */
--- 1926,1932 ----
  child_close (void)
  {
    DEBUG_EVENTS (("gdb: child_close, inferior_ptid=%d\n",
! 		 PIDGET (inferior_ptid)));
  }
  
  /* Explicitly upload file to remotedir */
*************** init_child_ops (void)
*** 1927,1938 ****
  }
  
  
! /* Handle 'set remoteupload' parameter. */
  
  #define replace_upload(what) \
!       upload_when = what; \
!       remote_upload = xrealloc (remote_upload, strlen (upload_options[upload_when].name) + 1); \
!       strcpy (remote_upload, upload_options[upload_when].name);
  
  static void
  set_upload_type (char *ignore, int from_tty)
--- 1977,1989 ----
  }
  
  
! /* Handle 'set remoteupload' parameter.  */
  
  #define replace_upload(what) \
!     upload_when = what; \
!     remote_upload = xrealloc (remote_upload, \
! 			      strlen (upload_options[upload_when].name) + 1); \
!     strcpy (remote_upload, upload_options[upload_when].name);
  
  static void
  set_upload_type (char *ignore, int from_tty)
*************** set_upload_type (char *ignore, int from_
*** 1949,1955 ****
      }
  
    len = strlen (remote_upload);
!   for (i = 0; i < (sizeof (upload_options) / sizeof (upload_options[0])); i++)
      if (len >= upload_options[i].abbrev &&
  	strncasecmp (remote_upload, upload_options[i].name, len) == 0)
        {
--- 2000,2008 ----
      }
  
    len = strlen (remote_upload);
!   for (i = 0; 
!        i < (sizeof (upload_options) / sizeof (upload_options[0])); 
!        i++)
      if (len >= upload_options[i].abbrev &&
  	strncasecmp (remote_upload, upload_options[i].name, len) == 0)
        {
*************** _initialize_wince (void)
*** 1978,2031 ****
  
    set = add_set_cmd ((char *) "remoteupload", no_class,
  		     var_string_noescape, (char *) &remote_upload,
! 	       (char *) "Set how to upload executables to remote device.\n",
  		     &setlist);
    deprecated_add_show_from_set (set, &showlist);
    set_cmd_cfunc (set, set_upload_type);
    set_upload_type (NULL, 0);
  
    deprecated_add_show_from_set
!     (add_set_cmd ((char *) "debugexec", class_support, var_boolean,
  		  (char *) &debug_exec,
! 	      (char *) "Set whether to display execution in child process.",
  		  &setlist),
       &showlist);
  
    deprecated_add_show_from_set
!     (add_set_cmd ((char *) "remoteaddhost", class_support, var_boolean,
  		  (char *) &remote_add_host,
  		  (char *) "\
  Set whether to add this host to remote stub arguments for\n\
! debugging over a network.", &setlist),
       &showlist);
  
    deprecated_add_show_from_set
!     (add_set_cmd ((char *) "debugevents", class_support, var_boolean,
  		  (char *) &debug_events,
! 	  (char *) "Set whether to display kernel events in child process.",
  		  &setlist),
       &showlist);
  
    deprecated_add_show_from_set
!     (add_set_cmd ((char *) "debugmemory", class_support, var_boolean,
  		  (char *) &debug_memory,
! 	(char *) "Set whether to display memory accesses in child process.",
  		  &setlist),
       &showlist);
  
!   deprecated_add_show_from_set
!     (add_set_cmd ((char *) "debugexceptions", class_support, var_boolean,
  		  (char *) &debug_exceptions,
!       (char *) "Set whether to display kernel exceptions in child process.",
  		  &setlist),
       &showlist);
  
    add_target (&deprecated_child_ops);
  }
  
! /* Determine if the thread referenced by "pid" is alive
!    by "polling" it.  If WaitForSingleObject returns WAIT_OBJECT_0
!    it means that the pid has died.  Otherwise it is assumed to be alive. */
  static int
  win32_child_thread_alive (ptid_t ptid)
  {
--- 2031,2096 ----
  
    set = add_set_cmd ((char *) "remoteupload", no_class,
  		     var_string_noescape, (char *) &remote_upload,
! 		     (char *) "\
! Set how to upload executables to remote device.\n",
  		     &setlist);
+ 
    deprecated_add_show_from_set (set, &showlist);
    set_cmd_cfunc (set, set_upload_type);
    set_upload_type (NULL, 0);
  
    deprecated_add_show_from_set
!     (add_set_cmd ((char *) "debugexec", 
! 		  class_support, var_boolean,
  		  (char *) &debug_exec,
! 		  (char *) "\
! Set whether to display execution in child process.",
  		  &setlist),
       &showlist);
  
    deprecated_add_show_from_set
!     (add_set_cmd ((char *) "remoteaddhost", 
! 		  class_support, var_boolean,
  		  (char *) &remote_add_host,
  		  (char *) "\
  Set whether to add this host to remote stub arguments for\n\
! debugging over a network.", 
! 		  &setlist),
       &showlist);
  
    deprecated_add_show_from_set
!     (add_set_cmd ((char *) "debugevents", 
! 		  class_support, var_boolean,
  		  (char *) &debug_events,
! 		  (char *) "\
! Set whether to display kernel events in child process.",
  		  &setlist),
       &showlist);
  
    deprecated_add_show_from_set
!     (add_set_cmd ((char *) "debugmemory", 
! 		  class_support, var_boolean,
  		  (char *) &debug_memory,
! 		  (char *) "\
! Set whether to display memory accesses in child process.",
  		  &setlist),
       &showlist);
  
!   deprecated_add_show_from_set 
!     (add_set_cmd ((char *) "debugexceptions", 
! 		  class_support, var_boolean,
  		  (char *) &debug_exceptions,
! 		  (char *) "\
! Set whether to display kernel exceptions in child process.",
  		  &setlist),
       &showlist);
  
    add_target (&deprecated_child_ops);
  }
  
! /* Determine if the thread referenced by "pid" is alive by "polling"
!    it.  If WaitForSingleObject returns WAIT_OBJECT_0 it means that the
!    pid has died.  Otherwise it is assumed to be alive.  */
  static int
  win32_child_thread_alive (ptid_t ptid)
  {
*************** win32_child_thread_alive (ptid_t ptid)
*** 2033,2039 ****
    return thread_alive (thread_rec (pid, FALSE)->h);
  }
  
! /* Convert pid to printable format. */
  char *
  cygwin_pid_to_str (int pid)
  {
--- 2098,2104 ----
    return thread_alive (thread_rec (pid, FALSE)->h);
  }
  
! /* Convert pid to printable format.  */
  char *
  cygwin_pid_to_str (int pid)
  {
*************** cygwin_pid_to_str (int pid)
*** 2041,2046 ****
    if (pid == current_event.dwProcessId)
      sprintf (buf, "process %d", pid);
    else
!     sprintf (buf, "thread %d.0x%x", (unsigned) current_event.dwProcessId, pid);
    return buf;
  }
--- 2106,2112 ----
    if (pid == current_event.dwProcessId)
      sprintf (buf, "process %d", pid);
    else
!     sprintf (buf, "thread %d.0x%x", 
! 	     (unsigned) current_event.dwProcessId, pid);
    return buf;
  }

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