• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 #include "chre/platform/slpi/debug_dump.h"
18 
19 // Some devices don't have ash/debug.h implemented for them so allow swapping
20 // out that implementation with an empty one until an implementation can be
21 // provided for all devices.
22 #ifdef CHRE_ENABLE_DEBUG_DUMP
23 #include "ash/debug.h"
24 #endif  // CHRE_ENABLE_DEBUG_DUMP
25 
26 namespace chre {
27 
28 // debugDumpTimeoutMs is unused outside of ash/debug.h, but is useful in helping
29 // understand where the value is defined until ash/debug.h is modified for use
30 // on all devices.
31 #ifdef CHRE_ENABLE_DEBUG_DUMP
32 size_t debugDumpStrMaxSize = ASH_DEBUG_DUMP_STR_MAX_SIZE;
33 uint16_t debugDumpTimeoutMs = ASH_DEBUG_DUMP_TIMEOUT_MS;
34 #else  // CHRE_ENABLE_DEBUG_DUMP
35 size_t debugDumpStrMaxSize = 0;
36 uint16_t debugDumpTimeoutMs = 0;
37 #endif  // CHRE_ENABLE_DEBUG_DUMP
38 
registerDebugDumpCallback(const char * name,debugDumpCbFunc * callback,void * cookie)39 bool registerDebugDumpCallback(const char *name, debugDumpCbFunc *callback,
40                                void *cookie) {
41 #ifdef CHRE_ENABLE_DEBUG_DUMP
42   return ashRegisterDebugDumpCallback(name, callback, cookie);
43 #else  // CHRE_ENABLE_DEBUG_DUMP
44   return false;
45 #endif  // CHRE_ENABLE_DEBUG_DUMP
46 }
47 
unregisterDebugDumpCallback(debugDumpCbFunc * callback)48 void unregisterDebugDumpCallback(debugDumpCbFunc *callback) {
49 #ifdef CHRE_ENABLE_DEBUG_DUMP
50   ashUnregisterDebugDumpCallback(callback);
51 #endif  // CHRE_ENABLE_DEBUG_DUMP
52 }
53 
commitDebugDump(uint32_t handle,const char * debugStr,bool done)54 bool commitDebugDump(uint32_t handle, const char *debugStr, bool done) {
55 #ifdef CHRE_ENABLE_DEBUG_DUMP
56   return ashCommitDebugDump(handle, debugStr, done);
57 #else  // CHRE_ENABLE_DEBUG_DUMP
58   return false;
59 #endif  // CHRE_ENABLE_DEBUG_DUMP
60 }
61 
triggerDebugDump(debugDumpReadyCbFunc * readyCb,void * cookie)62 bool triggerDebugDump(debugDumpReadyCbFunc *readyCb, void *cookie) {
63 #ifdef CHRE_ENABLE_DEBUG_DUMP
64   return ashTriggerDebugDump(readyCb, cookie);
65 #else  // CHRE_ENABLE_DEBUG_DUMP
66   return false;
67 #endif  // CHRE_ENABLE_DEBUG_DUMP
68 }
69 
70 }  // namespace chre
71