undoio / delve

Fork of go-delve debugger with UndoDB support.
MIT License
5 stars 0 forks source link

Update delve to support latest GoLand #11

Open magne-hov opened 4 years ago

magne-hov commented 4 years ago

Latest GoLand (GoLand-2020.1.3) ships with delve v1.4.1 and this patched version is v1.3.2.

There's a breaking issue when using our patched v1.3.2 delve:


/usr/lib/go-1.12/bin/go build -o /tmp/___go_build_main_go -gcflags "all=-N -l" /home/mhov/go/src/awesomeProject/main.go #gosetup
/home/mhov/goland/GoLand-2020.1.3/plugins/go/lib/dlv/linux/dlv --listen=localhost:39117 --headless=true --api-version=2 --check-go-version=false --only-same-user=false --backend=rr exec /tmp/___go_build_main_go -- #gosetup
Error: unknown flag: --only-same-user
Usage:
  dlv exec <path/to/binary> [flags]
gareth-rees commented 3 years ago

I tried merging with upstream and resolving conflicts by hand, but there were too many (about 120 conflicts with 1.4.1, nearly 300 conflicts with 1.7.2). So instead, I need a plan to do it semi-automatically. The idea would be to:

  1. Make a branch for doing the merge.
  2. Change all occurrences of github.com/undoio/delve in .go files back to github.com/go-delve/delve to avoid conflicts
  3. Get a list of all files that we've changed on the fork (but excluding mere updates to github.com/go-delve/delve).
  4. Start the merge and then git checkout --theirs for all the files not in the list from (3)
  5. Handle the remaining conflicts by hand.
  6. Change all occurrences of github.com/go-delve/delve in .go files back to github.com/undoio/delve

So, how to generate the list in (3)? We made the fork as of Delve 1.2.0 so the commits we are interested in are v1.2.0..undo, but we are not interested in the commits that only modify the github.com/go-delve/delve references, which are 875145e6, 354df30f and de0e64c9, and we are not interested in commits that merged upstream changes, which are 4fbb5d7b. So the files changes in our commits are given by

git log --pretty=format:%h v1.2.0..undo |
egrep -v '^(875145e6|354df30f|de0e64c9|4fbb5d7b)$' |
while read COMMIT; do
git diff-tree --no-commit-id --name-only -r "$COMMIT"
done |
sort -u

which outputs 29 files:

cmd/dlv/cmds/commands.go
cmd/dlv/main.go
Documentation/cli/README.md
Documentation/usage/dlv_attach.md
Documentation/usage/dlv_backend.md
Documentation/usage/dlv_connect.md
Documentation/usage/dlv_core.md
Documentation/usage/dlv_debug.md
Documentation/usage/dlv_exec.md
Documentation/usage/dlv.md
Documentation/usage/dlv_replay.md
Documentation/usage/dlv_run.md
Documentation/usage/dlv_test.md
Documentation/usage/dlv_trace.md
Documentation/usage/dlv_version.md
pkg/proc/gdbserial/gdbserver_conn.go
pkg/proc/gdbserial/gdbserver.go
pkg/proc/gdbserial/undo.go
pkg/proc/gdbserial/undo_test.go
pkg/proc/proc_test.go
pkg/terminal/command.go
pkg/terminal/command_test.go
pkg/version/version.go
README.md
scripts/make.go
service/debugger/debugger.go
service/test/integration1_test.go
service/test/integration2_test.go
service/test/variables_test.go

This might be manageable by hand.

The merge operation (4) went like this:

  1. Run the command above and save its output somewhere, say in UNDO_FILES
  2. Start the merge: git merge v1.7.2
  3. There are 296 files requiring resolution: git diff --name-only --diff-filter=U | wc -l
  4. Automatically accept theirs for all files we didn't touch:
    git diff --name-only --diff-filter=U |
    cat - UNDO_FILES |
    sort |
    uniq -u |
    while read FILE; do
       echo "$FILE"
       git checkout --theirs "$FILE"
       git add "$FILE"
    done
  5. This leaves 25 files requiring manual resolution.

But this ran aground because of commit f6c7f0bbd1786ab324f7919cf0e0d63a4092b5f3 -- I simply couldn't merge this with upstream because it rips out support for other backends. We need to replace this change with one that guards undo-specific code with if p.conn.isUndoServer. I made #26 for this.

gareth-rees commented 2 years ago

New plan: rebase all the commits on top of upstream, getting rid of the merge commit 741ae23d7da023b4b5227a3ef3c05aba4dd5fb3e (which was my fault unfortunately, if I had known then etc.) and resulting in a patch set (i.e. by fixing up old commits and not adding new ones, to keep the patch set small). We want the following five commits, I think:

  1. Change to G pointer code
  2. Update documentation for "rewind" command
  3. Rename paths from "go-delve" to "undoio"
  4. Expand test coverage for record-replay backends
  5. The Undo backend itself