@@ -40,7 +40,7 @@ import (
40
40
const MAX_FILE_SIZE = 1 * 1024 * 1024
41
41
42
42
// goroot is critical for stdlib
43
- func instrumentUserCode (goroot string , projectDir string , projectRoot string , goVersion * goinfo.GoVersion , xgoSrc string , mod string , modfile string , mainModule string , xgoRuntimeModuleDir string , mayHaveCover bool , overlayFS overlay.Overlay , includeTest bool , rules []Rule , trapPkgs []string , trapAll bool , collectTestTrace bool , collectTestTraceDir string , goFlag bool , triedUpgrade bool ) error {
43
+ func instrumentUserCode (goroot string , projectDir string , projectRoot string , goVersion * goinfo.GoVersion , xgoSrc string , mod string , modfile string , mainModule string , xgoRuntimeModuleDir string , mayHaveCover bool , overlayFS overlay.Overlay , includeTest bool , rules []Rule , trapPkgs []string , trapAll string , collectTestTrace bool , collectTestTraceDir string , goFlag bool , triedUpgrade bool ) error {
44
44
logDebug ("instrumentUserSpace: mod=%s, modfile=%s, xgoRuntimeModuleDir=%s, includeTest=%v, collectTestTrace=%v" , mod , modfile , xgoRuntimeModuleDir , includeTest , collectTestTrace )
45
45
if mod == "" {
46
46
// check vendor dir
@@ -189,13 +189,14 @@ func instrumentUserCode(goroot string, projectDir string, projectRoot string, go
189
189
mainPkgs := pkgs .Filter (func (pkg * edit.Package ) bool {
190
190
return pkg .Main && pkg .AllowInstrument
191
191
})
192
- var recorder resolve.Recorder
193
192
for _ , pkg := range mainPkgs {
194
193
resolve .CollectDecls (pkg )
195
194
}
196
195
197
196
traverseBegin := time .Now ()
198
197
logDebug ("traverse: len(mainPkgs)=%d" , len (mainPkgs ))
198
+
199
+ var recorder resolve.Recorder
199
200
err = resolve .Traverse (reg , mainPkgs , & recorder )
200
201
if err != nil {
201
202
return err
@@ -208,7 +209,10 @@ func instrumentUserCode(goroot string, projectDir string, projectRoot string, go
208
209
return err
209
210
}
210
211
211
- logDebug ("start instrumentFuncTrap: len(packages)=%d" , len (pkgs .Packages ))
212
+ // ""->default
213
+ needTrapAll := trapAll == "true" || (trapAll == "" && recorder .HasTrapInterceptorRef )
214
+
215
+ logDebug ("start instrumentFuncTrap: len(packages)=%d, needTrapAll=%v" , len (pkgs .Packages ), needTrapAll )
212
216
for _ , pkg := range pkgs .Packages {
213
217
if ! pkg .AllowInstrument {
214
218
continue
@@ -217,7 +221,7 @@ func instrumentUserCode(goroot string, projectDir string, projectRoot string, go
217
221
cfg := config .GetPkgConfig (pkgPath )
218
222
var defaultAllow bool
219
223
if ! pkg .LoadPackage .GoPackage .Standard {
220
- if trapAll || pkg .Initial {
224
+ if needTrapAll || pkg .Initial {
221
225
defaultAllow = true
222
226
}
223
227
}
0 commit comments