[patch] get_scno should test TCB_INSYSCALL at the beginning

jochen at penguin-breeder.org jochen at penguin-breeder.org
Thu Sep 11 20:53:37 UTC 2003


get_scno should test TCB_INSYSCALL at the beginning
the function get_scno in signal.c should test whether
the scno needs to be updated at the beginning, instead
of just determining it anyway and deciding at the end
whether it needs to be updated or not.

get_scno is invoked when a syscall is entered and when
it's left. When it's entered, we need the scno anyway,
but when it's left we don't need. Even more, when it's
left we might be already in some other context (signal
handler or similar), so we cannot determine it anyway.
Now on some architectures (s390) this may result in a
(failing) attempt to access memory of the traced
process to determine the scno.

and it's more efficient anyway.

see attached patch.

regards
-- jochen

ps: i also filed this as bug 803946 at your sf.net site
-------------- next part --------------
--- strace/syscall.c.orig	2003-09-10 21:02:20.000000000 +0200
+++ strace/syscall.c	2003-09-10 21:04:29.000000000 +0200
@@ -735,6 +735,8 @@
 	int pid = tcp->pid;
 #endif /* !PROCFS */
 
+	if (tcp->flags & TCB_INSYSCALL)
+		return 1;
 #ifdef LINUX
 #if defined(S390) || defined(S390X)
 	if (tcp->flags & TCB_WAITEXECVE) {
@@ -1197,8 +1199,7 @@
 #endif /* FREEBSD */
 #endif /* !HAVE_PR_SYSCALL */
 #endif /* USE_PROCFS */
-	if (!(tcp->flags & TCB_INSYSCALL))
-		tcp->scno = scno;
+	tcp->scno = scno;
 	return 1;
 }
 


More information about the Strace-devel mailing list