--- ./gdb/aix-thread.c_orig	2011-11-10 18:26:32.181606109 +0530
+++ ./gdb/aix-thread.c	2011-11-10 18:26:38.449606793 +0530
@@ -227,8 +227,8 @@
 	{
 	  if (debug_aix_thread)
 	    fprintf_unfiltered (gdb_stdlog, 
-				"ptrace (%d, %d) = %d (errno = %d)\n",
-				req, id, ret, errno);
+				"ptrace64 (%d, %lld) = %lld (errno = %d)\n",
+				req, (long long)id, (long long)ret, errno);
 	  return ret == -1 ? 0 : 1;
 	}
       break;
@@ -241,20 +241,20 @@
 /* Call ptracex (REQ, ID, ADDR, DATA, BUF).  Return success.  */
 
 static int
-ptrace64aix (int req, int id, long long addr, int data, int *buf)
+ptrace64aix (int req, long long id, long long addr, int data, int *buf)
 {
   errno = 0;
-  return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
+  return ptrace_check (req, id, ptrace64 (req, id, addr, data, buf));
 }
 
 /* Call ptrace (REQ, ID, ADDR, DATA, BUF).  Return success.  */
 
 static int
-ptrace32 (int req, int id, int *addr, int data, int *buf)
+ptrace32 (int req, long long id, long long addr, int data, int *buf)
 {
   errno = 0;
   return ptrace_check (req, id, 
-		       ptrace (req, id, (int *) addr, data, buf));
+		       ptrace64 (req, id, addr, data, buf));
 }
 
 /* If *PIDP is a composite process/thread id, convert it to a
@@ -347,13 +347,13 @@
       if (arch64)
 	{
 	  if (!ptrace64aix (PTT_READ_GPRS, tid, 
-			    (unsigned long) gprs64, 0, NULL))
+			    (long long) gprs64, 0, NULL))
 	    memset (gprs64, 0, sizeof (gprs64));
 	  memcpy (context->gpr, gprs64, sizeof(gprs64));
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_GPRS, tid, (long long)gprs32, 0, NULL))
 	    memset (gprs32, 0, sizeof (gprs32));
 	  memcpy (context->gpr, gprs32, sizeof(gprs32));
 	}
@@ -362,7 +362,7 @@
   /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (long long) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       memcpy (context->fpr, fprs, sizeof(fprs));
     }
@@ -373,13 +373,13 @@
       if (arch64)
 	{
 	  if (!ptrace64aix (PTT_READ_SPRS, tid, 
-			    (unsigned long) &sprs64, 0, NULL))
+			    (long long) &sprs64, 0, NULL))
 	    memset (&sprs64, 0, sizeof (sprs64));
       	  memcpy (&context->msr, &sprs64, sizeof(sprs64));
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (long long) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
       	  memcpy (&context->msr, &sprs32, sizeof(sprs32));
 	}
@@ -412,15 +412,15 @@
     {
       if (arch64)
 	ptrace64aix (PTT_WRITE_GPRS, tid, 
-		     (unsigned long) context->gpr, 0, NULL);
+		     (long long) context->gpr, 0, NULL);
       else
-	ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL);
+	ptrace32 (PTT_WRITE_GPRS, tid, (long long) context->gpr, 0, NULL);
     }
 
  /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (long long) context->fpr, 0, NULL);
     }
 
   /* Special-purpose registers.  */
@@ -429,11 +429,11 @@
       if (arch64)
 	{
 	  ptrace64aix (PTT_WRITE_SPRS, tid, 
-		       (unsigned long) &context->msr, 0, NULL);
+		       (long long) &context->msr, 0, NULL);
 	}
       else
 	{
-	  ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (long long) &context->msr, 0, NULL);
 	}
     }
   return 0;
@@ -998,10 +998,10 @@
       tid[1] = 0;
 
       if (arch64)
