[parisc-linux-cvs] fix for strace of execve calls

Richard Hirst rhirst@linuxcare.com
Thu, 22 Feb 2001 22:48:26 +0000


execve is funny - you get two traps on the way out of the call.
This stops strace getting confused about which traps are syscall
entry and which are syscall exit.

Index: defs.h
===================================================================
RCS file: /home/cvs/parisc/strace/defs.h,v
retrieving revision 1.4
diff -u -r1.4 defs.h
--- defs.h      2001/02/19 11:51:32     1.4
+++ defs.h      2001/02/22 22:37:41
@@ -261,7 +261,7 @@
 #define TCB_FOLLOWFORK 00400   /* Process should have forks followed */
 #define TCB_REPRINT    01000   /* We should reprint this syscall on exit */
 #ifdef LINUX
-#if defined(ALPHA) || defined(SPARC) || defined(POWERPC)
+#if defined(ALPHA) || defined(SPARC) || defined(POWERPC) || defined(HPPA)
 #define TCB_WAITEXECVE 02000   /* ignore SIGTRAP after exceve */
 #endif /* ALPHA */
 #endif /* LINUX */
Index: process.c
===================================================================
RCS file: /home/cvs/parisc/strace/process.c,v
retrieving revision 1.2
diff -u -r1.2 process.c
--- process.c   2001/02/19 11:51:32     1.2
+++ process.c   2001/02/22 22:37:44
@@ -1003,7 +1003,7 @@
                }
        }
 #ifdef LINUX
-#if defined(ALPHA) || defined(SPARC) || defined(POWERPC)
+#if defined(ALPHA) || defined(SPARC) || defined(POWERPC) || defined(HPPA)
        tcp->flags |= TCB_WAITEXECVE;
 #endif /* ALPHA || SPARC || POWERPC */
 #endif /* LINUX */
Index: syscall.c
===================================================================
RCS file: /home/cvs/parisc/strace/syscall.c,v
retrieving revision 1.3
diff -u -r1.3 syscall.c
--- syscall.c   2001/02/19 11:51:32     1.3
+++ syscall.c   2001/02/22 22:37:50
@@ -752,6 +752,13 @@
 #elif defined(HPPA)
        if (upeek(pid, PT_GR20, &scno) < 0)
                return -1;
+       if (!(tcp->flags & TCB_INSYSCALL)) {
+               /* Check if we return from execve. */
+               if ((tcp->flags & TCB_WAITEXECVE)) {
+                       tcp->flags &= ~TCB_WAITEXECVE;
+                       return 0;
+               }
+       }
 #endif 
 #endif /* LINUX */
 #ifdef SUNOS4
@@ -847,7 +854,6 @@
 #elif defined (HPPA)
        if (upeek(pid, PT_GR28, &r28) < 0)
                return -1;
-#else
 #endif
 #endif /* LINUX */