ptrace_user.c 1008 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <errno.h>
  2. #include <asm/ptrace.h>
  3. #include "sysdep/ptrace.h"
  4. int ptrace_getregs(long pid, unsigned long *regs_out)
  5. {
  6. int i;
  7. for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {
  8. errno = 0;
  9. regs_out->regs[i] = ptrace(PTRACE_PEEKUSR, pid, i*4, 0);
  10. if (errno) {
  11. return -errno;
  12. }
  13. }
  14. return 0;
  15. }
  16. int ptrace_setregs(long pid, unsigned long *regs_in)
  17. {
  18. int i;
  19. for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {
  20. if (i != 34 /* FIXME: PT_ORIG_R3 */ && i <= PT_MQ) {
  21. if (ptrace(PTRACE_POKEUSR, pid, i*4, regs_in->regs[i]) < 0) {
  22. return -errno;
  23. }
  24. }
  25. }
  26. return 0;
  27. }
  28. /*
  29. * Overrides for Emacs so that we follow Linus's tabbing style.
  30. * Emacs will notice this stuff at the end of the file and automatically
  31. * adjust the settings for this buffer only. This must remain at the end
  32. * of the file.
  33. * ---------------------------------------------------------------------------
  34. * Local variables:
  35. * c-file-style: "linux"
  36. * End:
  37. */