From: Raunaq 12 <raunaq12@in.ibm.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sourceware.org, tromey@redhat.com
Subject: Re: [PATCH 3/5] powerpc64-aix inf-ptrace patch
Date: Mon, 15 Jul 2013 07:32:00 -0000 [thread overview]
Message-ID: <OFA7DBDA74.2B3E3B73-ON65257BA9.00293949-65257BA9.00295CCB@in.ibm.com> (raw)
In-Reply-To: <201307101907.r6AJ7AfX021641@glazunov.sibelius.xs4all.nl>
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
next prev parent reply other threads:[~2013-07-15 7:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-10 9:15 Raunaq 12
2013-07-10 17:47 ` Tom Tromey
2013-07-10 19:07 ` Mark Kettenis
2013-07-15 7:32 ` Raunaq 12 [this message]
2013-07-15 9:12 ` Mark Kettenis
2013-07-16 10:48 ` Raunaq 12
2013-07-23 5:35 Raunaq 12
2013-07-23 9:01 ` Mark Kettenis
2013-07-23 12:57 ` Raunaq 12
2013-07-23 14:25 ` Mark Kettenis
2013-07-23 19:40 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=OFA7DBDA74.2B3E3B73-ON65257BA9.00293949-65257BA9.00295CCB@in.ibm.com \
--to=raunaq12@in.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=mark.kettenis@xs4all.nl \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox