From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2096 invoked by alias); 15 Jul 2013 07:32:19 -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 2067 invoked by uid 89); 15 Jul 2013 07:32:18 -0000 X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL,BAYES_20,KHOP_THREADED,RCVD_IN_DNSWL_MED,RDNS_NONE,SPF_PASS autolearn=ham version=3.3.1 Received: from Unknown (HELO e28smtp09.in.ibm.com) (122.248.162.9) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 15 Jul 2013 07:32:15 +0000 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jul 2013 12:56:59 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp09.in.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 Jul 2013 12:56:56 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id BA703E0053 for ; Mon, 15 Jul 2013 13:01:53 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6F7WgeK24444958 for ; Mon, 15 Jul 2013 13:02:42 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r6F7VxI9004180 for ; Mon, 15 Jul 2013 17:32:00 +1000 Received: from d23ml188.in.ibm.com (d23ml188.in.ibm.com [9.182.8.144]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r6F7VxR0004154; Mon, 15 Jul 2013 17:31:59 +1000 In-Reply-To: <201307101907.r6AJ7AfX021641@glazunov.sibelius.xs4all.nl> References: <87r4f6fgst.fsf@fleche.redhat.com> <201307101907.r6AJ7AfX021641@glazunov.sibelius.xs4all.nl> Subject: Re: [PATCH 3/5] powerpc64-aix inf-ptrace patch X-KeepSent: A7DBDA74:2B3E3B73-65257BA9:00293949; type=4; name=$KeepSent To: Mark Kettenis Cc: gdb-patches@sourceware.org, tromey@redhat.com Message-ID: From: Raunaq 12 Date: Mon, 15 Jul 2013 07:32: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: 13071507-2674-0000-0000-000009CCC5DE X-SW-Source: 2013-07/txt/msg00340.txt.bz2 Hi Mark/Tom, Thanks for the feedback. I removed the newly added file and instead used a wrapper function and macros. Kindly review the patch below and let me know if this should be okay ? --- ChangeLog :- * inf-ptrace.c: Add support for ptrace64 in 64 BIT mode (inf_ptrace_follow_fork): Likewise (inf_ptrace_me): Likewise (inf_ptrace_post_startup_inferior): Likewise (inf_ptrace_attach): Likewise (inf_ptrace_post_attach): Likewise (inf_ptrace_detach): Likewise (inf_ptrace_kill): Likewise (inf_ptrace_resume): Likewise (inf_ptrace_wait): Likewise (inf_ptrace_xfer_partial): Likewise (inf_ptrace_fetch_register): Likewise (inf_ptrace_store_register): Likewise (inf_ptrace_fetch_register): Likewise * rs6000-nat.c: Check for __ld_info64 if compiling 64 BIT gdb. (rs6000_ptrace32): Added ptrace64 support for 64 bit mode. (rs6000_ptrace64): Likewise. * gdb_ptrace.h: Add macro for ptrace64 call. --- Index: ./gdb/inf-ptrace.c =================================================================== --- ./gdb/inf-ptrace.c +++ ./gdb/inf-ptrace.c @@ -36,6 +36,17 @@ #include "gdbthread.h" ^L +#ifdef BFD64 +#define check_ptrace ptrace64 +#define addr_ptr long long +#define pid_type long long +#define addr_uintptr_t long long +#else +#define check_ptrace ptrace +#define addr_ptr PTRACE_TYPE_ARG3 +#define pid_type int +#define addr_uintptr_t uintptr_t +#endif #ifdef PT_GET_PROCESS_STATE @@ -47,8 +58,8 @@ pid = ptid_get_pid (inferior_ptid); - if (ptrace (PT_GET_PROCESS_STATE, pid, - (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1) + if (check_ptrace (PT_GET_PROCESS_STATE, (pid_type) pid, + (addr_ptr)&pe, sizeof pe) == -1) perror_with_name (("ptrace")); gdb_assert (pe.pe_report_event == PTRACE_FORK); @@ -72,7 +83,7 @@ it. */ remove_breakpoints (); - if (ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, 0) == -1) + if (check_ptrace (PT_DETACH, (pid_type) pid, (addr_ptr)1, 0) == -1) perror_with_name (("ptrace")); /* Switch inferior_ptid out of the parent's way. */ @@ -88,7 +99,7 @@ /* Breakpoints have already been detached from the child by infrun.c. */ - if (ptrace (PT_DETACH, fpid, (PTRACE_TYPE_ARG3)1, 0) == -1) + if (check_ptrace (PT_DETACH, (pid_type) fpid, (addr_ptr)1, 0) == -1) perror_with_name (("ptrace")); } @@ -104,7 +115,7 @@ inf_ptrace_me (void) { /* "Trace me, Dr. Memory!" */ - ptrace (PT_TRACE_ME, 0, (PTRACE_TYPE_ARG3)0, 0); + check_ptrace (PT_TRACE_ME, (pid_type) 0, (addr_ptr)0, 0); } /* Start a new inferior Unix child process. EXEC_FILE is the file to @@ -156,8 +167,8 @@ /* 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) + if (check_ptrace (PT_SET_EVENT_MASK, (pid_type) ptid_get_pid (pid), + (addr_ptr)&pe, sizeof pe) == -1) perror_with_name (("ptrace")); } @@ -226,7 +237,7 @@ #ifdef PT_ATTACH errno = 0; - ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3)0, 0); + check_ptrace (PT_ATTACH, (pid_type)pid, (addr_ptr)0, 0); if (errno != 0) perror_with_name (("ptrace")); #else @@ -255,8 +266,8 @@ /* 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) + if (check_ptrace (PT_SET_EVENT_MASK, (pid_type)pid, + (addr_ptr)&pe, sizeof pe) == -1) perror_with_name (("ptrace")); } @@ -289,7 +300,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); + check_ptrace (PT_DETACH, (pid_type)pid, (addr_ptr)1, sig); if (errno != 0) perror_with_name (("ptrace")); #else @@ -314,7 +325,7 @@ if (pid == 0) return; - ptrace (PT_KILL, pid, (PTRACE_TYPE_ARG3)0, 0); + check_ptrace (PT_KILL, (pid_type)pid, (addr_ptr)0, 0); waitpid (pid, &status, 0); target_mourn_inferior (); @@ -368,7 +379,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)); + check_ptrace (request, (pid_type)pid, (addr_ptr)1, gdb_signal_to_host (signal)); if (errno != 0) perror_with_name (("ptrace")); } @@ -421,8 +432,8 @@ ptrace_state_t pe; pid_t fpid; - if (ptrace (PT_GET_PROCESS_STATE, pid, - (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1) + if (check_ptrace (PT_GET_PROCESS_STATE, (pid_type)pid, + (addr_ptr)&pe, sizeof pe) == -1) perror_with_name (("ptrace")); switch (pe.pe_report_event) @@ -436,8 +447,8 @@ if (fpid == -1) perror_with_name (("waitpid")); - if (ptrace (PT_GET_PROCESS_STATE, fpid, - (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1) + if (check_ptrace (PT_GET_PROCESS_STATE, (pid_type)fpid, + (addr_ptr)&pe, sizeof pe) == -1) perror_with_name (("ptrace")); gdb_assert (pe.pe_report_event == PTRACE_FORK); @@ -491,7 +502,7 @@ piod.piod_len = len; errno = 0; - if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0) + if (check_ptrace (PT_IO, (pid_type)pid, (addr_ptr)&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 @@ -532,8 +543,8 @@ || (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) + buffer.word = check_ptrace (PT_READ_I, (pid_type)pid, + (addr_ptr)(addr_uintptr_t) rounded_offset, 0); /* Copy data to be written over corresponding part of @@ -542,16 +553,16 @@ writebuf, partial_len); errno = 0; - ptrace (PT_WRITE_D, pid, - (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset, + check_ptrace (PT_WRITE_D, (pid_type)pid, + (addr_ptr)(addr_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, + check_ptrace (PT_WRITE_I, (pid_type)pid, + (addr_ptr)(addr_uintptr_t)rounded_offset, buffer.word); if (errno) return 0; @@ -561,8 +572,8 @@ if (readbuf) { errno = 0; - buffer.word = ptrace (PT_READ_I, pid, - (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset, + buffer.word = check_ptrace (PT_READ_I, (pid_type)pid, + (addr_ptr)(addr_uintptr_t)rounded_offset, 0); if (errno) return 0; @@ -593,7 +604,7 @@ piod.piod_len = len; errno = 0; - if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0) + if (check_ptrace (PT_IO, (pid_type)pid, (addr_ptr)&piod, 0) == 0) /* Return the actual number of bytes read or written. */ return piod.piod_len; } @@ -741,7 +752,8 @@ 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] = check_ptrace (PT_READ_U, pid, + (addr_ptr)(addr_uintptr_t)addr, 0); if (errno != 0) error (_("Couldn't read register %s (#%d): %s."), gdbarch_register_name (gdbarch, regnum), @@ -800,7 +812,8 @@ 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]); + check_ptrace (PT_WRITE_U, (pid_type)pid, + (addr_ptr)(addr_uintptr_t)addr, buf[i]); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), gdbarch_register_name (gdbarch, regnum), Index: ./gdb/gdb_ptrace.h =================================================================== --- ./gdb.orig/gdb_ptrace.h +++ ./gdb/gdb_ptrace.h @@ -136,6 +136,8 @@ extern PTRACE_TYPE_RET ptrace(); #ifdef PTRACE_TYPE_ARG5 # define ptrace(request, pid, addr, data) ptrace (request, pid, addr, data, 0) +# define ptrace64(request, pid, addr, data) ptrace64 (request, pid, addr, data, 0) + #endif #endif /* gdb_ptrace.h */ 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