-	ptrace64aix (PTT_CONTINUE, tid[0], 1, 
+	ptrace64aix (PTT_CONTINUE, tid[0], (long long)1, 
 		     target_signal_to_host (sig), (void *) tid);
       else
-	ptrace32 (PTT_CONTINUE, tid[0], (int *) 1,
+	ptrace32 (PTT_CONTINUE, tid[0], (long long) 1,
 		  target_signal_to_host (sig), (void *) tid);
     }
 }
@@ -1232,13 +1232,13 @@
       if (arch64)
 	{
 	  if (!ptrace64aix (PTT_READ_GPRS, tid, 
-			    (unsigned long) gprs64, 0, NULL))
+			    (long long) gprs64, 0, NULL))
 	    memset (gprs64, 0, sizeof (gprs64));
 	  supply_gprs64 (regcache, gprs64);
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_GPRS, tid, (long long)gprs32, 0, NULL))
 	    memset (gprs32, 0, sizeof (gprs32));
 	  for (i = 0; i < ppc_num_gprs; i++)
 	    supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
@@ -1252,7 +1252,7 @@
           || (regno >= tdep->ppc_fp0_regnum
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (long long) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       supply_fprs (regcache, fprs);
     }
@@ -1264,7 +1264,7 @@
       if (arch64)
 	{
 	  if (!ptrace64aix (PTT_READ_SPRS, tid, 
-			    (unsigned long) &sprs64, 0, NULL))
+			    (long long) &sprs64, 0, NULL))
 	    memset (&sprs64, 0, sizeof (sprs64));
 	  supply_sprs64 (regcache, sprs64.pt_iar, sprs64.pt_msr,
 			 sprs64.pt_cr, sprs64.pt_lr, sprs64.pt_ctr,
@@ -1274,7 +1274,7 @@
 	{
 	  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (long long) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
 	  supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr, sprs32.pt_cr,
 			 sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer,
@@ -1561,16 +1561,16 @@
       if (arch64)
 	{
 	  /* Pre-fetch: some regs may not be in the cache.  */
-	  ptrace64aix (PTT_READ_GPRS, tid, (unsigned long) gprs64, 0, NULL);
+	  ptrace64aix (PTT_READ_GPRS, tid, (long long) gprs64, 0, NULL);
 	  fill_gprs64 (regcache, gprs64);
-	  ptrace64aix (PTT_WRITE_GPRS, tid, (unsigned long) gprs64, 0, NULL);
+	  ptrace64aix (PTT_WRITE_GPRS, tid, (long long) gprs64, 0, NULL);
 	}
       else
 	{
 	  /* Pre-fetch: some regs may not be in the cache.  */
-	  ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_READ_GPRS, tid, (long long)gprs32, 0, NULL);
 	  fill_gprs32 (regcache, gprs32);
-	  ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_GPRS, tid, (long long)gprs32, 0, NULL);
 	}
     }
 
@@ -1582,9 +1582,9 @@
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
       /* Pre-fetch: some regs may not be in the cache.  */
-      ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_READ_FPRS, tid, (long long) fprs, 0, NULL);
       fill_fprs (regcache, fprs);
-      ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (long long) fprs, 0, NULL);
     }
 
   /* Special-purpose registers.  */
@@ -1595,12 +1595,12 @@
 	{
 	  /* Pre-fetch: some registers won't be in the cache.  */
 	  ptrace64aix (PTT_READ_SPRS, tid, 
-		       (unsigned long) &sprs64, 0, NULL);
+		       (long long) &sprs64, 0, NULL);
 	  fill_sprs64 (regcache, &sprs64.pt_iar, &sprs64.pt_msr,
 		       &sprs64.pt_cr, &sprs64.pt_lr, &sprs64.pt_ctr,
 		       &sprs64.pt_xer, &sprs64.pt_fpscr);
 	  ptrace64aix (PTT_WRITE_SPRS, tid, 
-		       (unsigned long) &sprs64, 0, NULL);
+		       (long long) &sprs64, 0, NULL);
 	}
       else
 	{
@@ -1616,7 +1616,7 @@
 	  gdb_assert (sizeof (sprs32.pt_iar) == 4);
 
 	  /* Pre-fetch: some registers won't be in the cache.  */
-	  ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_READ_SPRS, tid, (long long) &sprs32, 0, NULL);
 
 	  fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
 		       &tmp_ctr, &tmp_xer, &tmp_fpscr);
