From: Fabiano Ramos <ramos_fabiano@yahoo.com.br>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: ptrace in 2.6.5
Date: Mon, 10 May 2004 13:22:58 -0300 [thread overview]
Message-ID: <1084206178.1420.10.camel@slack.domain.invalid> (raw)
In-Reply-To: <20040510161008.GA11114@nevyn.them.org>
On Mon, 2004-05-10 at 13:10, Daniel Jacobowitz wrote:
> On Mon, May 10, 2004 at 12:46:19PM -0300, Fabiano Ramos wrote:
> > Hi All.
> >
> > Is ptrace(), in singlestep mode, required to stop after a int 0x80?
> > When tracing a sequence like
> >
> > mov ...
> > int 0x80
> > mov ....
> >
> > ptrace would notify the tracer after the two movs, but not after the
> > int 0x80. I want to know if it is a bug or the expected behaviour.
>
> I think it's a bug.
When tracing the following code,
0x0804869f: 8B 4D 0C mov ecx, [ebp+12]
0x080486a2: CD 80 int 0x80
0x080486a4: 89 45 F8 mov [ebp-8], eax
0x080486a7: 83 7D F8 82 cmp [ebp-8], -126
the tracer would produce
EIP: 0x080486a2
EIP: 0x080486a7
--- tracer.c ----
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <syscall.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <linux/user.h>
#include <unistd.h>
#include <errno.h>
extern char **environ;
int main(int argc, char **argv)
{
struct user_regs_struct regs;
int wait_val; /* child's return value */
int pid; /* child's process id */
switch (pid = fork()) {
case -1:
perror("fork");
break;
case 0: /* child process starts */
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execv(argv[1],&argv[1]);
default:/* parent process starts */
waitpid(pid,&wait_val,0);
ptrace(PTRACE_SINGLESTEP,pid,NULL,NULL); waitpid(pid,&wait_val,0);
while (1) {
/* get EIP */
ptrace(PTRACE_GETREGS, pid, 0, (int)®s);
printf("\n0x%08lx", regs.eip);
ptrace(PTRACE_SINGLESTEP, pid, 0, 0);
wait(&wait_val);
if ( WIFEXITED(wait_val)) break;
}
}
}
next prev parent reply other threads:[~2004-05-10 16:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-10 15:46 ptrace in 2.6.5 Fabiano Ramos
2004-05-10 16:10 ` Daniel Jacobowitz
2004-05-10 16:22 ` Fabiano Ramos [this message]
[not found] <1UlcA-6lq-9@gated-at.bofh.it>
2004-05-10 18:49 ` Andi Kleen
2004-05-10 19:37 ` Davide Libenzi
2004-05-10 20:24 ` Fabiano Ramos
2004-05-10 21:49 ` OGAWA Hirofumi
2004-05-10 22:47 ` OGAWA Hirofumi
2004-05-10 22:58 ` Daniel Jacobowitz
2004-05-10 23:12 ` Davide Libenzi
2004-05-11 0:40 ` Fabiano Ramos
2004-05-11 6:14 ` Davide Libenzi
2004-05-11 6:27 ` Davide Libenzi
2004-05-11 6:41 ` Davide Libenzi
2004-05-11 14:07 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1084206178.1420.10.camel@slack.domain.invalid \
--to=ramos_fabiano@yahoo.com.br \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox