From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13344 invoked by alias); 23 Jul 2013 05:35:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 13334 invoked by uid 89); 23 Jul 2013 05:35:47 -0000 X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_MED,RCVD_IN_HOSTKARMA_W,RDNS_NONE,SPF_PASS autolearn=ham version=3.3.1 Received: from Unknown (HELO e28smtp04.in.ibm.com) (122.248.162.4) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 23 Jul 2013 05:35:45 +0000 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 23 Jul 2013 10:58:29 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 23 Jul 2013 10:58:27 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 78501394002D for ; Tue, 23 Jul 2013 11:05:26 +0530 (IST) Received: from d28av06.in.ibm.com (d28av06.in.ibm.com [9.184.220.48]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6N5aMp141418896 for ; Tue, 23 Jul 2013 11:06:22 +0530 Received: from d28av06.in.ibm.com (loopback [127.0.0.1]) by d28av06.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r6N5ZUlD023868 for ; Tue, 23 Jul 2013 11:05:31 +0530 Received: from d23ml188.in.ibm.com (d23ml188.in.ibm.com [9.182.8.144]) by d28av06.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r6N5ZU0E023865; Tue, 23 Jul 2013 11:05:30 +0530 Subject: Re: [PATCH 3/5] powerpc64-aix inf-ptrace patch X-KeepSent: 8903680D:BD89C8FA-65257BB1:001EA3F4; type=4; name=$KeepSent To: gdb-patches@sourceware.org Cc: Mark Kettenis , tromey@redhat.com Message-ID: From: Raunaq 12 Date: Tue, 23 Jul 2013 05:35:00 -0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13072305-5564-0000-0000-000008EACF99 X-SW-Source: 2013-07/txt/msg00520.txt.bz2 I have restricted the macro definitions to only gdb_ptrace.h. Something like this as seen below - #ifdef PTRACE_TYPE_ARG5 # ifdef BFD64 # define ptrace(request, pid, addr, data) \ ptrace64 (request, (long long)pid, (long long)addr, data, 0) # else # define ptrace(request, pid, addr, data) \ ptrace(request, (int)pid, (PTRACE_TYPE_ARG3)addr, data, 0) # endif #endif I have type cast pid here to avoid additional compiler warnings. > So unless I'm missing something, you should not need to make any > changes to inf-ptrace.c itself. But, inf-ptrace.c makes ptrace calls as seen below - ptrace (PT_DETACH, fpid, (PTRACE_TYPE_ARG3)1, 0) If I make the macro definitions in gdb_ptrace.h as seen above, then the casts for the 'Address'(3rd parameter in ptrace call) should be removed from ptrace calls in inf-ptrace.c as seen below - ptrace (PT_DETACH, fpid, 1, 0) The macro is taking care of all the type casts. ptrace64() accepts (long long) as the address parameter while ptrace() accepts int* or any integer pointer as the type for address. So, this type cast is necessary. Agree that pid cast is not needed. Here is the modified patch below - --- Index: ./gdb/gdb_ptrace.h =================================================================== --- ./gdb.orig/gdb_ptrace.h +++ ./gdb/gdb_ptrace.h @@ -135,7 +135,13 @@ zero. */ #ifdef PTRACE_TYPE_ARG5 -# define ptrace(request, pid, addr, data) ptrace (request, pid, addr, data, 0) +# ifdef BFD64 +# define ptrace(request, pid, addr, data) \ + ptrace64 (request, (long long)pid, (long long)addr, data, 0) +# else +# define ptrace(request, pid, addr, data) \ + ptrace(request, (int)pid, (PTRACE_TYPE_ARG3)addr, data, 0) +# endif #endif #endif /* gdb_ptrace.h */ Index: ./gdb/inf-ptrace.c =================================================================== --- ./gdb.orig/inf-ptrace.c +++ ./gdb/inf-ptrace.c @@ -48,7 +48,7 @@ pid = ptid_get_pid (inferior_ptid); if (ptrace (PT_GET_PROCESS_STATE, pid, - (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1) + &pe, sizeof pe) == -1) perror_with_name (("ptrace")); gdb_assert (pe.pe_report_event == PTRACE_FORK); @@ -72,7 +72,7 @@ it. */ remove_breakpoints (); - if (ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, 0) == -1) + if (ptrace (PT_DETACH, pid, 1, 0) == -1) perror_with_name (("ptrace")); /* Switch inferior_ptid out of the parent's way. */ @@ -88,7 +88,7 @@ /* Breakpoints have already been detached from the child by infrun.c. */ - if (ptrace (PT_DETACH, fpid, (PTRACE_TYPE_ARG3)1, 0) == -1) + if (ptrace (PT_DETACH, fpid, 1, 0) == -1) perror_with_name (("ptrace")); } @@ -104,7 +104,7 @@ inf_ptrace_me (void) { /* "Trace me, Dr. Memory!" */ - ptrace (PT_TRACE_ME, 0, (PTRACE_TYPE_ARG3)0, 0); + ptrace (PT_TRACE_ME, 0, 0, 0); } /* Start a new inferior Unix child process. EXEC_FILE is the file to @@ -157,7 +157,7 @@ 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) + &pe, sizeof pe) == -1) perror_with_name (("ptrace")); } @@ -226,7 +226,7 @@ #ifdef PT_ATTACH errno = 0; - ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3)0, 0); + ptrace (PT_ATTACH, pid, 0, 0); if (errno != 0) perror_with_name (("ptrace")); #else @@ -256,7 +256,7 @@ 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) + &pe, sizeof pe) == -1) perror_with_name (("ptrace")); } @@ -289,7 +289,7 @@ 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); + ptrace (PT_DETACH, pid, 1, sig); if (errno != 0) perror_with_name (("ptrace")); #else @@ -314,7 +314,7 @@ if (pid == 0) return; - ptrace (PT_KILL, pid, (PTRACE_TYPE_ARG3)0, 0); + ptrace (PT_KILL, pid, 0, 0); waitpid (pid, &status, 0); target_mourn_inferior (); @@ -368,7 +368,7 @@ 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, gdb_signal_to_host (signal)); + ptrace (request, pid, 1, gdb_signal_to_host (signal)); if (errno != 0) perror_with_name (("ptrace")); } @@ -422,7 +422,7 @@ pid_t fpid; if (ptrace (PT_GET_PROCESS_STATE, pid, - (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1) + &pe, sizeof pe) == -1) perror_with_name (("ptrace")); switch (pe.pe_report_event) @@ -437,7 +437,7 @@ perror_with_name (("waitpid")); if (ptrace (PT_GET_PROCESS_STATE, fpid, - (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1) + &pe, sizeof pe) == -1) perror_with_name (("ptrace")); gdb_assert (pe.pe_report_event == PTRACE_FORK); @@ -491,7 +491,7 @@ piod.piod_len = len; errno = 0; - if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0) + if (ptrace (PT_IO, pid, &piod, 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 @@ -533,8 +533,7 @@ < 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); + (uintptr_t)rounded_offset, 0); /* Copy data to be written over corresponding part of buffer. */ @@ -543,16 +542,14 @@ errno = 0; ptrace (PT_WRITE_D, pid, - (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset, - buffer.word); + (uintptr_t)rounded_offset, buffer.word); 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); + (uintptr_t)rounded_offset, buffer.word); if (errno) return 0; } @@ -562,8 +559,7 @@ { errno = 0; buffer.word = ptrace (PT_READ_I, pid, - (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset, - 0); + (uintptr_t)rounded_offset, 0); if (errno) return 0; /* Copy appropriate bytes out of the buffer. */ @@ -593,7 +589,7 @@ piod.piod_len = len; errno = 0; - if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0) + if (ptrace (PT_IO, pid, &piod, 0) == 0) /* Return the actual number of bytes read or written. */ return piod.piod_len; } @@ -741,7 +737,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] = ptrace (PT_READ_U, pid, (uintptr_t)addr, 0); if (errno != 0) error (_("Couldn't read register %s (#%d): %s."), gdbarch_register_name (gdbarch, regnum), @@ -800,7 +796,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]); + ptrace (PT_WRITE_U, pid, (uintptr_t)addr, buf[i]); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), gdbarch_register_name (gdbarch, regnum), Index: ./gdb/rs6000-nat.c =================================================================== --- ./gdb.orig/rs6000-nat.c +++ ./gdb/rs6000-nat.c @@ -66,7 +66,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 +#if defined (__ld_info32) || defined (__ld_info64) # define ARCH3264 #endif @@ -181,7 +181,11 @@ regmap (struct gdbarch *gdbarch, int reg static int rs6000_ptrace32 (int req, int id, int *addr, int data, int *buf) { + #ifdef BFD64 + int ret = ptrace64 (req, (long long) id, (long long) addr, data, buf); + #else int ret = ptrace (req, id, (int *)addr, data, buf); + #endif #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 +199,11 @@ static int rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf) { #ifdef ARCH3264 + #ifdef BFD64 + int ret = ptrace64 (req, (long long) id, addr, data, (int *)buf); + #else int ret = ptracex (req, id, addr, data, buf); + #endif #else int ret = 0; #endif --- Kindly review this and tell me if the changes to inf-ptrace.c are acceptable. Thanks & Regards, Raunaq