mirror of
https://github.com/go-delve/delve.git
synced 2025-11-02 04:36:29 +08:00
Move generic register structs/funcs to own file
This commit is contained in:
31
proctl/registers.go
Normal file
31
proctl/registers.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package proctl
|
||||||
|
|
||||||
|
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
|
||||||
|
SetPC(*ThreadContext, uint64) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtains register values from the debugged process.
|
||||||
|
func (thread *ThreadContext) 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 *ThreadContext) PC() (uint64, error) {
|
||||||
|
regs, err := thread.Registers()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return regs.PC(), nil
|
||||||
|
}
|
||||||
@ -23,34 +23,6 @@ type ThreadContext struct {
|
|||||||
os *OSSpecificDetails
|
os *OSSpecificDetails
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
|
||||||
SetPC(*ThreadContext, uint64) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtains register values from the debugged process.
|
|
||||||
func (thread *ThreadContext) 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 *ThreadContext) PC() (uint64, error) {
|
|
||||||
regs, err := thread.Registers()
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return regs.PC(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continue the execution of this thread. This method takes
|
// Continue the execution of this thread. This method takes
|
||||||
// software breakpoints into consideration and ensures that
|
// software breakpoints into consideration and ensures that
|
||||||
// we step over any breakpoints. It will restore the instruction,
|
// we step over any breakpoints. It will restore the instruction,
|
||||||
|
|||||||
Reference in New Issue
Block a user