Skip to content

Commit

Permalink
update CONTRIBUTING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
xhd2015 committed Jun 4, 2024
1 parent e6ba142 commit 7fa581a
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 8 deletions.
54 changes: 53 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
```

# 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:
<img width="1792" alt="image" src="https://github.com/xhd2015/xgo/assets/14964938/673df393-6632-4eed-a004-400e0c70d0d1">

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions cmd/xgo/runtime_gen/core/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
4 changes: 2 additions & 2 deletions cmd/xgo/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 := ""
Expand Down
4 changes: 2 additions & 2 deletions runtime/core/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down

0 comments on commit 7fa581a

Please sign in to comment.