]>
git.saurik.com Git - apple/system_cmds.git/blob - msa/ReadTraceFileAction.cpp
a1e07461fbec4d1b39cca515cd844546748ed1ca
2 // ReadTraceFileAction.cpp
5 // Created by James McIlree on 4/15/13.
6 // Copyright (c) 2014 Apple. All rights reserved.
11 template < typename SIZE
>
12 static void execute_arch_specific ( Globals
& globals
, TraceFile
& file
)
14 Machine
< SIZE
> machine ( file
);
16 if (! machine
. lost_events ()) {
17 if ( globals
. should_zero_base_timestamps () && machine
. event_count ()) {
18 globals
. set_beginning_of_time ( machine
. events ()[ 0 ]. timestamp ());
20 globals
. set_beginning_of_time ( AbsTime ( 0 ));
23 if (! globals
. is_timebase_set ()) {
24 if ( machine
. is_ios ()) {
25 globals
. set_timebase ({ 125 , 3 }, false );
27 globals
. set_timebase ({ 1 , 1 }, false );
32 char * buf_end
= buf
+ sizeof ( buf
);
33 print_mach_msg_header ( buf
, buf_end
, globals
);
34 dprintf ( globals
. output_fd (), " %s " , buf
);
36 std :: unordered_map
< pid_t
, bool > task_appnap_state
;
37 std :: unordered_map
< pid_t
, TaskRequestedPolicy
> task_requested_state
;
38 std :: unordered_map
< typename
SIZE :: ptr_t
, TaskRequestedPolicy
> thread_requested_state
;
39 std :: unordered_map
< pid_t
, std :: pair
< TaskEffectivePolicy
, uint32_t >> task_effective_state
;
40 std :: unordered_map
< typename
SIZE :: ptr_t
, std :: pair
< TaskEffectivePolicy
, uint32_t >> thread_effective_state
;
41 std :: unordered_map
< pid_t
, std :: pair
< uint32_t , uint32_t >> task_boosts
;
43 process_events ( globals
, machine
, task_appnap_state
, task_requested_state
, thread_requested_state
, task_effective_state
, thread_effective_state
, task_boosts
);
45 log_msg ( ASL_LEVEL_WARNING
, "The trace data indicates that events were lost, the file cannot be processed \n " );
49 void ReadTraceFileAction :: execute ( Globals
& globals
) {
50 TraceFile
file ( _path
. c_str (), globals
. should_presort_events (), globals
. cpu_count (), globals
. iop_count ());
51 if ( globals
. is_kernel_size_set ()) {
53 if ( globals
. kernel_size () == KernelSize :: k32
)
54 execute_arch_specific
< Kernel32
>( globals
, file
);
56 execute_arch_specific
< Kernel64
>( globals
, file
);
57 } catch ( Exception
& e
) {
58 log_msg ( ASL_LEVEL_ERR
, "An exception was raised: %s " , e
. what ());
59 log_msg ( ASL_LEVEL_ERR
, "An explicit kernel size was set, you may want to try not forcing the size to a single value \n " );
60 log_msg ( ASL_LEVEL_ERR
, "You may also want to check the number of cpus and iops configured if the file is from a device and does not have a cpumap \n " );
63 if ( file
. is_valid ()) {
64 if ( file
. is_64_bit ()) {
65 execute_arch_specific
< Kernel64
>( globals
, file
);
67 execute_arch_specific
< Kernel32
>( globals
, file
);
70 if ( file
. mmap_failed ()) {
71 log_msg ( ASL_LEVEL_ERR
, "Unable to mmap %s , it may exceed this devices memory limits \n " , _path
. c_str ());
73 log_msg ( ASL_LEVEL_ERR
, " %s does not appear to be a valid trace file \n " , _path
. c_str ());