Unix Programming - How To Do Single Step debugging Under Sparc

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2004 > How To Do Single Step debugging Under Sparc





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How To Do Single Step debugging Under Sparc
xtaci

2004-01-23, 4:59 pm

please someone give me an example .. like instruction counter under sparc

i googled and found it can be done with trap #1,but i don't know how to
do it.

please me ,my brain is melting...

xtaci

2004-01-23, 4:59 pm

xtaci wrote:
quote:

> please someone give me an example .. like instruction counter under sparc
>
> i googled and found it can be done with trap #1,but i don't know how to
> do it.
>
> please me ,my brain is melting...
>



to make it clear:
in x86 environment ,i can use ptrace(PTRACE_SINGLESTEP, pid, 0, 0) to do
single stepping.
i need the same thing under solaris/SPARC.


Victor Wagner

2004-01-23, 4:59 pm

xtaci <xtaci@163.com> wrote:
:>
:> please me ,my brain is melting...
:>

: to make it clear:
: in x86 environment ,i can use ptrace(PTRACE_SINGLESTEP, pid, 0, 0) to do
: single stepping.
: i need the same thing under solaris/SPARC.
:

What's wrong with same call on Sparc?


--
Norman Black

2004-01-23, 4:59 pm

In Solaris you use the /proc file system in your "debugger" to control a
process and its threads.

--
Norman Black
Stony Brook Software

"xtaci" <xtaci@163.com> wrote in message
news:bo87l5$1lop$1@mail.cn99.com...
quote:

> please someone give me an example .. like instruction counter under


sparc
quote:

>
> i googled and found it can be done with trap #1,but i don't know how


to
quote:

> do it.
>
> please me ,my brain is melting...
>



xtaci

2004-01-23, 4:59 pm

Victor Wagner wrote:
quote:

> xtaci <xtaci@163.com> wrote:
> :>
> :> please me ,my brain is melting...
> :>
>
> : to make it clear:
> : in x86 environment ,i can use ptrace(PTRACE_SINGLESTEP, pid, 0, 0) to do
> : single stepping.
> : i need the same thing under solaris/SPARC.
> :
>
> What's wrong with same call on Sparc?
>
>



Because ,ptrace(SINGLESTEP,pid,0,0) make use of hardware support,that is
MSW(Machine Status Word),if we set the bit,CPU will run in single step
mode..
but SPARC does not support.

xtaci

2004-01-23, 4:59 pm

Norman Black wrote:
quote:

> In Solaris you use the /proc file system in your "debugger" to control a
> process and its threads.
>
> --
> Norman Black
> Stony Brook Software
>
> "xtaci" <xtaci@163.com> wrote in message
> news:bo87l5$1lop$1@mail.cn99.com...
>
>
> sparc
>
>
> to
>
>
>



Can You Make it more clearer?
i dont quite cache up with you,maybe a short piece of C code would help.

Norman Black

2004-01-23, 5:00 pm

> Can You Make it more clearer?
quote:

> i dont quite cache up with you,maybe a short piece of C code would


help.

man -s 4 proc

I do not use C. I use Modula-2. My own compiler in fact.

The proc file system has a host of functions for debugging a process.
Read the man page. In short you would use the PCRUN code with the PRSTEP
flag. This code is written to the appropriate "file" handle. Typically
this is done on s specific LWP, but can be done to a process. In that
case, whatever the current LWP was is acted upon.

--
Norman Black
Stony Brook Software

"xtaci" <xtaci@163.com> wrote in message
news:bo9m6q$e5p$2@mail.cn99.com...
quote:

> Norman Black wrote:
control a[QUOTE][color=darkred]
>
> Can You Make it more clearer?
> i dont quite cache up with you,maybe a short piece of C code would


help.
quote:

>



xtaci

2004-01-23, 5:00 pm

Norman Black wrote:
quote:

> man -s 4 proc
>
> I do not use C. I use Modula-2. My own compiler in fact.
>
> The proc file system has a host of functions for debugging a process.
> Read the man page. In short you would use the PCRUN code with the PRSTEP
> flag. This code is written to the appropriate "file" handle. Typically
> this is done on s specific LWP, but can be done to a process. In that
> case, whatever the current LWP was is acted upon.
>
> --
> Norman Black
> Stony Brook Software
>
> "xtaci" <xtaci@163.com> wrote in message
> news:bo9m6q$e5p$2@mail.cn99.com...



