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 * @file 18 * @kit PerformanceAnalysisKit 19 */ 20 21/** 22 * Provide interfaces related to debugger access and obtaining CPU, 23 * memory and other virtual machine information during runtime for JS programs 24 * 25 * @namespace hidebug 26 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 27 * @since 8 28 */ 29 30/** 31 * This module provides multiple methods for debugging and profiling applications. With these methods, you can obtain 32 * memory, CPU, GPU, and GC data, collect process trace and profiler data, and dump VM heap snapshots. Since most APIs 33 * of this module are both performance-consuming and time-consuming, and are defined based on the HiDebug module, 34 * you are advised to use these APIs only during the application debugging and profiling phases. If the APIs are 35 * required in other scenarios, evaluate the impact of the APIs on application performance. 36 * 37 * @namespace hidebug 38 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 39 * @atomicservice 40 * @since arkts {'1.1':'12','1.2':'20'} 41 * @arkts 1.1&1.2 42 */ 43declare namespace hidebug { 44 /** 45 * Obtains the total number of bytes occupied by the total space (the sum of uordblks and fordblks obtained from 46 * mallinfo) held by a process, which is measured by the memory allocator. 47 * 48 * @returns { bigint } Returns the total number of bytes occupied by the total space. 49 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 50 * @since arkts {'1.1':'8','1.2':'20'} 51 * @arkts 1.1&1.2 52 */ 53 function getNativeHeapSize(): bigint; 54 55 /** 56 * Obtains the total number of bytes occupied by the total allocated space (uordblks obtained from mallinfo) held by 57 * a process, which is measured by the memory allocator. 58 * @returns { bigint } Returns the total number of bytes occupied by the total allocated space. 59 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 60 * @since arkts {'1.1':'8','1.2':'20'} 61 * @arkts 1.1&1.2 62 */ 63 function getNativeHeapAllocatedSize(): bigint; 64 65 /** 66 * Obtains the total number of bytes occupied by the total free space (fordblks obtained from mallinfo) 67 * held by a process, which is measured by the memory allocator. 68 * 69 * @returns { bigint } Returns the size of the memory occupied by the free normal blocks held by the process, in bytes. 70 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 71 * @since arkts {'1.1':'8','1.2':'20'} 72 * @arkts 1.1&1.2 73 */ 74 function getNativeHeapFreeSize(): bigint; 75 76 /** 77 * Obtains the virtual set size used by the application process. This API is implemented by multiplying the value of 78 * size (number of memory pages) in the /proc/{pid}/statm node by the page size (4 KB per page). 79 * 80 * @returns { bigint } Returns the virtual set size used by the application process, in KB. 81 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 82 * @since arkts {'1.1':'11','1.2':'20'} 83 * @arkts 1.1&1.2 84 */ 85 function getVss(): bigint; 86 87 /** 88 * Obtains the size of the physical memory actually used by the application process. This API is implemented by 89 * summing up the values of **Pss** and **SwapPss** in the /proc/{pid}/smaps_rollup** node. 90 * 91 * @returns { bigint } Returns the size of the physical memory actually used by the application process, in KB. 92 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 93 * @since arkts {'1.1':'8','1.2':'20'} 94 * @arkts 1.1&1.2 95 */ 96 function getPss(): bigint; 97 98 /** 99 * Obtains the size of the shared dirty memory of a process. This API is implemented by reading the value of 100 * Shared_Dirty in the /proc/{pid}/smaps_rollup node. 101 * 102 * @returns { bigint } Returns the size of the shared dirty memory of the process, in KB. 103 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 104 * @since arkts {'1.1':'8','1.2':'20'} 105 * @arkts 1.1&1.2 106 */ 107 function getSharedDirty(): bigint; 108 109 /** 110 * Obtains the size of the private dirty memory of a process. This API is implemented by reading the value of 111 * Private_Dirty in the /proc/{pid}/smaps_rollup node. 112 * 113 * @returns { bigint } Returns the size of the private dirty memory of the process, in KB. 114 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 115 * @since arkts {'1.1':'9','1.2':'20'} 116 * @arkts 1.1&1.2 117 */ 118 function getPrivateDirty(): bigint; 119 120 /** 121 * Obtains the CPU usage of a process. 122 * 123 * @returns { number } Returns the CPU usage of the process. 124 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 125 * @since arkts {'1.1':'9','1.2':'20'} 126 * @arkts 1.1&1.2 127 */ 128 function getCpuUsage(): number; 129 130 /** 131 * 132 * Starts the VM profiling method. startProfiling(filename: string) and stopProfiling() are called in pairs. 133 * startProfiling(filename: string) always occurs before stopProfiling(). You are advised not to call either of these 134 * methods repeatedly. Otherwise, an exception may occur. The generated file is in the files folder under the 135 * application directory. Such as "/data/accounts/account_0/appdata/[package name]/files/cpuprofiler-xxx.json" 136 * 137 * @param { string } filename - User-defined file name of the sampling data. The .json file is generated 138 * in the files directory of the application based on the specified file name. 139 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 140 * @since 8 141 * @deprecated since 9 142 * @useinstead ohos.hidebug/hidebug.startJsCpuProfiling 143 */ 144 function startProfiling(filename: string): void; 145 146 /** 147 * Stops the VM profiling method. stopProfiling() and startProfiling(filename: string) are called in pairs. 148 * startProfiling(filename: string) always occurs before stopProfiling(). You are advised not to call either of these 149 * methods repeatedly. Otherwise, an exception may occur. It takes effect only when the CPU profiler is turned on. 150 * 151 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 152 * @since 8 153 * @deprecated since 9 154 * @useinstead ohos.hidebug/hidebug.stopJsCpuProfiling 155 */ 156 function stopProfiling(): void; 157 158 /** 159 * Exports the VM heap data and generates a filename.heapsnapshot file. 160 * The input parameter is a user-defined file name, excluding the file suffix. 161 * The generated file is in the files folder under the application directory. 162 * Such as "/data/accounts/account_0/appdata/[package name]/files/xxx.heapsnapshot". 163 * 164 * @param { string } filename - Indicates the user-defined file name, excluding the file suffix. 165 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 166 * @since 8 167 * @deprecated since 9 168 * @useinstead ohos.hidebug/hidebug.dumpJsHeapData 169 */ 170 function dumpHeapData(filename: string): void; 171 172 /** 173 * Starts the VM profiling method. startJsCpuProfiling(filename: string) and stopJsCpuProfiling() are called in pairs. 174 * startJsCpuProfiling(filename: string) always occurs before stopJsCpuProfiling(). You are advised not to call either 175 * of these methods repeatedly. Otherwise, an exception may occur. 176 * 177 * @param { string } filename - User-defined heap file name. The .heapsnapshot file is generated in the files 178 * directory of the application based on the specified file name. 179 * @throws {BusinessError} 401 - the parameter check failed, Parameter type error 180 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 181 * @since 9 182 */ 183 function startJsCpuProfiling(filename: string): void; 184 185 /** 186 * Stops the VM profiling method. stopJsCpuProfiling() and startJsCpuProfiling(filename: string) are called in pairs. 187 * startJsCpuProfiling() always occurs before stopJsCpuProfiling(). You are advised not to call either of these 188 * methods repeatedly. Otherwise, an exception may occur. It takes effect only when the CPU profiler is turned on 189 * 190 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 191 * @since 9 192 */ 193 function stopJsCpuProfiling(): void; 194 195 /** 196 * Exports the heap data. 197 * The input parameter is a user-defined file name, excluding the file suffix. 198 * The generated file is in the files folder under the application directory. 199 * 200 * @param { string } filename - User-defined file name of the sampling data. The .heapsnapshot file is generated 201 * in the files directory of the application based on the specified file name. 202 * @throws {BusinessError} 401 - the parameter check failed, Parameter type error. 203 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 204 * @since 9 205 */ 206 function dumpJsHeapData(filename: string): void; 207 208 /** 209 * Obtains system service information. 210 * It need dump permission. 211 * This API can be called only by system application. 212 * 213 * @permission ohos.permission.DUMP 214 * @param { number } serviceid - Obtains the system service information based on the specified service ID. 215 * @param { number } fd - File descriptor to which data is written by the API. 216 * @param { Array<string> } args - Parameter list of the Dump API of the system service. 217 * @throws {BusinessError} 401 - the parameter check failed,Possible causes: 218 * 1.the parameter type error 219 * 2.the args parameter is not string array. 220 * @throws {BusinessError} 11400101 - ServiceId invalid. The system ability does not exist. 221 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 222 * @since arkts {'1.1':'9','1.2':'20'} 223 * @arkts 1.1&1.2 224 */ 225 function getServiceDump(serviceid: number, fd: number, args: Array<string>): void; 226 227 /** 228 * Obtains the CPU usage of the system. 229 * 230 * @returns { number } Returns the CPU usage of the system. 231 * @throws { BusinessError } 11400104 - The status of the system CPU usage is abnormal. 232 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 233 * @since arkts {'1.1':'12','1.2':'20'} 234 * @arkts 1.1&1.2 235 */ 236 function getSystemCpuUsage(): number; 237 238 /** 239 * Describes the CPU usage of a thread. 240 * 241 * @interface ThreadCpuUsage 242 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 243 * @since arkts {'1.1':'12','1.2':'20'} 244 * @arkts 1.1&1.2 245 */ 246 interface ThreadCpuUsage { 247 /** 248 * Thread id 249 * 250 * @type { number } 251 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 252 * @since arkts {'1.1':'12','1.2':'20'} 253 * @arkts 1.1&1.2 254 */ 255 threadId: number; 256 /** 257 * CPU usage of the thread. 258 * 259 * @type { number } 260 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 261 * @since arkts {'1.1':'12','1.2':'20'} 262 * @arkts 1.1&1.2 263 */ 264 cpuUsage: number; 265 } 266 267 /** 268 * Obtains the CPU usage of application threads. 269 * 270 * @returns { ThreadCpuUsage[] } Returns the CPU usage of all threads of the current application process. 271 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 272 * @since arkts {'1.1':'12','1.2':'20'} 273 * @arkts 1.1&1.2 274 */ 275 function getAppThreadCpuUsage(): ThreadCpuUsage[]; 276 277 /** 278 * Describes the system memory information, including the total memory, free memory, and available memory. 279 * 280 * @interface SystemMemInfo 281 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 282 * @since arkts {'1.1':'12','1.2':'20'} 283 * @arkts 1.1&1.2 284 */ 285 interface SystemMemInfo { 286 /** 287 * Total memory of the system, in KB. The value of this parameter is obtained by reading the value of 288 * MemTotal in the /proc/meminfo node. 289 * 290 * @type { bigint } 291 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 292 * @since arkts {'1.1':'12','1.2':'20'} 293 * @arkts 1.1&1.2 294 */ 295 totalMem: bigint; 296 /** 297 * Free memory of the system, in KB. The value of this parameter is obtained by reading the value of 298 * MemFree in the /proc/meminfo node. 299 * 300 * @type { bigint } 301 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 302 * @since arkts {'1.1':'12','1.2':'20'} 303 * @arkts 1.1&1.2 304 */ 305 freeMem: bigint; 306 /** 307 * Available memory of the system, in KB. The value of this parameter is obtained by reading the value of 308 * MemAvailable in the /proc/meminfo node. 309 * 310 * @type { bigint } 311 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 312 * @since arkts {'1.1':'12','1.2':'20'} 313 * @arkts 1.1&1.2 314 */ 315 availableMem: bigint; 316 } 317 318 /** 319 * Obtains system memory information. This API is implemented by reading data from the /proc/meminfo node. 320 * 321 * @returns { SystemMemInfo } Returns the system memory information. 322 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 323 * @since arkts {'1.1':'12','1.2':'20'} 324 * @arkts 1.1&1.2 325 */ 326 function getSystemMemInfo(): SystemMemInfo; 327 328 /** 329 * Describes memory information of the application process. 330 * 331 * @interface NativeMemInfo 332 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 333 * @since arkts {'1.1':'12','1.2':'20'} 334 * @arkts 1.1&1.2 335 */ 336 interface NativeMemInfo { 337 /** 338 * Size of the occupied physical memory (including the proportionally allocated memory occupied by the shared 339 * library), in KB. The value of this parameter is obtained by summing up the values of Pss and SwapPss in the 340 * /proc/{pid}/smaps_rollup node. 341 * 342 * @type { bigint } 343 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 344 * @since arkts {'1.1':'12','1.2':'20'} 345 * @arkts 1.1&1.2 346 */ 347 pss: bigint; 348 /** 349 * Size of the occupied virtual memory (including the memory occupied by the shared library), in KB. The value of 350 * this parameter is obtained by multiplying the value of size (number of memory pages) in the /proc/{pid}/statm 351 * node by the page size (4 KB per page). 352 * 353 * @type { bigint } 354 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 355 * @since arkts {'1.1':'12','1.2':'20'} 356 * @arkts 1.1&1.2 357 */ 358 vss: bigint; 359 /** 360 * Size of the occupied physical memory (including the memory occupied by the shared library), in KB. 361 * The value of this parameter is obtained by reading the value of Rss in the /proc/{pid}/smaps_rollup node. 362 * 363 * @type { bigint } 364 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 365 * @since arkts {'1.1':'12','1.2':'20'} 366 * @arkts 1.1&1.2 367 */ 368 rss: bigint; 369 /** 370 * Size of the shared dirty memory, in KB. The value of this parameter is obtained by reading the value of 371 * Shared_Dirty in the /proc/{pid}/smaps_rollup node. 372 * 373 * @type { bigint } 374 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 375 * @since arkts {'1.1':'12','1.2':'20'} 376 * @arkts 1.1&1.2 377 */ 378 sharedDirty: bigint; 379 /** 380 * Size of the private dirty memory, in KB. The value of this parameter is obtained by reading the value of 381 * Private_Dirty in the /proc/{pid}/smaps_rollup node. 382 * 383 * @type { bigint } 384 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 385 * @since arkts {'1.1':'12','1.2':'20'} 386 * @arkts 1.1&1.2 387 */ 388 privateDirty: bigint; 389 /** 390 * Size of the shared clean memory, in KB. The value of this parameter is obtained by reading the value of 391 * Shared_Clean in the /proc/{pid}/smaps_rollup node. 392 * 393 * @type { bigint } 394 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 395 * @since arkts {'1.1':'12','1.2':'20'} 396 * @arkts 1.1&1.2 397 */ 398 sharedClean: bigint; 399 /** 400 * Size of the private clean memory, in KB. The value of this parameter is obtained by reading the value of 401 * Private_Clean in the /proc/{pid}/smaps_rollup node. 402 * 403 * @type { bigint } 404 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 405 * @since arkts {'1.1':'12','1.2':'20'} 406 * @arkts 1.1&1.2 407 */ 408 privateClean: bigint; 409 } 410 411 /** 412 * Obtains the memory information of the application process. This API is implemented by reading data from the 413 * /proc/{pid}/smaps_rollup and /proc/{pid}/statm node. 414 * 415 * @returns { NativeMemInfo } Returns the memory information of the application process. 416 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 417 * @since arkts {'1.1':'12','1.2':'20'} 418 * @arkts 1.1&1.2 419 */ 420 function getAppNativeMemInfo(): NativeMemInfo; 421 422 /** 423 * Defines the memory limit of the application process. 424 * 425 * @interface MemoryLimit 426 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 427 * @since 12 428 */ 429 interface MemoryLimit { 430 /** 431 * Limit on the resident set size, in KB. 432 * 433 * @type { bigint } 434 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 435 * @since 12 436 */ 437 rssLimit: bigint; 438 /** 439 * Limit on the virtual memory size, in KB. 440 * 441 * @type { bigint } 442 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 443 * @since 12 444 */ 445 vssLimit: bigint; 446 /** 447 * Limit on the JS VM heap size of the calling thread, in KB. 448 * 449 * @type { bigint } 450 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 451 * @since 12 452 */ 453 vmHeapLimit: bigint; 454 /** 455 * Size limit of the JS heap memory of the process, in KB. 456 * 457 * @type { bigint } 458 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 459 * @since 12 460 */ 461 vmTotalHeapSize: bigint; 462 } 463 464 /** 465 * Obtains the memory limit of an application process. 466 * 467 * @returns { MemoryLimit } Returns the memory limit of the application process. 468 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 469 * @since 12 470 */ 471 function getAppMemoryLimit(): MemoryLimit; 472 473 /** 474 * Obtains the memory information of the application process asynchronous. This API is implemented 475 * by reading data from the /proc/{pid}/smaps_rollup and /proc/{pid}/statm node. 476 * 477 * @returns { Promise<NativeMemInfo> } Returns the memory information of the application process. 478 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 479 * @since 20 480 */ 481 function getAppNativeMemInfoAsync(): Promise<NativeMemInfo>; 482 483 /** 484 * Obtains the memory information of the application process, with optional caching to improve performance. 485 * The cached value remains valid for 5 minutes. This API is implemented by reading data from the 486 * /proc/{pid}/smaps_rollup and /proc/{pid}/statm node. 487 * 488 * @param { boolean } [forceRefresh] Whether to retrieve fresh data and immediate refresh the cached value. 489 * The default value is false. 490 * @returns { NativeMemInfo } Returns the memory information of the application process. 491 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 492 * @since 20 493 */ 494 function getAppNativeMemInfoWithCache(forceRefresh?: boolean): NativeMemInfo; 495 496 /** 497 * Describes the VM memory information. 498 * 499 * @interface VMMemoryInfo 500 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 501 * @since 12 502 */ 503 interface VMMemoryInfo { 504 /** 505 * Total heap size of the current VM, in KB. 506 * 507 * @type { bigint } 508 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 509 * @since 12 510 */ 511 totalHeap: bigint; 512 /** 513 * Heap size used by the current VM, in KB. 514 * 515 * @type { bigint } 516 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 517 * @since 12 518 */ 519 heapUsed: bigint; 520 /** 521 * Size of all array objects of the current VM, in KB. 522 * 523 * @type { bigint } 524 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 525 * @since 12 526 */ 527 allArraySize: bigint; 528 } 529 530 /** 531 * Obtains VM memory information. 532 * 533 * @returns { VMMemoryInfo } Returns the VM memory information. 534 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 535 * @since 12 536 */ 537 function getAppVMMemoryInfo(): VMMemoryInfo; 538 539 /** 540 * Describes types of trace collection threads, including the main thread and all threads. 541 * 542 * @enum { number } 543 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 544 * @since arkts {'1.1':'12','1.2':'20'} 545 * @arkts 1.1&1.2 546 */ 547 enum TraceFlag { 548 /** 549 * The main thread of the application. 550 * 551 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 552 * @since arkts {'1.1':'12','1.2':'20'} 553 * @arkts 1.1&1.2 554 */ 555 MAIN_THREAD = 1, 556 /** 557 * All threads of the application. 558 * 559 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 560 * @since arkts {'1.1':'12','1.2':'20'} 561 * @arkts 1.1&1.2 562 */ 563 ALL_THREADS = 2 564 } 565 566 /** 567 * Enumerates the tags used in trace collection. 568 * 569 * @namespace tags 570 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 571 * @since arkts {'1.1':'12','1.2':'20'} 572 * @arkts 1.1&1.2 573 */ 574 namespace tags { 575 /** 576 * Ability Manager tag. The corresponding HiTrace command is tagName:ability. 577 * 578 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 579 * @since arkts {'1.1':'12','1.2':'20'} 580 * @arkts 1.1&1.2 581 */ 582 const ABILITY_MANAGER: number; 583 /** 584 * ArkUI development framework. The corresponding HiTrace command is tagName:ace. 585 * 586 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 587 * @since arkts {'1.1':'12','1.2':'20'} 588 * @arkts 1.1&1.2 589 */ 590 const ARKUI: number; 591 /** 592 * JSVM VM. The corresponding HiTrace command is tagName:ark. 593 * 594 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 595 * @since arkts {'1.1':'12','1.2':'20'} 596 * @arkts 1.1&1.2 597 */ 598 const ARK: number; 599 /** 600 * Bluetooth. The corresponding HiTrace command is tagName:bluetooth. 601 * 602 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 603 * @since arkts {'1.1':'12','1.2':'20'} 604 * @arkts 1.1&1.2 605 */ 606 const BLUETOOTH: number; 607 /** 608 * Common library subsystem. The corresponding HiTrace command is tagName:commonlibrary. 609 * 610 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 611 * @since arkts {'1.1':'12','1.2':'20'} 612 * @arkts 1.1&1.2 613 */ 614 const COMMON_LIBRARY: number; 615 /** 616 * Distributed hardware device management. The corresponding HiTrace command is tagName:devicemanager. 617 * 618 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 619 * @since arkts {'1.1':'12','1.2':'20'} 620 * @arkts 1.1&1.2 621 */ 622 const DISTRIBUTED_HARDWARE_DEVICE_MANAGER: number; 623 /** 624 * Distributed audio. The corresponding HiTrace command is tagName:daudio. 625 * 626 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 627 * @since arkts {'1.1':'12','1.2':'20'} 628 * @arkts 1.1&1.2 629 */ 630 const DISTRIBUTED_AUDIO: number; 631 /** 632 * Distributed camera. The corresponding HiTrace command is tagName:dcamera. 633 * 634 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 635 * @since arkts {'1.1':'12','1.2':'20'} 636 * @arkts 1.1&1.2 637 */ 638 const DISTRIBUTED_CAMERA: number; 639 /** 640 * Distributed data management. The corresponding HiTrace command is tagName:distributeddatamgr. 641 * 642 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 643 * @since arkts {'1.1':'12','1.2':'20'} 644 * @arkts 1.1&1.2 645 */ 646 const DISTRIBUTED_DATA: number; 647 /** 648 * Distributed hardware framework. The corresponding HiTrace command is tagName:dhfwk. 649 * 650 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 651 * @since arkts {'1.1':'12','1.2':'20'} 652 * @arkts 1.1&1.2 653 */ 654 const DISTRIBUTED_HARDWARE_FRAMEWORK: number; 655 /** 656 * Distributed input. The corresponding HiTrace command is tagName:dinput. 657 * 658 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 659 * @since arkts {'1.1':'12','1.2':'20'} 660 * @arkts 1.1&1.2 661 */ 662 const DISTRIBUTED_INPUT: number; 663 /** 664 * Distributed screen. The corresponding HiTrace command is tagName:dscreen. 665 * 666 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 667 * @since arkts {'1.1':'12','1.2':'20'} 668 * @arkts 1.1&1.2 669 */ 670 const DISTRIBUTED_SCREEN: number; 671 /** 672 * Distributed scheduler. The corresponding HiTrace command is tagName:dsched. 673 * 674 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 675 * @since arkts {'1.1':'12','1.2':'20'} 676 * @arkts 1.1&1.2 677 */ 678 const DISTRIBUTED_SCHEDULER: number; 679 /** 680 * FFRT task. The corresponding HiTrace command is tagName:ffrt. 681 * 682 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 683 * @since arkts {'1.1':'12','1.2':'20'} 684 * @arkts 1.1&1.2 685 */ 686 const FFRT: number; 687 /** 688 * File management system. The corresponding HiTrace command is tagName:filemanagement. 689 * 690 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 691 * @since arkts {'1.1':'12','1.2':'20'} 692 * @arkts 1.1&1.2 693 */ 694 const FILE_MANAGEMENT: number; 695 /** 696 * Global resource management. The corresponding HiTrace command is tagName:gresource. 697 * 698 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 699 * @since arkts {'1.1':'12','1.2':'20'} 700 * @arkts 1.1&1.2 701 */ 702 const GLOBAL_RESOURCE_MANAGER: number; 703 /** 704 * Graphics module. The corresponding HiTrace command is tagName:graphic. 705 * 706 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 707 * @since arkts {'1.1':'12','1.2':'20'} 708 * @arkts 1.1&1.2 709 */ 710 const GRAPHICS: number; 711 /** 712 * HDF subsystem. The corresponding HiTrace command is tagName:hdf. 713 * 714 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 715 * @since arkts {'1.1':'12','1.2':'20'} 716 * @arkts 1.1&1.2 717 */ 718 const HDF: number; 719 /** 720 * MISC module. The corresponding HiTrace command is tagName:misc. 721 * 722 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 723 * @since arkts {'1.1':'12','1.2':'20'} 724 * @arkts 1.1&1.2 725 */ 726 const MISC: number; 727 /** 728 * Multi-modal input module. The corresponding HiTrace command is tagName:multimodalinput. 729 * 730 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 731 * @since arkts {'1.1':'12','1.2':'20'} 732 * @arkts 1.1&1.2 733 */ 734 const MULTIMODAL_INPUT: number; 735 /** 736 * Network. The corresponding HiTrace command is tagName:net. 737 * 738 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 739 * @since arkts {'1.1':'12','1.2':'20'} 740 * @arkts 1.1&1.2 741 */ 742 const NET: number; 743 /** 744 * Notification module. The corresponding HiTrace command is tagName:notification. 745 * 746 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 747 * @since arkts {'1.1':'12','1.2':'20'} 748 * @arkts 1.1&1.2 749 */ 750 const NOTIFICATION: number; 751 /** 752 * Nweb. The corresponding HiTrace command is tagName:nweb. 753 * 754 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 755 * @since arkts {'1.1':'12','1.2':'20'} 756 * @arkts 1.1&1.2 757 */ 758 const NWEB: number; 759 /** 760 * OHOS. The corresponding HiTrace command is tagName:ohos. 761 * 762 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 763 * @since arkts {'1.1':'12','1.2':'20'} 764 * @arkts 1.1&1.2 765 */ 766 const OHOS: number; 767 /** 768 * Power management. The corresponding HiTrace command is tagName:power. 769 * 770 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 771 * @since arkts {'1.1':'12','1.2':'20'} 772 * @arkts 1.1&1.2 773 */ 774 const POWER_MANAGER: number; 775 /** 776 * RPC. The corresponding HiTrace command is tagName:rpc. 777 * 778 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 779 * @since arkts {'1.1':'12','1.2':'20'} 780 * @arkts 1.1&1.2 781 */ 782 const RPC: number; 783 /** 784 * System capability management. The corresponding HiTrace command is tagName:samgr. 785 * 786 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 787 * @since arkts {'1.1':'12','1.2':'20'} 788 * @arkts 1.1&1.2 789 */ 790 const SAMGR: number; 791 /** 792 * Window management. The corresponding HiTrace command is tagName:window. 793 * 794 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 795 * @since arkts {'1.1':'12','1.2':'20'} 796 * @arkts 1.1&1.2 797 */ 798 const WINDOW_MANAGER: number; 799 /** 800 * Audio module. The corresponding HiTrace command is tagName:zaudio. 801 * 802 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 803 * @since arkts {'1.1':'12','1.2':'20'} 804 * @arkts 1.1&1.2 805 */ 806 const AUDIO: number; 807 /** 808 * Camera module. The corresponding HiTrace command is tagName:zcamera. 809 * 810 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 811 * @since arkts {'1.1':'12','1.2':'20'} 812 * @arkts 1.1&1.2 813 */ 814 const CAMERA: number; 815 /** 816 * Image module. The corresponding HiTrace command is tagName:zimage. 817 * 818 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 819 * @since arkts {'1.1':'12','1.2':'20'} 820 * @arkts 1.1&1.2 821 */ 822 const IMAGE: number; 823 /** 824 * Media module. The corresponding HiTrace command is tagName:zmedia. 825 * 826 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 827 * @since arkts {'1.1':'12','1.2':'20'} 828 * @arkts 1.1&1.2 829 */ 830 const MEDIA: number; 831 } 832 833 /** 834 * Starts automatic trace collection in a specified scope. This API is a supplement to the HiTrace module. 835 * The performance consumption during trace collection increases with the collection scope. Therefore, before 836 * using this API, you are advised to run the hitrace command to capture trace logs and select the key scope 837 * of trace collection to improve the API performance. 838 * 839 * @param { number[] } tags - Scope for trace collection. For details, see tags. 840 * @param { TraceFlag } flag - For details, see TraceFlag. 841 * @param { number } limitSize - Limit on the trace file size, in bytes. The maximum size of a single file is 500 MB. 842 * @returns { string } Returns the path of the trace file. 843 * @throws { BusinessError } 401 - Invalid argument, Possible causes: 844 * 1.The limit parameter is too small 845 * 2.The parameter is not within the enumeration type 846 * 3.The parameter type error or parameter order error 847 * @throws { BusinessError } 11400102 - Capture trace already enabled. 848 * @throws { BusinessError } 11400103 - No write permission on the file. 849 * @throws { BusinessError } 11400104 - Abnormal trace status. 850 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 851 * @since arkts {'1.1':'12','1.2':'20'} 852 * @arkts 1.1&1.2 853 */ 854 function startAppTraceCapture(tags: number[], flag: TraceFlag, limitSize: number): string; 855 856 /** 857 * Stops application trace collection. Use startAppTraceCapture() to start collection before calling this API. 858 * If this API is called before trace collection or it is repeatedly called, an exception will occur. 859 * 860 * @throws { BusinessError } 11400104 - The status of the trace is abnormal. 861 * @throws { BusinessError } 11400105 - No capture trace running. 862 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 863 * @since arkts {'1.1':'12','1.2':'20'} 864 * @arkts 1.1&1.2 865 */ 866 function stopAppTraceCapture(): void; 867 868 /** 869 * Describes the key-value pair used to store GC statistics. This type does not support multi-thread operations. 870 * If this type is operated by multiple threads at the same time in an application, use a lock for it. 871 * 872 * @typedef { Record<string, number> } GcStats 873 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 874 * @since 12 875 */ 876 type GcStats = Record<string, number>; 877 878 /** 879 * Obtains all system GC statistics. 880 * 881 * @returns { GcStats } Returns the system GC statistics. 882 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 883 * @since 12 884 */ 885 function getVMRuntimeStats(): GcStats; 886 887 /** 888 * Obtains the specified system GC statistics based on parameters. 889 * 890 * @param { string } item - statistical item. 891 * @returns { number } Returns the item of the GC statistics to be obtained. 892 * @throws { BusinessError } 401 - Possible causes: 893 * 1. Invalid parameter, a string parameter required. 894 * 2. Invalid parameter, unknown property. 895 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 896 * @since 12 897 */ 898 function getVMRuntimeStat(item: string): number; 899 900 /** 901 * Sets the number of FDs, number of threads, JS memory, or native memory limit of the application. 902 * 903 * @param { string } type - resource type. It could be pss_memory、js_heap、fd、or thread. 904 * @param { number } value - For different resource type, values could have different meaning: 905 * 1.For pss_memory, it means the baseline PSS memory size for the application, 906 * system memory control will be triggered if exceed the value too much. 907 * 2.For js_heap, it means the percentage of the used JS heap memory to the maximum limit exceed 908 * which heap dump will be triggered if enableDebugLog set as true, it can be set between 85 and 95. 909 * 3.For fd, it means the maximum fd number can be opened. 910 * 4.For thread, it means the maximum thread number can be created. 911 * @param { boolean } enableDebugLog - Whether to enable external debug log. Default is false, pls make sure set 912 * it as true only in gray release because collecting debug log will cost too much cpu or memory. 913 * @throws { BusinessError } 401 - Invalid argument, Possible causes: 914 * 1.The limit parameter is too small 915 * 2.The parameter is not in the specified type 916 * 3.The parameter type error or parameter order error 917 * @throws { BusinessError } 11400104 - Set limit failed due to remote exception 918 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 919 * @atomicservice 920 * @since 12 921 */ 922 function setAppResourceLimit(type: string, value: number , enableDebugLog: boolean): void; 923 924 /** 925 * Obtains the debugging state of an application process. If the Ark or native layer of the application process is in 926 * debugging state, true is returned. Otherwise, false is returned. 927 * 928 * @returns { boolean } true if the application is in the debugging state. 929 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 930 * @since 12 931 */ 932 function isDebugState(): boolean; 933 934 /** 935 * Obtains the size of the GPU memory. This API uses a promise to return the result. 936 * 937 * @returns { Promise<number> } Returns the size of the GPU memory, in KB. 938 * @throws { BusinessError } 11400104 - Failed to get the application memory due to a remote exception. 939 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 940 * @atomicservice 941 * @since arkts {'1.1':'14','1.2':'20'} 942 * @arkts 1.1&1.2 943 */ 944 function getGraphicsMemory(): Promise<number>; 945 946 /** 947 * Obtains the size of the GPU memory synchronously. 948 * 949 * @returns { number } Returns the size of the GPU memory, in KB. 950 * @throws { BusinessError } 11400104 - Failed to get the application memory due to a remote exception. 951 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 952 * @atomicservice 953 * @since arkts {'1.1':'14','1.2':'20'} 954 * @arkts 1.1&1.2 955 */ 956 function getGraphicsMemorySync(): number; 957 958 /** 959 * Dumps the original heap snapshot of the VM for the current thread. The API uses a promise to return the path of the 960 * .rawheap file. You can use rawheap-translator to convert the generated file into a .heapsnapshot file for parsing. 961 * The generated file will be stored in a folder within the application directory. However, since this file is usually 962 * large, the system imposes restrictions on the frequency and number of calls to this function. Consequently, you 963 * might fail to obtain the dump file due to quota limitations. These failures will persist until the quota is 964 * regularly refreshed by the system. Therefore, it is advisable to delete the file immediately after you have 965 * finished processing it. Moreover, it is recommended that you use this function in the gray - release version. 966 * 967 * @param { boolean } needGC - Whether GC is required when a heap snapshot is dumped. The default value is true. 968 * If this parameter is not specified, GC is triggered before dumping. 969 * @returns { Promise<string> } Returns the path of the generated snapshot file. 970 * @throws { BusinessError } 11400106 - Quota exceeded. 971 * @throws { BusinessError } 11400107 - Fork operation failed. 972 * @throws { BusinessError } 11400108 - Failed to wait for the child process to finish. 973 * @throws { BusinessError } 11400109 - Timeout while waiting for the child process to finish. 974 * @throws { BusinessError } 11400110 - Disk remaining space too low. 975 * @throws { BusinessError } 11400111 - Napi interface call exception. 976 * @throws { BusinessError } 11400112 - Repeated data dump. 977 * @throws { BusinessError } 11400113 - Failed to create dump file. 978 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 979 * @atomicservice 980 * @since 18 981 */ 982 function dumpJsRawHeapData(needGC?: boolean): Promise<string>; 983 984 /** 985 * GwpAsan Options. 986 * 987 * @interface GwpAsanOptions 988 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 989 * @since 20 990 */ 991 interface GwpAsanOptions { 992 /** 993 * Control whether to enable GWP-ASan every time 994 * 995 * @type { ?boolean } 996 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 997 * @since 20 998 */ 999 alwaysEnabled?: boolean; 1000 /** 1001 * sample rate of GWP-ASAN 1002 * 1003 * @type { ?number } 1004 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 1005 * @since 20 1006 */ 1007 sampleRate?: number; 1008 /** 1009 * the max simutaneous allocations of GWP-ASAN 1010 * 1011 * @type { ?number } 1012 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 1013 * @since 20 1014 */ 1015 maxSimutaneousAllocations?: number; 1016 } 1017 1018 /** 1019 * Enable the GWP-ASAN grayscale of your application. 1020 * @param { GwpAsanOptions } [options] - The options of GWP-ASAN grayscale. 1021 * @param { number } [duration] - The duration days of GWP-ASAN grayscale. 1022 * @throws { BusinessError } 11400114 - The number of GWP-ASAN applications of this device overflowed after last boot. 1023 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 1024 * @since 20 1025 */ 1026 function enableGwpAsanGrayscale(options?: GwpAsanOptions, duration?: number): void; 1027 1028 /** 1029 * Disable the GWP-ASAN grayscale of your application. 1030 * 1031 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 1032 * @since 20 1033 */ 1034 function disableGwpAsanGrayscale(): void; 1035 1036 /** 1037 * Obtain the remaining days of GWP-ASan grayscale for your application. 1038 * 1039 * @returns { number } The remaining days of GWP-ASan grayscale. 1040 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 1041 * @since 20 1042 */ 1043 function getGwpAsanGrayscaleState(): number; 1044 1045 /** 1046 * Trimming level of raw heap snapshot. 1047 * 1048 * @enum { number } 1049 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 1050 * @since 20 1051 */ 1052 enum JsRawHeapTrimLevel { 1053 /** 1054 * Basic heap snapshot trimming(e.g. reducing content of string object). 1055 * 1056 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 1057 * @since 20 1058 */ 1059 TRIM_LEVEL_1 = 0, 1060 /** 1061 * On top of level 1 trimming, object address size has been additionally trimmed. 1062 * Please use latest version of rawheap-translator tool for parsing and converting 1063 * .rawheap into .heapsnapshot file. Conversion process may fail when legacy tool is utilized. 1064 * 1065 * A higher trimming level means a longer time needed to generate the .rawheap file. 1066 * Ensure that this duration falls below the app freeze threshold. 1067 * 1068 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 1069 * @since 20 1070 */ 1071 TRIM_LEVEL_2 = 1, 1072 } 1073 1074 /** 1075 * Sets the raw heap snapshot trimming level for the current process. 1076 * @param { JsRawHeapTrimLevel } level - The trimming level of raw heap snapshot. 1077 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 1078 * @since 20 1079 */ 1080 function setJsRawHeapTrimLevel(level: JsRawHeapTrimLevel): void; 1081} 1082export default hidebug; 1083