Skip to content

Commit

Permalink
*: mark riscv64 port as experimental
Browse files Browse the repository at this point in the history
Delete non-working prologue detection code and mark port as experimental.

Updates go-delve#3832
  • Loading branch information
aarzilli committed Oct 14, 2024
1 parent 75c41f2 commit da68ddf
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 65 deletions.
31 changes: 18 additions & 13 deletions _scripts/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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())
}
Expand Down Expand Up @@ -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...)
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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
Expand Down
28 changes: 7 additions & 21 deletions cmd/dlv/dlv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,15 @@ func projectRoot() string {

func TestBuild(t *testing.T) {
const listenAddr = "127.0.0.1:40573"
var err error

cmd := exec.Command("go", "run", "_scripts/make.go", "build")
cmd.Dir = projectRoot()
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("makefile error: %v\noutput %s\n", err, string(out))
}

dlvbin := filepath.Join(cmd.Dir, "dlv")
dlvbin := getDlvBin(t)
defer os.Remove(dlvbin)

fixtures := protest.FindFixturesDir()

buildtestdir := filepath.Join(fixtures, "buildtest")

cmd = exec.Command(dlvbin, "debug", "--headless=true", "--listen="+listenAddr, "--api-version=2", "--backend="+testBackend, "--log", "--log-output=debugger,rpc")
cmd := exec.Command(dlvbin, "debug", "--headless=true", "--listen="+listenAddr, "--api-version=2", "--backend="+testBackend, "--log", "--log-output=debugger,rpc")
cmd.Dir = buildtestdir
stderr, err := cmd.StderrPipe()
assertNoError(err, t, "stderr pipe")
Expand Down Expand Up @@ -215,6 +207,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)
}

Expand Down Expand Up @@ -1483,23 +1478,14 @@ func TestUnixDomainSocket(t *testing.T) {

listenPath := filepath.Join(tmpdir, "delve_test")

var err error

cmd := exec.Command("go", "run", "_scripts/make.go", "build")
cmd.Dir = projectRoot()
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("makefile error: %v\noutput %s\n", err, string(out))
}

dlvbin := filepath.Join(cmd.Dir, "dlv")
dlvbin := getDlvBin(t)
defer os.Remove(dlvbin)

fixtures := protest.FindFixturesDir()

buildtestdir := filepath.Join(fixtures, "buildtest")

cmd = exec.Command(dlvbin, "debug", "--headless=true", "--listen=unix:"+listenPath, "--api-version=2", "--backend="+testBackend, "--log", "--log-output=debugger,rpc")
cmd := exec.Command(dlvbin, "debug", "--headless=true", "--listen=unix:"+listenPath, "--api-version=2", "--backend="+testBackend, "--log", "--log-output=debugger,rpc")
cmd.Dir = buildtestdir
stderr, err := cmd.StderrPipe()
assertNoError(err, t, "stderr pipe")
Expand Down
2 changes: 1 addition & 1 deletion pkg/proc/native/support_sentinel_linux.go
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion pkg/proc/riscv64_arch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 0 additions & 29 deletions pkg/proc/riscv64_disasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit da68ddf

Please sign in to comment.