2008-06-23  Michael Snyder  <msnyder@specifix.com>

	* gdbfreeplay.h: Replace all address values with unsigned long long.
	* gdbfreeplay-i386.c: Ditto.
	* gdbfreeplay-mips64.c: Ditto.
	* gdbfreeplay-back.c: Ditto.
	* remote-break.c: Ditto.
	* remote-break.h: Ditto.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index bee26c9..70b3306 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,7 +1,15 @@
 2008-06-23  Michael Snyder  <msnyder@specifix.com>
 
+	* gdbfreeplay.h: Replace all address values with unsigned long long.
+	* gdbfreeplay-i386.c: Ditto.
+	* gdbfreeplay-mips64.c: Ditto.
+	* gdbfreeplay-back.c: Ditto.
+	* remote-break.c: Ditto.
+	* remote-break.h: Ditto.
+
 	* configure.srv: Add configuration for mips64-linux.
 	* gdbfreeplay-mips64.c: New file, back-end for mips64.
+	* Makefile.in: Add rules for mips and intel back-ends.
 
 2008-06-21  Michael Snyder  <msnyder@specifix.com>
 
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index fdf40a1..8039bba 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -299,8 +299,11 @@
 thread-db.o: thread-db.c $(server_h) $(gdb_proc_service_h)
 utils.o: utils.c $(server_h)
 gdbreplay.o: gdbreplay.c config.h
-gdbfreeplay-front.o: gdbfreeplay-front.c gdbfreeplay.h
-gdbfreeplay-back.o:  gdbfreeplay-back.c  gdbfreeplay.h
+gdbfreeplay-front.o:  gdbfreeplay-front.c gdbfreeplay.h
+gdbfreeplay-back.o:   gdbfreeplay-back.c  gdbfreeplay.h remote-breakpoint.h
+gdbfreeplay-i386.o:   gdbfreeplay-i386.c  gdbfreeplay.h remote-breakpoint.h
+gdbfreeplay-mips64.o: gdbfreeplay-mips64.c  gdbfreeplay.h remote-breakpoint.h
+remote-breakpoint.o:  remote-breakpoint.c remote-breakpoint.h
 
 signals.o: ../signals/signals.c $(server_h)
 	$(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER
diff --git a/gdb/gdbserver/gdbfreeplay-back.c b/gdb/gdbserver/gdbfreeplay-back.c
index a270d1c..bcfe49b 100644
--- a/gdb/gdbserver/gdbfreeplay-back.c
+++ b/gdb/gdbserver/gdbfreeplay-back.c
@@ -21,11 +21,11 @@
   /* frame_id -- a unique identifier per stop frame.  */
   unsigned int frame_id;
   /* pc -- address of the next instruction to be "executed".  */
-  unsigned long pc;
-  /* predecr_pc -- address that will be reported by a breakpoint.
+  unsigned long long pc;
+  /* FIXME remove! predecr_pc -- address that will be reported by a breakpoint.
      These two are different on some targets, see gdb source code,
      DECR_PC_AFTER_BREAK.  */
-  unsigned long predecr_pc;
+  unsigned long long predecr_pc;
   unsigned long eventpos;
   unsigned long Opos;
 } StopFrame;
@@ -58,7 +58,7 @@
   /* Make a pass over the entire file -- cache the record positions.  */
   char *line, *p;
   unsigned long nextpos;
