5 // Created by James McIlree on 4/17/13.
6 // Copyright (c) 2014 Apple. All rights reserved.
14 _kernel_size(Kernel::is_64_bit() ? KernelSize::k64
: KernelSize::k32
),
15 _live_update_interval("100ms"),
16 _is_cpu_count_set(false),
17 _is_iop_count_set(false),
18 _is_kernel_size_set(false),
19 _is_timebase_set(false),
20 _beginning_of_time(0),
21 _should_print_mach_absolute_timestamps(false),
22 _should_print_event_index(false),
24 _should_presort_events(false),
25 _should_zero_base_timestamps(true),
26 _should_trace_voucher_contents(true),
27 _lifecycle_filter(kLifecycleFilter::User
),
28 _mach_msg_filter(kMachMsgFilter::Voucher
)
30 // Default to the current machine's values
31 mach_timebase_info(&_timebase_info
);
33 for (auto& entry
: KDBG::cpumap()) {
40 // If we are unable to get a cpumap,
41 // fallback on the current # of cpus
42 if (_cpu_count
== 0) {
43 _cpu_count
= Kernel::active_cpu_count();
47 // This is only used as is for live tracing or capturing a trace,
48 // so we want to use the current # of cpus.
49 _trace_buffer_size
= 250000 * _cpu_count
;
52 static AbsTime
parse_time(const char* arg
, mach_timebase_info_data_t timebase_info
) {
55 uint64_t value
= strtoull(arg
, &units
, 0);
57 // Unspecified units are treated as seconds
58 if (*units
== 0 || strcmp(units
, "s") == 0) {
59 return NanoTime(value
* NANOSECONDS_PER_SECOND
).abs_time(timebase_info
);
62 if (strcmp(units
, "ms") == 0)
63 return NanoTime(value
* NANOSECONDS_PER_MILLISECOND
).abs_time(timebase_info
);
65 if (strcmp(units
, "us") == 0)
66 return NanoTime(value
* NANOSECONDS_PER_MICROSECOND
).abs_time(timebase_info
);
68 if (strcmp(units
, "ns") == 0)
69 return NanoTime(value
).abs_time(timebase_info
);
71 if (strcmp(units
, "mabs") == 0) {
72 return AbsTime(value
);
75 usage("Unable to parse units on time value");
78 AbsTime
Globals::live_update_interval() const {
79 return parse_time(_live_update_interval
.c_str(), _timebase_info
);