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

next in thread | raw e-mail | index | archive | help
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



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