public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Ramos <ramos_fabiano@yahoo.com.br>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [patch] really-ptrace-single-step
Date: Tue, 11 May 2004 23:19:45 -0300	[thread overview]
Message-ID: <1084328384.1753.7.camel@slack.domain.invalid> (raw)
In-Reply-To: <Pine.LNX.4.58.0405111805220.10328@bigblue.dev.mdolabs.com>

On Tue, 2004-05-11 at 22:06, Davide Libenzi wrote:
> On Tue, 11 May 2004, Fabiano Ramos wrote:
> 
> > Sorry for that.
> > By the way the email was sent in response to the first
> > patch, not for the second version.
> 
> The second version works for me. Pls give it a spin.
> 
> 
> - Davide


Seems to be working just fine on 2.6.5 and 2.6.6. Tracing the following
code (tracer appended) would produce:


 8050cd6:	b8 c7 00 00 00       	mov    $0xc7,%eax
 8050cdb:	cd 80                	int    $0x80
 8050cdd:	3d 00 f0 ff ff       	cmp    $0xfffff000,%eax
 8050ce2:	76 f0                	jbe    8050cd4 <__getuid+0x14>



EIP = 0x08050cd6

EIP = 0x08050cdb

EIP = 0x08050cdd

EIP = 0x08050ce2


--------- TRACER -----------
#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          */

        long long totalinstr=0;        /* # of intr executed */
        unsigned char opcode;          /* syscall opcode goes in one
byte */


        int i;

       /* printing options */
       printf("\n\nPTRACE: Will execute \"");
       for (i=1; i<argc; i++)
             printf("%s ", argv[i]);

       printf("\". Please wait (it may take long...)\n\n\n");

       printf("***** SIMULATED PROGRAM OUTPUT *****\n\n");

        switch (pid = fork()) {

        case -1:
                perror("fork");
                break;

        case 0: /*  child process starts        */
                if ( ptrace(PTRACE_TRACEME, 0, NULL, NULL) < 0)
			perror("\nError in ptrace PTRACE_TRACEME");
		execv(argv[1],&argv[1]);
		break;

        default:/*  parent process starts       */
		if (waitpid(pid,&wait_val,0) < 0)
			perror("\nchild process EXITED");

		if (ptrace(PTRACE_SINGLESTEP,pid,NULL,NULL) < 0)
               		perror("\nError in ptrace PTRACE_SINGLESTEP");

                waitpid(pid,&wait_val,0);

                while (1) {

		      totalinstr++;

			/* get PC */
                      if (ptrace(PTRACE_GETREGS, pid, 0, (int)&regs) ==
-1){
                           perror("ptrace");
                            printf("Exiting on error ... \n");
                      }

		      printf("\nEIP = 0x%08lx\n", regs.eip);

		      // will stop after each instruction
                      if (ptrace(PTRACE_SINGLESTEP, pid, 0, 0) != 0)
                               perror("ptrace");

                      waitpid(pid,&wait_val,0);
		      if ( WIFEXITED(wait_val)) break;

                }

        }
	printf("\n************************************\n\n");
        printf("Number of machine instructions : %lld\n\n\n",
totalinstr);
        return 0;
}



  parent reply	other threads:[~2004-05-12  2:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-11 17:12 [patch] really-ptrace-single-step Davide Libenzi
2004-05-11 17:31 ` Fabiano Ramos
2004-05-12  0:17   ` Andrew Morton
2004-05-12  0:42     ` Davide Libenzi
2004-05-12  1:04     ` Fabiano Ramos
2004-05-12  1:06       ` Davide Libenzi
2004-05-12  1:15         ` Fabiano Ramos
2004-05-12  2:19         ` Fabiano Ramos [this message]
2004-05-11 17:36 ` Fabiano Ramos
2004-05-11 17:38   ` Davide Libenzi
2004-05-11 18:40     ` Fabiano Ramos

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=1084328384.1753.7.camel@slack.domain.invalid \
    --to=ramos_fabiano@yahoo.com.br \
    --cc=akpm@osdl.org \
    --cc=davidel@xmailserver.org \
    --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