Skip to content

Commit

Permalink
additional cleanup, go fmt run
Browse files Browse the repository at this point in the history
  • Loading branch information
archanaravindar committed Aug 7, 2023
1 parent 16d5746 commit a8d2c16
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
41 changes: 21 additions & 20 deletions pkg/proc/fncall.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,16 @@ func evalFunctionCall(scope *EvalScope, node *ast.CallExpr) (*Variable, error) {
if err := writePointer(bi, scope.Mem, regs.SP()-3*uint64(bi.Arch.PtrSize()), uint64(fncall.argFrameSize)); err != nil {
return nil, err
}
case "arm64","ppc64le":
case "arm64", "ppc64le":
// debugCallV2 on arm64 needs a special call sequence, callOP can not be used
sp := regs.SP()
var spOffset uint64
var spOffset uint64
if bi.Arch.Name == "arm64" {
spOffset = 2 * uint64(bi.Arch.PtrSize())
} else {
spOffset = 4 * uint64(bi.Arch.PtrSize())
}
sp -= spOffset
sp -= spOffset
if err := setSP(thread, sp); err != nil {
return nil, err
}
Expand Down Expand Up @@ -488,11 +488,11 @@ func callOP(bi *BinaryInfo, thread Thread, regs Registers, callAddr uint64) erro
return err
}
return setPC(thread, callAddr)
case "arm64","ppc64le":
if err := setLR(thread, regs.PC()); err != nil {
return err
}
return setPC(thread, callAddr)
case "arm64", "ppc64le":
if err := setLR(thread, regs.PC()); err != nil {
return err
}
return setPC(thread, callAddr)

default:
panic("not implemented")
Expand Down Expand Up @@ -547,6 +547,7 @@ func funcCallEvalFuncExpr(scope *EvalScope, fncall *functionCallState, allowCall
}

argnum := len(fncall.expr.Args)

