File: proc_darwin_amd64_test.go

package info (click to toggle)
delve 1.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,136 kB
  • sloc: ansic: 111,947; sh: 194; asm: 147; makefile: 43; python: 23
file content (49 lines) | stat: -rw-r--r-- 1,353 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package proc_test

import (
	"testing"

	"github.com/go-delve/delve/pkg/dwarf/op"
	"github.com/go-delve/delve/pkg/dwarf/regnum"
	"github.com/go-delve/delve/pkg/proc"

	protest "github.com/go-delve/delve/pkg/proc/test"
)

func TestSetYMMRegister(t *testing.T) {
	// Checks that setting a XMM register works. This checks that the
	// workaround for a bug in debugserver works.
	// See issue #2767.
	withTestProcess("setymmreg/", t, func(p *proc.Target, grp *proc.TargetGroup, fixture protest.Fixture) {
		setFunctionBreakpoint(p, t, "main.asmFunc")
		assertNoError(grp.Continue(), t, "Continue()")

		getReg := func(pos string) *op.DwarfRegister {
			regs := getRegisters(p, t)

			arch := p.BinInfo().Arch
			dregs := arch.RegistersToDwarfRegisters(0, regs)

			r := dregs.Reg(regnum.AMD64_XMM0)
			t.Logf("%s: %#v", pos, r)
			return r
		}

		getReg("before")

		p.CurrentThread().SetReg(regnum.AMD64_XMM0, op.DwarfRegisterFromBytes([]byte{
			0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
			0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
			0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
			0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44}))
		assertNoError(grp.StepInstruction(false), t, "StepInstruction")

		xmm0 := getReg("after")

		for i := range xmm0.Bytes {
			if xmm0.Bytes[i] != 0x44 {
				t.Fatalf("wrong register value")
			}
		}
	})
}