• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CHRE_CORE_DEBUG_DUMP_MANAGER_H_
18 #define CHRE_CORE_DEBUG_DUMP_MANAGER_H_
19 
20 #include <cstdarg>
21 #include <cstdbool>
22 #include <cstdint>
23 
24 #include "chre/core/nanoapp.h"
25 #include "chre/platform/platform_debug_dump_manager.h"
26 #include "chre/util/optional.h"
27 #include "chre/util/system/debug_dump.h"
28 
29 namespace chre {
30 
31 /**
32  * A helper class that manages the CHRE framework and nanoapp debug dump
33  * process.
34  */
35 class DebugDumpManager : public PlatformDebugDumpManager {
36  public:
37   /**
38    * Triggers the CHRE framework and nanoapp debug dump process.
39    */
40   void trigger();
41 
42   /**
43    * Helper function to log nanoapp debug dump.
44    */
45   void appendNanoappLog(const Nanoapp &nanoapp, const char *formatStr,
46                         va_list args);
47 
48  private:
49   //! Utility to hold the framework and nanoapp debug dumps.
50   DebugDumpWrapper mDebugDump{kDebugDumpStrMaxSize};
51 
52   //! Whether the DebugDumpManager is collecting nanoapp debug dumps.
53   bool mCollectingNanoappDebugDumps = false;
54 
55   //! Instance ID of the nanoapp that was last logging debug dumps in this
56   //! session.
57   Optional<uint32_t> mLastNanoappId;
58 
59   /**
60    * Collect CHRE framework debug dumps.
61    */
62   void collectFrameworkDebugDumps();
63 
64   /**
65    * Send collected framework debug dumps to the host.
66    */
67   void sendFrameworkDebugDumps();
68 
69   /**
70    * Send collected nanoapp debug dumps to the host.
71    */
72   void sendNanoappDebugDumps();
73 };
74 
75 }  // namespace chre
76 
77 #endif  // CHRE_CORE_DEBUG_DUMP_MANAGER_H_
78