I'm reading the man pages,and i saw SPARC.
Maybe you can give me your Modula-2 Code to speed up my process.
I have to finish a instruction counter before next week for some reason.
After all ,thank you very much.

xtaci

2004-01-23, 5:00 pm

Norman Black wrote:
quote:

> man -s 4 proc
>
> I do not use C. I use Modula-2. My own compiler in fact.
>
> The proc file system has a host of functions for debugging a process.
> Read the man page. In short you would use the PCRUN code with the PRSTEP
> flag. This code is written to the appropriate "file" handle. Typically
> this is done on s specific LWP, but can be done to a process. In that
> case, whatever the current LWP was is acted upon.
>
> --
> Norman Black
> Stony Brook Software



yes ,i'm reading the man page...it helps a lot .
Modula-2 sounds interesting...do you mind if you send your sample code
in Modula, a instruction counter maybe.

xtaci

2004-01-23, 5:00 pm

xtaci wrote: my code is
i don't know what is wrong with my code?
give me some hint please.

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/procfs.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>


int main(void)
{

long long counter = 0; /* machine instruction counter */
int wait_val; /* child's return value */
int pid; /* child's process id */


long iov[2];
int fd, temp = 0;
char filename[512];


puts("Please wait");
switch (pid = fork()) {
case -1:
perror("fork");
break;
case 0: /* child process starts */
sprintf(filename,"/proc/%d/ctl",getpid());
iov[0] =1L; //PCSTOP
iov[1] =0;


if ((fd = open(filename, O_WRONLY)) == -1) {
perror(filename);
exit(1);
}
printf("%s",filename);
write(fd,iov,2*sizeof(long));

/*
* let it stop first
*/
execl("/bin/ls", "ls", NULL);

break;
/* child process ends */






default:/* parent process starts */
sprintf(filename,"/proc/%d/ctl",pid);
iov[0] =5L;//PCRUN
iov[1] =PRSTEP;


if ((fd = open(filename, O_WRONLY)) == -1) {
perror(filename);
exit(1);
}
printf("%s",filename);
write(fd,iov,2*sizeof(long));
/* LET THE PROCESS RUN IN SINGLE STEP MODE */

wait(&wait_val);
/*
* parent waits for child to stop at next
* instruction (execl())
*/
while(wait_val==SIGTRAP){
counter++;
/*
* singlestep tracing and
* release child
* if unable call error.
*/
write(fd,iov,2*sizeof(long));
wait(&wait_val);
/* wait for next instruction to complete */
}

/*
* continue to stop, wait and release until
*/
}
printf("Number of machine instructions : %lld\n", counter);
return 0;
}

xtaci

2004-01-23, 5:00 pm

xtaci wrote:
i've made some modification;
firstly ,i stopped the child process in parent process
and then PCRUN PRSTEP.
but it hangs at wait();
why?

xtaci

2004-01-23, 5:00 pm

xtaci wrote:
i've made some modification later.
firstly i stopped the child process in the parent process
and then PCRUN PRSTEP.
but it hangs at wait();
why?

xtaci

2004-01-23, 5:00 pm

xtaci wrote:
i've made some modification later.
firstly i stopped the child process in the parent process
and then PCRUN PRSTEP.
but it hangs at wait();
why?

xtaci

2004-01-23, 5:01 pm

The below is what i think :
Firstl ,i PCSTOP the child process.
Second ,i PCSTRACE The SIGTRAP signal to the child process.
third ,i PCRUN with PRSTEP flag
fourth ,i wait()
and then , if signal is SIGTRAP,counter++, then PCRUN with PRSTEP
and then , continue to catch SIGTRAP.

if the signal is NOT SIGTRAP
printf the counter,exit the program.

i need you comment.


Norman Black

2004-01-23, 5:01 pm

Why are you using wait. Certainly the man page for /proc did not tell
you to do this. /proc does not just replace ptrace, it is an entire API
for controlling a process and its threads. In other words it replaces
ptrace/wait.

With the /proc interface you use poll on the file handle(s) you opened
to create the process. For example. If a process had 20 threads, you
would typically have 1 process file handle and one handle per thread,
so poll would have 21 handles. If you do not care about detailed thread
control then you can get by with just the process file handle.

POLLHUP = handle closed. for a process handle the process terminated.
POLLERR, POLLNVAL = some sort of error
POLLWRNORM, POLLPRI = an event occurred on the handle. then read the
status file handle to see what the event was. single step, crash,
breakpoint, etc...

