• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "aemu/base/AndroidHealthMonitorConsumerBasic.h"
16 
17 #include <log/log.h>
18 
19 #include "aemu/base/Process.h"
20 
21 namespace android {
22 namespace base {
23 namespace guest {
24 
logEventHangMetadata(const EventHangMetadata * metadata)25 void logEventHangMetadata(const EventHangMetadata* metadata) {
26     ALOGE("Metadata:");
27     ALOGE("\t file: %s", metadata->file);
28     ALOGE("\t function: %s", metadata->function);
29     ALOGE("\t line: %d", metadata->line);
30     ALOGE("\t msg: %s", metadata->msg);
31     ALOGE("\t thread: %lld (0x%08llx)", (long long)metadata->threadId,
32           (long long)metadata->threadId);
33     ALOGE("\t process name: %s", getProcessName().c_str());
34     if (metadata->data) {
35         ALOGE("\t Additional information:");
36         for (auto& [key, value] : *metadata->data) {
37             ALOGE("\t \t %s: %s", key.c_str(), value.c_str());
38         }
39     }
40 }
41 
42 // HealthMonitorConsumerBasic
consumeHangEvent(uint64_t taskId,const EventHangMetadata * metadata,int64_t otherHungTasks)43 void HealthMonitorConsumerBasic::consumeHangEvent(uint64_t taskId,
44                                                   const EventHangMetadata* metadata,
45                                                   int64_t otherHungTasks) {
46     ALOGE("Logging hang event. Number of tasks already hung: %lld", (long long)otherHungTasks);
47     logEventHangMetadata(metadata);
48 }
49 
consumeUnHangEvent(uint64_t taskId,const EventHangMetadata * metadata,int64_t hungMs)50 void HealthMonitorConsumerBasic::consumeUnHangEvent(uint64_t taskId,
51                                                     const EventHangMetadata* metadata,
52                                                     int64_t hungMs) {
53     ALOGE("Logging unhang event. Hang time: %lld ms", (long long)hungMs);
54     logEventHangMetadata(metadata);
55 }
56 
57 }  // namespace guest
58 }  // namespace base
59 }  // namespace android
60