diff --git a/pkg/proc/ppc64le_disasm.go b/pkg/proc/ppc64le_disasm.go index d8d55a1dc3..b91b98ae8d 100644 --- a/pkg/proc/ppc64le_disasm.go +++ b/pkg/proc/ppc64le_disasm.go @@ -2,6 +2,7 @@ package proc import ( "encoding/binary" + "github.com/go-delve/delve/pkg/dwarf/op" "github.com/go-delve/delve/pkg/dwarf/regnum" "golang.org/x/arch/ppc64/ppc64asm" @@ -61,7 +62,17 @@ func ppc64leAsmDecode(asmInst *AsmInstruction, mem []byte, regs *op.DwarfRegiste func resolveCallArgPPC64LE(inst *ppc64asm.Inst, instAddr uint64, currentGoroutine bool, regs *op.DwarfRegisters, mem MemoryReadWriter, bininfo *BinaryInfo) *Location { switch inst.Op { - case ppc64asm.B, ppc64asm.BL, ppc64asm.BLA, ppc64asm.BCL, ppc64asm.BCLA, ppc64asm.BCLR, ppc64asm.BCLRL, ppc64asm.BCCTRL, ppc64asm.BCTARL: + case ppc64asm.BCLRL, ppc64asm.BCLR: + if regs != nil && regs.PC() == instAddr { + pc := regs.Reg(bininfo.Arch.LRRegNum).Uint64Val + file, line, fn := bininfo.PCToLine(pc) + if fn == nil { + return &Location{PC: pc} + } + return &Location{PC: pc, File: file, Line: line, Fn: fn} + } + return nil + case ppc64asm.B, ppc64asm.BL, ppc64asm.BLA, ppc64asm.BCL, ppc64asm.BCLA, ppc64asm.BCCTRL, ppc64asm.BCTARL: // ok default: return nil diff --git a/pkg/proc/target_exec.go b/pkg/proc/target_exec.go index 703084b183..396d0e2dde 100644 --- a/pkg/proc/target_exec.go +++ b/pkg/proc/target_exec.go @@ -7,11 +7,12 @@ import ( "fmt" "go/ast" "go/token" - "golang.org/x/arch/ppc64/ppc64asm" "path/filepath" "runtime" "strings" + "golang.org/x/arch/ppc64/ppc64asm" + "github.com/go-delve/delve/pkg/astutil" "github.com/go-delve/delve/pkg/dwarf/reader" ) @@ -155,6 +156,7 @@ func (grp *TargetGroup) Continue() error { // here we either set a breakpoint into the destination of the CALL // instruction or we determined that the called function is hidden, // either way we need to resume execution + fmt.Println("stepping into ++++++++") if err = setStepIntoBreakpoint(dbp, fn, text, sameGoroutineCondition(dbp.SelectedGoroutine())); err != nil { return err } @@ -648,7 +650,9 @@ func next(dbp *Target, stepInto, inlinedStepOut bool) error { } func setStepIntoBreakpoints(dbp *Target, curfn *Function, text []AsmInstruction, topframe Stackframe, sameGCond ast.Expr) error { + fmt.Println("set step into breakpoints") for _, instr := range text { + fmt.Printf("instr: %v\n", instr.Text(IntelFlavour, dbp.BinInfo())) if instr.Loc.File != topframe.Current.File || instr.Loc.Line != topframe.Current.Line || !instr.IsCall() { continue } @@ -658,12 +662,14 @@ func setStepIntoBreakpoints(dbp *Target, curfn *Function, text []AsmInstruction, return err } } else { + fmt.Println("non absolute") // Non-absolute call instruction, set a StepBreakpoint here if _, err := allowDuplicateBreakpoint(dbp.SetBreakpoint(0, instr.Loc.PC, StepBreakpoint, sameGCond)); err != nil { return err } } } + fmt.Println("fin set step into breakpoints") return nil } @@ -754,19 +760,21 @@ func setStepIntoBreakpoint(dbp *Target, curfn *Function, text []AsmInstruction, pc := instr.DestLoc.PC fn := instr.DestLoc.Fn + fmt.Println("PC before: ", pc) + fmt.Printf("instr: %v\n", instr.Text(IntelFlavour, dbp.BinInfo())) + if fn != nil { + fmt.Println("fn before: ", fn.Name) + } - if runtime.GOARCH == "ppc64le" && (instr.Inst.OpcodeEquals(uint64(ppc64asm.BCLRL))) { + if runtime.GOARCH == "ppc64le" && instr.Inst.OpcodeEquals(uint64(ppc64asm.BCLRL)) { fmt.Println("----- found bclrl instruction") regs, err := dbp.CurrentThread().Registers() if err != nil { return err } - fmt.Println("LR after: ", pc) - pc = regs.LR() - fn = dbp.BinInfo().PCToFunc(pc) - fmt.Println("LR before: ", pc) - fmt.Println("FN: ", fn) - fmt.Printf("lr: %#x fn: %s\n", regs.LR(), fn.Name) + lr := regs.LR() + fn = dbp.BinInfo().PCToFunc(lr) + fmt.Printf("pc: %#x lr: %#x fn: %s\n", regs.PC(), regs.LR(), fn.Name) } // Skip unexported runtime functions