Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Mar 2009 18:46:32 +0300
From:      pluknet <pluknet@gmail.com>
To:        Gema niskazhu <gemochka@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Trying to use ptrace under FBSD
Message-ID:  <a31046fc0903170846m2b812e96l74a59d989aa55fd1@mail.gmail.com>
In-Reply-To: <84133fac0903170818j422891b2ibd0951fcced3368e@mail.gmail.com>
References:  <84133fac0903170818j422891b2ibd0951fcced3368e@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
2009/3/17 Gema niskazhu <gemochka@gmail.com>:
> Hi all!
>
> First of all sorry for my bad english.
>
> I am using Free BSD CURRENT x86_64.
>
> I am trying to =A0use 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()
> {
> =A0int pid;
> =A0int wait_val;
> =A0long long counter =3D 1;
>
> =A0switch(pid =3D fork() )
> =A0{
> =A0case 0:
>
>
> =A0ptrace(PT_TRACE_ME, 0, 0);
>
>
>
> =A0execl("/bin/ls","ls",0);
> =A0break;
>
> =A0default:
>
>
> =A0wait(&wait_val);
>
> =A0while(WIFSTOPED(wait_val))
> =A0{
> =A0if (ptrace(PT_STEP, pid, *(caddr_t)1)) break;
>
> =A0wait(&wait_val);
>
> =A0counter++;
> =A0}
>
>
> =A0}
>
> =A0printf("=3D=3D%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@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org=
"
>



--=20
wbr,
pluknet



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a31046fc0903170846m2b812e96l74a59d989aa55fd1>