diff --git a/_scripts/make.go b/_scripts/make.go index 4f4af65ec..41ee49c56 100644 --- a/_scripts/make.go +++ b/_scripts/make.go @@ -51,9 +51,9 @@ func NewMakeCommands() *cobra.Command { envflags = append(envflags, "GOOS="+OS) } if len(envflags) > 0 { - executeEnv(envflags, "go", "build", "-ldflags", "-extldflags -static", tagFlags(), buildFlags(), DelveMainPackagePath) + executeEnv(envflags, "go", "build", "-ldflags", "-extldflags -static", tagFlags(false), buildFlags(), DelveMainPackagePath) } else { - execute("go", "build", "-ldflags", "-extldflags -static", tagFlags(), buildFlags(), DelveMainPackagePath) + execute("go", "build", "-ldflags", "-extldflags -static", tagFlags(false), buildFlags(), DelveMainPackagePath) } if runtime.GOOS == "darwin" && os.Getenv("CERT") != "" && canMacnative() && !isCodesigned("./dlv") { codesign("./dlv") @@ -70,7 +70,7 @@ func NewMakeCommands() *cobra.Command { Use: "install", Short: "Installs delve", Run: func(cmd *cobra.Command, args []string) { - execute("go", "install", tagFlags(), buildFlags(), DelveMainPackagePath) + execute("go", "install", tagFlags(false), buildFlags(), DelveMainPackagePath) if runtime.GOOS == "darwin" && os.Getenv("CERT") != "" && canMacnative() && !isCodesigned(installedExecutablePath()) { codesign(installedExecutablePath()) } @@ -293,16 +293,21 @@ func prepareMacnative() string { return "macnative" } -func tagFlags() string { +func tagFlags(isTest bool) string { var tags []string if mactags := prepareMacnative(); mactags != "" { tags = append(tags, mactags) } - if runtime.GOOS == "windows" && runtime.GOARCH == "arm64" { - tags = append(tags, "exp.winarm64") - } - if runtime.GOOS == "linux" && runtime.GOARCH == "ppc64le" { - tags = append(tags, "exp.linuxppc64le") + if isTest { + if runtime.GOOS == "windows" && runtime.GOARCH == "arm64" { + tags = append(tags, "exp.winarm64") + } + if runtime.GOOS == "linux" && runtime.GOARCH == "ppc64le" { + tags = append(tags, "exp.linuxppc64le") + } + if runtime.GOOS == "linux" && runtime.GOARCH == "riscv64" { + tags = append(tags, "exp.linuxriscv64") + } } if Tags != nil && len(*Tags) > 0 { tags = append(tags, *Tags...) @@ -462,11 +467,11 @@ func testCmdIntl(testSet, testRegex, testBackend, testBuildMode string) { } if len(testPackages) > 3 { - executeq(env, "go", "test", testFlags(), buildFlags(), tagFlags(), testPackages, backendFlag, buildModeFlag) + executeq(env, "go", "test", testFlags(), buildFlags(), tagFlags(true), testPackages, backendFlag, buildModeFlag) } else if testRegex != "" { - executeq(env, "go", "test", testFlags(), buildFlags(), tagFlags(), testPackages, "-run="+testRegex, backendFlag, buildModeFlag) + executeq(env, "go", "test", testFlags(), buildFlags(), tagFlags(true), testPackages, "-run="+testRegex, backendFlag, buildModeFlag) } else { - executeq(env, "go", "test", testFlags(), buildFlags(), tagFlags(), testPackages, backendFlag, buildModeFlag) + executeq(env, "go", "test", testFlags(), buildFlags(), tagFlags(true), testPackages, backendFlag, buildModeFlag) } } @@ -505,7 +510,7 @@ func inpath(exe string) bool { func allPackages() []string { r := []string{} - for _, dir := range strings.Split(getoutput("go", "list", "-mod=vendor", tagFlags(), "./..."), "\n") { + for _, dir := range strings.Split(getoutput("go", "list", "-mod=vendor", tagFlags(true), "./..."), "\n") { dir = strings.TrimSpace(dir) if dir == "" || strings.Contains(dir, "/vendor/") || strings.Contains(dir, "/_scripts") { continue diff --git a/cmd/dlv/dlv_test.go b/cmd/dlv/dlv_test.go index c6ea5157c..840ba91a4 100644 --- a/cmd/dlv/dlv_test.go +++ b/cmd/dlv/dlv_test.go @@ -215,6 +215,9 @@ func getDlvBin(t *testing.T) string { if runtime.GOOS == "linux" && runtime.GOARCH == "ppc64le" { tags = "-tags=exp.linuxppc64le" } + if runtime.GOOS == "linux" && runtime.GOARCH == "riscv64" { + tags = "-tags=exp.linuxriscv64" + } return getDlvBinInternal(t, tags) } diff --git a/pkg/proc/native/support_sentinel_linux.go b/pkg/proc/native/support_sentinel_linux.go index c1149d7d4..8bcf33ab0 100644 --- a/pkg/proc/native/support_sentinel_linux.go +++ b/pkg/proc/native/support_sentinel_linux.go @@ -1,4 +1,4 @@ -//go:build linux && !amd64 && !arm64 && !386 && !(ppc64le && exp.linuxppc64le) && !riscv64 +//go:build linux && !amd64 && !arm64 && !386 && !(ppc64le && exp.linuxppc64le) && !(riscv64 && exp.linuxriscv64) // This file is used to detect build on unsupported GOOS/GOARCH combinations. diff --git a/pkg/proc/riscv64_arch.go b/pkg/proc/riscv64_arch.go index 71d9b5655..67c4b10c8 100644 --- a/pkg/proc/riscv64_arch.go +++ b/pkg/proc/riscv64_arch.go @@ -26,7 +26,7 @@ func RISCV64Arch(goos string) *Arch { altBreakpointInstruction: riscv64BreakInstruction, breakInstrMovesPC: false, derefTLS: false, - prologues: prologuesRISCV64, + prologues: nil, fixFrameUnwindContext: riscv64FixFrameUnwindContext, switchStack: riscv64SwitchStack, regSize: riscv64RegSize, diff --git a/pkg/proc/riscv64_disasm.go b/pkg/proc/riscv64_disasm.go index f7dc0e738..0a2be1236 100644 --- a/pkg/proc/riscv64_disasm.go +++ b/pkg/proc/riscv64_disasm.go @@ -116,35 +116,6 @@ func resolveCallArgRISCV64(inst *riscv64asm.Inst, instAddr uint64, currentGorout return &Location{PC: pc, File: file, Line: line, Fn: fn} } -// Possible stacksplit prologues are inserted by stacksplit in -// $GOROOT/src/cmd/internal/obj/riscv/obj.go. -var prologuesRISCV64 []opcodeSeq - -func init() { - var tinyStacksplit = opcodeSeq{uint64(riscv64asm.ADDI)} - var smallStacksplit = opcodeSeq{} - var bigStacksplit = opcodeSeq{uint64(riscv64asm.LUI), - uint64(riscv64asm.ADDIW), - uint64(riscv64asm.BLTU), - uint64(riscv64asm.LUI), - uint64(riscv64asm.ADDIW), - uint64(riscv64asm.ADD)} - - var unixGetG = opcodeSeq{uint64(riscv64asm.LD)} - var tailPrologues = opcodeSeq{uint64(riscv64asm.BLTU), - uint64(riscv64asm.JAL), - uint64(riscv64asm.JAL)} - - prologuesRISCV64 = make([]opcodeSeq, 0, 3) - for _, stacksplit := range []opcodeSeq{tinyStacksplit, smallStacksplit, bigStacksplit} { - prologue := make(opcodeSeq, 0, len(unixGetG)+len(stacksplit)+len(tailPrologues)) - prologue = append(prologue, unixGetG...) - prologue = append(prologue, stacksplit...) - prologue = append(prologue, tailPrologues...) - prologuesRISCV64 = append(prologuesRISCV64, prologue) - } -} - type riscv64ArchInst riscv64asm.Inst func (inst *riscv64ArchInst) Text(flavour AssemblyFlavour, pc uint64, symLookup func(uint64) (string, uint64)) string {