po polsku


Przykladowy program korzystajacy z tego mechanizmu to ( tresc skopiowana
z ksiazki Bacha ):
Proces sledzony:

int dane[32];
main()
{
int i;

for( i = 0; i < 32; i++)
printf("dane[%d] = %d\n", i, dane[i] );
printf("Adres sledzonych danych: 0x%x\n", dane );
}



Proces sledzacy:

int adres;

main( int argc, char *argv[] )
{
int i, ident;

sscanf( argv[1], "%x", &adres );

if(( ident = fork()) == 0 ) {
ptrace( PTRACE_TRACEME, 0, 0, 0 );
execl("trace","trace", 0 );
exit();
}
for( i = 0; i < 32; i++ ) {
wait((int *)0);
if(ptrace(PTRACE_POKEDATA,ident,adres,i) == -1 )
exit();
adres += sizeof(int);
}
ptrace(PTRACE_CONT,ident,1,0);
}
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • pajaa1981.pev.pl