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 #ifndef OHOS_ACELITE_MEM_PROC_H
17 #define OHOS_ACELITE_MEM_PROC_H
18 
19 #include "acelite_config.h"
20 #ifdef SIMULATOR_MEMORY_ANALYSIS
21 #define CLEAR_UP() AceMemProc::GetInstance()->ClearUp()
22 #define SYS_MEMORY_TRACING() AceMemProc::GetInstance()->SysMemTracing()
23 #define JERRY_MEMORY_TRACING() AceMemProc::GetInstance()->JerryMemTracing()
24 #else
25 #define CLEAR_UP()
26 #define SYS_MEMORY_TRACING()
27 #define JERRY_MEMORY_TRACING()
28 #endif // SIMULATOR_MEMORY_ANALYSIS
29 
30 #ifdef SIMULATOR_MEMORY_ANALYSIS
31 namespace OHOS {
32 namespace ACELite {
33 class AceMemProc {
34 public:
35     /**
36      * @brief Use static global variable for easy access in different source code file.
37      *
38      * @return global singleton AceMemProc object
39      */
40     static AceMemProc *GetInstance();
41 
42     /**
43      * @brief Check if the memory proc is enabled or not.
44      *
45      * @return true for enabled, false for not
46      */
47     static bool IsEnabled();
48 
49     /**
50      * @brief Clear up the previous analysis file.
51      */
52     void ClearUp();
53 
54     /**
55      * @brief Output the system memory.
56      */
57     void SysMemTracing();
58 
59     /**
60      * @brief Output the jerry memory.
61      *
62      */
63     void JerryMemTracing();
64 
65 private:
66     /**
67      * @brief Default constructor.
68      */
69     AceMemProc() = default;
70 
71     /**
72      * @brief Default destructor.
73      */
74     ~AceMemProc() = default;
75 };
76 } // namespace ACELite
77 } // namespace OHOS
78 #endif // SIMULATOR_MEMORY_ANALYSIS
79 #endif // OHOS_ACELITE_MEM_PROC_H
80