forked from hoanhan101/ultimate-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
stack_trace_2.go
41 lines (34 loc) · 1.1 KB
/
stack_trace_2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// -------
// Packing
// -------
// Sample stack races that pack values.
package main
func main() {
// Passing values that are 1-byte values.
example(true, false, true, 25)
}
func example(b1, b2, b3 bool, i uint8) {
panic("Want stack trace")
}
// This is the output that we get:
/*
panic: Want stack trace
goroutine 1 [running]:
main.example(0xc419010001)
/Users/hoanhan/go/src/github.com/hoanhan101/ultimate-go/go/profiling/stack_trace_2.go:12 +0x39
main.main()
/Users/hoanhan/go/src/github.com/hoanhan101/ultimate-go/go/profiling/stack_trace_2.go:8 +0x29
exit status 2
*/
// Analysis:
// ---------
// Since stack traces show 1 word at a time, all of these 4 bytes fit in a half-word on a 32-bit
// platform and a full word on 64-bit. Also, the system we are looking at is using little endian so
// we need to read from right to left. In our case, the word value 0xc419010001 can be represented as:
/*
Bits Binary Hex Value
00-07 0000 0001 01 true
08-15 0000 0000 00 false
16-23 0000 0001 01 true
24-31 0001 1001 19 25
*/