delve/proc/registers.go

35 lines
790 B
Go
Raw Normal View History

2015-06-12 19:49:23 +00:00
package proc
import "fmt"
// An interface for a generic register type. The
// interface encapsulates the generic values / actions
// we need independant of arch. The concrete register types
// will be different depending on OS/Arch.
type Registers interface {
PC() uint64
SP() uint64
CX() uint64
TLS() uint64
2015-06-12 19:51:23 +00:00
SetPC(*Thread, uint64) error
String() string
}
// Obtains register values from the debugged process.
2015-06-12 19:51:23 +00:00
func (thread *Thread) Registers() (Registers, error) {
regs, err := registers(thread)
if err != nil {
return nil, fmt.Errorf("could not get registers: %s", err)
}
return regs, nil
}
// Returns the current PC for this thread.
2015-06-12 19:51:23 +00:00
func (thread *Thread) PC() (uint64, error) {
regs, err := thread.Registers()
if err != nil {
return 0, err
}
return regs.PC(), nil
}