Trying to use ptrace under FBSD
Gema niskazhu
gemochka at gmail.com
Tue Mar 17 08:40:37 PDT 2009
Hi all!
First of all sorry for my bad english.
I am using Free BSD CURRENT x86_64.
I am trying to use ptrace under free bsd
simply to test that it works
Here is my code:
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
main()
{
int pid;
int wait_val;
long long counter = 1;
switch(pid = fork() )
{
case 0:
ptrace(PT_TRACE_ME, 0, 0);
execl("/bin/ls","ls",0);
break;
default:
wait(&wait_val);
while(WIFSTOPED(wait_val))
{
if (ptrace(PT_STEP, pid, *(caddr_t)1)) break;
wait(&wait_val);
counter++;
}
}
printf("==%lld\n", counter);
}
But on compilation i get smth like
/usr/include/sys/ptrace.h:90: error: expected specifier-qualifier-list
before 'lwpid_t'
/usr/include/sys/ptrace.h:158: error: expected declaration specifiers or
'...' before 'caddr_t'
I've googled a lot but cant understand whats wrong...
Any suggestions?
Thanks in advance
More information about the freebsd-hackers
mailing list