-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dynamically check trap mark to avoid nested trap issue
- Loading branch information
Showing
14 changed files
with
148 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//go:build go1.17 && !go1.18 | ||
// +build go1.17,!go1.18 | ||
|
||
package patch | ||
|
||
const goMajor = 1 | ||
const goMinor = 17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//go:build go1.18 && !go1.19 | ||
// +build go1.18,!go1.19 | ||
|
||
package patch | ||
|
||
const goMajor = 1 | ||
const goMinor = 18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package core | ||
|
||
const VERSION = "1.0.0" | ||
const REVISION = "37d37c71b68249a79d6cb3347d41945295ecde57+1" | ||
const NUMBER = 79 | ||
const VERSION = "1.0.1" | ||
const REVISION = "4a87957ab7175717205880ca95086e259f342c25+1" | ||
const NUMBER = 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/xhd2015/xgo/runtime/core" | ||
"github.com/xhd2015/xgo/runtime/trap" | ||
) | ||
|
||
// Prior to xgo v1.0.1, explicit trap.Skip() | ||
// must be made to avoid stack overflow. | ||
// This is called 'the nested trap' problem. | ||
// | ||
// After xgo v1.0.1,xgo can check dynamically | ||
// whether current goroutine is inside trap, if so | ||
// skip it | ||
|
||
func main() { | ||
if os.Getenv("XGO_TEST_HAS_INSTRUMENT") != "false" { | ||
trap.AddInterceptor(&trap.Interceptor{ | ||
Pre: func(ctx context.Context, f *core.FuncInfo, args core.Object, results core.Object) (interface{}, error) { | ||
fmt.Printf("trap pre: %s\n", f.Name) | ||
callFromTrap() | ||
return nil, nil | ||
}, | ||
}) | ||
} | ||
hello() | ||
} | ||
|
||
func hello() { | ||
fmt.Printf("hello world\n") | ||
} | ||
|
||
func callFromTrap() { | ||
fmt.Printf("call from trap\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters