Example #1
0
func defcfa(frame *FrameContext) {
	reg, _ := util.DecodeULEB128(frame.buf)
	offset, _ := util.DecodeULEB128(frame.buf)

	frame.cfa.register = reg
	frame.cfa.offset = int64(offset)
}
Example #2
0
func parseCIE(ctx *parseContext) parsefunc {
	data := ctx.buf.Next(int(ctx.length))
	buf := bytes.NewBuffer(data)
	// parse version
	ctx.common.Version = data[0]

	// parse augmentation
	ctx.common.Augmentation, _ = util.ParseString(buf)

	// parse code alignment factor
	ctx.common.CodeAlignmentFactor, _ = util.DecodeULEB128(buf)

	// parse data alignment factor
	ctx.common.DataAlignmentFactor, _ = util.DecodeSLEB128(buf)

	// parse return address register
	ctx.common.ReturnAddressRegister, _ = util.DecodeULEB128(buf)

	// parse initial instructions
	// The rest of this entry consists of the instructions
	// so we can just grab all of the data from the buffer
	// cursor to length.
	ctx.common.InitialInstructions = buf.Bytes() //ctx.buf.Next(int(ctx.length))
	ctx.length = 0

	return parselength
}
Example #3
0
func valoffset(frame *FrameContext) {
	var (
		reg, _    = util.DecodeULEB128(frame.buf)
		offset, _ = util.DecodeULEB128(frame.buf)
	)

	frame.regs[reg] = DWRule{offset: int64(offset), rule: rule_valoffset}
}
Example #4
0
func offsetextended(frame *FrameContext) {
	var (
		reg, _    = util.DecodeULEB128(frame.buf)
		offset, _ = util.DecodeULEB128(frame.buf)
	)

	frame.regs[reg] = DWRule{offset: int64(offset) * frame.dataAlignment, rule: rule_offset}
}
Example #5
0
func valexpression(frame *FrameContext) {
	var (
		reg, _ = util.DecodeULEB128(frame.buf)
		l, _   = util.DecodeULEB128(frame.buf)
		expr   = frame.buf.Next(int(l))
	)

	frame.regs[reg] = DWRule{rule: rule_valexpression, expression: expr}
}
Example #6
0
func definefile(sm *StateMachine, buf *bytes.Buffer) {
	var (
		_, _ = util.ParseString(buf)
		_, _ = util.DecodeULEB128(buf)
		_, _ = util.DecodeULEB128(buf)
		_, _ = util.DecodeULEB128(buf)
	)

	// Don't do anything here yet.
}
Example #7
0
func defcfasf(frame *FrameContext) {
	reg, _ := util.DecodeULEB128(frame.buf)
	offset, _ := util.DecodeSLEB128(frame.buf)

	frame.cfa.register = reg
	frame.cfa.offset = offset * frame.dataAlignment
}
Example #8
0
func valoffsetsf(frame *FrameContext) {
	var (
		reg, _    = util.DecodeULEB128(frame.buf)
		offset, _ = util.DecodeSLEB128(frame.buf)
	)

	frame.regs[reg] = DWRule{offset: offset * frame.dataAlignment, rule: rule_valoffset}
}
Example #9
0
func parseFileEntries(info *DebugLineInfo, buf *bytes.Buffer) {
	for {
		entry := new(FileEntry)

		name, _ := util.ParseString(buf)
		if name == "" {
			break
		}

		entry.Name = name
		entry.DirIdx, _ = util.DecodeULEB128(buf)
		entry.LastModTime, _ = util.DecodeULEB128(buf)
		entry.Length, _ = util.DecodeULEB128(buf)

		info.FileNames = append(info.FileNames, entry)
	}
}
Example #10
0
func defcfaexpression(frame *FrameContext) {
	var (
		l, _ = util.DecodeULEB128(frame.buf)
		expr = frame.buf.Next(int(l))
	)

	frame.cfa.expression = expr
	frame.cfa.rule = rule_expression
}
Example #11
0
func restoreextended(frame *FrameContext) {
	reg, _ := util.DecodeULEB128(frame.buf)

	oldrule, ok := frame.initialRegs[reg]
	if ok {
		frame.regs[reg] = DWRule{offset: oldrule.offset, rule: rule_offset}
	} else {
		frame.regs[reg] = DWRule{rule: rule_undefined}
	}
}
Example #12
0
func execExtendedOpcode(sm *StateMachine, instr byte, buf *bytes.Buffer) {
	_, _ = util.DecodeULEB128(buf)
	b, _ := buf.ReadByte()
	fn, ok := extendedopcodes[b]
	if !ok {
		panic(fmt.Sprintf("Encountered unknown extended opcode %#v\n", b))
	}
	sm.lastWasStandard = false

	fn(sm, buf)
}
Example #13
0
func offset(frame *FrameContext) {
	b, err := frame.buf.ReadByte()
	if err != nil {
		panic(err)
	}

	var (
		reg       = b & low_6_offset
		offset, _ = util.DecodeULEB128(frame.buf)
	)

	frame.regs[uint64(reg)] = DWRule{offset: int64(offset) * frame.dataAlignment, rule: rule_offset}
}
Example #14
0
func samevalue(frame *FrameContext) {
	reg, _ := util.DecodeULEB128(frame.buf)
	frame.regs[reg] = DWRule{rule: rule_sameval}
}
Example #15
0
func advancepc(sm *StateMachine, buf *bytes.Buffer) {
	addr, _ := util.DecodeULEB128(buf)
	sm.address += addr * uint64(sm.dbl.Prologue.MinInstrLength)
}
Example #16
0
func defcfaoffset(frame *FrameContext) {
	offset, _ := util.DecodeULEB128(frame.buf)
	frame.cfa.offset = int64(offset)
}
Example #17
0
func defcfaregister(frame *FrameContext) {
	reg, _ := util.DecodeULEB128(frame.buf)
	frame.cfa.register = reg
}
Example #18
0
func setfile(sm *StateMachine, buf *bytes.Buffer) {
	i, _ := util.DecodeULEB128(buf)
	sm.file = sm.dbl.FileNames[i-1].Name
}
Example #19
0
func setcolumn(sm *StateMachine, buf *bytes.Buffer) {
	c, _ := util.DecodeULEB128(buf)
	sm.column = uint(c)
}
Example #20
0
func undefined(frame *FrameContext) {
	reg, _ := util.DecodeULEB128(frame.buf)
	frame.regs[reg] = DWRule{rule: rule_undefined}
}
Example #21
0
File: op.go Project: no2key/delve
func plusuconsts(buf *bytes.Buffer, stack []int64, cfa int64) ([]int64, error) {
	slen := len(stack)
	num, _ := util.DecodeULEB128(buf)
	stack[slen-1] = stack[slen-1] + int64(num)
	return stack, nil
}
Example #22
0
func register(frame *FrameContext) {
	reg1, _ := util.DecodeULEB128(frame.buf)
	reg2, _ := util.DecodeULEB128(frame.buf)
	frame.regs[reg1] = DWRule{newreg: reg2, rule: rule_register}
}