1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
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 
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 
20 #include "securec.h"
21 
22 #include "hidumper.h"
23 #include "hidumper_adapter.h"
24 #include "ohos_init.h"
25 #include "ohos_types.h"
26 
27 #ifdef __cplusplus
28 #if __cplusplus
29 extern "C" {
30 #endif
31 #endif
32 
DumpSysInfo(void)33 WEAK int DumpSysInfo(void)
34 {
35     printf("Please implement the interface according to the platform!\n");
36     return 0;
37 }
38 
DumpCpuUsage(void)39 WEAK int DumpCpuUsage(void)
40 {
41     printf("Please implement the interface according to the platform!\n");
42     return 0;
43 }
44 
DumpMemUsage(void)45 WEAK int DumpMemUsage(void)
46 {
47     printf("Please implement the interface according to the platform!\n");
48 
49     return 0;
50 }
51 
DumpTaskInfo(void)52 WEAK int DumpTaskInfo(void)
53 {
54     printf("Please implement the interface according to the platform!\n");
55     return 0;
56 }
57 
DumpFaultLog(void)58 WEAK int DumpFaultLog(void)
59 {
60     printf("Please implement the interface according to the platform!\n");
61     return 0;
62 }
63 
DumpMemRegion(unsigned long long addr,unsigned long long size)64 WEAK int DumpMemRegion(unsigned long long addr, unsigned long long size)
65 {
66     (void)addr;
67     (void)size;
68     printf("Please implement the interface according to the platform!\n");
69     return 0;
70 }
71 
DumpAllMem(void)72 WEAK int DumpAllMem(void)
73 {
74     printf("Please implement the interface according to the platform!\n");
75     return 0;
76 }
77 
PlatformHiDumperIinit(void)78 WEAK int PlatformHiDumperIinit(void)
79 {
80     printf("Please implement the interface according to the platform!\n");
81     return 0;
82 }
83 
HiDumperAdapterInit(void)84 static void HiDumperAdapterInit(void)
85 {
86     struct HiDumperAdapter adapter = {
87         .DumpSysInfo = DumpSysInfo,
88         .DumpCpuUsage = DumpCpuUsage,
89         .DumpMemUsage = DumpMemUsage,
90         .DumpTaskInfo = DumpTaskInfo,
91         .DumpFaultLog = DumpFaultLog,
92         .DumpMemRegion = DumpMemRegion,
93         .DumpAllMem = DumpAllMem,
94     };
95 
96     if (HiDumperRegisterAdapter(&adapter) != 0) {
97         printf("HiDumperRegisterAdapter failed!\n");
98         return;
99     }
100     (void)PlatformHiDumperIinit();
101 }
102 CORE_INIT_PRI(HiDumperAdapterInit, 3);
103 
104 #ifdef __cplusplus
105 #if __cplusplus
106 }
107 #endif
108 #endif