xref: /llvm-project/lld/test/MachO/time-trace.s (revision a2c1f7c90da770167cecdb008fcf40eaa9f123ce)
1## When running main twice, we'll also output the time trace JSON twice, which
2## breaks JSON parsing.
3# XFAIL: main-run-twice
4
5# REQUIRES: x86
6# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
7
8## Test implicit trace file name
9# RUN: %lld --time-trace --time-trace-granularity=0 -o %t1.macho %t.o
10# RUN: cat %t1.macho.time-trace \
11# RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
12# RUN:   | FileCheck %s
13
14## Test specified trace file name.
15# RUN: %lld --time-trace=%t2.json --time-trace-granularity=0 -o %t2.macho %t.o
16# RUN: cat %t2.json \
17# RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
18# RUN:   | FileCheck %s
19
20## Test trace requested to stdout.
21# RUN: %lld --time-trace=- --time-trace-granularity=0 -o %t3.macho %t.o \
22# RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
23# RUN:   | FileCheck %s
24
25# CHECK:      "beginningOfTime": {{[0-9]{16},}}
26# CHECK-NEXT: "traceEvents": [
27
28## Check one event has correct fields
29# CHECK:      "dur":
30# CHECK-NEXT: "name":
31# CHECK-NEXT: "ph":
32# CHECK-NEXT: "pid":
33# CHECK-NEXT: "tid":
34# CHECK-NEXT: "ts":
35
36## Check there is an ExecuteLinker event
37# CHECK: "name": "ExecuteLinker"
38
39## Check process_name entry field
40# CHECK: "name": "ld64.lld{{(.exe)?}}"
41# CHECK: "name": "process_name"
42# CHECK: "name": "thread_name"
43
44.globl _main
45_main:
46  ret
47