Chuck Ebbert
635cf99a80
[PATCH] i386: fix singlestep through an int80 syscall
Using PTRACE_SINGLESTEP on a child that does an int80 syscall misses the
SIGTRAP that should be delivered upon syscall exit. Fix that by setting
TIF_SINGLESTEP when entering the kernel via int80 with TF set.
/* Test whether singlestep through an int80 syscall works.
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <asm/user.h>
static int child, status;
static struct user_regs_struct regs;
static void do_child()
{
ptrace(PTRACE_TRACEME, 0, 0, 0);
kill(getpid(), SIGUSR1);
asm ("int $0x80" : : "a" (20)); /* getpid */
}
static void do_parent()
{
unsigned long eip, expected = 0;
again:
waitpid(child, &status, 0);
if (WIFEXITED(status) || WIFSIGNALED(status))
return;
if (WIFSTOPPED(status)) {
ptrace(PTRACE_GETREGS, child, 0, ®s);
eip = regs.eip;
if (expected)
fprintf(stderr, "child stop @ %08x, expected %08x %s\n",
eip, expected,
eip == expected ? "" : " <== ERROR");
if (*(unsigned short *)eip == 0x80cd) {
fprintf(stderr, "int 0x80 at %08x\n", (unsigned int)eip);
expected = eip + 2;
} else
expected = 0;
ptrace(PTRACE_SINGLESTEP, child, NULL, NULL);
}
goto again;
}
int main(int argc, char * const argv[])
{
child = fork();
if (child)
do_parent();
else
do_child();
return 0;
}
Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-23 07:38:05 -08:00
..
2006-03-08 18:10:31 -08:00
2006-03-23 07:38:04 -08:00
2006-03-22 07:53:55 -08:00
2006-02-14 16:09:35 -08:00
2006-03-23 07:38:04 -08:00
2006-03-14 08:26:44 -08:00
2006-01-11 18:42:14 -08:00
2005-04-16 15:20:36 -07:00
2005-04-16 15:20:36 -07:00
2006-01-06 08:33:38 -08:00
2006-01-10 08:01:28 -08:00
2006-03-23 07:38:05 -08:00
2006-01-11 19:04:51 -08:00
2005-09-05 00:06:11 -07:00
2005-04-16 15:20:36 -07:00
2005-04-16 15:20:36 -07:00
2006-03-22 07:53:55 -08:00
2006-03-23 07:38:05 -08:00
2006-02-24 14:31:38 -08:00
2006-02-24 14:31:38 -08:00
2005-07-22 16:06:16 -04:00
2005-09-05 00:06:14 -07:00
2005-10-31 19:16:17 -08:00
2006-01-08 20:13:38 -08:00
2006-03-08 18:10:31 -08:00
2006-01-11 18:42:14 -08:00
2006-01-08 20:13:38 -08:00
2006-02-24 14:31:37 -08:00
2005-11-07 07:53:29 -08:00
2006-03-08 14:15:04 -08:00
2006-03-23 07:38:04 -08:00
2005-11-07 07:53:28 -08:00
2006-02-28 20:53:43 -08:00
2006-03-23 07:38:04 -08:00
2006-03-23 07:38:04 -08:00
2006-01-06 08:33:38 -08:00
2006-03-08 14:14:01 -08:00
2005-07-28 21:46:05 -07:00
2005-10-08 15:00:57 -07:00
2006-03-23 07:38:05 -08:00
2006-03-23 07:38:04 -08:00
2006-01-18 19:20:31 -08:00
2005-11-07 07:53:29 -08:00
2006-01-11 19:04:50 -08:00
2005-06-25 16:24:49 -07:00
2006-01-09 12:13:21 -08:00
2006-03-23 07:38:04 -08:00
2006-03-23 07:38:05 -08:00
2005-09-09 10:31:59 -07:00
2006-03-23 07:38:05 -08:00
2006-03-22 07:53:59 -08:00
2006-03-23 07:38:04 -08:00
2005-11-14 19:55:13 -08:00
2005-04-16 15:20:36 -07:00
2006-03-22 07:54:02 -08:00
2006-02-11 21:41:10 -08:00
2005-06-25 16:24:29 -07:00
2006-01-08 20:13:47 -08:00
2006-03-06 18:40:44 -08:00
2006-02-24 14:31:39 -08:00
2005-04-16 15:20:36 -07:00
2006-03-23 07:38:05 -08:00
2006-01-15 02:43:54 +01:00
2006-03-23 07:38:04 -08:00
2005-04-16 15:20:36 -07:00
2005-04-16 15:24:48 -07:00
2005-09-09 19:28:28 +02:00
2006-02-14 16:09:35 -08:00
2005-09-09 19:28:28 +02:00
2005-04-16 15:20:36 -07:00