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 #include "resource/memory.h" 23 #include "hidebug/hidebug_type.h" 24 25 namespace OHOS { 26 namespace HiviewDFX { 27 enum MemoryState { 28 MEMORY_FAILED = -1, 29 MEMORY_SUCCESS = 0, 30 }; 31 32 class HidebugNativeInterface { 33 public: 34 static HidebugNativeInterface& GetInstance(); 35 virtual ~HidebugNativeInterface() = default; 36 37 /** 38 * GetSystemCpuUsage 39 * 40 * @return the cpu usage of the system 41 */ 42 virtual std::optional<double> GetSystemCpuUsage() = 0; 43 44 virtual double GetCpuUsage() = 0; 45 virtual std::map<uint32_t, double> GetAppThreadCpuUsage() = 0; 46 virtual HiDebug_ErrorCode StartAppTraceCapture(uint64_t tags, uint32_t flag, 47 uint32_t limitsize, std::string &file) = 0; 48 virtual HiDebug_ErrorCode StopAppTraceCapture() = 0; 49 virtual int GetMemoryLeakResource(const std::string& type, int32_t value, bool enabledDebugLog) = 0; 50 virtual std::optional<MemoryLimit> GetAppMemoryLimit() = 0; 51 virtual std::optional<HiDebug_NativeMemInfo> GetAppNativeMemInfo() = 0; 52 virtual std::optional<SysMemory> GetSystemMemInfo() = 0; 53 virtual bool IsDebuggerConnected() = 0; 54 virtual std::optional<int32_t> GetGraphicsMemory() = 0; 55 }; 56 } 57 } 58 59 #endif // HIVIEWDFX_HIDEBUG_NATIVE_INTERFACE_H 60