Skip to content

Commit

Permalink
/proc/PID/syscall
Browse files Browse the repository at this point in the history
This adds /proc/PID/syscall and /proc/PID/task/TID/syscall magic files.
These use task_current_syscall() to show the task's current system call
number and argument registers, stack pointer and PC.  For a task blocked
but not in a syscall, the file shows "-1" in place of the syscall number,
followed by only the SP and PC.  For a task that's not blocked, it shows
"running".

Signed-off-by: Roland McGrath <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Reviewed-by: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Roland McGrath authored and torvalds committed Jul 26, 2008
1 parent bbc6986 commit ebcb673
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,26 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
return count;
}

#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
static int proc_pid_syscall(struct task_struct *task, char *buffer)
{
long nr;
unsigned long args[6], sp, pc;

if (task_current_syscall(task, &nr, args, 6, &sp, &pc))
return sprintf(buffer, "running\n");

if (nr < 0)
return sprintf(buffer, "%ld 0x%lx 0x%lx\n", nr, sp, pc);

return sprintf(buffer,
"%ld 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n",
nr,
args[0], args[1], args[2], args[3], args[4], args[5],
sp, pc);
}
#endif /* CONFIG_HAVE_ARCH_TRACEHOOK */

/************************************************************************/
/* Here the fs part begins */
/************************************************************************/
Expand Down Expand Up @@ -2477,6 +2497,9 @@ static const struct pid_entry tgid_base_stuff[] = {
INF("limits", S_IRUSR, pid_limits),
#ifdef CONFIG_SCHED_DEBUG
REG("sched", S_IRUGO|S_IWUSR, pid_sched),
#endif
#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
INF("syscall", S_IRUSR, pid_syscall),
#endif
INF("cmdline", S_IRUGO, pid_cmdline),
ONE("stat", S_IRUGO, tgid_stat),
Expand Down Expand Up @@ -2809,6 +2832,9 @@ static const struct pid_entry tid_base_stuff[] = {
INF("limits", S_IRUSR, pid_limits),
#ifdef CONFIG_SCHED_DEBUG
REG("sched", S_IRUGO|S_IWUSR, pid_sched),
#endif
#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
INF("syscall", S_IRUSR, pid_syscall),
#endif
INF("cmdline", S_IRUGO, pid_cmdline),
ONE("stat", S_IRUGO, tid_stat),
Expand Down

0 comments on commit ebcb673

Please sign in to comment.