Skip to content

Commit f2aefcd

Browse files
committed
Ensured dynagrok can analyze older Go compilers
Signed-off-by: Tim Henderson <[email protected]>
1 parent bfe2d41 commit f2aefcd

File tree

4 files changed

+49
-22
lines changed

4 files changed

+49
-22
lines changed

dgruntime/dgtypes/profile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (p *Profile) Empty() bool {
4545

4646
func (p *Profile) WriteFunctions(fout io.Writer) error {
4747
e := json.NewEncoder(fout)
48-
e.SetIndent("", " ")
48+
// e.SetIndent("", " ")
4949
return e.Encode(ExportFunctions(p.Funcs))
5050
}
5151

src/runtime/getcallerpc.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// +build 1.9
2+
3+
package runtime
4+
5+
import "unsafe"
6+
7+
// GetCallerPC, finds the PC (program counter) of the function
8+
// that calls this function. So if you have
9+
//
10+
// func foo() int {
11+
// bar(7)
12+
// return 1
13+
// }
14+
//
15+
// func bar(wacky int) {
16+
// runtime.GetCallerPC(unsafe.Pointer(&wacky))
17+
// }
18+
//
19+
// you will get the pc of `return 1` in foo. This works a lot like
20+
// the built-in Caller() function but is massively less safe calling
21+
// the compiler intrinsic getcallerpc(.) directly.
22+
func GetCallerPC(arg0 unsafe.Pointer) uintptr {
23+
return uintptr(getcallerpc())
24+
}

src/runtime/goid.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
11
package runtime
22

3-
import "unsafe"
4-
53
// Get the current goroutine's id
64
func GoID() int64 {
75
g := getg()
86
return g.goid
97
}
108

11-
// GetCallerPC, finds the PC (program counter) of the function
12-
// that calls this function. So if you have
13-
//
14-
// func foo() int {
15-
// bar(7)
16-
// return 1
17-
// }
18-
//
19-
// func bar(wacky int) {
20-
// runtime.GetCallerPC(unsafe.Pointer(&wacky))
21-
// }
22-
//
23-
// you will get the pc of `return 1` in foo. This works a lot like
24-
// the built-in Caller() function but is massively less safe calling
25-
// the compiler intrinsic getcallerpc(.) directly.
26-
func GetCallerPC(arg0 unsafe.Pointer) uintptr {
27-
return uintptr(getcallerpc())
28-
}
29-
309
func Wacky() string {
3110
return "wacky"
3211
}

src/runtime/old_getcallerpc.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// +build !go1.9
2+
3+
package runtime
4+
5+
import "unsafe"
6+
7+
// GetCallerPC, finds the PC (program counter) of the function
8+
// that calls this function. So if you have
9+
//
10+
// func foo() int {
11+
// bar(7)
12+
// return 1
13+
// }
14+
//
15+
// func bar(wacky int) {
16+
// runtime.GetCallerPC(unsafe.Pointer(&wacky))
17+
// }
18+
//
19+
// you will get the pc of `return 1` in foo. This works a lot like
20+
// the built-in Caller() function but is massively less safe calling
21+
// the compiler intrinsic getcallerpc(.) directly.
22+
func GetCallerPC(arg0 unsafe.Pointer) uintptr {
23+
return uintptr(getcallerpc(arg0))
24+
}

0 commit comments

Comments
 (0)