• 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 gfxstream {
22 namespace guest {
23 
logEventHangMetadata(const EventHangMetadata * metadata)24 void logEventHangMetadata(const EventHangMetadata* metadata) {
25     ALOGE("Metadata:");
26     ALOGE("\t file: %s", metadata->file);
27     ALOGE("\t function: %s", metadata->function);
28     ALOGE("\t line: %d", metadata->line);
29     ALOGE("\t msg: %s", metadata->msg);
30     ALOGE("\t thread: %lld (0x%08llx)", (long long)metadata->threadId,
31           (long long)metadata->threadId);
32     ALOGE("\t process name: %s", getProcessName().c_str());
33     if (metadata->data) {
34         ALOGE("\t Additional information:");
35         for (auto& [key, value] : *metadata->data) {
36             ALOGE("\t \t %s: %s", key.c_str(), value.c_str());
37         }
38     }
39 }
40 
41 // HealthMonitorConsumerBasic
consumeHangEvent(uint64_t,const EventHangMetadata * metadata,int64_t otherHungTasks)42 void HealthMonitorConsumerBasic::consumeHangEvent(uint64_t,
43                                                   const EventHangMetadata* metadata,
44                                                   int64_t otherHungTasks) {
45     ALOGE("Logging hang event. Number of tasks already hung: %lld", (long long)otherHungTasks);
46     logEventHangMetadata(metadata);
47 }
48 
consumeUnHangEvent(uint64_t,const EventHangMetadata * metadata,int64_t hungMs)49 void HealthMonitorConsumerBasic::consumeUnHangEvent(uint64_t,
50                                                     const EventHangMetadata* metadata,
51                                                     int64_t hungMs) {
52     ALOGE("Logging unhang event. Hang time: %lld ms", (long long)hungMs);
53     logEventHangMetadata(metadata);
54 }
55 
56 } // namespace guest
57 } // namespace gfxstream
58