| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/browser_watcher/postmortem_report_extractor.h" | 5 #include "components/browser_watcher/postmortem_report_extractor.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 std::string debug_identifier = base::StringPrintf( | 133 std::string debug_identifier = base::StringPrintf( |
| 134 "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X%x", uuid->data_1, | 134 "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X%x", uuid->data_1, |
| 135 uuid->data_2, uuid->data_3, uuid->data_4[0], uuid->data_4[1], | 135 uuid->data_2, uuid->data_3, uuid->data_4[0], uuid->data_4[1], |
| 136 uuid->data_5[0], uuid->data_5[1], uuid->data_5[2], uuid->data_5[3], | 136 uuid->data_5[0], uuid->data_5[1], uuid->data_5[2], uuid->data_5[3], |
| 137 uuid->data_5[4], uuid->data_5[5], recorded.age); | 137 uuid->data_5[4], uuid->data_5[5], recorded.age); |
| 138 collected->set_debug_identifier(debug_identifier); | 138 collected->set_debug_identifier(debug_identifier); |
| 139 collected->set_is_unloaded(!recorded.is_loaded); | 139 collected->set_is_unloaded(!recorded.is_loaded); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 void CollectActivity(const base::debug::Activity& recorded, |
| 144 Activity* collected) { |
| 145 DCHECK(collected); |
| 146 |
| 147 collected->set_time(recorded.time_internal); |
| 148 collected->set_address(recorded.calling_address); |
| 149 collected->set_origin_address(recorded.origin_address); |
| 150 |
| 151 // TODO(manzagop): the current collection deals with specific activity types; |
| 152 // consider modifying it to handle the notion of activity categories. |
| 153 switch (recorded.activity_type) { |
| 154 case base::debug::Activity::ACT_TASK_RUN: |
| 155 collected->set_type(Activity::ACT_TASK_RUN); |
| 156 collected->set_task_sequence_id(recorded.data.task.sequence_id); |
| 157 break; |
| 158 case base::debug::Activity::ACT_LOCK_ACQUIRE: |
| 159 collected->set_type(Activity::ACT_LOCK_ACQUIRE); |
| 160 collected->set_lock_address(recorded.data.lock.lock_address); |
| 161 break; |
| 162 case base::debug::Activity::ACT_EVENT_WAIT: |
| 163 collected->set_type(Activity::ACT_EVENT_WAIT); |
| 164 collected->set_event_address(recorded.data.event.event_address); |
| 165 break; |
| 166 case base::debug::Activity::ACT_THREAD_JOIN: |
| 167 collected->set_type(Activity::ACT_THREAD_JOIN); |
| 168 collected->set_thread_id(recorded.data.thread.thread_id); |
| 169 break; |
| 170 case base::debug::Activity::ACT_PROCESS_WAIT: |
| 171 collected->set_type(Activity::ACT_PROCESS_WAIT); |
| 172 collected->set_process_id(recorded.data.process.process_id); |
| 173 break; |
| 174 case base::debug::Activity::ACT_GENERIC: |
| 175 collected->set_type(Activity::ACT_GENERIC); |
| 176 collected->set_generic_id(recorded.data.generic.id); |
| 177 collected->set_generic_data(recorded.data.generic.info); |
| 178 break; |
| 179 default: |
| 180 break; |
| 181 } |
| 182 } |
| 183 |
| 143 void CollectThread( | 184 void CollectThread( |
| 144 const base::debug::ThreadActivityAnalyzer::Snapshot& snapshot, | 185 const base::debug::ThreadActivityAnalyzer::Snapshot& snapshot, |
| 145 ThreadState* thread_state) { | 186 ThreadState* thread_state) { |
| 146 DCHECK(thread_state); | 187 DCHECK(thread_state); |
| 147 | 188 |
| 148 thread_state->set_thread_name(snapshot.thread_name); | 189 thread_state->set_thread_name(snapshot.thread_name); |
| 149 thread_state->set_thread_id(snapshot.thread_id); | 190 thread_state->set_thread_id(snapshot.thread_id); |
| 150 thread_state->set_activity_count(snapshot.activity_stack_depth); | 191 thread_state->set_activity_count(snapshot.activity_stack_depth); |
| 151 | 192 |
| 152 for (size_t i = 0; i < snapshot.activity_stack.size(); ++i) { | 193 for (size_t i = 0; i < snapshot.activity_stack.size(); ++i) { |
| 153 const base::debug::Activity& recorded = snapshot.activity_stack[i]; | |
| 154 Activity* collected = thread_state->add_activities(); | 194 Activity* collected = thread_state->add_activities(); |
| 155 | 195 |
| 156 // Collect activity. | 196 CollectActivity(snapshot.activity_stack[i], collected); |
| 157 switch (recorded.activity_type) { | |
| 158 case base::debug::Activity::ACT_TASK_RUN: | |
| 159 collected->set_type(Activity::ACT_TASK_RUN); | |
| 160 collected->set_origin_address(recorded.origin_address); | |
| 161 collected->set_task_sequence_id(recorded.data.task.sequence_id); | |
| 162 break; | |
| 163 case base::debug::Activity::ACT_LOCK_ACQUIRE: | |
| 164 collected->set_type(Activity::ACT_LOCK_ACQUIRE); | |
| 165 collected->set_lock_address(recorded.data.lock.lock_address); | |
| 166 break; | |
| 167 case base::debug::Activity::ACT_EVENT_WAIT: | |
| 168 collected->set_type(Activity::ACT_EVENT_WAIT); | |
| 169 collected->set_event_address(recorded.data.event.event_address); | |
| 170 break; | |
| 171 case base::debug::Activity::ACT_THREAD_JOIN: | |
| 172 collected->set_type(Activity::ACT_THREAD_JOIN); | |
| 173 collected->set_thread_id(recorded.data.thread.thread_id); | |
| 174 break; | |
| 175 case base::debug::Activity::ACT_PROCESS_WAIT: | |
| 176 collected->set_type(Activity::ACT_PROCESS_WAIT); | |
| 177 collected->set_process_id(recorded.data.process.process_id); | |
| 178 break; | |
| 179 default: | |
| 180 break; | |
| 181 } | |
| 182 | |
| 183 // Collect user data. | |
| 184 if (i < snapshot.user_data_stack.size()) { | 197 if (i < snapshot.user_data_stack.size()) { |
| 185 CollectUserData(snapshot.user_data_stack[i], | 198 CollectUserData(snapshot.user_data_stack[i], |
| 186 collected->mutable_user_data(), nullptr); | 199 collected->mutable_user_data(), nullptr); |
| 187 } | 200 } |
| 188 } | 201 } |
| 189 } | 202 } |
| 190 | 203 |
| 191 } // namespace | 204 } // namespace |
| 192 | 205 |
| 193 CollectionStatus Extract(const base::FilePath& stability_file, | 206 CollectionStatus Extract(const base::FilePath& stability_file, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 CollectThread(thread_analyzer->activity_snapshot(), thread_state); | 253 CollectThread(thread_analyzer->activity_snapshot(), thread_state); |
| 241 } | 254 } |
| 242 | 255 |
| 243 // Collect module information. | 256 // Collect module information. |
| 244 CollectModuleInformation(global_analyzer->GetModules(), process_state); | 257 CollectModuleInformation(global_analyzer->GetModules(), process_state); |
| 245 | 258 |
| 246 return SUCCESS; | 259 return SUCCESS; |
| 247 } | 260 } |
| 248 | 261 |
| 249 } // namespace browser_watcher | 262 } // namespace browser_watcher |
| OLD | NEW |