2020-07-16 12:53:59 +00:00
|
|
|
package proc
|
|
|
|
|
2022-05-05 15:41:40 +00:00
|
|
|
import (
|
|
|
|
"github.com/go-delve/delve/pkg/dwarf/op"
|
|
|
|
"golang.org/x/arch/x86/x86asm"
|
|
|
|
)
|
2021-03-04 18:28:28 +00:00
|
|
|
|
2020-07-16 12:53:59 +00:00
|
|
|
// PackageVars returns bi.packageVars (for tests)
|
|
|
|
func (bi *BinaryInfo) PackageVars() []packageVar {
|
|
|
|
return bi.packageVars
|
|
|
|
}
|
2021-03-04 18:28:28 +00:00
|
|
|
|
2021-07-02 16:37:55 +00:00
|
|
|
func NewCompositeMemory(p *Target, pieces []op.Piece, base uint64) (*compositeMemory, error) {
|
2021-03-04 18:28:28 +00:00
|
|
|
regs, err := p.CurrentThread().Registers()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
arch := p.BinInfo().Arch
|
|
|
|
dwarfregs := arch.RegistersToDwarfRegisters(0, regs)
|
|
|
|
dwarfregs.ChangeFunc = p.CurrentThread().SetReg
|
|
|
|
|
2023-05-15 21:46:33 +00:00
|
|
|
mem, err := newCompositeMemory(p.Memory(), arch, *dwarfregs, pieces, 0)
|
2021-07-02 16:37:55 +00:00
|
|
|
if mem != nil {
|
|
|
|
mem.base = base
|
|
|
|
}
|
|
|
|
return mem, err
|
2021-03-04 18:28:28 +00:00
|
|
|
}
|
2022-05-05 15:41:40 +00:00
|
|
|
|
|
|
|
func IsJNZ(inst archInst) bool {
|
|
|
|
return inst.(*x86Inst).Op == x86asm.JNE
|
|
|
|
}
|
2024-10-04 17:44:57 +00:00
|
|
|
|
|
|
|
// HasDebugPinner returns true if the target has runtime.debugPinner.
|
|
|
|
func (bi *BinaryInfo) HasDebugPinner() bool {
|
|
|
|
return bi.hasDebugPinner()
|
|
|
|
}
|
|
|
|
|
|
|
|
// DebugPinCount returns the number of addresses pinned during the last
|
|
|
|
// function call injection.
|
|
|
|
func DebugPinCount() int {
|
|
|
|
return debugPinCount
|
|
|
|
}
|