-  unsigned long GPC;
+  unsigned long long GPC;
 
   /* First skip empty lines.  */
   do {
@@ -79,7 +79,7 @@
       {
 	/* See if we need to grab the PC from this packet.  */
 	if (stopframe[last_cached_frame].pc == 0 ||
-	    stopframe[last_cached_frame].pc == (unsigned long) -1)
+	    stopframe[last_cached_frame].pc == (unsigned long long) -1)
 	  {
 	    nextpos = ftell (infile);
 	    line = fgets (inbuf, sizeof (inbuf), infile);
@@ -92,13 +92,14 @@
       {
 	GPC = target_pc_from_G (p);
 	if (stopframe[last_cached_frame].pc == 0 ||
-	    stopframe[last_cached_frame].pc == (unsigned long) -1)
+	    stopframe[last_cached_frame].pc == (unsigned long long) -1)
 	  {
 	    /* Unlikely, but if we need to, we can just grab this PC.  */
 	    stopframe[last_cached_frame].pc = GPC;
 	  }
 	else if (stopframe[last_cached_frame].pc == GPC + 1)
 	  {
+	    /* FIXME remove!  */
 	    /* OK, this is gdb decrementing the PC after a breakpoint.  */
 	    stopframe[last_cached_frame].predecr_pc =
 	      stopframe[last_cached_frame].pc;
@@ -640,6 +641,10 @@
   int cksum = 0;
   char *p = inbuf;
 
+  /* Sanity check.  */
+  if (inbuf == NULL)
+    return NULL;
+
   /* If the string doesn't start with a '$', it's broken.  */
   if (*p++ != '$')
     return inbuf;
@@ -708,7 +713,7 @@
 static char *
 handle_special_case (FILE *infile, int fd, char *request)
 {
-  unsigned long addr;
+  unsigned long long addr;
   unsigned long len;
   int next_event_frame;
   char *p;
@@ -932,7 +937,7 @@
     {
       if (p[3] == ',')
 	{
-	  addr = strtoul (p + 4, &p, 16);
+	  addr = strtoull (p + 4, &p, 16);
 	  if (p[0] == ',')
 	    {
 	      len = strtoul (p + 1, NULL, 16);
@@ -947,7 +952,7 @@
     {
       if (p[3] == ',')
 	{
-	  addr = strtoul (p + 4, &p, 16);
+	  addr = strtoull (p + 4, &p, 16);
 	  if (p[0] == ',')
 	    {
 	      len = strtoul (p + 1, NULL, 16);
diff --git a/gdb/gdbserver/gdbfreeplay-i386.c b/gdb/gdbserver/gdbfreeplay-i386.c
index aaeb8cf..f2ae4ba 100644
--- a/gdb/gdbserver/gdbfreeplay-i386.c
+++ b/gdb/gdbserver/gdbfreeplay-i386.c
@@ -79,10 +79,10 @@
  * target_pc_from_T
  *
  * Extract the PC value from the gdb protocol 'T' packet.
- * Returns PC as host unsigned long.
+ * Returns PC as host unsigned long long.
  */
 
-unsigned long
+unsigned long long
 target_pc_from_T (char *tpacket)
 {
   char *p;
@@ -90,43 +90,43 @@
   if (tpacket[0] == '$' && tpacket[1] == 'T' &&
       (p = strstr (tpacket, ";08:")) != NULL)
     {
-      return ix86_hex_to_unsigned_long (p + 4);
+      return (unsigned long long) ix86_hex_to_unsigned_long (p + 4);
     }
 
   /* Fail -- just assume no legitimate PC will ever be -1...  */
-  return (unsigned long) -1;
+  return (unsigned long long) -1;
 }
 
 /*
  * ix86_pc_from_registers
  * 
  * Extract the PC value from a gdb protocol registers file.
- * Returns PC as host unsigned long.
+ * Returns PC as host unsigned long long.
  */
 
-static unsigned long
+static unsigned long long
 ix86_pc_from_registers (char *regs)
 {
-  return ix86_hex_to_unsigned_long (regs + 64);
+  return (unsigned long long) ix86_hex_to_unsigned_long (regs + 64);
 }
 
 /*
  * target_pc_from_G
  *
  * Extract the PC value from the gdb protocol 'G' packet.
- * Returns PC as host unsigned long.
+ * Returns PC as host unsigned long long.
  */
 
-unsigned long
+unsigned long long
 target_pc_from_G (char *gpacket)
 {
   if (gpacket[0] == '$' && gpacket[1] == 'G')
     {
-      return ix86_pc_from_registers (gpacket + 2);
+      return (unsigned long long) ix86_pc_from_registers (gpacket + 2);
     }
 
   /* Fail -- just assume no legitimate PC will ever be -1...  */
-  return (unsigned long) -1;
+  return (unsigned long long) -1;
 }
 
 /*
@@ -202,10 +202,10 @@
  * Unlike the two above, this function accepts a FILE pointer
  * rather than a char pointer, and must read data from the file.
  *
- * Returns PC as host unsigned long.
+ * Returns PC as host unsigned long long.
  */
 
-unsigned long
+unsigned long long
 target_pc_from_g (char *gpacket)
 {
   if (gpacket[0] == 'r' && gpacket[1] == ' ')
@@ -217,7 +217,7 @@
 	gpacket++;
     }
 
-  return ix86_pc_from_registers (expand_rle (gpacket));
+  return (unsigned long long) ix86_pc_from_registers (expand_rle (gpacket));
 }
 
 /*
@@ -248,10 +248,10 @@
 
 char *
 target_compose_T_packet (char *origTpacket, 
-			 unsigned long instruction_pc,
+			 unsigned long long instruction_pc,
 			 int breakpoint_p)
 {
-  unsigned long origTpacket_pc = target_pc_from_T (origTpacket);
+  unsigned long long origTpacket_pc = target_pc_from_T (origTpacket);
   static char reply_buf[128];
   char *p;
 
diff --git a/gdb/gdbserver/gdbfreeplay-mips64.c b/gdb/gdbserver/gdbfreeplay-mips64.c
index 3e3978a..3a9ce1b 100644
--- a/gdb/gdbserver/gdbfreeplay-mips64.c
+++ b/gdb/gdbserver/gdbfreeplay-mips64.c
@@ -14,37 +14,37 @@
  * target_pc_from_T
  *
  * Extract the PC value from the gdb protocol 'T' packet.
- * Returns PC as host unsigned long.
+ * Returns PC as host unsigned long long.
  */
 
-unsigned long
+unsigned long long
 target_pc_from_T (char *tpacket)
 {
   /* Unimplimented -- make caller fall back to using g packet.  */
-  return -1;
+  return (unsigned long long) -1;
 }
 
 /*
  * target_pc_from_G
  *
  * Extract the PC value from the gdb protocol 'G' packet.
- * Returns PC as host unsigned long.
+ * Returns PC as host unsigned long long.
  */
 
-unsigned long
+unsigned long long
 target_pc_from_G (char *gpacket)
 {
   char localbuf [24];
 
   if (gpacket[0] == '$' && gpacket[1] == 'G')
     {
-      strncpy (localbuf, gpacket + 592, 8);
+      strncpy (localbuf, gpacket + 592, 16);
       localbuf[16] = '\0';
       return strtoul (localbuf, NULL, 16);
     }
 
   /* Fail -- just assume no legitimate PC will ever be -1...  */
-  return (unsigned long) -1;
+  return (unsigned long long) -1;
 }
 
 /*
@@ -55,10 +55,10 @@
  * Unlike the two above, this function accepts a FILE pointer
  * rather than a char pointer, and must read data from the file.
  *
- * Returns PC as host unsigned long.
+ * Returns PC as host unsigned long long.
  */
 
-unsigned long
+unsigned long long
 target_pc_from_g (char *gpacket)
 {
   char localbuf [24];
@@ -72,9 +72,9 @@
 	gpacket++;
     }
 
-  strncpy (localbuf, gpacket + 592, 8);
+  strncpy (localbuf, gpacket + 592, 16);
   localbuf[16] = '\0';
-  return strtoul (localbuf, NULL, 16);
+  return strtoull (localbuf, NULL, 16);
 }
 
 
@@ -89,7 +89,7 @@
 
 char *
 target_compose_T_packet (char *origTpacket, 
-			 unsigned long instruction_pc,
+			 unsigned long long instruction_pc,
 			 int breakpoint_p)
 {
   return origTpacket;
diff --git a/gdb/gdbserver/gdbfreeplay.h b/gdb/gdbserver/gdbfreeplay.h
index d9c70c5..7d38651 100644
--- a/gdb/gdbserver/gdbfreeplay.h
+++ b/gdb/gdbserver/gdbfreeplay.h
@@ -12,12 +12,12 @@
 extern enum successcode gdbfreeplay_open (char *filename);
 extern void gdbfreeplay (int socket_fd);
 
-extern unsigned long target_pc_from_T (char *tpacket);
-extern unsigned long target_pc_from_G (char *gpacket);
-extern unsigned long target_pc_from_g (char *gpacket);
+extern unsigned long long target_pc_from_T (char *tpacket);
+extern unsigned long long target_pc_from_G (char *gpacket);
+extern unsigned long long target_pc_from_g (char *gpacket);
 
 extern char *target_compose_T_packet (char *origTpacket, 
-				      unsigned long pc,
+				      unsigned long long pc,
 				      int breakpoint_p);
 extern char *target_compose_g_packet (char *origTpacket);
 
diff --git a/gdb/gdbserver/remote-breakpoint.c b/gdb/gdbserver/remote-breakpoint.c
index 5308932..adebf9f 100644
--- a/gdb/gdbserver/remote-breakpoint.c
+++ b/gdb/gdbserver/remote-breakpoint.c
@@ -23,7 +23,7 @@
 
 static enum successcode
 insert_breakpoint (enum breakpoint_type bptype,
-		   unsigned long        addr,
+		   unsigned long long   addr,
 		   unsigned long        len)
 {
   breakpoint *this_bp;
@@ -55,7 +55,7 @@
 
 static int
 unlink_breakpoint (enum breakpoint_type bptype,
-		   unsigned long        addr,
+		   unsigned long long   addr,
 		   unsigned long        len)
 {
   breakpoint *this_bp, *tmp;
@@ -104,7 +104,7 @@
 
 extern enum successcode
 remote_remove_breakpoint (enum breakpoint_type bptype,
-			  unsigned long        addr,
+			  unsigned long long   addr,
 			  unsigned long        len)
 {
   if (verbose)
@@ -120,7 +120,7 @@
 
 extern enum successcode
 remote_set_breakpoint (enum breakpoint_type bptype,
-		       unsigned long        addr,
+		       unsigned long long   addr,
 		       unsigned long        len)
 {
   if (verbose)
@@ -145,7 +145,7 @@
 
 enum successcode 
 remote_breakpoint_here_p (enum breakpoint_type bptype,
-			  unsigned long addr)
+			  unsigned long long addr)
 {
   breakpoint *bp = bplist[bptype];
 
diff --git a/gdb/gdbserver/remote-breakpoint.h b/gdb/gdbserver/remote-breakpoint.h
index d98a659..10d746a 100644
--- a/gdb/gdbserver/remote-breakpoint.h
+++ b/gdb/gdbserver/remote-breakpoint.h
@@ -6,7 +6,7 @@
 #define REMOTE_BREAKPOINT_H
 
 typedef struct BREAKPOINT {
-  unsigned long addr;
+  unsigned long long addr;
   unsigned long len;
   struct BREAKPOINT *next;
 } breakpoint;
@@ -31,15 +31,15 @@
 };
 
 extern enum successcode remote_remove_breakpoint (enum breakpoint_type,
-						  unsigned long,
+						  unsigned long long,
 						  unsigned long);
 
 extern enum successcode remote_set_breakpoint    (enum breakpoint_type,
-						  unsigned long,
+						  unsigned long long,
 						  unsigned long);
 
 extern enum successcode remote_breakpoint_here_p (enum breakpoint_type,
-						  unsigned long);
+						  unsigned long long);
 
 #endif