delve icon indicating copy to clipboard operation
delve copied to clipboard

Support android operating system

Open kcubeterm opened this issue 4 years ago • 8 comments

  1. What version of Delve are you using (dlv version)?
$ dlv version
Delve Debugger
Version: 1.5.1
Build: $Id: bca418ea7ae2a4dcda985e623625da727d4525b5 $
  1. What version of Go are you using? (go version)?
$ go version
go version go1.15.5 android/arm64
  1. What operating system and processor architecture are you using? OS: Android pie Arch: aarch64
  2. What did you do? Official golang hello example.
dlv debug ./hello
panic: attempting to open file Delve cannot parse

goroutine 1 [running]:
github.com/go-delve/delve/service/debugger.verifyBinaryFormat(0x400003a1e0, 0x4d, 0x0, 0x0)
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/service/debugger/debugger_unix.go:36 +0x120
github.com/go-delve/delve/service/debugger.(*Debugger).Launch(0x4000200a80, 0x40000745c0, 0x1, 0x1, 0x55a26d906d, 0x1, 0x1, 0x55a2241024, 0x73304145c0)
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/service/debugger/debugger.go:225 +0x40
github.com/go-delve/delve/service/debugger.New(0x4000254000, 0x40000745c0, 0x1, 0x1, 0x0, 0x0, 0x0)
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/service/debugger/debugger.go:176 +0x464
github.com/go-delve/delve/service/rpccommon.(*ServerImpl).Run(0x40002009c0, 0x40002009c0, 0x40002285a0)
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/service/rpccommon/server.go:112 +0xa8
github.com/go-delve/delve/cmd/dlv/cmds.execute(0x0, 0x40000745c0, 0x1, 0x1, 0x4000221f80, 0x0, 0x0, 0x1, 0x4000074550, 0x1, ...)
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/cmd/dlv/cmds/commands.go:856 +0x620
github.com/go-delve/delve/cmd/dlv/cmds.debugCmd.func1(0x4000218fc0, 0x4000074550, 0x1, 0x1, 0x0)
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/cmd/dlv/cmds/commands.go:473 +0x330
github.com/go-delve/delve/cmd/dlv/cmds.debugCmd(0x4000218fc0, 0x4000074550, 0x1, 0x1)
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/cmd/dlv/cmds/commands.go:474 +0x38
github.com/go-delve/delve/vendor/github.com/spf13/cobra.(*Command).execute(0x4000218fc0, 0x4000074510, 0x1, 0x1, 0x4000218fc0, 0x4000074510)
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/vendor/github.com/spf13/cobra/command.go:647 +0x17c
github.com/go-delve/delve/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x40002186c0, 0x40002186c0, 0x55a26dc582, 0x6)
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/vendor/github.com/spf13/cobra/command.go:733 +0x1f8
github.com/go-delve/delve/vendor/github.com/spf13/cobra.(*Command).Execute(...)
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/vendor/github.com/spf13/cobra/command.go:692
main.main()
        /data/data/com.termux/files/home/go/src/github.com/go-delve/delve/cmd/dlv/main.go:24 +0xb8

kcubeterm avatar Dec 14 '20 19:12 kcubeterm

IIUC Android just ends up running elf binaries anyways, this may be as simple as modifying verifyBinaryFormat to check for "android" in the switch checking runtime.GOOS.

derekparker avatar Dec 14 '20 21:12 derekparker

Adding "android" in switch fix error for now. https://github.com/go-delve/delve/blob/master/service/debugger/debugger_unix.go

switch runtime.GOOS {
        case "darwin":
                _, err = macho.NewFile(f)
        case "linux", "freebsd","android": //android added
                _, err = elf.NewFile(f)
        default:
                panic("attempting to open file Delve cannot parse")
        }
        if err != nil {
                return api.ErrNotExecutable
        }
        return nil

kcubeterm avatar Dec 15 '20 06:12 kcubeterm

@derekparker Why delve have no support for android platform officially. Android is quite similar to linux and it requires few more lines of code to work on android.

kcubeterm avatar Dec 15 '20 10:12 kcubeterm

Why delve have no support for android platform officially. Android is quite similar to linux and it requires few more lines of code to work on android.

Nobody wrote those, and also CI availability.

aarzilli avatar Dec 15 '20 11:12 aarzilli

@kcubeterm feel free to submit a PR with Delve working on Android. Due to the lack of CI for it, it will mostly always be "best effort" to support it.

derekparker avatar Dec 15 '20 16:12 derekparker

I added Delve in termux repo and it works as expected. Didn't checked all features and subcommand yet. Leaving it on user. If user reports error. will try to fix it and submit PRs for sure if possible.

kcubeterm avatar Dec 16 '20 12:12 kcubeterm

Oi

Umsemana avatar Oct 31 '21 21:10 Umsemana