syscall_user.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #include <unistd.h>
  6. #include <signal.h>
  7. #include <errno.h>
  8. #include <asm/unistd.h>
  9. #include "sysdep/ptrace.h"
  10. #include "sigcontext.h"
  11. #include "ptrace_user.h"
  12. #include "task.h"
  13. #include "user_util.h"
  14. #include "kern_util.h"
  15. #include "syscall.h"
  16. #include "tt.h"
  17. void do_sigtrap(void *task)
  18. {
  19. UPT_SYSCALL_NR(TASK_REGS(task)) = -1;
  20. }
  21. void do_syscall(void *task, int pid, int local_using_sysemu)
  22. {
  23. unsigned long proc_regs[FRAME_SIZE];
  24. if(ptrace_getregs(pid, proc_regs) < 0)
  25. tracer_panic("Couldn't read registers");
  26. UPT_SYSCALL_NR(TASK_REGS(task)) = PT_SYSCALL_NR(proc_regs);
  27. #ifdef UPT_ORIGGPR2
  28. UPT_ORIGGPR2(TASK_REGS(task)) = REGS_ORIGGPR2(proc_regs);
  29. #endif
  30. if(((unsigned long *) PT_IP(proc_regs) >= &_stext) &&
  31. ((unsigned long *) PT_IP(proc_regs) <= &_etext))
  32. tracer_panic("I'm tracing myself and I can't get out");
  33. /* advanced sysemu mode set syscall number to -1 automatically */
  34. if (local_using_sysemu==2)
  35. return;
  36. /* syscall number -1 in sysemu skips syscall restarting in host */
  37. if(ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
  38. local_using_sysemu ? -1 : __NR_getpid) < 0)
  39. tracer_panic("do_syscall : Nullifying syscall failed, "
  40. "errno = %d", errno);
  41. }
  42. /*
  43. * Overrides for Emacs so that we follow Linus's tabbing style.
  44. * Emacs will notice this stuff at the end of the file and automatically
  45. * adjust the settings for this buffer only. This must remain at the end
  46. * of the file.
  47. * ---------------------------------------------------------------------------
  48. * Local variables:
  49. * c-file-style: "linux"
  50. * End:
  51. */