Unix Programming - [SPARC] /proc and process debugging.

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2006 > [SPARC] /proc and process debugging.





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 [SPARC] /proc and process debugging.
nicolas

2006-04-27, 7:55 am

Hi all,

I am trying to write a little tracer on solaris 9.

I have some problem with the single-step mode,
I'm not sure to really understand how /proc works.

There is my little program:

-------------------------------------------------------
int son;

if ((son = fork()) == -1)
(void) exit(1);
if (son)
{
long ctl[2];
pcsfault_t pcsfault;


ctl[0] = PCDSTOP;
ctl[1] = 0;
if (write_procfs(obj, "ctl", 2 * sizeof(long),
(char*) ctl) == -1)
(void) exit(1)


pcsfault.ctl = PCSFAULT;
praddset(&pcsfault.s_fltset, FLTTRACE);
praddset(&pcsfault.s_fltset, FLTBPT);
if (write_procfs(obj, "ctl", sizeof(pcsfault_t),
(char*) &pcsfault) == -1)
(void) exit(1);


ctl[0] = PCUNSET;
ctl[1] = PR_ASYNC;
if (write_procfs(obj, "ctl", 2 * sizeof(long),
(char*) ctl) == -1)
(void) exit(1);


ctl[0] = PCUNSET;
ctl[1] = PR_FORK;
if (write_procfs(obj, "ctl", 2 * sizeof(long),
(char*) ctl == -1)
(void) exit(1);

ctl[0] = PCRUN;
ctl[1] = PRSABORT|PRCFAULT|PRSTEP;
if (write_procfs(obj, "ctl", 2 * sizeof(long),
(char*) ctl) != 2 * sizeof(long))
(void) exit(1);

while (1)
{
ctl[0] = PCWSTOP;
ctl[1] = 0;
if (write_procfs(obj, "ctl", 2 * sizeof(long),
(char*) ctl) == -1)
break;

ctl[0] = PCRUN;
ctl[1] = PRSTEP|PRCFAULT;
if (write_procfs(obj, "ctl", 2 * sizeof(long),
(char*) ctl) == -1)
(void) exit(1);
}
(void) wait(0);
(void) exit(0);
}

if (setpgid(0, 0) == -1)
(void) exit(1);
/* Waiting for PRSABORT */
(void) pause();
(void) printf("execv !\n");
(void) execv(path, argv);
(void) printf("oups\n");
(void) exit(1);
-------------------------------------------------------

there is the output with /bin/ls

nico # ./a.out -e /bin/ls
execv
nico #

If I remove the PRSTEP flag:

nico # ./a.out -e /bin/ls
execv
a.out
nico #

I don't understand why when I use PRSTEP /bin/ls isn't executed.

Thanks in advance for your help.
--
Nico
Paul Pluzhnikov

2006-04-27, 7:55 am

nicolas <nico@no-spam.fr> writes:

> I am trying to write a little tracer on solaris 9.
> I have some problem with the single-step mode,
> I'm not sure to really understand how /proc works.
>
> There is my little program:


This is missing *critical* details, e.g. we are left to guess what
'obj' is, and whether it refers to the child, the parent, or is
uninitialized.

You may wish to read this:
http://www.catb.org/~esr/faqs/smart-questions.html
and ask a better question.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com