--
Norman Black
Stony Brook Software

"xtaci" <xtaci@163.com> wrote in message
news:bocqo5$f8b$1@mail.cn99.com...
quote:

> xtaci wrote: my code is
> i don't know what is wrong with my code?
> give me some hint please.
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <signal.h>
> #include <sys/types.h>
> #include <sys/procfs.h>
> #include <sys/wait.h>
> #include <fcntl.h>
> #include <unistd.h>
> #include <errno.h>
>
>
> int main(void)
> {
>
> long long counter = 0; /* machine instruction counter */
> int wait_val; /* child's return value */
> int pid; /* child's process id */
>
>
> long iov[2];
> int fd, temp = 0;
> char filename[512];
>
>
> puts("Please wait");
> switch (pid = fork()) {
> case -1:
> perror("fork");
> break;
> case 0: /* child process starts */
> sprintf(filename,"/proc/%d/ctl",getpid());
> iov[0] =1L; //PCSTOP
> iov[1] =0;
>
>
> if ((fd = open(filename, O_WRONLY)) == -1) {
> perror(filename);
> exit(1);
> }
> printf("%s",filename);
> write(fd,iov,2*sizeof(long));
>
> /*
> * let it stop first
> */
> execl("/bin/ls", "ls", NULL);
>
> break;
> /* child process ends */
>
>
>
>
>
>
> default:/* parent process starts */
> sprintf(filename,"/proc/%d/ctl",pid);
> iov[0] =5L;//PCRUN
> iov[1] =PRSTEP;
>
>
> if ((fd = open(filename, O_WRONLY)) == -1) {
> perror(filename);
> exit(1);
> }
> printf("%s",filename);
> write(fd,iov,2*sizeof(long));
> /* LET THE PROCESS RUN IN SINGLE STEP MODE */
>
> wait(&wait_val);
> /*
> * parent waits for child to stop at next
> * instruction (execl())
> */
> while(wait_val==SIGTRAP){
> counter++;
> /*
> * singlestep tracing and
> * release child
> * if unable call error.
> */
> write(fd,iov,2*sizeof(long));
> wait(&wait_val);
> /* wait for next instruction to complete */
> }
>
> /*
> * continue to stop, wait and release until
> */
> }
> printf("Number of machine instructions : %lld\n", counter);
> return 0;
> }
>



xtaci

2004-01-23, 5:02 pm

i'm not living in a english-speaking country,so there maybe some
misunderstanding with what you've said.

sorry about my poor english.

so, i made some modification again.

the problem with my code is:
1.too slow to do single stepping instruction counter.
2.the child(forked process) does not stop.
3.when i Ctrl+C ,it shows that the instructions i've executed is more
than 2 million, is that correct?


/* instruction counter under sparc */


#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#define _STRUCTURED_PROC 1
#include <sys/procfs.h>
#include <sys/fault.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stropts.h>
#include <poll.h>

void handler_sigint();
long counter=0;

int main(void)
{
// long counter = 0;
int pid; /* child process pid */

long iovp[2]; //parent process control

int fd, temp = 0;
char filename[512];
char statfn[512];/*status file descriptor */
struct pollfd fds[1];
pstatus_t s_stat;
int statfd;
struct {
long ctl;
fltset_t s_fltset;
} pcsfault;
signal(SIGINT,handler_sigint);
puts("Please wait");
switch (pid = fork()) {
case -1:
perror("fork");
break;
case 0: /* child process starts */

execl("/bin/ls", "ls", NULL);
break;

/* child process ends */

default:/* parent process starts */




sprintf(filename,"/proc/%d/ctl",pid);
puts(filename);

if ((fd = open(filename, O_WRONLY)) == -1) {
perror(filename);
exit(1);
}

/* let the child process stop first */
iovp[0] = PCDSTOP;
iovp[1] =0;
write(fd,iovp,2*sizeof(long));

/* set to trace FLTTRACE */
pcsfault.ctl=PCSFAULT;
praddset(&pcsfault.s_fltset,FLTTRACE);
write(fd,&pcsfault,sizeof(pcsfault));
/* set to run in step mode */
iovp[0]=PCRUN;
iovp[1]=PRSTEP|PRCFAULT;
write(fd,iovp,2*sizeof(long));

/* set to capture the events the poll
will return */

fds[0].fd=fd;
fds[0].events=POLLWRNORM|POLLPRI|POLLHUP;
poll(fds,1,0);

/*open the status file first */
sprintf(statfn,"/proc/%d/status",pid);
if((statfd=open(statfn,O_RDONLY))==-1){
perror(statfn);
exit(1);
}






while((fds[0].revents&POLLHUP)==0){ /* is the child terminated? */

// read(statfd,&s_stat,sizeof(pstatus_t));
// printf("%d",fds[0].revents);
//

if(s_stat.pr_lwp.pr_why==PR_FAULTED&&s_stat.pr_lwp.pr_what==FLTTRACE)
counter++;

iovp[0]=PCRUN;
iovp[1]=PRCFAULT|PRSTEP;
write(fd,iovp,2*sizeof(long)); continue to run step mode
}
close(fd);
close(statfd);
printf("Number of machine instructions : %ld\n", counter);
return 0;
}
}
void handler_sigint()
{
printf("%d\n",counter);
exit(0);
}

