aboutsummaryrefslogtreecommitdiff
path: root/gdb/inf-ptrace.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2004-09-30 16:46:40 +0000
committerAndrew Cagney <cagney@redhat.com>2004-09-30 16:46:40 +0000
commit56157dbefc9f44aa294e92b773224141aeef6237 (patch)
treed705a73fdfd4daff174ceffc6bee581c0a6e3e40 /gdb/inf-ptrace.c
parent7479dfd4deee7e65f5a9f89bfdd027a213172c42 (diff)
downloadgdb-56157dbefc9f44aa294e92b773224141aeef6237.zip
gdb-56157dbefc9f44aa294e92b773224141aeef6237.tar.gz
gdb-56157dbefc9f44aa294e92b773224141aeef6237.tar.bz2
Really delete inf_ptrace_xfer_memory!
Diffstat (limited to 'gdb/inf-ptrace.c')
-rw-r--r--gdb/inf-ptrace.c139
1 files changed, 0 insertions, 139 deletions
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 8754af7..4a37d39 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -95,145 +95,6 @@ inf_ptrace_resume (ptid_t ptid, int step, enum target_signal signal)
perror_with_name ("ptrace");
}
-/* Set an upper limit on alloca. */
-#define GDB_MAX_ALLOCA 0x1000
-
-/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory
- in the NEW_SUN_PTRACE case. It ought to be straightforward. But
- it appears that writing did not write the data that I specified. I
- cannot understand where it got the data that it actually did
- write. */
-
-/* Copy LEN bytes to or from inferior's memory starting at MEMADDR to
- debugger memory starting at MYADDR. Copy to inferior if WRITE is
- nonzero. TARGET is ignored.
-
- Returns the length copied, which is either the LEN argument or
- zero. This xfer function does not do partial moves, since
- ptrace_ops_hack doesn't allow memory operations to cross below us in the
- target stack anyway. */
-
-int
-inf_ptrace_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
- struct mem_attrib *attrib, struct target_ops *target)
-{
- int i;
- /* Round starting address down to longword boundary. */
- CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_TYPE_RET);
- /* Round ending address up; get number of longwords that makes. */
- int count = ((((memaddr + len) - addr) + sizeof (PTRACE_TYPE_RET) - 1)
- / sizeof (PTRACE_TYPE_RET));
- int alloc = count * sizeof (PTRACE_TYPE_RET);
- PTRACE_TYPE_RET *buffer;
- struct cleanup *old_chain = NULL;
-
-#ifdef PT_IO
- /* OpenBSD 3.1, NetBSD 1.6 and FreeBSD 5.0 have a new PT_IO request
- that promises to be much more efficient in reading and writing
- data in the traced process's address space. */
-
- {
- struct ptrace_io_desc piod;
-
- /* NOTE: We assume that there are no distinct address spaces for
- instruction and data. */
- piod.piod_op = write ? PIOD_WRITE_D : PIOD_READ_D;
- piod.piod_offs = (void *) memaddr;
- piod.piod_addr = myaddr;
- piod.piod_len = len;
-
- if (ptrace (PT_IO, PIDGET (inferior_ptid), (caddr_t) &piod, 0) == -1)
- {
- /* If the PT_IO request is somehow not supported, fallback on
- using PT_WRITE_D/PT_READ_D. Otherwise we will return zero
- to indicate failure. */
- if (errno != EINVAL)
- return 0;
- }
- else
- {
- /* Return the actual number of bytes read or written. */
- return piod.piod_len;
- }
- }
-#endif
-
- /* Allocate buffer of that many longwords. */
- if (len < GDB_MAX_ALLOCA)
- {
- buffer = (PTRACE_TYPE_RET *) alloca (alloc);
- }
- else
- {
- buffer = (PTRACE_TYPE_RET *) xmalloc (alloc);
- old_chain = make_cleanup (xfree, buffer);
- }
-
- if (write)
- {
- /* Fill start and end extra bytes of buffer with existing memory
- data. */
- if (addr != memaddr || len < (int) sizeof (PTRACE_TYPE_RET))
- {
- /* Need part of initial word -- fetch it. */
- buffer[0] = ptrace (PT_READ_I, PIDGET (inferior_ptid),
- (PTRACE_TYPE_ARG3) addr, 0);
- }
-
- if (count > 1) /* FIXME, avoid if even boundary. */
- {
- buffer[count - 1] =
- ptrace (PT_READ_I, PIDGET (inferior_ptid),
- ((PTRACE_TYPE_ARG3)
- (addr + (count - 1) * sizeof (PTRACE_TYPE_RET))), 0);
- }
-
- /* Copy data to be written over corresponding part of buffer. */
- memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_TYPE_RET) - 1)),
- myaddr, len);
-
- /* Write the entire buffer. */
- for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
- {
- errno = 0;
- ptrace (PT_WRITE_D, PIDGET (inferior_ptid),
- (PTRACE_TYPE_ARG3) addr, buffer[i]);
- if (errno)
- {
- /* Using the appropriate one (I or D) is necessary for
- Gould NP1, at least. */
- errno = 0;
- ptrace (PT_WRITE_I, PIDGET (inferior_ptid),
- (PTRACE_TYPE_ARG3) addr, buffer[i]);
- }
- if (errno)
- return 0;
- }
- }
- else
- {
- /* Read all the longwords. */
- for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
- {
- errno = 0;
- buffer[i] = ptrace (PT_READ_I, PIDGET (inferior_ptid),
- (PTRACE_TYPE_ARG3) addr, 0);
- if (errno)
- return 0;
- QUIT;
- }
-
- /* Copy appropriate bytes out of the buffer. */
- memcpy (myaddr,
- (char *) buffer + (memaddr & (sizeof (PTRACE_TYPE_RET) - 1)),
- len);
- }
-
- if (old_chain != NULL)
- do_cleanups (old_chain);
- return len;
-}
-
/* Wait for child to do something. Return pid of child, or -1 in case
of error; store status through argument pointer OURSTATUS. */