mirror of
https://github.com/go-delve/delve.git
synced 2025-10-30 10:17:03 +08:00
35 lines
790 B
Go
35 lines
790 B
Go
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
|
|
SetPC(*Thread, uint64) error
|
|
String() string
|
|
}
|
|
|
|
// Obtains register values from the debugged process.
|
|
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.
|
|
func (thread *Thread) PC() (uint64, error) {
|
|
regs, err := thread.Registers()
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return regs.PC(), nil
|
|
}
|