// If the function variable has a child then that child is the method
// receiver. However, if the method receiver is not being used (e.g.
// func (_ X) Foo()) then it will not actually be listed as a formal
Expand Down Expand Up @@ -718,6 +719,7 @@ func funcCallArgs(fn *Function, bi *BinaryInfo, includeRet bool) (argFrameSize i
func funcCallArgOldABI(fn *Function, bi *BinaryInfo, entry reader.Variable, argname string, typ godwarf.Type, pargFrameSize *int64) (*funcCallArg, error) {
const CFA = 0x1000
var off int64

locprog, _, err := bi.locationExpr(entry, dwarf.AttrLocation, fn.Entry)
if err != nil {
err = fmt.Errorf("could not get argument location of %s: %v", argname, err)
Expand Down Expand Up @@ -755,6 +757,7 @@ func funcCallArgRegABI(fn *Function, bi *BinaryInfo, entry reader.Variable, argn
// Conservatively calculate the full stack argument space for ABI0.
*pargFrameSize = alignAddr(*pargFrameSize, typ.Align())
*pargFrameSize += typ.Size()

isret, _ := entry.Val(dwarf.AttrVarParam).(bool)
return &funcCallArg{name: argname, typ: typ, dwarfEntry: entry.Tree, isret: isret}, nil
}
Expand Down Expand Up @@ -920,7 +923,7 @@ func funcCallStep(callScope *EvalScope, fncall *functionCallState, thread Thread
case "amd64":
setSP(thread, cfa)
setPC(thread, oldpc)
case "arm64","ppc64le":
case "arm64", "ppc64le":
setLR(thread, oldlr)
setPC(thread, oldpc)
default:
Expand Down Expand Up @@ -1063,8 +1066,6 @@ func fakeFunctionEntryScope(scope *EvalScope, fn *Function, cfa int64, sp uint64
scope.PC = fn.Entry
scope.Fn = fn
scope.File, scope.Line = scope.BinInfo.EntryLineForFunc(fn)


scope.Regs.CFA = cfa
scope.Regs.Reg(scope.Regs.SPRegNum).Uint64Val = sp
scope.Regs.Reg(scope.Regs.PCRegNum).Uint64Val = fn.Entry
Expand Down Expand Up @@ -1248,7 +1249,7 @@ func debugCallProtocolReg(archName string, version int) (uint64, bool) {
return 0, false
}
return protocolReg, true
case "arm64","ppc64le":
case "arm64", "ppc64le":
if version == 2 {
return regnum.ARM64_X0 + 20, true
}
Expand Down Expand Up @@ -1323,14 +1324,14 @@ func regabiMallocgcWorkaround(bi *BinaryInfo) ([]*godwarf.Tree, error) {
m("~r1", t("unsafe.Pointer"), regnum.ARM64_X0, true),
}
return r, err1
case "ppc64le":
r := []*godwarf.Tree{
m("size", t("uintptr"), regnum.PPC64LE_R0+3, false),
m("typ", t(ptrToRuntimeType), regnum.PPC64LE_R0+4, false),
m("needzero", t("bool"), regnum.PPC64LE_R0+5, false),
m("~r1", t("unsafe.Pointer"), regnum.PPC64LE_R0+3,true),
}
return r, err1
case "ppc64le":
r := []*godwarf.Tree{
m("size", t("uintptr"), regnum.PPC64LE_R0+3, false),
m("typ", t(ptrToRuntimeType), regnum.PPC64LE_R0+4, false),
m("needzero", t("bool"), regnum.PPC64LE_R0+5, false),
m("~r1", t("unsafe.Pointer"), regnum.PPC64LE_R0+3, true),
}
return r, err1

default:
// do nothing
Expand Down
4 changes: 2 additions & 2 deletions pkg/proc/linutil/regs_ppc64le_arch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package linutil
import (
"fmt"

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

// PPC64LERegisters implements the proc.Registers interface for the native/linux
Expand Down Expand Up @@ -189,7 +189,7 @@ func (r *PPC64LERegisters) SetReg(regNum uint64, reg *op.DwarfRegister) (fpchang
return false, err
}
}
// On ppc64le, PPC64LE_VS0 .. PPC64LE_VS31 are mapped onto
// On ppc64le, PPC64LE_VS0 .. PPC64LE_VS31 are mapped onto
// PPC64LE_F0 .. PPC64LE_F31
i := regNum - regnum.PPC64LE_VS0
reg.FillBytes()
Expand Down
1 change: 0 additions & 1 deletion pkg/proc/native/registers_linux_ppc64le.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (thread *nativeThread) SetReg(regNum uint64, reg *op.DwarfRegister) error {
return err
}
r := ir.(*linutil.PPC64LERegisters)
//println("reg num passed in ptrace setreg, ",regNum)

fpchanged, err := r.SetReg(regNum, reg)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/proc/proc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4310,7 +4310,7 @@ func TestReadDeferArgs(t *testing.T) {

func TestIssue1374(t *testing.T) {
// Continue did not work when stopped at a breakpoint immediately after calling CallFunction.
skipOn(t, "broken - pie mode", "linux", "ppc64le", "native", "pie")
skipOn(t, "broken - pie mode", "linux", "ppc64le", "native", "pie")

protest.MustSupportFunctionCalls(t, testBackend)
withTestProcess("issue1374", t, func(p *proc.Target, grp *proc.TargetGroup, fixture protest.Fixture) {
Expand Down Expand Up @@ -4542,7 +4542,7 @@ func testCallConcurrentCheckReturns(p *proc.Target, t *testing.T, gid1, gid2 int
}

func TestCallConcurrent(t *testing.T) {
skipOn(t, "broken - pie mode", "linux", "ppc64le", "native", "pie")
skipOn(t, "broken - pie mode", "linux", "ppc64le", "native", "pie")

protest.MustSupportFunctionCalls(t, testBackend)
withTestProcess("teststepconcurrent", t, func(p *proc.Target, grp *proc.TargetGroup, fixture protest.Fixture) {
Expand Down Expand Up @@ -4939,7 +4939,7 @@ func TestIssue1925(t *testing.T) {
// In particular the stepInstructionOut function called at the end of a
// 'call' procedure should clean the G cache like every other function
// altering the state of the target process.
skipOn(t, "broken - pie mode", "linux", "ppc64le", "native", "pie")
skipOn(t, "broken - pie mode", "linux", "ppc64le", "native", "pie")
protest.MustSupportFunctionCalls(t, testBackend)
withTestProcess("testvariables2", t, func(p *proc.Target, grp *proc.TargetGroup, fixture protest.Fixture) {
assertNoError(grp.Continue(), t, "Continue()")
Expand Down
5 changes: 2 additions & 3 deletions pkg/proc/test/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"testing"

"github.com/go-delve/delve/pkg/goversion"

)

// EnableRace allows to configure whether the race detector is enabled on target process.
Expand Down Expand Up @@ -311,7 +310,7 @@ func MustSupportFunctionCalls(t *testing.T, testBackend string) {
if runtime.GOOS == "darwin" && os.Getenv("TRAVIS") == "true" && runtime.GOARCH == "amd64" {
t.Skip("function call injection tests are failing on macOS on Travis-CI (see #1802)")
}
if runtime.GOARCH == "386" {
if runtime.GOARCH == "386" {
t.Skip(fmt.Errorf("%s does not support FunctionCall for now", runtime.GOARCH))
}
if runtime.GOARCH == "arm64" {
Expand All @@ -321,7 +320,7 @@ func MustSupportFunctionCalls(t *testing.T, testBackend string) {
}

if runtime.GOARCH == "ppc64le" {
if !goversion.VersionAfterOrEqual(runtime.Version(), 1, 22) {
if !goversion.VersionAfterOrEqual(runtime.Version(), 1, 22) {
t.Skip("On PPC64LE Building with Go lesser than 1.22 does not support function calls")
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/proc/variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,9 @@ func TestCallFunction(t *testing.T) {

withTestProcessArgs("fncall", t, ".", nil, protest.AllNonOptimized, func(p *proc.Target, grp *proc.TargetGroup, fixture protest.Fixture) {
testCallFunctionSetBreakpoint(t, p, grp, fixture)

assertNoError(grp.Continue(), t, "Continue()")

for _, tc := range testcases {
testCallFunction(t, grp, p, tc)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/terminal/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,8 @@ func findStarFile(name string) string {

func TestIssue1598(t *testing.T) {
if buildMode == "pie" && runtime.GOARCH == "ppc64le" {
t.Skip("Debug function call Test broken in PIE mode")
}
t.Skip("Debug function call Test broken in PIE mode")
}
test.MustSupportFunctionCalls(t, testBackend)
withTestTerminal("issue1598", t, func(term *FakeTerminal) {
term.MustExec("break issue1598.go:5")
Expand Down
8 changes: 4 additions & 4 deletions service/test/integration2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2110,8 +2110,8 @@ func TestForceStopWhileContinue(t *testing.T) {

func TestClientServerFunctionCall(t *testing.T) {
if buildMode == "pie" && runtime.GOARCH == "ppc64le" {
t.Skip("Debug function call Test broken in PIE mode")
}
t.Skip("Debug function call Test broken in PIE mode")
}

protest.MustSupportFunctionCalls(t, testBackend)
withTestClient2("fncall", t, func(c service.Client) {
Expand Down Expand Up @@ -2144,8 +2144,8 @@ func TestClientServerFunctionCall(t *testing.T) {

func TestClientServerFunctionCallPanic(t *testing.T) {
if buildMode == "pie" && runtime.GOARCH == "ppc64le" {
t.Skip("Debug function call Test broken in PIE mode")
}
t.Skip("Debug function call Test broken in PIE mode")
}
protest.MustSupportFunctionCalls(t, testBackend)
withTestClient2("fncall", t, func(c service.Client) {
c.SetReturnValuesLoadConfig(&normalLoadConfig)
Expand Down

0 comments on commit a8d2c16

Please sign in to comment.