1/* 2* Copyright (C) 2022 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/** 17 * Provide interfaces related to debugger access and obtaining CPU, 18 * memory and other virtual machine information during runtime for JS programs 19 * 20 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 21 * @import import hidebug from '@ohos.hidebug' 22 * @since 8 23 */ 24declare namespace hidebug { 25 /** 26 * Get total native heap memory size 27 * @param - 28 * @returns Returns total native heap memory size. 29 * @since 8 30 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 31 */ 32 function getNativeHeapSize() : bigint; 33 34 /** 35 * Get Native heap memory allocation size. 36 * @param - 37 * @returns Returns native heap memory allocation size. 38 * @since 8 39 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 40 */ 41 function getNativeHeapAllocatedSize() : bigint; 42 43 /** 44 * Get Native heap memory free size 45 * @param - 46 * @returns Returns native heap memory free size. 47 * @since 8 48 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 49 */ 50 function getNativeHeapFreeSize() : bigint; 51 52 /** 53 * Get application process proportional set size memory information 54 * @param - 55 * @returns Returns application process proportional set size memory information. 56 * @since 8 57 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 58 */ 59 function getPss() : bigint; 60 61 /** 62 * Obtains the size of the shared dirty memory of a process. 63 * @param - 64 * @returns Returns the size of the shared dirty memory. 65 * @since 8 66 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 67 */ 68 function getSharedDirty() : bigint; 69 70 /** 71 * Obtains the size of the private dirty memory of a process. 72 * @param - 73 * @returns Returns the size of the private dirty memory. 74 * @since 9 75 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 76 */ 77 function getPrivateDirty() : bigint; 78 79 /** 80 * Obtains the cpu usage percent of a process. 81 * @param - 82 * @returns Returns the cpu usage of a process. 83 * @since 9 84 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 85 */ 86 function getCpuUsage() : number; 87 88 /** 89 * Start CPU Profiling. 90 * The input parameter is a user-defined file name, excluding the file suffix. 91 * The generated file is in the files folder under the application directory. 92 * Such as "/data/accounts/account_0/appdata/[package name]/files/cpuprofiler-xxx.json" 93 * 94 * @param filename Indicates the user-defined file name, excluding the file suffix. 95 * @returns - 96 * @since 8 97 * @deprecated since 9 98 * @useinstead ohos.hidebug/hidebug.startJsCpuProfiling 99 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 100 */ 101 function startProfiling(filename : string) : void; 102 103 /** 104 * Stop CPU Profiling. 105 * It takes effect only when the CPU profiler is turned on 106 * 107 * @param - 108 * @returns - 109 * @since 8 110 * @deprecated since 9 111 * @useinstead ohos.hidebug/hidebug.stopJsCpuProfiling 112 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 113 */ 114 function stopProfiling() : void; 115 116 /** 117 * Dump JS Virtual Machine Heap Snapshot. 118 * The input parameter is a user-defined file name, excluding the file suffix. 119 * The generated file is in the files folder under the application directory. 120 * Such as "/data/accounts/account_0/appdata/[package name]/files/xxx.heapsnapshot" 121 * 122 * @param filename Indicates the user-defined file name, excluding the file suffix. 123 * @returns - 124 * @since 8 125 * @deprecated since 9 126 * @useinstead ohos.hidebug/hidebug.dumpJsHeapData 127 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 128 */ 129 function dumpHeapData(filename : string) : void; 130 131 /** 132 * Start CPU Profiling. 133 * The input parameter is a user-defined file name, excluding the file suffix. 134 * The generated file is in the files folder under the application directory. 135 * 136 * @param filename Indicates the user-defined file name, excluding the file suffix. 137 * @throws {BusinessError} 401 - the parameter check failed 138 * @returns - 139 * @since 9 140 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 141 */ 142 function startJsCpuProfiling(filename : string) : void; 143 144 /** 145 * Stop CPU Profiling. 146 * It takes effect only when the CPU profiler is turned on 147 * 148 * @param - 149 * @returns - 150 * @since 9 151 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 152 */ 153 function stopJsCpuProfiling() : void; 154 155 /** 156 * Dump JS Virtual Machine Heap Snapshot. 157 * The input parameter is a user-defined file name, excluding the file suffix. 158 * The generated file is in the files folder under the application directory. 159 * 160 * @param filename Indicates the user-defined file name, excluding the file suffix. 161 * @throws {BusinessError} 401 - the parameter check failed 162 * @returns - 163 * @since 9 164 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 165 */ 166 function dumpJsHeapData(filename : string) : void; 167 168 /** 169 * Get a debugging dump of a system service by service id. 170 * It need dump permission. 171 * 172 * @param serviceid Indicates the id of the service ability. 173 * @param fd The file descriptor. 174 * @param args The args list of the system ability dump interface. 175 * @throws {BusinessError} 401 - the parameter check failed 176 * @throws {BusinessError} 11400101 - the service id is invalid 177 * @returns - 178 * @permission ohos.permission.DUMP 179 * @since 9 180 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 181 */ 182 function getServiceDump(serviceid : number, fd : number, args : Array<string>) : void; 183} 184export default hidebug; 185