Index: gdb/inf-ptrace.c |
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c |
index aa6dcf4c06b109b9afbf0ad9169286db48b5dc98..e6729ac5679c05ca1b5484b28528c6c86367347a 100644 |
--- a/gdb/inf-ptrace.c |
+++ b/gdb/inf-ptrace.c |
@@ -250,7 +250,7 @@ inf_ptrace_attach (struct target_ops *ops, char *args, int from_tty) |
#ifdef PT_GET_PROCESS_STATE |
-void |
+static void |
inf_ptrace_post_attach (int pid) |
{ |
ptrace_event_t pe; |
@@ -342,7 +342,7 @@ inf_ptrace_stop (ptid_t ptid) |
static void |
inf_ptrace_resume (struct target_ops *ops, |
- ptid_t ptid, int step, enum target_signal signal) |
+ ptid_t ptid, int step, enum gdb_signal signal) |
{ |
pid_t pid = ptid_get_pid (ptid); |
int request; |
@@ -371,7 +371,7 @@ inf_ptrace_resume (struct target_ops *ops, |
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)); |
+ ptrace (request, pid, (PTRACE_TYPE_ARG3)1, gdb_signal_to_host (signal)); |
if (errno != 0) |
perror_with_name (("ptrace")); |
} |
@@ -408,7 +408,7 @@ inf_ptrace_wait (struct target_ops *ops, |
/* Claim it exited with unknown signal. */ |
ourstatus->kind = TARGET_WAITKIND_SIGNALLED; |
- ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN; |
+ ourstatus->value.sig = GDB_SIGNAL_UNKNOWN; |
return inferior_ptid; |
} |
@@ -581,6 +581,26 @@ inf_ptrace_xfer_partial (struct target_ops *ops, enum target_object object, |
return -1; |
case TARGET_OBJECT_AUXV: |
+#if defined (PT_IO) && defined (PIOD_READ_AUXV) |
+ /* OpenBSD 4.5 has a new PIOD_READ_AUXV operation for the PT_IO |
+ request that allows us to read the auxilliary vector. Other |
+ BSD's may follow if they feel the need to support PIE. */ |
+ { |
+ struct ptrace_io_desc piod; |
+ |
+ if (writebuf) |
+ return -1; |
+ piod.piod_op = PIOD_READ_AUXV; |
+ piod.piod_addr = readbuf; |
+ piod.piod_offs = (void *) (long) offset; |
+ piod.piod_len = len; |
+ |
+ errno = 0; |
+ if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0) |
+ /* Return the actual number of bytes read or written. */ |
+ return piod.piod_len; |
+ } |
+#endif |
return -1; |
case TARGET_OBJECT_WCOOKIE: |
@@ -618,6 +638,41 @@ inf_ptrace_pid_to_str (struct target_ops *ops, ptid_t ptid) |
return normal_pid_to_str (ptid); |
} |
+#if defined (PT_IO) && defined (PIOD_READ_AUXV) |
+ |
+/* Read one auxv entry from *READPTR, not reading locations >= ENDPTR. |
+ Return 0 if *READPTR is already at the end of the buffer. |
+ Return -1 if there is insufficient buffer for a whole entry. |
+ Return 1 if an entry was read into *TYPEP and *VALP. */ |
+ |
+static int |
+inf_ptrace_auxv_parse (struct target_ops *ops, gdb_byte **readptr, |
+ gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) |
+{ |
+ struct type *int_type = builtin_type (target_gdbarch)->builtin_int; |
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; |
+ const int sizeof_auxv_type = TYPE_LENGTH (int_type); |
+ const int sizeof_auxv_val = TYPE_LENGTH (ptr_type); |
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch); |
+ gdb_byte *ptr = *readptr; |
+ |
+ if (endptr == ptr) |
+ return 0; |
+ |
+ if (endptr - ptr < 2 * sizeof_auxv_val) |
+ return -1; |
+ |
+ *typep = extract_unsigned_integer (ptr, sizeof_auxv_type, byte_order); |
+ ptr += sizeof_auxv_val; /* Alignment. */ |
+ *valp = extract_unsigned_integer (ptr, sizeof_auxv_val, byte_order); |
+ ptr += sizeof_auxv_val; |
+ |
+ *readptr = ptr; |
+ return 1; |
+} |
+ |
+#endif |
+ |
/* Create a prototype ptrace target. The client can override it with |
local methods. */ |
@@ -643,6 +698,9 @@ inf_ptrace_target (void) |
t->to_pid_to_str = inf_ptrace_pid_to_str; |
t->to_stop = inf_ptrace_stop; |
t->to_xfer_partial = inf_ptrace_xfer_partial; |
+#if defined (PT_IO) && defined (PIOD_READ_AUXV) |
+ t->to_auxv_parse = inf_ptrace_auxv_parse; |
+#endif |
return t; |
} |