Skip to content

Commit

Permalink
Fix prologue detection on testvariables2.go's main.main (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarzilli authored and derekparker committed Sep 6, 2016
1 parent f2c1789 commit e4c7df1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
4 changes: 3 additions & 1 deletion proc/disasm_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ type instrseq []x86asm.Op

var windowsPrologue = instrseq{x86asm.MOV, x86asm.MOV, x86asm.LEA, x86asm.CMP, x86asm.JBE}
var windowsPrologue2 = instrseq{x86asm.MOV, x86asm.MOV, x86asm.CMP, x86asm.JBE}
var windowsPrologue3 = instrseq{x86asm.MOV, x86asm.MOV, x86asm.MOV, x86asm.CMP, x86asm.JE}
var unixPrologue = instrseq{x86asm.MOV, x86asm.LEA, x86asm.CMP, x86asm.JBE}
var unixPrologue2 = instrseq{x86asm.MOV, x86asm.CMP, x86asm.JBE}
var prologues = []instrseq{windowsPrologue, windowsPrologue2, unixPrologue, unixPrologue2}
var unixPrologue3 = instrseq{x86asm.MOV, x86asm.MOV, x86asm.CMP, x86asm.JE}
var prologues = []instrseq{windowsPrologue, windowsPrologue2, unixPrologue, unixPrologue2, unixPrologue3}

// FirstPCAfterPrologue returns the address of the first instruction after the prologue for function fn
// If sameline is set FirstPCAfterPrologue will always return an address associated with the same line as fn.Entry
Expand Down
2 changes: 1 addition & 1 deletion proc/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"go/token"
"reflect"

"golang.org/x/debug/dwarf"
"github.com/derekparker/delve/dwarf/reader"
"golang.org/x/debug/dwarf"
)

// EvalExpression returns the value of the given expression.
Expand Down
2 changes: 1 addition & 1 deletion proc/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"strings"
"sync"

"golang.org/x/debug/dwarf"
"github.com/derekparker/delve/dwarf/frame"
"github.com/derekparker/delve/dwarf/line"
"github.com/derekparker/delve/dwarf/reader"
"golang.org/x/debug/dwarf"
)

// Process represents all of the information the debugger
Expand Down
2 changes: 1 addition & 1 deletion proc/proc_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (

sys "golang.org/x/sys/unix"

"golang.org/x/debug/elf"
"github.com/derekparker/delve/dwarf/frame"
"github.com/derekparker/delve/dwarf/line"
"golang.org/x/debug/elf"
)

// Process statuses
Expand Down
14 changes: 13 additions & 1 deletion proc/proc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1882,7 +1882,7 @@ func TestUnsupportedArch(t *testing.T) {
}
}

func Test1Issue573(t *testing.T) {
func TestIssue573(t *testing.T) {
// calls to runtime.duffzero and runtime.duffcopy jump directly into the middle
// of the function and the temp breakpoint set by StepInto may be missed.
withTestProcess("issue573", t, func(p *Process, fixture protest.Fixture) {
Expand All @@ -1895,3 +1895,15 @@ func Test1Issue573(t *testing.T) {
assertNoError(p.Step(), t, "Step() #3") // Third step ought to be possible; program ought not have exited.
})
}

func TestTestvariables2Prologue(t *testing.T) {
withTestProcess("testvariables2", t, func(p *Process, fixture protest.Fixture) {
addrEntry, err := p.FindFunctionLocation("main.main", false, 0)
assertNoError(err, t, "FindFunctionLocation - entrypoint")
addrPrologue, err := p.FindFunctionLocation("main.main", true, 0)
assertNoError(err, t, "FindFunctionLocation - postprologue")
if addrEntry == addrPrologue {
t.Fatalf("Prologue detection failed on testvariables2.go/main.main")
}
})
}
2 changes: 1 addition & 1 deletion proc/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"strings"
"unsafe"

"golang.org/x/debug/dwarf"
"github.com/derekparker/delve/dwarf/op"
"github.com/derekparker/delve/dwarf/reader"
"golang.org/x/debug/dwarf"
)

const (
Expand Down

0 comments on commit e4c7df1

Please sign in to comment.