xtaci

2004-01-23, 5:02 pm

xtaci wrote:

forget about last post.

i forget to add poll in the while
but it still very slow.
it cost me 30seconds to finish a ls command.

xtaci

2004-01-23, 5:02 pm

xtaci wrote:

i got it.
in my own machine P4/linux2.4 the 'ls' command is about 10,000 instructions.
on the server SPARC/Solaris 2.9 the 'ls' command is about 100,000
instructions..


quote:

> xtaci wrote:
>
> forget about last post.
>
> i forget to add poll in the while
> but it still very slow.
> it cost me 30seconds to finish a ls command.
>



Norman Black

2004-01-23, 5:02 pm

> i forget to add poll in the while
quote:

> but it still very slow.
> it cost me 30seconds to finish a ls command.



Yes, controlling a process is slow. If you are stepping by single
instruction when think of the amount of code that must be executed
(yours and the OS receiving/executing your commands) just to control the
process and the process in only going to execute one instruction.

--
Norman Black
Stony Brook Software

"xtaci" <xtaci@163.com> wrote in message
news:bog46l$q4m$1@mail.cn99.com...
quote:

> xtaci wrote:
>
> forget about last post.
>
> i forget to add poll in the while
> but it still very slow.
> it cost me 30seconds to finish a ls command.
>



xtaci

2004-01-23, 5:04 pm

Thank you very much.

There is another problem with my program.

lwpstatus_t pr_lwp; /* status of the representative lwp */

when i access the pr_reg provided in the pr_lwp struct.(when the program
stopped by the PRSTEP )
the registers seems not to be changed ,it always remains the same.
i'm sure i read the status file every time the program stopped.

i donnot know what does 'the representative lwp' mean , is this the main
reason the registers does not change? or i have to check some other
lwp's status file?(the process being traced is never forked or something)

xtaci

2004-01-23, 5:04 pm

xtaci wrote:
I started to Use PCSENTRY to trace systemcall
the program stopped at the right place
but

if (read(statfd, (void *) &s_stat, sizeof(pstatus_t)) != sizeof(pstatus_t))
{
perror("read_status(read)");
return 1;
}


reported that i cannot read status file.


#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#define _STRUCTURED_PROC 1
#include <sys/procfs.h>
#include <sys/fault.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stropts.h>
#include <poll.h>


