public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Question regarding ptrace
       [not found]       ` <20110810173851.GA19981@redhat.com>
@ 2011-08-10 17:39         ` Oleg Nesterov
  0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2011-08-10 17:39 UTC (permalink / raw)
  To: samir baid; +Cc: tj, jan.kratochvil, vda.linux, linux-kernel

I just noticed we discuss this offlist.

We hate the private discussions ;) lets add lkml. Perhaps you
found a kernel bug...

On 08/10, Oleg Nesterov wrote:
>
> On 08/10, samir baid wrote:
> >
> > Here is a
> > brief description of the code -
> 
> Oops. it is not that brief ;) I simply do not understand it, may be you
> can show the code... But please try to simplify it as much as possible
> to remove the unnecessary details,
> 
> > Running the above programs -
> >  1. Ran Tracee.
> >  2. Ran Tracer with the PID.
> >  3. Ran command - kill -s 30 <tracee pid>
> >
> > My understanding was, after i did step 3 above, tracer should get a signal
> > stop with signal 30. And then i perform a signal injection to tracee. What i
> > wanted to acheive was, once injected the signal to the tracee i wanted to
> > single step it at the instruction level.
> 
> This should work, the tracee should enter the handler. For example, see
> the test-case below.
> 
> Oleg.
> 
> #include <stdio.h>
> #include <unistd.h>
> #include <signal.h>
> #include <sys/ptrace.h>
> #include <sys/wait.h>
> #include <sys/user.h>
> #include <stddef.h>
> #include <assert.h>
> 
> void sigh(int sig)
> {
> }
> 
> void *getip(int pid)
> {
> 	return (void*)ptrace(PTRACE_PEEKUSER, pid,
> 			offsetof(struct user, regs.rip), 0);
> }
> 
> int main(void)
> {
> 	int pid;
> 
> 	signal(30, sigh);
> 
> 	pid = fork();
> 	if (!pid) {
> 		assert(ptrace(PTRACE_TRACEME, 0,0,0) == 0);
> 
> 		kill(getpid(), SIGSTOP);
> 
> 		return 0;
> 	}
> 
> 	assert(wait(NULL) == pid);
> 
> 	assert(ptrace(PTRACE_SINGLESTEP, pid, 0, 30) == 0);
> 	assert(wait(NULL) == pid);
> 
> 	assert(sigh == getip(pid));
> 
> 	kill(SIGKILL, pid);
> 	return 0;
> }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-08-10 17:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAPoVYDc85W3qM_7vLwuMqP88epGgpvu4oBG5RiaRUKLWB-y6mA@mail.gmail.com>
     [not found] ` <20110810120042.GA3500@redhat.com>
     [not found]   ` <CAPoVYDd1YfenMmdT6TS5-F1EXuJnkAh6sKbo4iFGjj7Q6ZDmWw@mail.gmail.com>
     [not found]     ` <20110810172250.GA19099@redhat.com>
     [not found]       ` <20110810173851.GA19981@redhat.com>
2011-08-10 17:39         ` Question regarding ptrace Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox