delve/pkg/proc/dwarf_export_test.go
Alessandro Arzilli 025d47c6e9
proc: adds pointer pinning to call injection (#3787)
This commit adds a new mode to call injection. If the runtime.debugPinner
function is available in the target executable it obtains a pinner by
calling it and then uses it to pin the pointers in the results of call
injection.

This allows the code for call injection to be refactored to execute the
calls in the normal order, since it doesn't need to be concerned with having
space on the target's memory to store intermediate values.

Updates #3310
2024-10-04 10:44:57 -07:00

44 lines
1.0 KiB
Go

package proc
import (
"github.com/go-delve/delve/pkg/dwarf/op"
"golang.org/x/arch/x86/x86asm"
)
// PackageVars returns bi.packageVars (for tests)
func (bi *BinaryInfo) PackageVars() []packageVar {
return bi.packageVars
}
func NewCompositeMemory(p *Target, pieces []op.Piece, base uint64) (*compositeMemory, error) {
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
mem, err := newCompositeMemory(p.Memory(), arch, *dwarfregs, pieces, 0)
if mem != nil {
mem.base = base
}
return mem, err
}
func IsJNZ(inst archInst) bool {
return inst.(*x86Inst).Op == x86asm.JNE
}
// 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
}