delve/pkg/proc/native
Joel Sing 9c5777e762
pkg/proc: fix and improve freebsd register handling (#3019)
* pkg/proc: convert freebsd ptrace code to cgo

There is little point in having cgo call a custom C function, when the same
can be done directly from cgo (with less code and effort). Split the amd64
specific code into ptrace_freebsd_amd64.go. Also avoid mixing C.ptrace()
with syscall.SYS_PTRACE.

This will make further changes easier - no functional change intended.

* pkg/proc: check return values of ptrace calls on freebsd

The return values of the PT_GETNUMLWPS and PT_GETLWPLIST ptrace calls were
previously unchecked. While these should not fail, panic instead of using
-1 with slice allocation/handling.

* pkg/proc: return *amd64util.AMD64Xstate from freebsd ptraceGetRegset

Return a pointer to a struct, rather than a struct - this simplifies the
code in both the caller and the ptraceGetRegset function, while also avoiding
struct copying.

* pkg/proc: fix floating point register setting on freebsd

The original code could never work - PT_SETREGS on freebsd does not
take an iovec, nor does it set FP registers. Furthermore, the xsave
bytes were not stored in the amd64util.AMD64Xstate struct.

Updates #3001

* pkg/proc: re-enable function call injection on freebsd

Floating point registers can now be set and restored correctly.

This is a partial revert of 51090f003bace1f8cc37b8480ffdb6f6cc91fa5a.

Fixes #3001

* pkg/proc: deduplicate register setting code on freebsd
2022-05-31 16:04:36 -07:00
..
dump_linux_amd64.go terminal,service,proc/*: adds dump command (gcore equivalent) (#2173) 2021-01-29 13:39:33 -08:00
dump_linux_other.go fmt code (#2826) 2021-12-13 10:25:23 -08:00
dump_linux.go proc/native: ignore 'pf' mappings during core dump creation (#2761) 2021-12-14 06:26:08 -08:00
dump_other.go fmt code (#2826) 2021-12-13 10:25:23 -08:00
dump_windows_amd64.go terminal,service,proc/*: adds dump command (gcore equivalent) (#2173) 2021-01-29 13:39:33 -08:00
exc_user_darwin.c proc/native,Makefile: allow compiling on macOS without native backend 2018-10-02 10:46:09 -07:00
exc.h proc: refactoring: split backends to separate packages 2017-04-21 14:00:04 -07:00
exec_darwin.c proc/native,Makefile: allow compiling on macOS without native backend 2018-10-02 10:46:09 -07:00
exec_darwin.h proc/native,Makefile: allow compiling on macOS without native backend 2018-10-02 10:46:09 -07:00
hwbreak_amd64.go proc/native: support watchpoints on Windows (#2651) 2021-09-24 15:17:46 -07:00
hwbreak_other.go proc/native: support watchpoints on linux/arm64 (#2667) 2021-10-18 13:11:59 -07:00
mach_exc_user_darwin.c proc/native,Makefile: allow compiling on macOS without native backend 2018-10-02 10:46:09 -07:00
mach_exc.h proc: refactoring: split backends to separate packages 2017-04-21 14:00:04 -07:00
nonative_darwin.go proc: move resume notify and manual stop handling to Target (#2921) 2022-03-21 12:42:37 -07:00
proc_darwin.c proc/native,Makefile: allow compiling on macOS without native backend 2018-10-02 10:46:09 -07:00
proc_darwin.go proc: move resume notify and manual stop handling to Target (#2921) 2022-03-21 12:42:37 -07:00
proc_darwin.h proc/native,Makefile: allow compiling on macOS without native backend 2018-10-02 10:46:09 -07:00
proc_ebpf_linux.go *: Replace libbpfgo with cilium/ebpf (#2771) 2021-11-03 16:58:04 +01:00
proc_freebsd.c fix cast to smaller integer type 'int' from 'void *' (#2511) 2021-05-26 10:23:27 -07:00
proc_freebsd.go proc: move resume notify and manual stop handling to Target (#2921) 2022-03-21 12:42:37 -07:00
proc_freebsd.h fix cast to smaller integer type 'int' from 'void *' (#2511) 2021-05-26 10:23:27 -07:00
proc_linux.go proc: move resume notify and manual stop handling to Target (#2921) 2022-03-21 12:42:37 -07:00
proc_no_ebpf_linux.go *: Replace libbpfgo with cilium/ebpf (#2771) 2021-11-03 16:58:04 +01:00
proc_unix.go fmt code (#2826) 2021-12-13 10:25:23 -08:00
proc_windows.go proc: move resume notify and manual stop handling to Target (#2921) 2022-03-21 12:42:37 -07:00
proc.go proc: unlock OS thread on exit from handlePtraceFuncs (#2972) 2022-04-26 14:33:16 -07:00
ptrace_darwin.go fmt code (#2826) 2021-12-13 10:25:23 -08:00
ptrace_freebsd_amd64.go pkg/proc: fix and improve freebsd register handling (#3019) 2022-05-31 16:04:36 -07:00
ptrace_freebsd.go pkg/proc: fix and improve freebsd register handling (#3019) 2022-05-31 16:04:36 -07:00
ptrace_linux_64bit.go proc/native/linux: replace uses of unix.Iovec for target addresses (#2922) 2022-03-15 14:33:12 -07:00
ptrace_linux_386.go proc/native/linux: replace uses of unix.Iovec for target addresses (#2922) 2022-03-15 14:33:12 -07:00
ptrace_linux_amd64.go terminal,service,proc/*: adds dump command (gcore equivalent) (#2173) 2021-01-29 13:39:33 -08:00
ptrace_linux.go proc/native/linux: replace uses of unix.Iovec for target addresses (#2922) 2022-03-15 14:33:12 -07:00
register_linux_386.go proc/*: implement proc.(*compositeMemory).WriteMemory (#2271) 2021-03-04 10:28:28 -08:00
registers_darwin_amd64.go proc: support function call injection on arm64 (#2996) 2022-05-03 10:46:24 -07:00
registers_freebsd_amd64.go pkg/proc: fix and improve freebsd register handling (#3019) 2022-05-31 16:04:36 -07:00
registers_linux_amd64.go proc/*: implement proc.(*compositeMemory).WriteMemory (#2271) 2021-03-04 10:28:28 -08:00
registers_linux_arm64.go proc: support function call injection on arm64 (#2996) 2022-05-03 10:46:24 -07:00
registers_windows_amd64.go proc/native: fix Windows build (#3023) 2022-05-31 16:03:57 -07:00
support_sentinel.go fmt code (#2826) 2021-12-13 10:25:23 -08:00
syscall_windows_amd64.go proc: move windows register handling code to winutil package 2018-11-21 12:17:16 -08:00
syscall_windows.go terminal,service,proc/*: adds dump command (gcore equivalent) (#2173) 2021-01-29 13:39:33 -08:00
threads_darwin.c *: fix some typos 2022-03-23 16:10:00 +01:00
threads_darwin.go proc: better handling of hardcoded breakpoints (#2852) 2022-02-22 09:57:37 -08:00
threads_darwin.h proc/native,Makefile: allow compiling on macOS without native backend 2018-10-02 10:46:09 -07:00
threads_freebsd.go pkg/proc: fix and improve freebsd register handling (#3019) 2022-05-31 16:04:36 -07:00
threads_linux_386.go proc/native: support watchpoints on Windows (#2651) 2021-09-24 15:17:46 -07:00
threads_linux_amd64.go *: clean up staticcheck problems (#2723) 2021-09-28 12:07:42 -07:00
threads_linux_arm64.go proc: support function call injection on arm64 (#2996) 2022-05-03 10:46:24 -07:00
threads_linux.go proc: better handling of hardcoded breakpoints (#2852) 2022-02-22 09:57:37 -08:00
threads_windows.go proc: better handling of hardcoded breakpoints (#2852) 2022-02-22 09:57:37 -08:00
threads.go proc: move breakpoint condition evaluation out of backends (#2628) 2021-08-09 10:16:24 -07:00
zsyscall_windows.go terminal,service,proc/*: adds dump command (gcore equivalent) (#2173) 2021-01-29 13:39:33 -08:00