106f6ba60Sopenharmony_ci/*
206f6ba60Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
306f6ba60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
406f6ba60Sopenharmony_ci * you may not use this file except in compliance with the License.
506f6ba60Sopenharmony_ci * You may obtain a copy of the License at
606f6ba60Sopenharmony_ci *
706f6ba60Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
806f6ba60Sopenharmony_ci *
906f6ba60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1006f6ba60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1106f6ba60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1206f6ba60Sopenharmony_ci * See the License for the specific language governing permissions and
1306f6ba60Sopenharmony_ci * limitations under the License.
1406f6ba60Sopenharmony_ci */
1506f6ba60Sopenharmony_ci
1606f6ba60Sopenharmony_ci#ifndef HIDEBUG_FFI_H
1706f6ba60Sopenharmony_ci#define HIDEBUG_FFI_H
1806f6ba60Sopenharmony_ci
1906f6ba60Sopenharmony_ci#include <cstdint>
2006f6ba60Sopenharmony_ci#include "cj_ffi/cj_common_ffi.h"
2106f6ba60Sopenharmony_ci
2206f6ba60Sopenharmony_ciextern "C" {
2306f6ba60Sopenharmony_ci    struct CSystemMemInfo {
2406f6ba60Sopenharmony_ci        uint64_t totalMem;
2506f6ba60Sopenharmony_ci        uint64_t freeMem;
2606f6ba60Sopenharmony_ci        uint64_t availableMem;
2706f6ba60Sopenharmony_ci    };
2806f6ba60Sopenharmony_ci
2906f6ba60Sopenharmony_ci    struct CThreadCpuUsage {
3006f6ba60Sopenharmony_ci        uint32_t threadId;
3106f6ba60Sopenharmony_ci        double cpuUsage;
3206f6ba60Sopenharmony_ci    };
3306f6ba60Sopenharmony_ci
3406f6ba60Sopenharmony_ci    struct ThreadCpuUsageArr {
3506f6ba60Sopenharmony_ci        CThreadCpuUsage *head;
3606f6ba60Sopenharmony_ci        int64_t size;
3706f6ba60Sopenharmony_ci    };
3806f6ba60Sopenharmony_ci
3906f6ba60Sopenharmony_ci    struct CNativeMemInfo {
4006f6ba60Sopenharmony_ci        uint64_t pss;
4106f6ba60Sopenharmony_ci        uint64_t vss;
4206f6ba60Sopenharmony_ci        uint64_t rss;
4306f6ba60Sopenharmony_ci        uint64_t sharedDirty;
4406f6ba60Sopenharmony_ci        uint64_t privateDirty;
4506f6ba60Sopenharmony_ci        uint64_t sharedClean;
4606f6ba60Sopenharmony_ci        uint64_t privateClean;
4706f6ba60Sopenharmony_ci    };
4806f6ba60Sopenharmony_ci
4906f6ba60Sopenharmony_ci    struct CMemoryLimit {
5006f6ba60Sopenharmony_ci        uint64_t rssLimit;
5106f6ba60Sopenharmony_ci        uint64_t vssLimit;
5206f6ba60Sopenharmony_ci    };
5306f6ba60Sopenharmony_ci
5406f6ba60Sopenharmony_ci    FFI_EXPORT uint64_t FfiHidebugGetPss();
5506f6ba60Sopenharmony_ci    FFI_EXPORT uint64_t FfiHidebugGetVss();
5606f6ba60Sopenharmony_ci    FFI_EXPORT uint64_t FfiHidebugGetNativeHeapSize();
5706f6ba60Sopenharmony_ci    FFI_EXPORT uint64_t FfiHidebugGetNativeHeapAllocatedSize();
5806f6ba60Sopenharmony_ci    FFI_EXPORT uint64_t FfiHidebugGetNativeHeapFreeSize();
5906f6ba60Sopenharmony_ci    FFI_EXPORT uint64_t FfiHidebugGetSharedDirty();
6006f6ba60Sopenharmony_ci    FFI_EXPORT uint64_t FfiHidebugGetPrivateDirty();
6106f6ba60Sopenharmony_ci    FFI_EXPORT double FfiHidebugGetCpuUsage();
6206f6ba60Sopenharmony_ci    FFI_EXPORT double FfiHidebugGetSystemCpuUsage(int32_t &code);
6306f6ba60Sopenharmony_ci    FFI_EXPORT ThreadCpuUsageArr FfiHidebugGetAppThreadCpuUsage(int32_t &code);
6406f6ba60Sopenharmony_ci    FFI_EXPORT CSystemMemInfo FfiHidebugGetSystemMemInfo(int32_t &code);
6506f6ba60Sopenharmony_ci    FFI_EXPORT CNativeMemInfo FfiHidebugGetAppNativeMemInfo(int32_t &code);
6606f6ba60Sopenharmony_ci    FFI_EXPORT CMemoryLimit FfiHidebugGetAppMemoryLimit(int32_t &code);
6706f6ba60Sopenharmony_ci    FFI_EXPORT int32_t FfiHidebugGetServiceDump(int32_t serviceId, int32_t fd, CArrString args);
6806f6ba60Sopenharmony_ci    FFI_EXPORT char *FfiHidebugStartAppTraceCapture(CArrUnit tags, int32_t flag, uint32_t limitSize, int32_t &code);
6906f6ba60Sopenharmony_ci    FFI_EXPORT int32_t FfiHidebugStopAppTraceCapture();
7006f6ba60Sopenharmony_ci    FFI_EXPORT int32_t FfiHidebugSetAppResourceLimit(const char *type, int32_t value, bool enableDebugLog);
7106f6ba60Sopenharmony_ci    FFI_EXPORT bool FfiHidebugIsDebugState();
7206f6ba60Sopenharmony_ci}
7306f6ba60Sopenharmony_ci
7406f6ba60Sopenharmony_ci#endif // HIDEBUG_FFI_H
75