ptrace_user.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2003 PathScale, Inc.
  3. *
  4. * Licensed under the GPL
  5. */
  6. #include <stddef.h>
  7. #include <errno.h>
  8. #include "ptrace_user.h"
  9. #include "user.h"
  10. #include "kern_constants.h"
  11. int ptrace_getregs(long pid, unsigned long *regs_out)
  12. {
  13. if(ptrace(PTRACE_GETREGS, pid, 0, regs_out) < 0)
  14. return(-errno);
  15. return(0);
  16. }
  17. int ptrace_setregs(long pid, unsigned long *regs)
  18. {
  19. if(ptrace(PTRACE_SETREGS, pid, 0, regs) < 0)
  20. return(-errno);
  21. return(0);
  22. }
  23. int ptrace_setfpregs(long pid, unsigned long *regs)
  24. {
  25. if (ptrace(PTRACE_SETFPREGS, pid, 0, regs) < 0)
  26. return -errno;
  27. return 0;
  28. }
  29. void ptrace_pokeuser(unsigned long addr, unsigned long data)
  30. {
  31. panic("ptrace_pokeuser");
  32. }
  33. #define DS 184
  34. #define ES 192
  35. #define __USER_DS 0x2b
  36. void arch_enter_kernel(void *task, int pid)
  37. {
  38. }
  39. void arch_leave_kernel(void *task, int pid)
  40. {
  41. #ifdef UM_USER_CS
  42. if(ptrace(PTRACE_POKEUSR, pid, CS, UM_USER_CS) < 0)
  43. printk("POKEUSR CS failed");
  44. #endif
  45. if(ptrace(PTRACE_POKEUSR, pid, DS, __USER_DS) < 0)
  46. printk("POKEUSR DS failed");
  47. if(ptrace(PTRACE_POKEUSR, pid, ES, __USER_DS) < 0)
  48. printk("POKEUSR ES failed");
  49. }