MCPcopy Create free account
hub / github.com/google/pprof / testDisasm

Function testDisasm

internal/binutils/binutils_test.go:273–306  ·  view source on GitHub ↗
(t *testing.T, intelSyntax bool)

Source from the content-addressed store, hash-verified

271}
272
273func testDisasm(t *testing.T, intelSyntax bool) {
274 _, llvmObjdump, buObjdump := findObjdump([]string{""})
275 if !llvmObjdump && !buObjdump {
276 t.Skip("cannot disasm: no objdump tool available")
277 }
278
279 bu := &Binutils{}
280 var testexe string
281 switch runtime.GOOS {
282 case "linux":
283 testexe = "exe_linux_64"
284 case "darwin":
285 testexe = "exe_mac_64"
286 case "windows":
287 testexe = "exe_windows_64.exe"
288 default:
289 t.Skipf("unsupported OS %q", runtime.GOOS)
290 }
291
292 insts, err := bu.Disasm(filepath.Join("testdata", testexe), 0, math.MaxUint64, intelSyntax)
293 if err != nil {
294 t.Fatalf("Disasm: unexpected error %v", err)
295 }
296 mainCount := 0
297 for _, x := range insts {
298 // macOS symbols have a leading underscore.
299 if x.Function == "main" || x.Function == "_main" {
300 mainCount++
301 }
302 }
303 if mainCount == 0 {
304 t.Error("Disasm: found no main instructions")
305 }
306}
307
308func TestDisasm(t *testing.T) {
309 if (runtime.GOOS != "linux" && runtime.GOOS != "darwin" && runtime.GOOS != "windows") || runtime.GOARCH != "amd64" {

Callers 2

TestDisasmFunction · 0.85
TestDisasmIntelSyntaxFunction · 0.85

Calls 2

DisasmMethod · 0.95
findObjdumpFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…