syscall_user.c 1.6 KB

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