1 /* Low-level child interface to ptrace.
3 Copyright (C) 1988-2013 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
28 #include "gdb_assert.h"
29 #include "gdb_string.h"
30 #include "gdb_ptrace.h"
34 #include "inf-ptrace.h"
35 #include "inf-child.h"
36 #include "gdbthread.h"
40 #ifdef PT_GET_PROCESS_STATE
43 inf_ptrace_follow_fork (struct target_ops
*ops
, int follow_child
)
48 pid
= ptid_get_pid (inferior_ptid
);
50 if (ptrace (PT_GET_PROCESS_STATE
, pid
,
51 (PTRACE_TYPE_ARG3
)&pe
, sizeof pe
) == -1)
52 perror_with_name (("ptrace"));
54 gdb_assert (pe
.pe_report_event
== PTRACE_FORK
);
55 fpid
= pe
.pe_other_pid
;
59 struct inferior
*parent_inf
, *child_inf
;
60 struct thread_info
*tp
;
62 parent_inf
= find_inferior_pid (pid
);
65 child_inf
= add_inferior (fpid
);
66 child_inf
->attach_flag
= parent_inf
->attach_flag
;
67 copy_terminal_info (child_inf
, parent_inf
);
68 child_inf
->pspace
= parent_inf
->pspace
;
69 child_inf
->aspace
= parent_inf
->aspace
;
71 /* Before detaching from the parent, remove all breakpoints from
73 remove_breakpoints ();
75 if (ptrace (PT_DETACH
, pid
, (PTRACE_TYPE_ARG3
)1, 0) == -1)
76 perror_with_name (("ptrace"));
78 /* Switch inferior_ptid out of the parent's way. */
79 inferior_ptid
= pid_to_ptid (fpid
);
81 /* Delete the parent. */
82 detach_inferior (pid
);
84 add_thread_silent (inferior_ptid
);
88 /* Breakpoints have already been detached from the child by
91 if (ptrace (PT_DETACH
, fpid
, (PTRACE_TYPE_ARG3
)1, 0) == -1)
92 perror_with_name (("ptrace"));
98 #endif /* PT_GET_PROCESS_STATE */
101 /* Prepare to be traced. */
106 /* "Trace me, Dr. Memory!" */
107 ptrace (PT_TRACE_ME
, 0, (PTRACE_TYPE_ARG3
)0, 0);
110 /* Start a new inferior Unix child process. EXEC_FILE is the file to
111 run, ALLARGS is a string containing the arguments to the program.
112 ENV is the environment vector to pass. If FROM_TTY is non-zero, be
116 inf_ptrace_create_inferior (struct target_ops
*ops
,
117 char *exec_file
, char *allargs
, char **env
,
122 /* Do not change either targets above or the same target if already present.
123 The reason is the target stack is shared across multiple inferiors. */
124 int ops_already_pushed
= target_is_pushed (ops
);
125 struct cleanup
*back_to
= NULL
;
127 if (! ops_already_pushed
)
129 /* Clear possible core file with its process_stratum. */
131 back_to
= make_cleanup_unpush_target (ops
);
134 pid
= fork_inferior (exec_file
, allargs
, env
, inf_ptrace_me
, NULL
,
137 if (! ops_already_pushed
)
138 discard_cleanups (back_to
);
140 /* START_INFERIOR_TRAPS_EXPECTED is defined in inferior.h, and will
141 be 1 or 2 depending on whether we're starting without or with a
143 startup_inferior (START_INFERIOR_TRAPS_EXPECTED
);
145 /* On some targets, there must be some explicit actions taken after
146 the inferior has been started up. */
147 target_post_startup_inferior (pid_to_ptid (pid
));
150 #ifdef PT_GET_PROCESS_STATE
153 inf_ptrace_post_startup_inferior (ptid_t pid
)
157 /* Set the initial event mask. */
158 memset (&pe
, 0, sizeof pe
);
159 pe
.pe_set_event
|= PTRACE_FORK
;
160 if (ptrace (PT_SET_EVENT_MASK
, ptid_get_pid (pid
),
161 (PTRACE_TYPE_ARG3
)&pe
, sizeof pe
) == -1)
162 perror_with_name (("ptrace"));
167 /* Clean up a rotting corpse of an inferior after it died. */
170 inf_ptrace_mourn_inferior (struct target_ops
*ops
)
174 /* Wait just one more time to collect the inferior's exit status.
175 Do not check whether this succeeds though, since we may be
176 dealing with a process that we attached to. Such a process will
177 only report its exit status to its original parent. */
178 waitpid (ptid_get_pid (inferior_ptid
), &status
, 0);
180 generic_mourn_inferior ();
182 if (!have_inferiors ())
186 /* Attach to the process specified by ARGS. If FROM_TTY is non-zero,
187 be chatty about it. */
190 inf_ptrace_attach (struct target_ops
*ops
, char *args
, int from_tty
)
194 struct inferior
*inf
;
196 /* Do not change either targets above or the same target if already present.
197 The reason is the target stack is shared across multiple inferiors. */
198 int ops_already_pushed
= target_is_pushed (ops
);
199 struct cleanup
*back_to
= NULL
;
201 pid
= parse_pid_to_attach (args
);
203 if (pid
== getpid ()) /* Trying to masturbate? */
204 error (_("I refuse to debug myself!"));
206 if (! ops_already_pushed
)
208 /* target_pid_to_str already uses the target. Also clear possible core
209 file with its process_stratum. */
211 back_to
= make_cleanup_unpush_target (ops
);
216 exec_file
= get_exec_file (0);
219 printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file
,
220 target_pid_to_str (pid_to_ptid (pid
)));
222 printf_unfiltered (_("Attaching to %s\n"),
223 target_pid_to_str (pid_to_ptid (pid
)));
225 gdb_flush (gdb_stdout
);
230 ptrace (PT_ATTACH
, pid
, (PTRACE_TYPE_ARG3
)0, 0);
232 perror_with_name (("ptrace"));
234 error (_("This system does not support attaching to a process"));
237 inf
= current_inferior ();
238 inferior_appeared (inf
, pid
);
239 inf
->attach_flag
= 1;
240 inferior_ptid
= pid_to_ptid (pid
);
242 /* Always add a main thread. If some target extends the ptrace
243 target, it should decorate the ptid later with more info. */
244 add_thread_silent (inferior_ptid
);
246 if (! ops_already_pushed
)
247 discard_cleanups (back_to
);
250 #ifdef PT_GET_PROCESS_STATE
253 inf_ptrace_post_attach (int pid
)
257 /* Set the initial event mask. */
258 memset (&pe
, 0, sizeof pe
);
259 pe
.pe_set_event
|= PTRACE_FORK
;
260 if (ptrace (PT_SET_EVENT_MASK
, pid
,
261 (PTRACE_TYPE_ARG3
)&pe
, sizeof pe
) == -1)
262 perror_with_name (("ptrace"));
267 /* Detach from the inferior, optionally passing it the signal
268 specified by ARGS. If FROM_TTY is non-zero, be chatty about it. */
271 inf_ptrace_detach (struct target_ops
*ops
, char *args
, int from_tty
)
273 pid_t pid
= ptid_get_pid (inferior_ptid
);
278 char *exec_file
= get_exec_file (0);
281 printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file
,
282 target_pid_to_str (pid_to_ptid (pid
)));
283 gdb_flush (gdb_stdout
);
289 /* We'd better not have left any breakpoints in the program or it'll
290 die when it hits one. Also note that this may only work if we
291 previously attached to the inferior. It *might* work if we
292 started the process ourselves. */
294 ptrace (PT_DETACH
, pid
, (PTRACE_TYPE_ARG3
)1, sig
);
296 perror_with_name (("ptrace"));
298 error (_("This system does not support detaching from a process"));
301 inferior_ptid
= null_ptid
;
302 detach_inferior (pid
);
304 if (!have_inferiors ())
308 /* Kill the inferior. */
311 inf_ptrace_kill (struct target_ops
*ops
)
313 pid_t pid
= ptid_get_pid (inferior_ptid
);
319 ptrace (PT_KILL
, pid
, (PTRACE_TYPE_ARG3
)0, 0);
320 waitpid (pid
, &status
, 0);
322 target_mourn_inferior ();
325 /* Stop the inferior. */
328 inf_ptrace_stop (ptid_t ptid
)
330 /* Send a SIGINT to the process group. This acts just like the user
331 typed a ^C on the controlling terminal. Note that using a
332 negative process number in kill() is a System V-ism. The proper
333 BSD interface is killpg(). However, all modern BSDs support the
334 System V interface too. */
335 kill (-inferior_process_group (), SIGINT
);
338 /* Resume execution of thread PTID, or all threads if PTID is -1. If
339 STEP is nonzero, single-step it. If SIGNAL is nonzero, give it
343 inf_ptrace_resume (struct target_ops
*ops
,
344 ptid_t ptid
, int step
, enum gdb_signal signal
)
346 pid_t pid
= ptid_get_pid (ptid
);
350 /* Resume all threads. Traditionally ptrace() only supports
351 single-threaded processes, so simply resume the inferior. */
352 pid
= ptid_get_pid (inferior_ptid
);
354 if (catch_syscall_enabled () > 0)
355 request
= PT_SYSCALL
;
357 request
= PT_CONTINUE
;
361 /* If this system does not support PT_STEP, a higher level
362 function will have called single_step() to transmute the step
363 request into a continue request (by setting breakpoints on
364 all possible successor instructions), so we don't have to
365 worry about that here. */
369 /* An address of (PTRACE_TYPE_ARG3)1 tells ptrace to continue from
370 where it was. If GDB wanted it to start some other way, we have
371 already written a new program counter value to the child. */
373 ptrace (request
, pid
, (PTRACE_TYPE_ARG3
)1, gdb_signal_to_host (signal
));
375 perror_with_name (("ptrace"));
378 /* Wait for the child specified by PTID to do something. Return the
379 process ID of the child, or MINUS_ONE_PTID in case of error; store
380 the status in *OURSTATUS. */
383 inf_ptrace_wait (struct target_ops
*ops
,
384 ptid_t ptid
, struct target_waitstatus
*ourstatus
, int options
)
387 int status
, save_errno
;
395 pid
= waitpid (ptid_get_pid (ptid
), &status
, 0);
398 while (pid
== -1 && errno
== EINTR
);
400 clear_sigint_trap ();
404 fprintf_unfiltered (gdb_stderr
,
405 _("Child process unexpectedly missing: %s.\n"),
406 safe_strerror (save_errno
));
408 /* Claim it exited with unknown signal. */
409 ourstatus
->kind
= TARGET_WAITKIND_SIGNALLED
;
410 ourstatus
->value
.sig
= GDB_SIGNAL_UNKNOWN
;
411 return inferior_ptid
;
414 /* Ignore terminated detached child processes. */
415 if (!WIFSTOPPED (status
) && pid
!= ptid_get_pid (inferior_ptid
))
420 #ifdef PT_GET_PROCESS_STATE
421 if (WIFSTOPPED (status
))
426 if (ptrace (PT_GET_PROCESS_STATE
, pid
,
427 (PTRACE_TYPE_ARG3
)&pe
, sizeof pe
) == -1)
428 perror_with_name (("ptrace"));
430 switch (pe
.pe_report_event
)
433 ourstatus
->kind
= TARGET_WAITKIND_FORKED
;
434 ourstatus
->value
.related_pid
= pid_to_ptid (pe
.pe_other_pid
);
436 /* Make sure the other end of the fork is stopped too. */
437 fpid
= waitpid (pe
.pe_other_pid
, &status
, 0);
439 perror_with_name (("waitpid"));
441 if (ptrace (PT_GET_PROCESS_STATE
, fpid
,
442 (PTRACE_TYPE_ARG3
)&pe
, sizeof pe
) == -1)
443 perror_with_name (("ptrace"));
445 gdb_assert (pe
.pe_report_event
== PTRACE_FORK
);
446 gdb_assert (pe
.pe_other_pid
== pid
);
447 if (fpid
== ptid_get_pid (inferior_ptid
))
449 ourstatus
->value
.related_pid
= pid_to_ptid (pe
.pe_other_pid
);
450 return pid_to_ptid (fpid
);
453 return pid_to_ptid (pid
);
458 store_waitstatus (ourstatus
, status
);
459 return pid_to_ptid (pid
);
462 /* Attempt a transfer all LEN bytes starting at OFFSET between the
463 inferior's OBJECT:ANNEX space and GDB's READBUF/WRITEBUF buffer.
464 Return the number of bytes actually transferred. */
467 inf_ptrace_xfer_partial (struct target_ops
*ops
, enum target_object object
,
468 const char *annex
, gdb_byte
*readbuf
,
469 const gdb_byte
*writebuf
,
470 ULONGEST offset
, LONGEST len
)
472 pid_t pid
= ptid_get_pid (inferior_ptid
);
476 case TARGET_OBJECT_MEMORY
:
478 /* OpenBSD 3.1, NetBSD 1.6 and FreeBSD 5.0 have a new PT_IO
479 request that promises to be much more efficient in reading
480 and writing data in the traced process's address space. */
482 struct ptrace_io_desc piod
;
484 /* NOTE: We assume that there are no distinct address spaces
485 for instruction and data. However, on OpenBSD 3.9 and
486 later, PIOD_WRITE_D doesn't allow changing memory that's
487 mapped read-only. Since most code segments will be
488 read-only, using PIOD_WRITE_D will prevent us from
489 inserting breakpoints, so we use PIOD_WRITE_I instead. */
490 piod
.piod_op
= writebuf
? PIOD_WRITE_I
: PIOD_READ_D
;
491 piod
.piod_addr
= writebuf
? (void *) writebuf
: readbuf
;
492 piod
.piod_offs
= (void *) (long) offset
;
496 if (ptrace (PT_IO
, pid
, (caddr_t
)&piod
, 0) == 0)
497 /* Return the actual number of bytes read or written. */
498 return piod
.piod_len
;
499 /* If the PT_IO request is somehow not supported, fallback on
500 using PT_WRITE_D/PT_READ_D. Otherwise we will return zero
501 to indicate failure. */
509 PTRACE_TYPE_RET word
;
510 gdb_byte byte
[sizeof (PTRACE_TYPE_RET
)];
512 ULONGEST rounded_offset
;
515 /* Round the start offset down to the next long word
517 rounded_offset
= offset
& -(ULONGEST
) sizeof (PTRACE_TYPE_RET
);
519 /* Since ptrace will transfer a single word starting at that
520 rounded_offset the partial_len needs to be adjusted down to
521 that (remember this function only does a single transfer).
522 Should the required length be even less, adjust it down
524 partial_len
= (rounded_offset
+ sizeof (PTRACE_TYPE_RET
)) - offset
;
525 if (partial_len
> len
)
530 /* If OFFSET:PARTIAL_LEN is smaller than
531 ROUNDED_OFFSET:WORDSIZE then a read/modify write will
532 be needed. Read in the entire word. */
533 if (rounded_offset
< offset
534 || (offset
+ partial_len
535 < rounded_offset
+ sizeof (PTRACE_TYPE_RET
)))
536 /* Need part of initial word -- fetch it. */
537 buffer
.word
= ptrace (PT_READ_I
, pid
,
538 (PTRACE_TYPE_ARG3
)(uintptr_t)
541 /* Copy data to be written over corresponding part of
543 memcpy (buffer
.byte
+ (offset
- rounded_offset
),
544 writebuf
, partial_len
);
547 ptrace (PT_WRITE_D
, pid
,
548 (PTRACE_TYPE_ARG3
)(uintptr_t)rounded_offset
,
552 /* Using the appropriate one (I or D) is necessary for
553 Gould NP1, at least. */
555 ptrace (PT_WRITE_I
, pid
,
556 (PTRACE_TYPE_ARG3
)(uintptr_t)rounded_offset
,
566 buffer
.word
= ptrace (PT_READ_I
, pid
,
567 (PTRACE_TYPE_ARG3
)(uintptr_t)rounded_offset
,
571 /* Copy appropriate bytes out of the buffer. */
572 memcpy (readbuf
, buffer
.byte
+ (offset
- rounded_offset
),
579 case TARGET_OBJECT_UNWIND_TABLE
:
582 case TARGET_OBJECT_AUXV
:
583 #if defined (PT_IO) && defined (PIOD_READ_AUXV)
584 /* OpenBSD 4.5 has a new PIOD_READ_AUXV operation for the PT_IO
585 request that allows us to read the auxilliary vector. Other
586 BSD's may follow if they feel the need to support PIE. */
588 struct ptrace_io_desc piod
;
592 piod
.piod_op
= PIOD_READ_AUXV
;
593 piod
.piod_addr
= readbuf
;
594 piod
.piod_offs
= (void *) (long) offset
;
598 if (ptrace (PT_IO
, pid
, (caddr_t
)&piod
, 0) == 0)
599 /* Return the actual number of bytes read or written. */
600 return piod
.piod_len
;
605 case TARGET_OBJECT_WCOOKIE
:
613 /* Return non-zero if the thread specified by PTID is alive. */
616 inf_ptrace_thread_alive (struct target_ops
*ops
, ptid_t ptid
)
618 /* ??? Is kill the right way to do this? */
619 return (kill (ptid_get_pid (ptid
), 0) != -1);
622 /* Print status information about what we're accessing. */
625 inf_ptrace_files_info (struct target_ops
*ignore
)
627 struct inferior
*inf
= current_inferior ();
629 printf_filtered (_("\tUsing the running image of %s %s.\n"),
630 inf
->attach_flag
? "attached" : "child",
631 target_pid_to_str (inferior_ptid
));
635 inf_ptrace_pid_to_str (struct target_ops
*ops
, ptid_t ptid
)
637 return normal_pid_to_str (ptid
);
640 #if defined (PT_IO) && defined (PIOD_READ_AUXV)
642 /* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
643 Return 0 if *READPTR is already at the end of the buffer.
644 Return -1 if there is insufficient buffer for a whole entry.
645 Return 1 if an entry was read into *TYPEP and *VALP. */
648 inf_ptrace_auxv_parse (struct target_ops
*ops
, gdb_byte
**readptr
,
649 gdb_byte
*endptr
, CORE_ADDR
*typep
, CORE_ADDR
*valp
)
651 struct type
*int_type
= builtin_type (target_gdbarch ())->builtin_int
;
652 struct type
*ptr_type
= builtin_type (target_gdbarch ())->builtin_data_ptr
;
653 const int sizeof_auxv_type
= TYPE_LENGTH (int_type
);
654 const int sizeof_auxv_val
= TYPE_LENGTH (ptr_type
);
655 enum bfd_endian byte_order
= gdbarch_byte_order (target_gdbarch ());
656 gdb_byte
*ptr
= *readptr
;
661 if (endptr
- ptr
< 2 * sizeof_auxv_val
)
664 *typep
= extract_unsigned_integer (ptr
, sizeof_auxv_type
, byte_order
);
665 ptr
+= sizeof_auxv_val
; /* Alignment. */
666 *valp
= extract_unsigned_integer (ptr
, sizeof_auxv_val
, byte_order
);
667 ptr
+= sizeof_auxv_val
;
675 /* Create a prototype ptrace target. The client can override it with
679 inf_ptrace_target (void)
681 struct target_ops
*t
= inf_child_target ();
683 t
->to_attach
= inf_ptrace_attach
;
684 t
->to_detach
= inf_ptrace_detach
;
685 t
->to_resume
= inf_ptrace_resume
;
686 t
->to_wait
= inf_ptrace_wait
;
687 t
->to_files_info
= inf_ptrace_files_info
;
688 t
->to_kill
= inf_ptrace_kill
;
689 t
->to_create_inferior
= inf_ptrace_create_inferior
;
690 #ifdef PT_GET_PROCESS_STATE
691 t
->to_follow_fork
= inf_ptrace_follow_fork
;
692 t
->to_post_startup_inferior
= inf_ptrace_post_startup_inferior
;
693 t
->to_post_attach
= inf_ptrace_post_attach
;
695 t
->to_mourn_inferior
= inf_ptrace_mourn_inferior
;
696 t
->to_thread_alive
= inf_ptrace_thread_alive
;
697 t
->to_pid_to_str
= inf_ptrace_pid_to_str
;
698 t
->to_stop
= inf_ptrace_stop
;
699 t
->to_xfer_partial
= inf_ptrace_xfer_partial
;
700 #if defined (PT_IO) && defined (PIOD_READ_AUXV)
701 t
->to_auxv_parse
= inf_ptrace_auxv_parse
;
708 /* Pointer to a function that returns the offset within the user area
709 where a particular register is stored. */
710 static CORE_ADDR (*inf_ptrace_register_u_offset
)(struct gdbarch
*, int, int);
712 /* Fetch register REGNUM from the inferior. */
715 inf_ptrace_fetch_register (struct regcache
*regcache
, int regnum
)
717 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
720 PTRACE_TYPE_RET
*buf
;
723 /* This isn't really an address, but ptrace thinks of it as one. */
724 addr
= inf_ptrace_register_u_offset (gdbarch
, regnum
, 0);
725 if (addr
== (CORE_ADDR
)-1
726 || gdbarch_cannot_fetch_register (gdbarch
, regnum
))
728 regcache_raw_supply (regcache
, regnum
, NULL
);
732 /* Cater for systems like GNU/Linux, that implement threads as
733 separate processes. */
734 pid
= ptid_get_lwp (inferior_ptid
);
736 pid
= ptid_get_pid (inferior_ptid
);
738 size
= register_size (gdbarch
, regnum
);
739 gdb_assert ((size
% sizeof (PTRACE_TYPE_RET
)) == 0);
742 /* Read the register contents from the inferior a chunk at a time. */
743 for (i
= 0; i
< size
/ sizeof (PTRACE_TYPE_RET
); i
++)
746 buf
[i
] = ptrace (PT_READ_U
, pid
, (PTRACE_TYPE_ARG3
)(uintptr_t)addr
, 0);
748 error (_("Couldn't read register %s (#%d): %s."),
749 gdbarch_register_name (gdbarch
, regnum
),
750 regnum
, safe_strerror (errno
));
752 addr
+= sizeof (PTRACE_TYPE_RET
);
754 regcache_raw_supply (regcache
, regnum
, buf
);
757 /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
758 for all registers. */
761 inf_ptrace_fetch_registers (struct target_ops
*ops
,
762 struct regcache
*regcache
, int regnum
)
766 regnum
< gdbarch_num_regs (get_regcache_arch (regcache
));
768 inf_ptrace_fetch_register (regcache
, regnum
);
770 inf_ptrace_fetch_register (regcache
, regnum
);
773 /* Store register REGNUM into the inferior. */
776 inf_ptrace_store_register (const struct regcache
*regcache
, int regnum
)
778 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
781 PTRACE_TYPE_RET
*buf
;
784 /* This isn't really an address, but ptrace thinks of it as one. */
785 addr
= inf_ptrace_register_u_offset (gdbarch
, regnum
, 1);
786 if (addr
== (CORE_ADDR
)-1
787 || gdbarch_cannot_store_register (gdbarch
, regnum
))
790 /* Cater for systems like GNU/Linux, that implement threads as
791 separate processes. */
792 pid
= ptid_get_lwp (inferior_ptid
);
794 pid
= ptid_get_pid (inferior_ptid
);
796 size
= register_size (gdbarch
, regnum
);
797 gdb_assert ((size
% sizeof (PTRACE_TYPE_RET
)) == 0);
800 /* Write the register contents into the inferior a chunk at a time. */
801 regcache_raw_collect (regcache
, regnum
, buf
);
802 for (i
= 0; i
< size
/ sizeof (PTRACE_TYPE_RET
); i
++)
805 ptrace (PT_WRITE_U
, pid
, (PTRACE_TYPE_ARG3
)(uintptr_t)addr
, buf
[i
]);
807 error (_("Couldn't write register %s (#%d): %s."),
808 gdbarch_register_name (gdbarch
, regnum
),
809 regnum
, safe_strerror (errno
));
811 addr
+= sizeof (PTRACE_TYPE_RET
);
815 /* Store register REGNUM back into the inferior. If REGNUM is -1, do
816 this for all registers. */
819 inf_ptrace_store_registers (struct target_ops
*ops
,
820 struct regcache
*regcache
, int regnum
)
824 regnum
< gdbarch_num_regs (get_regcache_arch (regcache
));
826 inf_ptrace_store_register (regcache
, regnum
);
828 inf_ptrace_store_register (regcache
, regnum
);
831 /* Create a "traditional" ptrace target. REGISTER_U_OFFSET should be
832 a function returning the offset within the user area where a
833 particular register is stored. */
836 inf_ptrace_trad_target (CORE_ADDR (*register_u_offset
)
837 (struct gdbarch
*, int, int))
839 struct target_ops
*t
= inf_ptrace_target();
841 gdb_assert (register_u_offset
);
842 inf_ptrace_register_u_offset
= register_u_offset
;
843 t
->to_fetch_registers
= inf_ptrace_fetch_registers
;
844 t
->to_store_registers
= inf_ptrace_store_registers
;