1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
3
4# Test implicit trace file name
5# RUN: ld.lld --time-trace --time-trace-granularity=0 -o %t1.elf %t.o
6# RUN: cat %t1.elf.time-trace \
7# RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
8# RUN:   | FileCheck %s
9
10# Test specified trace file name
11# RUN: ld.lld --time-trace --time-trace-file=%t2.json --time-trace-granularity=0 -o %t2.elf %t.o
12# RUN: cat %t2.json \
13# RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
14# RUN:   | FileCheck %s
15
16# Test trace requested to stdout
17# RUN: ld.lld --time-trace --time-trace-file=- --time-trace-granularity=0 -o %t3.elf %t.o \
18# RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
19# RUN:   | FileCheck %s
20
21# CHECK:      "beginningOfTime": {{[0-9]{16},}}
22# CHECK-NEXT: "traceEvents": [
23
24# Check one event has correct fields
25# CHECK:      "dur":
26# CHECK-NEXT: "name":
27# CHECK-NEXT: "ph":
28# CHECK-NEXT: "pid":
29# CHECK-NEXT: "tid":
30# CHECK-NEXT: "ts":
31
32# Check there is an ExecuteLinker event
33# CHECK: "name": "ExecuteLinker"
34
35# Check process_name entry field
36# CHECK: "name": "ld.lld{{(.exe)?}}"
37# CHECK: "name": "process_name"
38# CHECK: "name": "thread_name"
39
40.globl _start
41_start:
42  ret
43