Skip to content

Commit

Permalink
get_scno is an unholy mess, make it less horrible
Browse files Browse the repository at this point in the history
Currently, get_scno does *much* more than "get syscall no".
It checks for post-execve SIGTRAP. It checks for changes
in personality. It retrieves params on entry and registers on exit.
Worse still, it is different in different architectures: for example,
for AVR32 regs are fetched in get_scno(), while for e.g. I386
it is done in syscall_enter().

Another problem is that get_scno() is called on both syscall entry and
syscall exit, which is stupid: we don't need to know scno on syscall
exit, it is already known from last syscall entry and stored in
tcp->scno! In essence, get_scno() does two completely different things
on syscall entry and on exit, they are just mixed into one bottle, like
shampoo and conditioner.

The following patches will try to improve this situation.

This change duplicates get_scno into identical get_scno_on_sysenter,
get_scno_on_sysexit functions. Call them in syscall enter and syscall
exit, correspondingly.

* defs.h: Rename get_scno to get_scno_on_sysenter; declare it only
if USE_PROCFS.
* strace.c (proc_open): Call get_scno_on_sysenter instead of get_scno.
* syscall.c (get_scno): Split into two (so far identical) functions
get_scno_on_sysenter and get_scno_on_sysexit.
(trace_syscall_entering): Call get_scno_on_sysenter instead of get_scno.
(trace_syscall_exiting): Call get_scno_on_sysexit instead of get_scno.

Signed-off-by: Denys Vlasenko <[email protected]>
  • Loading branch information
dvlasenk committed Aug 24, 2011
1 parent 5f731c4 commit 9a36ae5
Show file tree
Hide file tree
Showing 3 changed files with 623 additions and 5 deletions.
4 changes: 3 additions & 1 deletion defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,9 @@ extern void droptcb(struct tcb *);
extern void set_sortby(const char *);
extern void set_overhead(int);
extern void qualify(const char *);
extern int get_scno(struct tcb *);
#ifdef USE_PROCFS
extern int get_scno_on_sysenter(struct tcb *);
#endif
extern long known_scno(struct tcb *);
extern long do_ptrace(int request, struct tcb *tcp, void *addr, void *data);
extern int ptrace_restart(int request, struct tcb *tcp, int sig);
Expand Down
2 changes: 1 addition & 1 deletion strace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ proc_open(struct tcb *tcp, int attaching)
}
if (tcp->status.PR_WHY == PR_SYSENTRY) {
tcp->flags &= ~TCB_INSYSCALL;
get_scno(tcp);
get_scno_on_sysenter(tcp);
if (known_scno(tcp) == SYS_execve)
break;
}
Expand Down
Loading

0 comments on commit 9a36ae5

Please sign in to comment.