From f37a26d525902194a6430a0079392512c53beb51 Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Tue, 12 Apr 2016 22:53:13 -0700 Subject: [PATCH] proc: Use correct type for mach task --- proc/exec_darwin.c | 2 +- proc/exec_darwin.h | 2 +- proc/proc_darwin.c | 2 +- proc/proc_darwin.go | 15 ++++++++------- proc/proc_darwin.h | 2 +- proc/threads_darwin.c | 4 ++-- proc/threads_darwin.h | 4 ++-- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/proc/exec_darwin.c b/proc/exec_darwin.c index f46dccae..9b9ed6e1 100644 --- a/proc/exec_darwin.c +++ b/proc/exec_darwin.c @@ -12,7 +12,7 @@ close_exec_pipe(int fd[2]) { int fork_exec(char *argv0, char **argv, int size, - mach_port_name_t *task, + task_t *task, mach_port_t *port_set, mach_port_t *exception_port, mach_port_t *notification_port) diff --git a/proc/exec_darwin.h b/proc/exec_darwin.h index 395cad43..c25ae4d8 100644 --- a/proc/exec_darwin.h +++ b/proc/exec_darwin.h @@ -7,4 +7,4 @@ #include int -fork_exec(char *, char **, int, mach_port_name_t*, mach_port_t*, mach_port_t*, mach_port_t*); +fork_exec(char *, char **, int, task_t*, mach_port_t*, mach_port_t*, mach_port_t*); diff --git a/proc/proc_darwin.c b/proc/proc_darwin.c index 30ea8c76..c2085691 100644 --- a/proc/proc_darwin.c +++ b/proc/proc_darwin.c @@ -23,7 +23,7 @@ __attribute__ ((section ("__TEXT,__info_plist"),used)) = kern_return_t acquire_mach_task(int tid, - mach_port_name_t *task, + task_t *task, mach_port_t *port_set, mach_port_t *exception_port, mach_port_t *notification_port) diff --git a/proc/proc_darwin.go b/proc/proc_darwin.go index 86a13721..e1eb8a42 100644 --- a/proc/proc_darwin.go +++ b/proc/proc_darwin.go @@ -9,13 +9,14 @@ import ( "debug/gosym" "errors" "fmt" - "golang.org/x/debug/macho" "os" "os/exec" "path/filepath" "sync" "unsafe" + "golang.org/x/debug/macho" + "github.com/derekparker/delve/dwarf/frame" "github.com/derekparker/delve/dwarf/line" sys "golang.org/x/sys/unix" @@ -23,9 +24,9 @@ import ( // OSProcessDetails holds Darwin specific information. type OSProcessDetails struct { - task C.mach_port_name_t // mach task for the debugged process. - exceptionPort C.mach_port_t // mach port for receiving mach exceptions. - notificationPort C.mach_port_t // mach port for dead name notification (process exit). + task C.task_t // mach task for the debugged process. + exceptionPort C.mach_port_t // mach port for receiving mach exceptions. + notificationPort C.mach_port_t // mach port for dead name notification (process exit). // the main port we use, will return messages from both the // exception and notification ports. @@ -144,7 +145,7 @@ func (dbp *Process) updateThreadList() error { ) for { - count = C.thread_count(C.task_t(dbp.os.task)) + count = C.thread_count(dbp.os.task) if count == -1 { return fmt.Errorf("could not get thread count") } @@ -152,7 +153,7 @@ func (dbp *Process) updateThreadList() error { // TODO(dp) might be better to malloc mem in C and then free it here // instead of getting count above and passing in a slice - kret = C.get_threads(C.task_t(dbp.os.task), unsafe.Pointer(&list[0]), count) + kret = C.get_threads(dbp.os.task, unsafe.Pointer(&list[0]), count) if kret != -2 { break } @@ -337,7 +338,7 @@ func (dbp *Process) waitForStop() ([]int, error) { count = 0 ports = append(ports, int(port)) } else { - n := C.num_running_threads(C.task_t(dbp.os.task)) + n := C.num_running_threads(dbp.os.task) if n == 0 { return ports, nil } else if n < 0 { diff --git a/proc/proc_darwin.h b/proc/proc_darwin.h index 1598cdf9..6abb7bfc 100644 --- a/proc/proc_darwin.h +++ b/proc/proc_darwin.h @@ -24,7 +24,7 @@ boolean_t mach_exc_server( mach_msg_header_t *OutHeadP); kern_return_t -acquire_mach_task(int, mach_port_name_t*, mach_port_t*, mach_port_t*, mach_port_t*); +acquire_mach_task(int, task_t*, mach_port_t*, mach_port_t*, mach_port_t*); char * find_executable(int pid); diff --git a/proc/threads_darwin.c b/proc/threads_darwin.c index 16f7a6da..ce3a850c 100644 --- a/proc/threads_darwin.c +++ b/proc/threads_darwin.c @@ -1,7 +1,7 @@ #include "threads_darwin.h" int -write_memory(mach_port_name_t task, mach_vm_address_t addr, void *d, mach_msg_type_number_t len) { +write_memory(task_t task, mach_vm_address_t addr, void *d, mach_msg_type_number_t len) { kern_return_t kret; vm_region_submap_short_info_data_64_t info; mach_msg_type_number_t count = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64; @@ -27,7 +27,7 @@ write_memory(mach_port_name_t task, mach_vm_address_t addr, void *d, mach_msg_ty } int -read_memory(mach_port_name_t task, mach_vm_address_t addr, void *d, mach_msg_type_number_t len) { +read_memory(task_t task, mach_vm_address_t addr, void *d, mach_msg_type_number_t len) { kern_return_t kret; pointer_t data; mach_msg_type_number_t count; diff --git a/proc/threads_darwin.h b/proc/threads_darwin.h index a77d434d..16c2513c 100644 --- a/proc/threads_darwin.h +++ b/proc/threads_darwin.h @@ -5,10 +5,10 @@ #include int -write_memory(mach_port_name_t, mach_vm_address_t, void *, mach_msg_type_number_t); +write_memory(task_t, mach_vm_address_t, void *, mach_msg_type_number_t); int -read_memory(mach_port_name_t, mach_vm_address_t, void *, mach_msg_type_number_t); +read_memory(task_t, mach_vm_address_t, void *, mach_msg_type_number_t); kern_return_t get_registers(mach_port_name_t, x86_thread_state64_t*);