Search code examples
goreverse-engineeringdelve

How to change a register value during debugging a Go binary using Delve?


Exactly as the question says: During debugging a Go binary, I want to change the value of a register. help set in (dlv) returns:

(dlv) help set

Changes the value of a variable.

[goroutine <n>] [frame <m>] set <variable> = <value>

See $GOPATH/src/github.com/go-delve/delve/Documentation/cli/expr.md for a description of supported expressions. Only numerical variables and pointers can be changed.

I've looked at the documentation but it sounds confusing to me. I appreciate any clarification. I simply need to change the value in a register.


Solution

  • The delve debugger CLI set command doesn't offer access to machine registers. You can only set source-code level variables. The phrase:

    Only numerical variables and pointers can be changed.

    means that some source-code variables cannot be manipulated this way, e.g., you can't call most runtime functions. For instance, even if you have math/big and therefore NewInt, you cannot use this to build a new *Int value.