You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/debugging.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1013,6 +1013,49 @@ culprits are remote debugging where the program is built in the remote location,
1013
1013
use of symbolic links, or use of `-trimpath` build flags. In this case,
1014
1014
configure the `substitutePath` attribute in your launch configuration.
1015
1015
1016
+
#### Trimpath tips
1017
+
1018
+
If you are using `-trimpath` to build your program, you need to add entries to substitute
1019
+
path to let the debugger know how to map the package paths that are compiled in the
1020
+
binary to the files that you are looking at in the editor.
1021
+
1022
+
Here are some tips for configuring substitutePath. This assumes that your program is using module mode, which is the default.
1023
+
1024
+
One rule that you will need will map your main module. The mapping will map `"from"` the file path to the directory containing the module, `"to"` the module path.
1025
+
1026
+
You will also need to create a similar mapping for all dependencies. These include modules
1027
+
in the module cache, vendored modules, and the standard library.
1028
+
1029
+
```json
1030
+
"substitutePath": [
1031
+
// Main module.
1032
+
{
1033
+
"from": "${workspaceFolder}",
1034
+
"to": "moduleName",
1035
+
},
1036
+
// Module cache paths.
1037
+
{
1038
+
"from": "${env:HOME}/go/pkg/mod/github.com",
1039
+
"to": "github.com",
1040
+
},
1041
+
{
1042
+
"from": "${env:HOME}/go/pkg/mod/golang.org",
1043
+
"to": "golang.org",
1044
+
},
1045
+
...
1046
+
// Standard library paths.
1047
+
// This rule should come last since the empty "to" will match every path.
1048
+
{ "from": "/path/to/local/goroot/pkg" , "to": ""}
1049
+
],
1050
+
```
1051
+
1052
+
Since rules are applied both from client to server and server to client,
1053
+
rules with an empty string will be applied to *all* paths that it sees, so even
1054
+
dependencies will be mapped to `"/path/to/module"`.
1055
+
1056
+
We plan to make this easier in the future. Progress can be tracked
1057
+
in the issue tracker [golang/vscode-go#1985](https://github.com/golang/vscode-go/issues/1985).
1058
+
1016
1059
### Debug sessions started with the "debug test" CodeLens or the test UI does not use my `launch.json` configuration
1017
1060
1018
1061
The "debug test" CodeLens and the [test UI](features.md#test-and-benchmark) do
0 commit comments