Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace skip std with options #125

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@

# coverage
/covers
cover*.out
cover*.out

/tmp
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.35"
const REVISION = "efe86afb9931162ad0926648c13c4109383beef3+1"
const NUMBER = 223
const REVISION = "cec0b300e2a4c0d5d0137936c2e68a67ea1798f7+1"
const NUMBER = 224

// these fields will be filled by compiler
const XGO_VERSION = ""
Expand Down
17 changes: 17 additions & 0 deletions cmd/xgo/runtime_gen/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ import (
var stackMap sync.Map // uintptr(goroutine) -> *Root
var testInfoMapping sync.Map // uintptr(goroutine) -> *testInfo

// stack trace options:
//
// on: automatically collect when test starts and ends
var xgoStackTrace = os.Getenv("XGO_STACK_TRACE")

// options:
//
// true: stdlib is by default allowed
// TODO: use compiler inserted flag instead of env
var xgoStdlibTrapDefaultAllow = os.Getenv("XGO_STD_LIB_TRAP_DEFAULT_ALLOW")
var skipStdlibTraceByDefault = xgoStdlibTrapDefaultAllow == "true"

type testInfo struct {
name string

Expand Down Expand Up @@ -194,11 +204,18 @@ func setupInterceptor() func() {
}
}

// returns a value to be passed to post
// if returns err trap.ErrSkip, this interceptor is skipped, handleTracePost is not called, next interceptors will
// be normally executed
// if returns nil error, handleTracePost is called
func handleTracePre(ctx context.Context, f *core.FuncInfo, args core.Object, results core.Object) (interface{}, error) {
if !__xgo_link_init_finished() {
// do not collect trace while init
return nil, trap.ErrSkip
}
if f.Stdlib && skipStdlibTraceByDefault {
return nil, trap.ErrSkip
}
key := uintptr(__xgo_link_getcurg())
localOptStack, ok := collectingMap.Load(key)
var localOpts *collectOpts
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.35"
const REVISION = "efe86afb9931162ad0926648c13c4109383beef3+1"
const NUMBER = 223
const REVISION = "cec0b300e2a4c0d5d0137936c2e68a67ea1798f7+1"
const NUMBER = 224

func getRevision() string {
revSuffix := ""
Expand Down
7 changes: 4 additions & 3 deletions patch/ctxt/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ var stdBlocklist = map[string]map[string]bool{
"sync/atomic": map[string]bool{
"*": true,
},
"testing": map[string]bool{
"*": true,
},
// testing is not harmful
// "testing": map[string]bool{
// "*": true,
// },
"unsafe": map[string]bool{
"*": true,
},
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.35"
const REVISION = "efe86afb9931162ad0926648c13c4109383beef3+1"
const NUMBER = 223
const REVISION = "cec0b300e2a4c0d5d0137936c2e68a67ea1798f7+1"
const NUMBER = 224

// these fields will be filled by compiler
const XGO_VERSION = ""
Expand Down
17 changes: 17 additions & 0 deletions runtime/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ import (
var stackMap sync.Map // uintptr(goroutine) -> *Root
var testInfoMapping sync.Map // uintptr(goroutine) -> *testInfo

// stack trace options:
//
// on: automatically collect when test starts and ends
var xgoStackTrace = os.Getenv("XGO_STACK_TRACE")

// options:
//
// true: stdlib is by default allowed
// TODO: use compiler inserted flag instead of env
var xgoStdlibTrapDefaultAllow = os.Getenv("XGO_STD_LIB_TRAP_DEFAULT_ALLOW")
var skipStdlibTraceByDefault = xgoStdlibTrapDefaultAllow == "true"

type testInfo struct {
name string

Expand Down Expand Up @@ -194,11 +204,18 @@ func setupInterceptor() func() {
}
}

// returns a value to be passed to post
// if returns err trap.ErrSkip, this interceptor is skipped, handleTracePost is not called, next interceptors will
// be normally executed
// if returns nil error, handleTracePost is called
func handleTracePre(ctx context.Context, f *core.FuncInfo, args core.Object, results core.Object) (interface{}, error) {
if !__xgo_link_init_finished() {
// do not collect trace while init
return nil, trap.ErrSkip
}
if f.Stdlib && skipStdlibTraceByDefault {
return nil, trap.ErrSkip
}
key := uintptr(__xgo_link_getcurg())
localOptStack, ok := collectingMap.Load(key)
var localOpts *collectOpts
Expand Down
6 changes: 3 additions & 3 deletions script/github-actions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ func checkMerge(args []string) error {
}
}
if !found {
return fmt.Errorf("%s cannot be merged into %s without creating intermediate commit", branch, targetBranch)
return fmt.Errorf("%s is not based on newest %s, please rebase with %s", branch, targetBranch, targetBranch)
}
if i == 0 {
return fmt.Errorf("%s is the same with %s", branch, targetBranch)
return fmt.Errorf("%s is same with %s, nothing to merge", branch, targetBranch)
}
if i != 1 {
return fmt.Errorf("expect 1 commit to be merged, actual: %d", i)
return fmt.Errorf("%s has %d commits to be merged into %s, please squash them into 1(using 'git reset --soft origin/%s')", branch, i, targetBranch, targetBranch)
}
return nil
}
Loading