Trying to use ptrace under FBSD
pluknet
pluknet at gmail.com
Tue Mar 17 08:46:35 PDT 2009
2009/3/17 Gema niskazhu <gemochka at gmail.com>:
> 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>
There is at least an incorrect include order.
sys/types.h is a prerequisite for sys/ptrace.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
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>
--
wbr,
pluknet
More information about the freebsd-hackers
mailing list