@@ -1635,7 +1635,7 @@
 	      regcache_raw_collect (regcache, tdep->ppc_mq_regnum,
 				    &sprs32.pt_mq);
 
-	  ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (long long) &sprs32, 0, NULL);
 	}
     }
 }
--- ./gdb/inf-ptrace.c_orig	2011-11-10 18:34:21.370609164 +0530
+++ ./gdb/inf-ptrace.c	2011-11-10 18:34:17.945627633 +0530
@@ -49,9 +49,9 @@
 
   pid = ptid_get_pid (inferior_ptid);
 
-  if (ptrace (PT_GET_PROCESS_STATE, pid,
-	       (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
-    perror_with_name (("ptrace"));
+  if (ptrace64 (PT_GET_PROCESS_STATE, (long long)pid,
+	       (long long)&pe, sizeof pe, 0) == -1)
+    perror_with_name (("ptrace64"));
 
   gdb_assert (pe.pe_report_event == PTRACE_FORK);
   fpid = pe.pe_other_pid;
@@ -74,8 +74,8 @@
 	 it.  */
       remove_breakpoints ();
 
-      if (ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
-	perror_with_name (("ptrace"));
+      if (ptrace64 (PT_DETACH, (long long)pid, (long long)1, 0, 0) == -1)
+	perror_with_name (("ptrace64"));
 
       /* Switch inferior_ptid out of the parent's way.  */
       inferior_ptid = pid_to_ptid (fpid);
@@ -90,8 +90,8 @@
       /* Breakpoints have already been detached from the child by
 	 infrun.c.  */
 
-      if (ptrace (PT_DETACH, fpid, (PTRACE_TYPE_ARG3)1, 0) == -1)
-	perror_with_name (("ptrace"));
+      if (ptrace64 (PT_DETACH, (long long)fpid, (long long)1, 0, 0) == -1)
+	perror_with_name (("ptrace64"));
     }
 
   return 0;
@@ -106,7 +106,7 @@
 inf_ptrace_me (void)
 {
   /* "Trace me, Dr. Memory!"  */
-  ptrace (PT_TRACE_ME, 0, (PTRACE_TYPE_ARG3)0, 0);
+  ptrace64 (PT_TRACE_ME, (long long)0, (long long)0, 0, 0);
 }
 
 /* Start a new inferior Unix child process.  EXEC_FILE is the file to
@@ -159,9 +159,9 @@
   /* Set the initial event mask.  */
   memset (&pe, 0, sizeof pe);
   pe.pe_set_event |= PTRACE_FORK;
-  if (ptrace (PT_SET_EVENT_MASK, ptid_get_pid (pid),
-	      (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
-    perror_with_name (("ptrace"));
+  if (ptrace64 (PT_SET_EVENT_MASK, (long long) ptid_get_pid (pid),
+	      (long long)&pe, sizeof pe, 0) == -1)
+    perror_with_name (("ptrace64"));
 }
 
 #endif
@@ -229,9 +229,9 @@
 
 #ifdef PT_ATTACH
   errno = 0;
-  ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3)0, 0);
+  ptrace64 (PT_ATTACH, (long long)pid, (long long)0, 0, 0);
   if (errno != 0)
-    perror_with_name (("ptrace"));
+    perror_with_name (("ptrace64"));
 #else
   error (_("This system does not support attaching to a process"));
 #endif
@@ -259,9 +259,9 @@
   /* Set the initial event mask.  */
   memset (&pe, 0, sizeof pe);
   pe.pe_set_event |= PTRACE_FORK;
-  if (ptrace (PT_SET_EVENT_MASK, pid,
-	      (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
-    perror_with_name (("ptrace"));
+  if (ptrace64 (PT_SET_EVENT_MASK, (long long)pid,
+	      (long long)&pe, sizeof pe, 0) == -1)
+    perror_with_name (("ptrace64"));
 }
 
 #endif
@@ -293,9 +293,9 @@
      previously attached to the inferior.  It *might* work if we
      started the process ourselves.  */
   errno = 0;
-  ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, sig);
+  ptrace64 (PT_DETACH, (long long) pid, (long long)1, sig, 0);
   if (errno != 0)
-    perror_with_name (("ptrace"));
+    perror_with_name (("ptrace64"));
 #else
   error (_("This system does not support detaching from a process"));
 #endif
@@ -318,7 +318,7 @@
   if (pid == 0)
     return;
 
-  ptrace (PT_KILL, pid, (PTRACE_TYPE_ARG3)0, 0);
+  ptrace64 (PT_KILL, (long long)pid, (long long)0, 0, 0);
   waitpid (pid, &status, 0);
 
   target_mourn_inferior ();
@@ -368,13 +368,13 @@
       request = PT_STEP;
     }
 
-  /* An address of (PTRACE_TYPE_ARG3)1 tells ptrace to continue from
+  /* An address of (long long)1 tells ptrace to continue from
      where it was.  If GDB wanted it to start some other way, we have
      already written a new program counter value to the child.  */
   errno = 0;
-  ptrace (request, pid, (PTRACE_TYPE_ARG3)1, target_signal_to_host (signal));
+  ptrace64 (request, (long long)pid, (long long)1, target_signal_to_host (signal), 0);
   if (errno != 0)
-    perror_with_name (("ptrace"));
+    perror_with_name (("ptrace64"));
 }
 
 /* Wait for the child specified by PTID to do something.  Return the
@@ -425,9 +425,9 @@
       ptrace_state_t pe;
       pid_t fpid;
 
-      if (ptrace (PT_GET_PROCESS_STATE, pid,
-		  (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
-	perror_with_name (("ptrace"));
+      if (ptrace64 (PT_GET_PROCESS_STATE, (long long)pid,
+		  (long long)&pe, sizeof pe, 0) == -1)
+	perror_with_name (("ptrace64"));
 
       switch (pe.pe_report_event)
 	{
@@ -440,9 +440,9 @@
 	  if (fpid == -1)
 	    perror_with_name (("waitpid"));
 
-	  if (ptrace (PT_GET_PROCESS_STATE, fpid,
-		      (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
-	    perror_with_name (("ptrace"));
+	  if (ptrace64 (PT_GET_PROCESS_STATE, (long long)fpid,
+		      (long long)&pe, sizeof pe, 0) == -1)
+	    perror_with_name (("ptrace64"));
 
 	  gdb_assert (pe.pe_report_event == PTRACE_FORK);
 	  gdb_assert (pe.pe_other_pid == pid);
@@ -495,7 +495,7 @@
 	piod.piod_len = len;
 
 	errno = 0;
-	if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0)
+	if (ptrace64 (PT_IO, (long long)pid, (long long)&piod, 0, 0) == 0)
 	  /* Return the actual number of bytes read or written.  */
 	  return piod.piod_len;
 	/* If the PT_IO request is somehow not supported, fallback on
@@ -536,9 +536,9 @@
 		|| (offset + partial_len
 		    < rounded_offset + sizeof (PTRACE_TYPE_RET)))
 	      /* Need part of initial word -- fetch it.  */
-	      buffer.word = ptrace (PT_READ_I, pid,
-				    (PTRACE_TYPE_ARG3)(uintptr_t)
-				    rounded_offset, 0);
+	      buffer.word = ptrace64 (PT_READ_I, (long long)pid,
+				    (long long)
+				    rounded_offset, 0, 0);
 
 	    /* Copy data to be written over corresponding part of
 	       buffer.  */
@@ -546,17 +546,17 @@
 		    writebuf, partial_len);
 
 	    errno = 0;
-	    ptrace (PT_WRITE_D, pid,
-		    (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset,
-		    buffer.word);
+	    ptrace64 (PT_WRITE_D, (long long)pid,
+		    (long long)rounded_offset,
+		    buffer.word, 0);
 	    if (errno)
 	      {
 		/* Using the appropriate one (I or D) is necessary for
 		   Gould NP1, at least.  */
 		errno = 0;
-		ptrace (PT_WRITE_I, pid,
-			(PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset,
-			buffer.word);
+		ptrace64 (PT_WRITE_I, (long long)pid,
+			(long long)(uintptr_t)rounded_offset,
+			buffer.word, 0);
 		if (errno)
 		  return 0;
 	      }
@@ -565,9 +565,9 @@
 	if (readbuf)
 	  {
 	    errno = 0;
-	    buffer.word = ptrace (PT_READ_I, pid,
-				  (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset,
-				  0);
+	    buffer.word = ptrace64 (PT_READ_I, (long long)pid,
+				  (long long)rounded_offset,
+				  0, 0);
 	    if (errno)
 	      return 0;
 	    /* Copy appropriate bytes out of the buffer.  */
@@ -687,7 +687,7 @@
   for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
     {
       errno = 0;
-      buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)(uintptr_t)addr, 0);
+      buf[i] = ptrace64 (PT_READ_U, (long long)pid, (long long)addr, 0, 0);
       if (errno != 0)
 	error (_("Couldn't read register %s (#%d): %s."),
 	       gdbarch_register_name (gdbarch, regnum),
@@ -746,7 +746,7 @@
   for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
     {
       errno = 0;
-      ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)(uintptr_t)addr, buf[i]);
+      ptrace64 (PT_WRITE_U, (long long)pid, (long long)addr, buf[i], 0);
       if (errno != 0)
 	error (_("Couldn't write register %s (#%d): %s."),
 	       gdbarch_register_name (gdbarch, regnum),
--- ./gdb/rs6000-nat.c_orig	2011-11-10 18:52:53.185607203 +0530
+++ ./gdb/rs6000-nat.c	2011-11-10 18:52:55.901816523 +0530
@@ -58,6 +58,7 @@
 #define __LDINFO_PTRACE64__	/* for __ld_info64 */
 #include <sys/ldr.h>
 #include <sys/systemcfg.h>
+#include <sys/ptrace.h>
 
 /* On AIX4.3+, sys/ldr.h provides different versions of struct ld_info for
    debugging 32-bit and 64-bit processes.  Define a typedef and macros for
@@ -66,7 +67,7 @@
 /* In 32-bit compilation mode (which is the only mode from which ptrace()
    works on 4.3), __ld_info32 is #defined as equivalent to ld_info.  */
 
-#ifdef __ld_info32
+#ifdef __ld_info64
 # define ARCH3264
 #endif
 
@@ -181,7 +182,7 @@
 static int
 rs6000_ptrace32 (int req, int id, int *addr, int data, int *buf)
 {
-  int ret = ptrace (req, id, (int *)addr, data, buf);
+  int ret = ptrace64 (req, (long long)id, (long long)addr, data, buf);
 #if 0
   printf ("rs6000_ptrace32 (%d, %d, 0x%x, %08x, 0x%x) = 0x%x\n",
 	  req, id, (unsigned int)addr, data, (unsigned int)buf, ret);
@@ -195,7 +196,7 @@
 rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf)
 {
 #ifdef ARCH3264
-  int ret = ptracex (req, id, addr, data, buf);
+  int ret = ptrace64 (req, (long long)id, addr, data, (int *)buf);
 #else
   int ret = 0;
 #endif
--- ./gdb/xcoffread.c_orig	2011-11-10 18:53:25.477609993 +0530
+++ ./gdb/xcoffread.c	2011-11-10 18:53:30.793606371 +0530
@@ -956,7 +956,7 @@
   unsigned int max_symnum;
   int just_started = 1;
   int depth = 0;
-  int fcn_start_addr = 0;
+  file_ptr fcn_start_addr = 0;
 
   struct coff_symbol fcn_stab_saved = { 0 };
 
