• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 HIVIEWDFX_HIDEBUG_NATIVE_INTERFACE_H
17 #define HIVIEWDFX_HIDEBUG_NATIVE_INTERFACE_H
18 
19 #include <map>
20 #include <memory>
21 #include <optional>
22 
23 #include "hidebug_native_type.h"
24 #include "hidebug/hidebug_type.h"
25 
26 namespace OHOS {
27 namespace HiviewDFX {
28 
29 class HidebugNativeInterface {
30 public:
31     static HidebugNativeInterface& GetInstance();
32     virtual ~HidebugNativeInterface() = default;
33 
34     /**
35      * GetSystemCpuUsage
36      *
37      * @return the cpu usage of the system
38      */
39     virtual std::optional<double> GetSystemCpuUsage() = 0;
40 
41     virtual double GetCpuUsage() = 0;
42     virtual std::map<uint32_t, double> GetAppThreadCpuUsage() = 0;
43     virtual TraceErrorCode StartAppTraceCapture(uint64_t tags, uint32_t flag,
44         uint32_t limitsize, std::string &file) = 0;
45     virtual TraceErrorCode StopAppTraceCapture() = 0;
46     virtual int GetMemoryLeakResource(const std::string& type, int32_t value, bool enabledDebugLog) = 0;
47     virtual std::optional<MemoryLimitInfo> GetAppMemoryLimit() = 0;
48     virtual std::optional<NativeMemInfo> GetAppNativeMemInfo(bool withCache = false) = 0;
49     virtual std::optional<uint64_t> GetVss() = 0;
50     virtual std::optional<SystemMemoryInfo> GetSystemMemInfo() = 0;
51     virtual bool IsDebuggerConnected() = 0;
52     virtual std::optional<int32_t> GetGraphicsMemory() = 0;
53 };
54 }
55 }
56 
57 #endif  // HIVIEWDFX_HIDEBUG_NATIVE_INTERFACE_H
58