void handler_sigint();
long counter=0;
int main(void)
{

int pid;


long iovp[2]; //parent process control
int fd, temp = 0;
char filename[512];
char statfn[512];
struct pollfd fds[1];
pstatus_t s_stat;
int statfd;
int execcount=0;
struct {
long ctl;
sysset_t evilsys;
} pcsentry;



puts("Please wait");
switch (pid = fork()) {
case -1:
perror("fork");
break;
case 0: /* child process starts */
/*
* must be called in order to allow the
* control over the child process
*/
sleep(2);
execl("./sparc-sh", "sparc-sh", NULL);
/*
* executes the program and causes
* the child to stop and send a signal
* to the parent, the parent can now
* switch to PTRACE_SINGLESTEP
*/
break;
/* child process ends */

default:/* parent process starts */
sprintf(filename,"/proc/%d/ctl",pid);
puts(filename);

if ((fd = open(filename, O_WRONLY)) == -1) {
perror(filename);
exit(1);
}


iovp[0] = PCDSTOP;
iovp[1] =0L;
write(fd,iovp,2*sizeof(long));



pcsentry.ctl=PCSENTRY;
premptyset(&pcsentry.evilsys);
praddset(&pcsentry.evilsys,SYS_fork);
write(fd,&pcsentry,sizeof(pcsentry));


fds[0].fd=fd;
fds[0]. events=POLLERR|POLLNVAL|POLLWRNORM|POLLP
RI|POLLHUP;
poll(fds,1,0);


sprintf(statfn,"/proc/%d/status",pid);
if((statfd=open(statfn,O_RDONLY))==-1){
perror(statfn);
exit(1);
}


iovp[0]=PCRUN;
iovp[1]=0L;
write(fd,iovp,2*sizeof(long));
while((fds[0].revents&POLLHUP)==0){


if (read(statfd, (void *) &s_stat, sizeof(pstatus_t)) !=
sizeof(pstatus_t))
{
perror("read_status(read)");
return 1;
}

printf("%x\n",s_stat.pr_lwp.pr_why);

if(s_stat.pr_lwp.pr_why==PR_SYSENTRY){
puts("caught illegal syscall");
exit(-1);
}

poll(fds,1,0);

}
close(fd);
close(statfd);
printf("no illegal instructions found : %ld\n", counter);
return 0;
}
return 0;
}
void handler_sigint()
{
printf("%d\n",counter);
exit(0);
}

Norman Black

2004-01-23, 5:06 pm

I have only controlled each LWP directly, but as I understand it the LWP
listed in the process status record is the active LWP at the time of the
process event.

--
Norman Black
Stony Brook Software

"xtaci" <xtaci@163.com> wrote in message
news:boilnn$26bn$1@mail.cn99.com...
quote:

> Thank you very much.
>
> There is another problem with my program.
>
> lwpstatus_t pr_lwp; /* status of the representative lwp */
>
> when i access the pr_reg provided in the pr_lwp struct.(when the


program
quote:

> stopped by the PRSTEP )
> the registers seems not to be changed ,it always remains the same.
> i'm sure i read the status file every time the program stopped.
>
> i donnot know what does 'the representative lwp' mean , is this the


main
quote:

> reason the registers does not change? or i have to check some other
> lwp's status file?(the process being traced is never forked or


something)
quote:

>



Norman Black

2004-01-23, 5:06 pm

I have never used PCSENTRY. I have used PCSEXIT. I use PCSEXIT to detect
when a LWP has been created and for when I create the process I am going
to debug.

Thread creation. Setup on the main process control("ctl") file handle.
sys.code := PCSEXIT;
premptyset(sys.set);
praddset(sys.set, SYS_lwp_create);
IF NOT WriteFile(ControlFile, sys) THEN
RETURN FALSE;
END;

Creating process
pid := fork();
CASE pid OF
-1:
(* ouch!*)
FUNC close(success[0]);
FUNC close(success[1]);
cleanup;
RETURN FALSE;
|
0*child*)

FUNC close(success[0]);

zapHandles;

ProcessId := getpid();

f := OpenProcessFile("ctl", O_WRONLY);
IF f >= 0 THEN
sys.code := PCSEXIT;
premptyset(sys.set);
praddset(sys.set, SYS_exec);
praddset(sys.set, SYS_execve);
IF WriteFile(f, sys) THEN
set.code := PCSET;
set.flags := PR_ASYNC;
FUNC WriteFile(f, set);

IF execv(progBuf^, commands) < 0 THEN
(* failed *)
FUNC write(success[1], progBuf^[0], 1);
_exit(255);
END;
(*never get here*)
END;
END;
FUNC write(success[1], progBuf^[0], 1);
_exit(255);
ELSE
FUNC close(success[1]);
IF read(success[0], progBuf^[0], 1) <= 0 THEN
(* nothing on the other end of the pipe.
this means the exec succeeded
*)
FUNC close(success[0]);
cleanup;

ProcessId := pid;
IF OpenProcessFiles() THEN
RETURN WaitForExec();
ELSE
kill(ProcessId, SIGKILL);
waitpid(ProcessId, stat, 0);
END;
RETURN TRUE;
END;
FUNC close(success[0]);
cleanup;
END;



--
Norman Black
Stony Brook Software

"xtaci" <xtaci@163.com> wrote in message
news:boiv29$2emt$1@mail.cn99.com...
quote:

> xtaci wrote:
> I started to Use PCSENTRY to trace systemcall
> the program stopped at the right place
> but
>
> if (read(statfd, (void *) &s_stat, sizeof(pstatus_t)) !=


sizeof(pstatus_t))
quote:


