{"record":{"id":"230c89e77432e411","repo":"go-delve/delve","slug":"failed-to-get-xstate-info-v","errorCode":null,"errorMessage":"failed to get xstate info: %v","messagePattern":"failed to get xstate info: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/native/ptrace_freebsd_amd64.go","lineNumber":29,"sourceCode":"\t\"unsafe\"\n\n\t\"github.com/go-delve/delve/pkg/proc/amd64util\"\n\t\"github.com/go-delve/delve/pkg/proc/native/cpuid\"\n)\n\nvar (\n\txsaveLen int\n\txsaveErr error\n)\n\nfunc ptraceGetXsaveLen(tid int) (int, error) {\n\tvar info C.struct_ptrace_xstate_info\n\tret, err := C.ptrace(C.PT_GETXSTATE_INFO, C.pid_t(tid), C.caddr_t(unsafe.Pointer(&info)), C.int(unsafe.Sizeof(info)))\n\tif ret == 0 {\n\t\txsaveLen = int(info.xsave_len)\n\t} else {\n\t\txsaveLen, xsaveErr = -1, err\n\t\treturn xsaveLen, fmt.Errorf(\"failed to get xstate info: %v\", err)\n\t}\n\treturn xsaveLen, nil\n}\n\nfunc ptraceXsaveLen(tid int) (int, error) {\n\tif xsaveLen > 0 {\n\t\treturn xsaveLen, nil\n\t}\n\tif xsaveLen < 0 {\n\t\treturn xsaveLen, fmt.Errorf(\"failed to get xstate info: %v\", xsaveErr)\n\t}\n\treturn ptraceGetXsaveLen(tid)\n}\n\n// ptraceGetXsave gets the X86 XSAVE data for the given tid.\nfunc ptraceGetXsave(tid int) ([]byte, error) {\n\tlen, err := ptraceXsaveLen(tid)\n\tif err != nil {","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/native/ptrace_freebsd_amd64.go#L11-L47","documentation":"On FreeBSD/amd64 the native backend reads the XSAVE area size via PT_GETXSTATE_INFO to read extended CPU register state (XMM, AVX). ptraceGetXsaveLen caches this length; if the ptrace call fails it stores a negative length plus this wrapped error. Failure means the kernel does not support the xstate ptrace interface or the tid is invalid.","triggerScenarios":"Register/register-info evaluation on FreeBSD when PT_GETXSTATE_INFO fails — unsupported kernel (pre-xsave ptrace interface), non-amd64 mismatch, or dead/invalid thread id.","commonSituations":"Running an older FreeBSD kernel without XSAVE ptrace support; debugging a thread that just exited (stale tid); virtualized environments restricting ptrace xstate operations.","solutions":["Check the wrapped ptrace error in %v (errno) — ESRCH usually means the thread exited; retry with a live thread.","Verify kernel support: sysctl hw.instruction and FreeBSD version >= 9 with XSAVE enabled.","Ensure XSAVE is enabled in BIOS/hypervisor (it can be disabled in some VM configurations).","Update Delve — FreeBSD register support continues to evolve."],"exampleFix":"// before\npw.error: failed to get xstate info: no such process\n// (thread exited before register read)\n// after\n# ensure the process is still stopped/alive before reading registers\nproc status <pid>  # or re-select a live goroutine in delve\ndlv attach <pid>","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"v, err := eval.Variable(\"someVar\")\nif err != nil && strings.Contains(err.Error(), \"failed to get xstate info\") {\n    // check errno in message: ESRCH -> thread exited, re-select live goroutine and retry\n}","preventionTips":["Ensure the target stays stopped/alive while reading registers.","Enable XSAVE in BIOS/hypervisor configuration.","Use a FreeBSD version with xstate ptrace support."],"tags":["freebsd","ptrace","registers","xsave"],"backgroundTag":"xstate-read-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}