How To Do Single Step debugging Under Sparc
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > How To Do Single Step debugging Under Sparc




Pages (3): [1] 2 3 »   Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    How To Do Single Step debugging Under Sparc  
xtaci


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09: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...






[ Post a follow-up to this message ]



    Re: How To Do Single Step debugging Under Sparc  
xtaci


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09: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.




[ Post a follow-up to this message ]



    Re: How To Do Single Step debugging Under Sparc  
Victor Wagner


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09: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?


--





[ Post a follow-up to this message ]



    Re: How To Do Single Step debugging Under Sparc  
Norman Black


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09: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... >




[ Post a follow-up to this message ]



    Re: How To Do Single Step debugging Under Sparc  
xtaci


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09: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.




[ Post a follow-up to this message ]



    Re: How To Do Single Step debugging Under Sparc  
xtaci


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09: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.




[ Post a follow-up to this message ]



    Re: How To Do Single Step debugging Under Sparc  
Norman Black


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10: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] > > Can You Make it more clearer? > i dont quite cache up with you,maybe a short piece of C code would
help.
quote:
>




[ Post a follow-up to this message ]



    Re: How To Do Single Step debugging Under Sparc  
xtaci


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10: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.




[ Post a follow-up to this message ]



    Re: How To Do Single Step debugging Under Sparc  
xtaci


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10: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.




[ Post a follow-up to this message ]



    Re: How To Do Single Step debugging Under Sparc  
xtaci


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10: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;
}






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:19 PM.      Post New Thread    Post A Reply      
Pages (3): [1] 2 3 »   Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register