Skip to content

Commit a56b59c

Browse files
committed
update error messages for hardware profiler
1 parent 5a8f8c1 commit a56b59c

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

hardware_profiler.go

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
package perf
55

66
import (
7+
"fmt"
8+
79
"go.uber.org/multierr"
810
"golang.org/x/sys/unix"
911
)
@@ -20,70 +22,80 @@ func NewHardwareProfiler(pid, cpu int, opts ...int) (HardwareProfiler, error) {
2022

2123
cpuCycleProfiler, err := NewCPUCycleProfiler(pid, cpu, opts...)
2224
if err != nil {
23-
e = multierr.Append(e, err)
25+
e = multierr.Append(e,
26+
fmt.Errorf("Failed to setup CPU cycle profiler: pid (%d) cpu (%d) %q", pid, cpu, err))
2427
} else {
2528
profilers[unix.PERF_COUNT_HW_CPU_CYCLES] = cpuCycleProfiler
2629
}
2730

2831
instrProfiler, err := NewInstrProfiler(pid, cpu, opts...)
2932
if err != nil {
30-
e = multierr.Append(e, err)
33+
e = multierr.Append(e,
34+
fmt.Errorf("Failed to CPU setup instruction profiler: pid (%d) cpu (%d) %q", pid, cpu, err))
3135
} else {
3236
profilers[unix.PERF_COUNT_HW_INSTRUCTIONS] = instrProfiler
3337
}
3438

3539
cacheRefProfiler, err := NewCacheRefProfiler(pid, cpu, opts...)
3640
if err != nil {
37-
e = multierr.Append(e, err)
41+
e = multierr.Append(e,
42+
fmt.Errorf("Failed to setup cache ref profiler: pid (%d) cpu (%d) %q", pid, cpu, err))
3843
} else {
3944
profilers[unix.PERF_COUNT_HW_CACHE_REFERENCES] = cacheRefProfiler
4045
}
4146

4247
cacheMissesProfiler, err := NewCacheMissesProfiler(pid, cpu, opts...)
4348
if err != nil {
44-
e = multierr.Append(e, err)
49+
e = multierr.Append(e,
50+
fmt.Errorf("Failed to setup cache misses profiler: pid (%d) cpu (%d) %q", pid, cpu, err))
4551
} else {
4652
profilers[unix.PERF_COUNT_HW_CACHE_MISSES] = cacheMissesProfiler
4753
}
4854

4955
branchInstrProfiler, err := NewBranchInstrProfiler(pid, cpu, opts...)
5056
if err != nil {
51-
e = multierr.Append(e, err)
57+
e = multierr.Append(e,
58+
fmt.Errorf("Failed to setup branch instruction profiler: pid (%d) cpu (%d) %q", pid, cpu, err))
5259
} else {
5360
profilers[unix.PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = branchInstrProfiler
5461
}
5562

5663
branchMissesProfiler, err := NewBranchMissesProfiler(pid, cpu, opts...)
5764
if err != nil {
58-
e = multierr.Append(e, err)
65+
e = multierr.Append(e,
66+
fmt.Errorf("Failed to setup branch miss profiler: pid (%d) cpu (%d) %q", pid, cpu, err))
5967
} else {
6068
profilers[unix.PERF_COUNT_HW_BRANCH_MISSES] = branchMissesProfiler
6169
}
6270

6371
busCyclesProfiler, err := NewBusCyclesProfiler(pid, cpu, opts...)
6472
if err != nil {
65-
e = multierr.Append(e, err)
73+
e = multierr.Append(e,
74+
fmt.Errorf("Failed to setup bus cycles profiler: pid (%d) cpu (%d) %q", pid, cpu, err))
6675
} else {
6776
profilers[unix.PERF_COUNT_HW_BUS_CYCLES] = busCyclesProfiler
6877
}
6978

7079
stalledCyclesFrontProfiler, err := NewStalledCyclesFrontProfiler(pid, cpu, opts...)
7180
if err != nil {
72-
e = multierr.Append(e, err)
81+
e = multierr.Append(e,
82+
fmt.Errorf("Failed to setup stalled fronted cycles profiler: pid (%d) cpu (%d) %q", pid, cpu, err))
7383
} else {
7484
profilers[unix.PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = stalledCyclesFrontProfiler
7585
}
7686

7787
stalledCyclesBackProfiler, err := NewStalledCyclesBackProfiler(pid, cpu, opts...)
7888
if err != nil {
79-
e = multierr.Append(e, err)
89+
e = multierr.Append(e,
90+
fmt.Errorf("Failed to setup stalled backend cycles profiler: pid (%d) cpu (%d) %q", pid, cpu, err))
8091
} else {
8192
profilers[unix.PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = stalledCyclesBackProfiler
8293
}
8394

8495
refCPUCyclesProfiler, err := NewRefCPUCyclesProfiler(pid, cpu, opts...)
8596
if err != nil {
86-
e = multierr.Append(e, err)
97+
e = multierr.Append(e,
98+
fmt.Errorf("Failed to setup ref CPU cycles profiler: pid (%d) cpu (%d) %q", pid, cpu, err))
8799
} else {
88100
profilers[unix.PERF_COUNT_HW_REF_CPU_CYCLES] = refCPUCyclesProfiler
89101
}

0 commit comments

Comments
 (0)