2015-06-12 19:49:23 +00:00
|
|
|
package proc
|
2015-04-28 14:01:28 +00:00
|
|
|
|
2016-02-06 06:00:48 +00:00
|
|
|
import "errors"
|
2015-04-28 14:01:28 +00:00
|
|
|
|
2016-01-10 08:57:52 +00:00
|
|
|
// Registers is an interface for a generic register type. The
|
2015-04-28 14:01:28 +00:00
|
|
|
// interface encapsulates the generic values / actions
|
2016-05-29 19:44:10 +00:00
|
|
|
// we need independent of arch. The concrete register types
|
2015-04-28 14:01:28 +00:00
|
|
|
// will be different depending on OS/Arch.
|
|
|
|
type Registers interface {
|
|
|
|
PC() uint64
|
|
|
|
SP() uint64
|
2015-06-11 20:17:56 +00:00
|
|
|
CX() uint64
|
2015-07-28 05:33:07 +00:00
|
|
|
TLS() uint64
|
2016-02-06 06:00:48 +00:00
|
|
|
Get(int) (uint64, error)
|
2015-06-12 19:51:23 +00:00
|
|
|
SetPC(*Thread, uint64) error
|
2015-06-19 07:20:10 +00:00
|
|
|
String() string
|
2015-04-28 14:01:28 +00:00
|
|
|
}
|
|
|
|
|
2016-02-06 06:00:48 +00:00
|
|
|
var UnknownRegisterError = errors.New("unknown register")
|
|
|
|
|
2016-01-10 08:57:52 +00:00
|
|
|
// Registers obtains register values from the debugged process.
|
|
|
|
func (t *Thread) Registers() (Registers, error) {
|
2016-07-20 22:36:31 +00:00
|
|
|
return registers(t)
|
2015-04-28 14:01:28 +00:00
|
|
|
}
|
|
|
|
|
2016-01-10 08:57:52 +00:00
|
|
|
// PC returns the current PC for this thread.
|
|
|
|
func (t *Thread) PC() (uint64, error) {
|
|
|
|
regs, err := t.Registers()
|
2015-04-28 14:01:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return regs.PC(), nil
|
|
|
|
}
|