> {
> perror("read_status(read)");
> return 1;
> }
>
>
> reported that i cannot read status file.
>
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <signal.h>
> #include <sys/types.h>
> #define _STRUCTURED_PROC 1
> #include <sys/procfs.h>
> #include <sys/fault.h>
> #include <sys/syscall.h>
> #include <sys/wait.h>
> #include <fcntl.h>
> #include <unistd.h>
> #include <errno.h>
> #include <stropts.h>
> #include <poll.h>
>
>
> void handler_sigint();
> long counter=0;
> int main(void)
> {
>
> int pid;
>
>
> long iovp[2]; //parent process control
> int fd, temp = 0;
> char filename[512];
> char statfn[512];
> struct pollfd fds[1];
> pstatus_t s_stat;
> int statfd;
> int execcount=0;
> struct {
> long ctl;
> sysset_t evilsys;
> } pcsentry;
>
>
>
> puts("Please wait");
> switch (pid = fork()) {
> case -1:
> perror("fork");
> break;
> case 0: /* child process starts */
> /*
> * must be called in order to allow the
> * control over the child process
> */
> sleep(2);
> execl("./sparc-sh", "sparc-sh", NULL);
> /*
> * executes the program and causes
> * the child to stop and send a signal
> * to the parent, the parent can now
> * switch to PTRACE_SINGLESTEP
> */
> break;
> /* child process ends */
>
> default:/* parent process starts */
> sprintf(filename,"/proc/%d/ctl",pid);
> puts(filename);
>
> if ((fd = open(filename, O_WRONLY)) == -1) {
> perror(filename);
> exit(1);
> }
>
>
> iovp[0] = PCDSTOP;
> iovp[1] =0L;
> write(fd,iovp,2*sizeof(long));
>
>
>
> pcsentry.ctl=PCSENTRY;
> premptyset(&pcsentry.evilsys);
> praddset(&pcsentry.evilsys,SYS_fork);
> write(fd,&pcsentry,sizeof(pcsentry));
>
>
> fds[0].fd=fd;
>


fds[0]. events=POLLERR|POLLNVAL|POLLWRNORM|POLLP
RI|POLLHUP;
quote:

> poll(fds,1,0);
>
>
> sprintf(statfn,"/proc/%d/status",pid);
> if((statfd=open(statfn,O_RDONLY))==-1){
> perror(statfn);
> exit(1);
> }
>
>
> iovp[0]=PCRUN;
> iovp[1]=0L;
> write(fd,iovp,2*sizeof(long));
> while((fds[0].revents&POLLHUP)==0){
>
>
> if (read(statfd, (void *) &s_stat, sizeof(pstatus_t)) !=
> sizeof(pstatus_t))
> {
> perror("read_status(read)");
> return 1;
> }
>
> printf("%x\n",s_stat.pr_lwp.pr_why);
>
> if(s_stat.pr_lwp.pr_why==PR_SYSENTRY){
> puts("caught illegal syscall");
> exit(-1);
> }
>
> poll(fds,1,0);
>
> }
> close(fd);
> close(statfd);
> printf("no illegal instructions found : %ld\n", counter);
> return 0;
> }
> return 0;
> }
> void handler_sigint()
> {
> printf("%d\n",counter);
> exit(0);
> }
>



xtaci

2004-01-23, 5:07 pm

how to wake up the process after PCSENTRY or PCSEXIT caught systemcall?
i PCRUN 0 it,but it doesn't work.
i just want the process to continue to execute.

Norman Black

2004-01-23, 5:07 pm

That is what I use (RCRUN, 0).

What was the value of the pr_why field.

If PR_FAULTED then you need to clear/handle the fault (PRCFAULT).
If PR_SIGNALLED then you need to clear/handle the signal (PRCSIG).

--
Norman Black
Stony Brook Software

"xtaci" <xtaci@163.com> wrote in message
news:bos4j0$145f$1@mail.cn99.com...
quote:

> how to wake up the process after PCSENTRY or PCSEXIT caught


systemcall?
quote:

> i PCRUN 0 it,but it doesn't work.
> i just want the process to continue to execute.
>



xtaci

2004-01-23, 5:07 pm

PCSENTRY

pr_why==PR_SYSENTRY

I PCRUN & PRCFAULT|PRCSIG.
then PCWSTOP 0L;
read status file again.
then...
i found pr_why does not change ,then i look at the registers.
nothing changed at all.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com