linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] ptrace_test.c program on PPC
@ 2005-03-18  0:15 ashwin tanugula
  2005-03-20 10:36 ` Blaisorblade
  0 siblings, 1 reply; 3+ messages in thread
From: ashwin tanugula @ 2005-03-18  0:15 UTC (permalink / raw)
  To: user-mode-linux-devel

Hi!
I tried running ptrace_test.c on my ppc. Initially i initialized
ORIG_EAX to 20 which is the system call number for getpid on my ppc,
but it gave out two different pids.
Then i started playing with the numbers
Finally i got same pids when i put ORIG_EAX to 0 , which is the system
call number for  restart_syscall.
Can somebody tell me if my machine is able to run UML?
Thanks,
Ashwin.


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [uml-devel] ptrace_test.c program on PPC
  2005-03-18  0:15 [uml-devel] ptrace_test.c program on PPC ashwin tanugula
@ 2005-03-20 10:36 ` Blaisorblade
       [not found]   ` <838f7c5005032011255f738335@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Blaisorblade @ 2005-03-20 10:36 UTC (permalink / raw)
  To: user-mode-linux-devel, ashwin tanugula

On Friday 18 March 2005 01:15, ashwin tanugula wrote:
> Hi!
> I tried running ptrace_test.c on my ppc. Initially i initialized
> ORIG_EAX to 20 which is the system call number for getpid on my ppc,
> but it gave out two different pids.
> Then i started playing with the numbers
> Finally i got same pids when i put ORIG_EAX to 0 , which is the system
> call number for  restart_syscall.
> Can somebody tell me if my machine is able to run UML?
Not lookign at the above results, UML used to run on PPC, but there is not a 
current version of UML working... there is some work towards a port (see 
http://www.usermodelinux.org/ news). However nothing for users at the moment.
> Thanks,
> Ashwin.

-- 
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade





-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [uml-devel] ptrace_test.c program on PPC
       [not found]   ` <838f7c5005032011255f738335@mail.gmail.com>
@ 2005-03-22 19:26     ` Blaisorblade
  0 siblings, 0 replies; 3+ messages in thread
From: Blaisorblade @ 2005-03-22 19:26 UTC (permalink / raw)
  To: ashwin tanugula; +Cc: user-mode-linux-devel

[-- Attachment #1: Type: text/plain, Size: 1717 bytes --]

On Sunday 20 March 2005 20:25, ashwin tanugula wrote:
> Hi,
> I know that UML has to be ported to PPC. I want to resume that work. I
> just wanted to make sure that my PPC box can run uml.(because the
> first step in porting uml is to check that the ptrace_test.c file
> outputs two same pids).
Since there have been working versions of the PPC port, it should be working 
well.
> I have set ORIG_EAX to 0. Is that correct or wrong?

Hmm, actually this is wrong... by reading ptrace_test.c, which I just found on 
my HD, it should work almost "out of the box".

However, if you look at the source, what it puts inside the ORIG_EAX is the 
number of getppid(), not of getpid(), i.e. 64. You don't need to change the 
value IMHO.

If you write 20 there it is perfectly expectable that the pids you get are 
different (as an exercise, try to understand why: if the child executes 
getpid() it gets its own PID, if it executes getppid() it gets the father's 
pid).

That said, the problem you should get is that I don't expect ORIG_EAX to be 
accepted. From reading include/asm-ppc/unistd.h, it seems that the register 
to be changed is r0 (so the macro is PT_R0).

Also, the ptrace_test.c requirement has been reduced a lot by SYSEMU 
introduction. Basically, ptrace_test.c uses a hack to avoid that the syscall 
is executed on the host, i.e. changing the syscall number to getpid. 
PTRACE_SYSEMU is a ptrace() option that says that the syscall invoked by the 
debugged thread must not be executed: we write the result from the UML 
execution of the syscall to the result register.
> Thanks,
> Ashwin.
>

-- 
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade

[-- Attachment #2: ptrace_test.c --]
[-- Type: text/x-csrc, Size: 1331 bytes --]

#include <stdio.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/ptrace.h>
#include <asm/ptrace.h>
#include <asm/unistd.h>

static char stack[65536];

int child(void *arg)
{
  if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
    perror("ptrace");
    exit(1);
  }
  kill(getpid(), SIGSTOP);
  while(1){
    printf("getpid() returned %d\n", getpid());
    sleep(3);
  }
  return(0);
}

int main(int argc, char **argv)
{
  int pid, status, syscall;

  printf("Parent pid = %d\n", getpid());
  if((pid = clone(child, &stack[65532], SIGCHLD, NULL)) < 0){
    perror("clone");
    exit(1);
  }
  if((pid = waitpid(pid, &status, WUNTRACED)) < 0){
    perror("Waiting for stop");
    exit(1);
  }
  if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0){
    perror("continuing");
    exit(1);
  }
  while(1){
    if((pid = waitpid(-1, &status, WUNTRACED)) <= 0){
      perror("wait");
      exit(1);
    }
    if(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP)){
      syscall = ptrace(PTRACE_PEEKUSER, pid, 4 * ORIG_EAX, 0);
      if(syscall == __NR_getpid){
	if(ptrace(PTRACE_POKEUSER, pid, 4 * ORIG_EAX, __NR_getppid) < 0){
	  perror("ptrace");
	  exit(1);
	}
      }
      if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0){
	perror("continuing");
	exit(1);
      }
    }
    else printf("wait failed - pid = %d, status = %d\n", pid, status);
  }
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-03-22 19:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-18  0:15 [uml-devel] ptrace_test.c program on PPC ashwin tanugula
2005-03-20 10:36 ` Blaisorblade
     [not found]   ` <838f7c5005032011255f738335@mail.gmail.com>
2005-03-22 19:26     ` Blaisorblade

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