{"record":{"id":"1f830178508d6612","repo":"go-delve/delve","slug":"changing-register-d-not-implemented-1f8301","errorCode":null,"errorMessage":"changing register %d not implemented","messagePattern":"changing register (.+?) not implemented","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/proc/native/registers_darwin_amd64.go","lineNumber":130,"sourceCode":"}\n\nfunc (r *Regs) GAddr() (uint64, bool) {\n\treturn 0, false\n}\n\n// SetPC sets the RIP register to the value specified by `pc`.\nfunc (thread *nativeThread) setPC(pc uint64) error {\n\tkret := C.set_pc(thread.os.threadAct, C.uint64_t(pc))\n\tif kret != C.KERN_SUCCESS {\n\t\treturn fmt.Errorf(\"could not set pc\")\n\t}\n\treturn nil\n}\n\n// SetReg changes the value of the specified register.\nfunc (thread *nativeThread) SetReg(regNum uint64, reg *op.DwarfRegister) error {\n\tif regNum != regnum.AMD64_Rip {\n\t\treturn fmt.Errorf(\"changing register %d not implemented\", regNum)\n\t}\n\treturn thread.setPC(reg.Uint64Val)\n}\n\nfunc (r *Regs) Get(n int) (uint64, error) {\n\treg := x86asm.Reg(n)\n\tconst (\n\t\tmask8  = 0x000f\n\t\tmask16 = 0x00ff\n\t\tmask32 = 0xffff\n\t)\n\n\tswitch reg {\n\t// 8-bit\n\tcase x86asm.AL:\n\t\treturn r.rax & mask8, nil\n\tcase x86asm.CL:\n\t\treturn r.rcx & mask8, nil","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/native/registers_darwin_amd64.go#L112-L148","documentation":"On darwin/amd64, nativeThread.SetReg only implements changing the instruction pointer (AMD64_Rip via setPC). Any other register number returns this 'not implemented' error. It is an explicit API limitation of the darwin backend, not a runtime/kernel fault.","triggerScenarios":"Calling SetReg (directly or via register-restoring machinery such as non-step breakpoint clears or RPC calls) with any register other than Rip on macOS.","commonSituations":"Restoring full register sets saved earlier; setting variables held in registers; automation/scripts issuing SetReg for arbitrary DWARF register numbers on macOS.","solutions":["Restrict register mutation to Rip on darwin; for other registers use higher-level operations (restart, step)","Extend SetReg with a Mach thread_set_state path for additional registers and upstream the patch","Use a Linux target if arbitrary register writes are required by your workflow"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before calling SetReg on darwin\nif regNum != regnum.AMD64_Rip {\n\treturn fmt.Errorf(\"only Rip can be set on darwin/amd64 (got %d)\", regNum)\n}","typeGuard":"func canSetRegDarwin(regNum uint64) bool {\n\treturn regNum == regnum.AMD64_Rip\n}","tryCatchPattern":"err := thread.SetReg(regNum, reg)\nif err != nil && strings.Contains(err.Error(), \"not implemented\") {\n\treturn fmt.Errorf(\"register %d unsupported on darwin; use restart/step instead\", regNum)\n}","preventionTips":["Only set Rip on macOS; avoid full-register restores on darwin backend","Design workflows around step/restart rather than raw register writes","Extend via thread_set_state upstream if more registers are needed"],"tags":["darwin","mach","registers","not-implemented","limitation"],"backgroundTag":"register-write-not-implemented","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}