
Implement debugging function for 386 on linux with reference to AMD64. There are a few remaining problems that need to be solved in another time. 1. The stacktrace of cgo are not exactly as expected. 2. Not implement `core` for now. 3. Not implement `call` for now. Can't not find `runtime·debugCallV1` or similar function in $GOROOT/src/runtime/asm_386.s. Update #20
26 lines
515 B
Go
26 lines
515 B
Go
package op
|
|
|
|
import (
|
|
"testing"
|
|
"unsafe"
|
|
)
|
|
|
|
func ptrSizeByRuntimeArch() int {
|
|
return int(unsafe.Sizeof(uintptr(0)))
|
|
}
|
|
|
|
func TestExecuteStackProgram(t *testing.T) {
|
|
var (
|
|
instructions = []byte{byte(DW_OP_consts), 0x1c, byte(DW_OP_consts), 0x1c, byte(DW_OP_plus)}
|
|
expected = int64(56)
|
|
)
|
|
actual, _, err := ExecuteStackProgram(DwarfRegisters{}, instructions, ptrSizeByRuntimeArch())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if actual != expected {
|
|
t.Fatalf("actual %d != expected %d", actual, expected)
|
|
}
|
|
}
|