mirror of
				https://github.com/go-delve/delve.git
				synced 2025-10-31 02:36:18 +08:00 
			
		
		
		
	 463b97dd36
			
		
	
	463b97dd36
	
	
	
		
			
			* pkg/proc: pad variable mem in extractVarInfoFromEntry
On 64 bit system, the byte size of the following struct is 16:
    type myStruct struct {
       a int
       b uint32
    }
But extractVarInfoFromEntry only allocates a mem of 12 bytes for it.
When calling method of this struct with the "call" command, it will
result in this error:
    write out of bounds
This patch extends the mem by adding padding bytes to the end of the
mem.
Fixes #3364.
* move the padding logic into newCompositeMemory
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			742 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			742 B
		
	
	
	
		
			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
 | |
| }
 |