diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d84b2610..271f1454 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,4 +61,56 @@ go run ./script/run-test/ --include go1.17.13 --include go1.18.10 --include go1. If a go version is not found in `go-release`, we can download it with: ```sh go run ./script/download-go go1.22.1 -``` \ No newline at end of file +``` + +# Install xgo from source +Just clone the repository, and run: +```sh +go install ./cmd/xgo +``` + +It's totally the same as `go install github.com/xhd2015/xgo/cmd/xgo@latest`, but for local. + +# Debug the go compiler +First, build a package with `--debug-compile` flag: +```sh +go run -tags dev ./cmd/xgo test -c --debug-compile --project-dir runtime/test/debug +``` + +Then, run `go-tool-debug-compile` +```sh +go run ./cmd/go-tool-debug-compile +``` + + +Output: +```log +dlv listen on localhost:2345 +Debug with IDEs: + > VSCode: add the following config to .vscode/launch.json configurations: + { + "configurations": [ + { + "name": "Debug dlv localhost:2345", + "type": "go", + "debugAdapter": "dlv-dap", + "request": "attach", + "mode": "remote", + "port": 2345, + "host": "127.0.0.1", + "cwd":"./" + } + } + } + NOTE: VSCode will map source files to workspace's goroot, which causes problem when debugging go compiler. + To fix this, update go.goroot in .vscode/settings.json to: + /Users/xhd2015/.xgo/go-instrument-dev/go1.21.7_Us_xh_in_go_096be049/go1.21.7 + And set a breakpoint at: + /Users/xhd2015/.xgo/go-instrument-dev/go1.21.7_Us_xh_in_go_096be049/go1.21.7/src/cmd/compile/main.go + > GoLand: click Add Configuration > Go Remote > localhost:2345 + > Terminal: dlv connect localhost:2345 +``` + +Following these instructions, using your favorite IDE like VSCode,GoLand or just terminal to debug: +image + diff --git a/README.md b/README.md index 3d97776f..5ea95ef8 100644 --- a/README.md +++ b/README.md @@ -433,7 +433,7 @@ Trap also have a helper function called `Direct(fn)`, which can be used to bypas # Tools ## Test Explorer -The `xgo e` sub command will open a test explorer UI in the browser, provide go developers a easy way to test and debug go code. +The `xgo e` sub command will open a test explorer UI in the browser, provide go developers an easy way to test and debug go code. With the test explorer, `xgo test` is used instead of `go test`, to enable mocking functionalities. diff --git a/cmd/xgo/runtime_gen/core/version.go b/cmd/xgo/runtime_gen/core/version.go index 52f8ebaf..ade54178 100755 --- a/cmd/xgo/runtime_gen/core/version.go +++ b/cmd/xgo/runtime_gen/core/version.go @@ -7,8 +7,8 @@ import ( ) const VERSION = "1.0.39" -const REVISION = "c35e746c1476c5565030f4505e6c7b69099f922e+1" -const NUMBER = 260 +const REVISION = "e6ba142b8a4c344bfd9e009090d1666635e1c9e5+1" +const NUMBER = 261 // these fields will be filled by compiler const XGO_VERSION = "" diff --git a/cmd/xgo/version.go b/cmd/xgo/version.go index d724f74d..805aeb89 100644 --- a/cmd/xgo/version.go +++ b/cmd/xgo/version.go @@ -3,8 +3,8 @@ package main import "fmt" const VERSION = "1.0.39" -const REVISION = "c35e746c1476c5565030f4505e6c7b69099f922e+1" -const NUMBER = 260 +const REVISION = "e6ba142b8a4c344bfd9e009090d1666635e1c9e5+1" +const NUMBER = 261 func getRevision() string { revSuffix := "" diff --git a/runtime/core/version.go b/runtime/core/version.go index 52f8ebaf..ade54178 100644 --- a/runtime/core/version.go +++ b/runtime/core/version.go @@ -7,8 +7,8 @@ import ( ) const VERSION = "1.0.39" -const REVISION = "c35e746c1476c5565030f4505e6c7b69099f922e+1" -const NUMBER = 260 +const REVISION = "e6ba142b8a4c344bfd9e009090d1666635e1c9e5+1" +const NUMBER = 261 // these fields will be filled by compiler const XGO_VERSION = ""