ptrace_user.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. void ptrace_pokeuser(unsigned long addr, unsigned long data)
  24. {
  25. panic("ptrace_pokeuser");
  26. }
  27. #define DS 184
  28. #define ES 192
  29. #define __USER_DS 0x2b
  30. void arch_enter_kernel(void *task, int pid)
  31. {
  32. }
  33. void arch_leave_kernel(void *task, int pid)
  34. {
  35. #ifdef UM_USER_CS
  36. if(ptrace(PTRACE_POKEUSR, pid, CS, UM_USER_CS) < 0)
  37. printk("POKEUSR CS failed");
  38. #endif
  39. if(ptrace(PTRACE_POKEUSR, pid, DS, __USER_DS) < 0)
  40. printk("POKEUSR DS failed");
  41. if(ptrace(PTRACE_POKEUSR, pid, ES, __USER_DS) < 0)
  42. printk("POKEUSR ES failed");
  43. }