[LWN Logo]

Date:	Sat, 20 Mar 1999 16:33:51 -0800
From:	Nate Eldredge <nate@cartsys.com>
To:	Michael Elizabeth Chastain <mec@shout.net>
Subject: [PATCH] Re: Tracing of vfork

Here is a patch that will allow, on x86, debuggers to change the number
of a system call when they trace it.  This is useful for:

* Changing a call that can't be handled by the debugger into a similar
one that can.  (The example which started this was vfork, which can be
changed into fork.)

* Vetoing a system call altogether.

* Probably some other things I haven't thought of yet. :)

Sorry it took so long to create such a trivial thing; I've been rather
busy.  Thanks to Michael Chastain <mec@shout.net> for suggesting this
implementation (essentially writing it).

I would like to propose that it be added to the standard kernel so that
everyone can take advantage of the features it will allow in strace. 
Comments are welcome.

People familiar with other architectures may wish to submit similar
changes for their platforms.  x86 is all I know, sorry!

Patch follows.

--- arch/i386/kernel/entry.S~   Sun Feb  7 13:12:48 1999
+++ arch/i386/kernel/entry.S    Sat Mar 20 16:01:17 1999
@@ -214,8 +214,11 @@
        movl $-ENOSYS,EAX(%esp)
        call SYMBOL_NAME(syscall_trace)
        movl ORIG_EAX(%esp),%eax
+       cmpl $(NR_syscalls),%eax
+       jae tracesys_exit
        call *SYMBOL_NAME(sys_call_table)(,%eax,4)
        movl %eax,EAX(%esp)             # save the return value
+tracesys_exit:
        call SYMBOL_NAME(syscall_trace)
        jmp ret_from_sys_call
 badsys:
--- arch/i386/kernel/ptrace.c~  Sun Feb  7 13:12:27 1999
+++ arch/i386/kernel/ptrace.c   Sat Mar 20 15:38:30 1999
@@ -289,8 +289,6 @@
        unsigned long regno, unsigned long value)
 {
        switch (regno >> 2) {
-               case ORIG_EAX:
-                       return -EIO;
                case FS:
                        if (value && (value & 3) != 3)
                                return -EIO;

-- 

Nate Eldredge
nate@cartsys.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/