delve/pkg/dwarf/regnum/arm64.go
Alessandro Arzilli 6a70d531bb
proc/*: implement proc.(*compositeMemory).WriteMemory (#2271)
Delve represents registerized variables (fully or partially) using
compositeMemory, implementing proc.(*compositeMemory).WriteMemory is
necessary to make SetVariable and function calls work when Go will
switch to using the register calling convention in 1.17.

This commit also makes some refactoring by moving the code that
converts between register numbers and register names out of pkg/proc
into a different package.
2021-03-04 10:28:28 -08:00

36 lines
729 B
Go

package regnum
import (
"fmt"
)
// The mapping between hardware registers and DWARF registers is specified
// in the DWARF for the ARM® Architecture page 7,
// Table 1
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0040b/IHI0040B_aadwarf.pdf
const (
ARM64_X0 = 0 // X1 through X30 follow
ARM64_BP = 29 // also X29
ARM64_LR = 30 // also X30
ARM64_SP = 31
ARM64_PC = 32
ARM64_V0 = 64 // V1 through V31 follow
)
func ARM64ToName(num uint64) string {
switch {
case num <= 30:
return fmt.Sprintf("X%d", num)
case num == ARM64_SP:
return "SP"
case num == ARM64_PC:
return "PC"
case num >= ARM64_V0 && num <= 95:
return fmt.Sprintf("V%d", num-64)
default:
return fmt.Sprintf("unknown%d", num)
}
}