Back to index

php5  5.3.10
Functions | Variables
fpm_trace_mach.c File Reference
#include "fpm_config.h"
#include <mach/mach.h>
#include <mach/mach_vm.h>
#include <unistd.h>
#include "fpm_trace.h"
#include "fpm_process_ctl.h"
#include "fpm_unix.h"
#include "zlog.h"

Go to the source code of this file.

Functions

static void fpm_mach_vm_deallocate ()
static int fpm_mach_vm_read_page (vm_offset_t page)
int fpm_trace_signal (pid_t pid)
int fpm_trace_ready (pid_t pid)
int fpm_trace_close (pid_t pid)
int fpm_trace_get_long (long addr, long *data)

Variables

static mach_port_name_t target
static vm_offset_t target_page_base
static vm_offset_t local_page
static mach_msg_type_number_t local_size

Function Documentation

static void fpm_mach_vm_deallocate ( ) [static]

Definition at line 23 of file fpm_trace_mach.c.

{
       if (local_page) {
              mach_vm_deallocate(mach_task_self(), local_page, local_size);
              target_page_base = 0;
              local_page = 0;
              local_size = 0;
       }
}

Here is the caller graph for this function:

static int fpm_mach_vm_read_page ( vm_offset_t  page) [static]

Definition at line 34 of file fpm_trace_mach.c.

{
       kern_return_t kr;

       kr = mach_vm_read(target, page, fpm_pagesize, &local_page, &local_size);
       if (kr != KERN_SUCCESS) {
              zlog(ZLOG_ERROR, "failed to read vm page: mach_vm_read(): %s (%d)", mach_error_string(kr), kr);
              return -1;
       }
       return 0;
}

Here is the caller graph for this function:

Definition at line 75 of file fpm_trace_mach.c.

{
       fpm_mach_vm_deallocate();
       target = 0;
       return 0;
}

Here is the call graph for this function:

int fpm_trace_get_long ( long  addr,
long *  data 
)

Definition at line 83 of file fpm_trace_mach.c.

{
       size_t offset = ((uintptr_t) (addr) % fpm_pagesize);
       vm_offset_t base = (uintptr_t) (addr) - offset;

       if (base != target_page_base) {
              fpm_mach_vm_deallocate();
              if (0 > fpm_mach_vm_read_page(base)) {
                     return -1;
              }
       }
       *data = * (long *) (local_page + offset);
       return 0;
}

Here is the call graph for this function:

Definition at line 57 of file fpm_trace_mach.c.

{
       kern_return_t kr;

       kr = task_for_pid(mach_task_self(), pid, &target);
       if (kr != KERN_SUCCESS) {
              char *msg = "";

              if (kr == KERN_FAILURE) {
                     msg = " It seems that master process does not have enough privileges to trace processes.";
              }
              zlog(ZLOG_ERROR, "task_for_pid() failed: %s (%d)%s", mach_error_string(kr), kr, msg);
              return -1;
       }
       return 0;
}

Definition at line 47 of file fpm_trace_mach.c.

{
       if (0 > fpm_pctl_kill(pid, FPM_PCTL_STOP)) {
              zlog(ZLOG_SYSERROR, "failed to send SIGSTOP to %d", pid);
              return -1;
       }
       return 0;
}

Here is the call graph for this function:


Variable Documentation

vm_offset_t local_page [static]

Definition at line 20 of file fpm_trace_mach.c.

mach_msg_type_number_t local_size [static]

Definition at line 21 of file fpm_trace_mach.c.

mach_port_name_t target [static]

Definition at line 18 of file fpm_trace_mach.c.

vm_offset_t target_page_base [static]

Definition at line 19 of file fpm_trace_mach.c.