delve/pkg/proc
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
..
amd64util fmt code (#2826) 2021-12-13 10:25:23 -08:00
core proc/core: return true for calls to Recorded (#2979) 2022-05-04 10:56:41 -07:00
debuginfod Implement source listing from debuginfo (#2885) 2022-01-30 13:39:30 -08:00
fbsdutil pkg/proc: fix and improve freebsd register handling (#3019) 2022-05-31 16:04:36 -07:00
gdbserial proc,service: represent logical breakpoints explicitly (#2946) 2022-05-25 13:58:26 -07:00
internal/ebpf pkg/proc: switch to Dual MIT/GPL license for ebpf (#2849) 2021-12-30 20:14:37 +01:00
linutil proc: fix RFLAGS corruption after call injection on amd64 (#3002) 2022-05-05 08:41:40 -07:00
macutil fmt code (#2826) 2021-12-13 10:25:23 -08:00
native pkg/proc: fix and improve freebsd register handling (#3019) 2022-05-31 16:04:36 -07:00
test pkg/proc: fix and improve freebsd register handling (#3019) 2022-05-31 16:04:36 -07:00
winutil proc: support function call injection on arm64 (#2996) 2022-05-03 10:46:24 -07:00
amd64_arch.go proc: support function call injection on arm64 (#2996) 2022-05-03 10:46:24 -07:00
amd64_disasm.go proc: remove duplicate Registers.Get implementations (#2415) 2021-04-28 10:00:26 -07:00
arch.go proc: support function call injection on arm64 (#2996) 2022-05-03 10:46:24 -07:00
arm64_arch.go proc: support function call injection on arm64 (#2996) 2022-05-03 10:46:24 -07:00
arm64_disasm.go proc: remove duplicate Registers.Get implementations (#2415) 2021-04-28 10:00:26 -07:00
bininfo.go *: fix some typos 2022-03-23 16:10:00 +01:00
breakpoints.go proc,service: represent logical breakpoints explicitly (#2946) 2022-05-25 13:58:26 -07:00
disasm.go proc: remove duplicate Registers.Get implementations (#2415) 2021-04-28 10:00:26 -07:00
doc.go Move top-level packages into pkg 2017-02-08 12:17:19 -08:00
dump.go *: fix some typos 2022-03-23 16:10:00 +01:00
dwarf_export_test.go proc: fix RFLAGS corruption after call injection on amd64 (#3002) 2022-05-05 08:41:40 -07:00
dwarf_expr_test.go pkg/proc: merge register data before writing to register (#2699) 2021-09-24 15:27:44 -07:00
eval_go117.go proc: better error messages for ambiguous function calls/type casts (#2903) 2022-02-22 09:55:59 -08:00
eval_go118.go proc: better error messages for ambiguous function calls/type casts (#2903) 2022-02-22 09:55:59 -08:00
eval.go proc: allow low index == len in reslice (#2951) 2022-03-29 09:57:11 -07:00
fncall.go proc: fix RFLAGS corruption after call injection on amd64 (#3002) 2022-05-05 08:41:40 -07:00
goroutine_cache.go proc/*,service: replace uses of uintptr with uint64 (#2163) 2020-09-09 10:36:15 -07:00
i386_arch.go Misc fixes for test problems (#2751) 2021-10-18 13:17:47 -07:00
i386_disasm.go proc: remove duplicate Registers.Get implementations (#2415) 2021-04-28 10:00:26 -07:00
interface.go proc: move resume notify and manual stop handling to Target (#2921) 2022-03-21 12:42:37 -07:00
mem.go pkg/proc: merge register data before writing to register (#2699) 2021-09-24 15:27:44 -07:00
moduledata.go _scripts: auto check that pkg/proc and runtime are synchronized (#2557) 2021-08-23 11:32:02 -07:00
pe.go proc: fix typo 'unkown' => 'unknown' (#2473) 2021-05-10 11:36:03 -07:00
proc_general_test.go proc,locspec: support setting breakpoints by func name on generic funcs (#2745) 2021-10-30 11:52:26 -07:00
proc_linux_test.go proc/*: add launch option to disable ASLR (#2202) 2020-10-21 12:50:52 -07:00
proc_test.go proc,service: represent logical breakpoints explicitly (#2946) 2022-05-25 13:58:26 -07:00
proc_unexported_test.go proc: correctly truncate the result of binary ops on integers (#2463) 2021-05-17 10:31:05 -07:00
proc_unix_test.go tests: fix TestIssue419 (#2682) 2021-08-31 10:44:57 -07:00
registers.go proc: support function call injection on arm64 (#2996) 2022-05-03 10:46:24 -07:00
scope_test.go proc/*: minor miscellaneous code cleanups (#2790) 2021-11-26 08:06:23 -08:00
stack.go Updates for go1.18beta1 (#2831) 2021-12-22 10:26:21 -08:00
stackwatch.go proc,service: represent logical breakpoints explicitly (#2946) 2022-05-25 13:58:26 -07:00
target_exec.go proc,service: represent logical breakpoints explicitly (#2946) 2022-05-25 13:58:26 -07:00
target.go pkg/proc: fix and improve freebsd register handling (#3019) 2022-05-31 16:04:36 -07:00
threads.go proc: support function call injection on arm64 (#2996) 2022-05-03 10:46:24 -07:00
types.go proc,dwarf/godwarf: support parametric types with dictionaries 2021-10-02 15:44:30 +02:00
variable_test.go pkg/proc: Move proc exec funcs to Target methods 2020-03-25 17:45:12 +01:00
variables.go proc,service: pretty print time.Time variables (#2865) 2022-03-25 13:59:57 -07:00
x86_disasm.go proc: remove duplicate Registers.Get implementations (#2415) 2021-04-28 10:00:26 -07:00