Method, apparatus, readable medium and program product for determining performance indicator

By generating and utilizing indicator observation hook functions, the problem of code inserts in the existing technology increasing development workload and being unable to monitor third-party dynamic library functions is solved, and non-invasive monitoring and flexible monitoring operations of software performance are realized.

CN119645786APending Publication Date: 2025-03-18SHANGHAI BILIBILI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411660421.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

Existing software performance monitoring methods rely on code instrumentation, increase development workload, reduce code maintainability, and cannot effectively monitor functions in third-party dynamic libraries.

Method used

A non-invasive method is used to generate the code of the indicator observation hook, intercept the call operation of the objective function, and instead call the indicator observation hook function to determine the performance indicator of the objective function. This method includes generating, compiling and loading metric observation dynamic libraries, and using hook technology to achieve performance monitoring.

Benefits of technology

It realizes non-invasive monitoring of software performance, improves the flexibility and convenience of monitoring operations, avoids the limitations of code insertion, and can dynamically monitor the performance indicators of the objective function.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645786A_ABST
    Figure CN119645786A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for determining a performance index, a computer readable medium and a program product, and a specific implementation mode of the application is as follows: generating a code of an index observation hook according to function data of a target function, calling an index observation hook function, and determining a performance index in the operation process of the target function; compiling the code of the index observation hook, and generating and loading an index observation dynamic library; and determining a performance index based on the index observation hook function in the index observation dynamic library. According to the non-intrusive performance index monitoring method, on-demand monitoring of the target function can be dynamically achieved only according to the function data, provided by the user, of the target function, and the flexibility and convenience of performance monitoring operation are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, specifically to the field of software performance monitoring, and in particular to a method, device, computer-readable medium, and program product for determining performance indicators. Background Art

[0002] In the field of software performance monitoring and optimization, traditional performance observation methods mostly rely on code instrumentation in the source code, which manually adds tracking code at the entry and exit of the function to be monitored to achieve time-consuming monitoring of function calls. In the existing code instrumentation method, manual modification of the source code is required, which increases the development workload, increases code complexity, and reduces code maintainability. In addition, manual modification of code for instrumentation has obvious limitations. Since dynamic libraries or system libraries provided by third parties cannot be easily modified, the code instrumentation method cannot monitor the performance of functions in these dynamic libraries.

[0003] This section is intended to provide a background or context to the embodiments of the application that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section. Summary of the invention

[0004] Multiple aspects of the present application provide a method, device, computer-readable storage medium, and program product for determining performance indicators, so as to monitor software performance in a non-invasive manner.

[0005] In one aspect of the present application, a method for determining performance indicators is provided, comprising: generating indicator observation hook code based on function data of a target function, wherein the indicator observation hook is used to intercept a call operation to the target function and instead call the indicator observation hook function to determine performance indicators during the operation of the target function; compiling the indicator observation hook code to generate and load an indicator observation dynamic library; and determining the performance indicators of the target function based on the indicator observation hook function in the indicator observation dynamic library.

[0006] Another aspect of the present application provides a method for determining performance indicators, including: using hook technology to intercept the call operation to the target function and instead call the indicator observation hook function; through the indicator observation hook function, determining the performance indicator during the operation of the target function.

[0007] On the other hand, the present application provides a device for determining performance indicators, including: a generation module, configured to generate the code of the indicator observation hook according to the function data of the target function, wherein the indicator observation hook is used to intercept the call operation to the target function, and instead call the indicator observation hook function to determine the performance indicators during the operation of the target function; a compilation module, configured to compile the code of the indicator observation hook, generate and load the indicator observation dynamic library; a first determination module, configured to determine the performance indicator based on the indicator observation hook function in the indicator observation dynamic library.

[0008] On the other hand, the present application provides a device for determining performance indicators, including: a calling module, configured to adopt hook technology to intercept the calling operation of the target function and instead call the indicator observation hook function; a second determination module, configured to determine the performance indicators during the operation of the target function through the indicator observation hook function.

[0009] Another aspect of the present application provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for determining performance indicators as shown above.

[0010] In another aspect of the present application, a computer-readable storage medium is provided, on which computer program instructions are stored. The computer program instructions can be executed by a processor to implement a method for determining a performance indicator.

[0011] In another aspect of the present application, a computer program product is provided, comprising a computer program, which implements a method for determining a performance indicator when the computer program is executed by a processor.

[0012] In the solution provided in the embodiment of the present application, the code of the indicator observation hook is generated according to the function data of the target function, wherein the indicator observation hook is used to respond to the software's call to the target function and call the indicator observation function at the same time to track and determine the performance indicators of the target function during its operation; the generated indicator observation hook code is compiled into a new dynamic library - the indicator observation dynamic library, which is dynamically added to the software through the dynamic library injection technology, so that the software operation process automatically loads the indicator observation dynamic library; based on the indicator observation hook function in the indicator observation dynamic library, the performance indicator is determined, thereby providing a non-invasive performance indicator monitoring method, which can dynamically realize on-demand monitoring of the target function based on the function data of the target function provided by the user, thereby improving the flexibility and convenience of performance monitoring operations. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present application, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0014] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0015] Figure 1 A flowchart of a method for determining a performance indicator provided by an embodiment of the present application;

[0016] Figure 2 A flowchart of a method for determining a performance indicator provided by another embodiment of the present application;

[0017] Figure 3 A flowchart of a method for determining a performance indicator provided in yet another embodiment of the present application;

[0018] Figure 4 A flowchart of a method for determining a performance indicator provided in yet another embodiment of the present application;

[0019] Figure 5 A schematic diagram of the structure of a device for determining a performance indicator provided in an embodiment of the present application;

[0020] Figure 6 A schematic diagram of the structure of a device for determining a performance indicator provided in yet another embodiment of the present application;

[0021] Figure 7 This is a structural schematic diagram of a device suitable for implementing the solution in the embodiment of the present application. The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0023] In a typical configuration of the present application, the terminal and the equipment of the service network each include one or more processors (CPU), input / output interface, network interface and memory.

[0024] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0025] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer program instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0026] The following is an introduction to the terms involved in the embodiments of the present application.

[0027] Dynamic library: DLL (Dynamic Link Library) is a library that is loaded only when the program is running. Its code will be loaded into the memory only when the program is running. On the Android platform, the extension of the dynamic library is .so and it is in ELF format.

[0028] Hook: Hook technology is a technology that modifies function calls at runtime, which can modify and track target function calls.

[0029] ELF: ELF (Executable and Linkable Format) is a standard format for executable files and object files, and is the executable file format under the Linux system.

[0030] PLT: PLT (Procedure Linkage Table) is a table in the ELF file that stores the addresses of functions in the dynamic library and is used to implement dynamic linking.

[0031] PLT Hook: When the program is running, the function address in the PLT table is tampered with to hook the target function.

[0032] Inline Hook: Inline Hook is a Hook technology that monitors the target function calls by modifying the function's instructions.

[0033] Code instrumentation: Code instrumentation refers to inserting code into the source code to track and monitor function calls.

[0034] Jinja: Jinja is a template engine that supports the Python language and is used to generate text files such as code files.

[0035] An embodiment of the present application provides a method for determining performance indicators, which generates code for an indicator observation hook based on function data of a target function, wherein the indicator observation hook is used to call the indicator observation hook function in response to calling the target function, and determine the performance indicators during the operation of the target function; compile the code for the indicator observation hook, generate and load an indicator observation dynamic library; and determine the performance indicators based on the indicator observation hook function in the indicator observation dynamic library, thereby providing a non-intrusive performance indicator monitoring method, which can dynamically implement on-demand monitoring of the target function based on the function data of the target function provided by the user, thereby improving the flexibility and convenience of performance monitoring operations.

[0036] In actual scenarios, the execution subject of the method can be a user device, or a device formed by integrating a user device and a network device through a network, or an application running on the above device. The user device includes but is not limited to various terminal devices such as computers, mobile phones, tablet computers, smart watches, and bracelets. The network device includes but is not limited to network hosts, single network servers, multiple network server sets, or cloud computing-based computer sets, which can be used to implement some processing functions when setting an alarm. Here, the cloud is composed of a large number of hosts or network servers based on cloud computing, where cloud computing is a type of distributed computing, a virtual computer composed of a group of loosely coupled computer sets.

[0037] Figure 1 The present invention provides a method for determining a performance indicator according to an embodiment of the present invention. The method for determining a performance indicator includes at least the following processing steps:

[0038] Step S101, generating the code of the indicator observation hook according to the function data of the target function.

[0039] Among them, the indicator observation hook is used to intercept the call operation to the target function, and instead call the indicator observation hook function to determine the performance indicators during the operation of the target function.

[0040] The target function can be any function in the dynamic library contained in the application. The function data is the data related to the target function, including the function's name, symbol, input parameters, output parameters, function address and other data. It can also include the name of the dynamic library (for example, xx.so).

[0041] The performance indicators during the operation of the target function include, for example, operation time consumption, CPU (Central Processing Unit, central processing unit) utilization rate, GPU (Graphics Processing Unit, graphics processing unit) utilization rate and other indicators.

[0042] As an example, the execution subject can generate the code of the indicator observation hook according to the function data of the target function and the code template for generating the code of the indicator observation hook. Specifically, for each item to be filled in the code template, the data corresponding to the item to be filled in the function data of the target function is used to supplement the code of the indicator observation hook.

[0043] The code template can be obtained in the following way: the relevant technical personnel write an indicator observation hook function for a function to be monitored, the indicator observation hook function includes an indicator observation function for performance indicators and an operation indication part for ensuring the complete operation of the target function, and different indicator observation functions are used for different performance indicators; and, for the use of hook technology, in response to calling the target function, the application program's call process for the target function is intercepted, and the execution process of the indicator observation hook function is called instead, and the relevant technical personnel write its execution code. After combining the function code and execution code of the above-mentioned indicator observation hook function to obtain the standard code, the part of the standard code that can be dynamically replaced (the part for the function to be monitored) is stripped off to obtain the code template.

[0044] The indicator observation hook is used to intercept the application's call process to the target function using hook technology, and call the indicator observation hook function instead. The indicator observation hook function is used to determine the performance indicators of the target function during its operation when the target function is running normally.

[0045] In the code template, corresponding description information can be set for each item to be filled in, so as to guide the user to manually fill in each item to be filled in the code template. In some implementations, the execution subject can also automatically analyze and understand the function data, and fill each item of data in the function data into the corresponding item to be filled in the code template.

[0046] In some optional implementations of this embodiment, the execution subject may perform step 101 in the following manner:

[0047] The first step is to determine the hook type of the indicator observation hook according to the function type of the target function.

[0048] Function types can be distinguished based on whether the function is exposed through symbols, such as exported functions, internal functions, and hidden functions. Functions exposed through symbols are called exported functions. When the dynamic library is created, these functions are explicitly marked as available for use by external programs. The compiler and linker will add the symbols of these functions to the dynamic link table of the dynamic library so that other programs can find and use these functions when linking.

[0049] Functions that are not exposed through symbols are called internal functions. These functions are only used within the dynamic library and are not designed to be accessed by external programs. Since these functions are not added to the symbol table of the dynamic library, external programs cannot directly find and use them when linking.

[0050] Hook types include but are not limited to PLT Hook, Inline Hook, IAT (Import Address Table) Hook, EAT (Export Address Table) Hook, SSDT (System Services Descriptor Table) Hook, IDT (Interrupt Descriptor Table) Hook and other types.

[0051] In this implementation, the above-mentioned execution entity or the electronic device communicating with the above-mentioned execution entity may be provided with a two-dimensional table representing the correspondence between function types and hook types, so as to determine the hook type of the indicator observation hook based on the two-dimensional table and the function type of the objective function.

[0052] The second step is to generate the code of the indicator observation hook under the hook type based on the function data.

[0053] As an example, for multiple hook types, multiple code templates are set in one-to-one correspondence. For each hook type, the code of the indicator observation hook under the above hook type is generated according to the function data and the code template corresponding to the hook type. Specifically, for each item to be filled in the code template corresponding to the hook type, the data corresponding to the item to be filled in the function data of the target function is used to supplement it to obtain the code of the indicator observation hook.

[0054] Among them, the code template corresponding to each hook type can be obtained in the following way: the relevant technical personnel write an indicator observation hook function for a function to be monitored under the function type corresponding to the hook type, and the indicator observation hook function includes an indicator observation function for performance indicators and an operation indication part for ensuring the complete operation of the target function, and different indicator observation functions are used for different performance indicators; and for the use of hook technology, in response to calling the target function, the application's call process for the target function is intercepted, and the execution process of the indicator observation hook function is called instead, and the relevant technical personnel write its execution code. After combining the function code and execution code of the above-mentioned indicator observation hook function to obtain the standard code, the part of the standard code that can be dynamically replaced (the part for the function to be monitored) is stripped to obtain the code template corresponding to the hook type.

[0055] In this implementation, codes of indicator observation hooks of different hook types are generated for different types of functions, thereby improving the accuracy of the code generation process and the adaptability between the code indicator observation hook and the target function.

[0056] In some optional implementations of this embodiment, the execution subject may perform the first step in the following manner: in response to determining that the function type is an export function, determining that the hook type is a procedure linkage table hook.

[0057] The process connection table hook is PLT Hook.

[0058] In this implementation, the execution subject may perform the second step as follows:

[0059] First, generate interception code based on function data.

[0060] Among them, the interception code is used to represent the use of indicator observation hook function to intercept the target function.

[0061] As an example, the interception code looks like this:

[0062] void hook(){

[0063] createSurface_stub=BLhook_hook_single("libbli.so",NULL,"createSurface",createSurface_proxy,hooked_callback,NULL)

[0064] }

[0065] Use the BLhook_hook_single function to suspend the target function createSurface in the libbli.so dynamic library. For the target function, a proxy function (indicator observation hook function) (createSurface_proxy) and a callback function (hooked_callback) are specified.

[0066] Then, based on the function data, generate the function code of the indicator observation hook function.

[0067] The function code includes the code for calling the target function and the code for the indicator observation function for determining the performance indicator.

[0068] As an example, the function code of the indicator observation hook function is as follows:

[0069] static int createSurface_proxy(int arg0,int arg1){

[0070] int id=TRACE_BENGIN("createSurface");

[0071] int ret=BLHOOK_CALL_PREV(createSurface_proxy,createSurface,arg0,arg1);

[0072] BLHOOK_POP_STACK();

[0073] TRACE_END(id);

[0074] return ret;

[0075] }

[0076] Among them, createSurface_proxy is an indicator observation hook function, TRACE_BENGIN and TRACE_END are indicator observation functions for users to determine the running time of the target function; BLHOOK_CALL_PREV is used to call the original createSurface function and pass arg0 and arg1 as parameters. createSurface is a function pointer variable that points to the original createSurface function. The return value of BLHOOK_CALL_PREV (that is, the return value of the original createSurface function) is stored in the ret variable.

[0077] Finally, combine the interception code and the function code to get the code of the indicator observation hook.

[0078] In this implementation, for the target function of the exported function type, a code generation method for the corresponding procedure linkage table hook is provided, which further improves the accuracy of the code generation process and the adaptability between the code indicator observation hook and the target function.

[0079] In some optional implementations of this embodiment, the execution subject may perform the first step in the following manner: in response to determining that the function type is an internal function, determining that the hook type is an inline hook.

[0080] Among them, the inline hook is Inline Hook.

[0081] In this implementation, the execution subject may perform the second step as follows:

[0082] First, generate replacement code based on the function data.

[0083] The replacement code is used to represent replacing the starting part of the target function in the memory with a jump instruction for the indicator observation hook function.

[0084] As an example, use a debugger, disassembler or memory scanning technology to determine the memory address of the target function; back up several instructions at the beginning of the target function so that execution can be resumed in the Hook function; replace the beginning of the target function with one or more jump instructions so that the program jumps to the specified indicator observation hook function.

[0085] Then, based on the function data, generate the function code of the indicator observation hook function.

[0086] The function code includes the code of the indicator observation function for determining the performance indicator and the code representing the return to the target function after the indicator observation function is executed.

[0087] As an example, during the generation of the indicator observation hook function, after executing the user-defined code, the function can resume executing the backup code of the original target function, or directly jump to the address after the backup code to continue execution.

[0088] Finally, combine the replacement code and the function code to get the code of the indicator observation hook.

[0089] In this implementation, for the target function of the internal function type, a code generation method for the corresponding inline hook is provided, which further improves the accuracy of the code generation process and the adaptability between the code indicator observation hook and the target function.

[0090] In some optional implementations of this embodiment, before executing the above step 101, the above execution subject may further perform the following operations:

[0091] First, the visualization configuration page is displayed, where the visualization configuration page is used to instruct the user to configure the function data of the objective function.

[0092] Then, according to the received configuration instruction, the function data is determined.

[0093] As an example, the visualization configuration page includes a plurality of input boxes corresponding to a plurality of necessary data in the function data, and the user can fill in the corresponding function data in the input boxes.

[0094] As another example, the user directly provides a C language header file exported by the dynamic library, and the above-mentioned execution subject can automatically parse the C language header file to determine the function data of the target function.

[0095] In this implementation, the user can configure the function data of the objective function based on the visual configuration page, and only needs to configure the function data of the objective function to realize the monitoring of the objective function, which improves the convenience and configuration efficiency of the data configuration process, and at the same time improves the flexibility and convenience of the monitoring operation.

[0096] Step S102, compile the code of the indicator observation hook, generate and load the indicator observation dynamic library.

[0097] Use tool chains such as cmake, ninja, and ndk to automatically compile and execute the code for the indicator observation hook, and encapsulate the code into a dynamic library form (such as libbli_hook.so file) to facilitate loading in the software application of the target system (for example, the Android system). Use an APK compilation tool (such as apktool) with the function of repackaging APK (Android application package) to add the compiled files (the indicator observation dynamic library and the code injected into the indicator observation dynamic library) into the target software and repackage them. When the target application is running, the indicator observation dynamic library is automatically loaded, so that each hooked target function will pass through the indicator observation hook function before calling it.

[0098] Step 103, determining the performance indicator based on the indicator observation hook function in the indicator observation dynamic library.

[0099] In response to the target function being called by the application, the application's calling process of the target function is intercepted, and the indicator observation hook function in the indicator observation dynamic library is called instead. Through the indicator observation hook function, the performance indicators of the target function during its operation are determined.

[0100] In some optional implementations of this embodiment, for a target function of a derived function type, the execution subject may perform step 103 in the following manner:

[0101] First, determine the target function address in the procedure linkage table.

[0102] Then, update the target function address to the function address of the indicator observation hook function.

[0103] Finally, in response to calling the target function, the indicator observation hook function is called according to the updated target function address to determine the performance indicator.

[0104] PLT is a function pointer table that stores the address of the function. The address of the function in the PLT table is modified to point to the indicator observation hook function. Therefore, when the application calls the target function, the calling process is intercepted by the indicator observation hook function, and the application calls the indicator observation hook function instead.

[0105] The indicator observation hook function includes the indicator observation function, and by calling the target function, it realizes the indicator monitoring of the target function while ensuring the complete operation of the target function.

[0106] In this implementation, based on the update of the function address in the process link table, the indicator observation hook function intercepts and monitors the target function, thereby improving the stability and accuracy of the monitoring process for the target function of the exported function type.

[0107] In some optional implementations of this embodiment, for a target function of an internal function type, the execution subject may perform step 103 in the following manner: in response to calling the target function, calling an indicator observation hook function according to a jump instruction to determine a performance indicator.

[0108] Since the starting part of the target function is replaced by the jump instruction for the indicator observation hook function, when the target function is called and executed, the jump instruction of the starting part is executed first, jumping to the indicator observation hook function, and executing the indicator observation hook function.

[0109] It should be noted that the indicator observation hook function includes code that represents the return to the target function after the indicator observation function is executed. After the custom logic of the indicator observation hook function (for example, the indicator observation function) is completed, control needs to be returned to the original target function. This is usually achieved by calculating the address of the remaining part of the target function and executing a jump instruction.

[0110] In this implementation, based on the modification of some instructions of the target function, the indicator observation hook function intercepts and monitors the target function, which improves the stability and accuracy of the monitoring process for the target function of the internal function type.

[0111] In some optional implementations of this embodiment, the target function is a function in a dynamic library. For example, for a target application, a third party provides a dynamic library of the target application, and the target function is a function in the dynamic library.

[0112] In this implementation, before executing the above step 103, the above execution subject may also perform the following operation: loading a dynamic library.

[0113] In this implementation, the dynamic library of the target function is loaded first, and then the indicator observation dynamic library is loaded. The indicator observation hook function in the indicator observation dynamic library will be called when the target function is called, thereby realizing the monitoring of the target function.

[0114] In some optional implementations of this embodiment, the execution subject may also remove the indicator observation hook function according to the received hook removal instruction. In this implementation, the user may flexibly determine the existence period of the indicator observation hook function according to their own monitoring needs, thereby improving the flexibility of the monitoring process.

[0115] Figure 2 The processing flow of another embodiment of a method for determining a performance indicator provided by an embodiment of the present application is shown. The method for determining a performance indicator includes at least the following processing steps:

[0116] Step 201 : determining function data of the target function based on the visualization configuration page.

[0117] Step 202, in response to determining that the function type of the target function is a derived function, determining that the hook type of the indicator observation hook is a procedure linkage table hook.

[0118] Step 203: Generate an interception code according to the function data.

[0119] Among them, the interception code is used to represent the use of indicator observation hook function to intercept the target function.

[0120] Step 204, generating the function code of the indicator observation hook function according to the function data.

[0121] The function code includes the code for calling the target function and the code for the indicator observation function for determining the performance indicator.

[0122] Step 205, combine the interception code and the function code to obtain the code of the indicator observation hook.

[0123] Step 206, compile the code of the indicator observation hook, generate and load the indicator observation dynamic library.

[0124] Step 207, determining the target function address of the target function in the procedure linkage table.

[0125] Step 208, update the target function address to the function address of the indicator observation hook function.

[0126] Step 209, in response to calling the target function, calling the indicator observation hook function in the indicator observation dynamic library according to the updated target function address, and determining the performance indicator during the operation of the target function.

[0127] Figure 3 The processing flow of another embodiment of a method for determining a performance indicator provided by an embodiment of the present application is shown. The method for determining a performance indicator includes at least the following processing steps:

[0128] Step 301: Determine function data of the target function based on the visualization configuration page.

[0129] Step 302, in response to determining that the function type of the target function is an internal function, determining that the hook type of the indicator observation hook is an inline hook.

[0130] Step 303: Generate replacement code according to the function data.

[0131] The replacement code is used to represent replacing the starting part of the target function in the memory with a jump instruction for the indicator observation hook function.

[0132] Step 304, generating the function code of the indicator observation hook function according to the function data.

[0133] The function code includes the code of the indicator observation function for determining the performance indicator and the code representing the return to the target function after the indicator observation function is executed.

[0134] Step 305, combine the replacement code and the function code to obtain the code of the indicator observation hook.

[0135] Step 306, compile the code of the indicator observation hook, generate and load the indicator observation dynamic library.

[0136] Step 307, in response to calling the target function, calling the indicator observation hook function in the indicator observation dynamic library according to the jump instruction, and determining the performance indicator during the operation of the target function.

[0137] Figure 4The processing flow of another embodiment of a method for determining a performance indicator provided by an embodiment of the present application is shown. The method for determining a performance indicator includes at least the following processing steps:

[0138] Step 401, using hook technology, in response to calling the target function, calls the indicator observation hook function.

[0139] The target function may be any function in the application program that has a monitoring requirement. As an example, in response to the application program calling the target function, the calling process is intercepted by the indicator observation hook function, and the application program calls the indicator observation hook function instead.

[0140] Step 402, determining the performance index of the target function during its operation through the index observation hook function.

[0141] The indicator observation hook function includes an indicator observation function for determining the performance indicators during the operation of the target function, and can return the control authority to the target function at an appropriate time, thereby achieving the acquisition of performance indicators without affecting the operation of the target function.

[0142] In this embodiment, hook technology is used to convert the call of the target function into a call to the indicator observation hook function. The indicator observation hook function achieves the acquisition of performance indicators without affecting the operation of the target function, and the flexibility and convenience of monitoring operations are improved by using a non-invasive method.

[0143] In some optional implementations of this embodiment, the execution subject may perform step 401 in the following manner:

[0144] First, in response to the target function being an exported function, the target function address of the target function in the procedure linkage table is determined; then, the target function address is updated to the function address of the indicator observation hook function; finally, in response to calling the target function, the indicator observation hook function is called according to the updated target function address.

[0145] In this implementation, the function code includes code for calling the target function and code for the indicator observation function for determining the performance indicator.

[0146] PLT is a function pointer table that stores the address of the function. The address of the function in the PLT table is modified to point to the indicator observation hook function. Therefore, when the application calls the target function, the calling process is intercepted by the indicator observation hook function, and the application calls the indicator observation hook function instead.

[0147] In this implementation, based on the update of the function address in the process link table, the indicator observation hook function intercepts and monitors the target function, which improves the stability and accuracy of the observation process for the target function of the exported function type.

[0148] In some optional implementations of this embodiment, the above-mentioned execution subject can execute the above-mentioned step 401 in the following manner: first, in response to the target function being an internal function, determine the jump instruction of the starting part of the target function in the memory; then, in response to calling the target function, call the indicator observation hook function according to the jump instruction.

[0149] The function code of the indicator observation hook function includes the code of the indicator observation function for determining the performance indicator and the code representing the return to the target function after the indicator observation function is executed.

[0150] Since the starting part of the target function is replaced by the jump instruction for the indicator observation hook function, when the target function is called and executed, the jump instruction of the starting part is executed first, jumping to the indicator observation hook function, and executing the indicator observation hook function.

[0151] It should be noted that the indicator observation hook function includes code that represents the return to the target function after the indicator observation function is executed. After the custom logic of the indicator observation hook function (for example, the indicator observation function) is completed, control needs to be returned to the original target function. This is usually achieved by calculating the address of the remaining part of the target function and executing a jump instruction.

[0152] In this implementation, based on the modification of some instructions of the target function, the indicator observation hook function intercepts and monitors the target function, which improves the stability and accuracy of the observation process of the target function of the internal function type.

[0153] In addition, the present application also provides a device for determining a performance indicator, the structure of which is as follows: Figure 5 shown.

[0154] A device for determining performance indicators, including: a generation module 501 is configured to generate indicator observation hook code based on function data of a target function, wherein the indicator observation hook is used to intercept the call operation to the target function, and instead call the indicator observation hook function to determine the performance indicator during the operation of the target function; a compilation module 502 is configured to compile the indicator observation hook code, generate and load an indicator observation dynamic library; a first determination module 503 is configured to determine the performance indicator based on the indicator observation hook function in the indicator observation dynamic library.

[0155] In some optional implementations of this embodiment, the generation module 501 is further configured to: determine the hook type of the indicator observation hook according to the function type of the target function; and generate the code of the indicator observation hook under the hook type according to the function data.

[0156] In some optional implementations of this embodiment, the generation module 501 is further configured to: in response to determining that the function type is an exported function, determine that the hook type is a procedure linkage table hook; generate an interception code based on the function data, wherein the interception code is used to characterize the interception of the target function using the indicator observation hook function; generate a function code of the indicator observation hook function based on the function data, wherein the function code includes a code for calling the target function and a code for the indicator observation function for determining the performance indicator; combine the interception code and the function code to obtain the code of the indicator observation hook.

[0157] In some optional implementations of this embodiment, the first determination module 503 is further configured to: determine the target function address of the target function in the process linkage table; update the target function address to the function address of the indicator observation hook function; in response to calling the target function, call the indicator observation hook function according to the updated target function address to determine the performance indicator.

[0158] In some optional implementations of this embodiment, the generation module 501 is further configured to: in response to determining that the function type is an internal function, determine that the hook type is an inline hook; and generate code for the indicator observation hook under the hook type based on the function data, including: generating a replacement code based on the function data, wherein the replacement code is used to represent the replacement of the starting part of the target function in the memory with a jump instruction for the indicator observation hook function; generating function code for the indicator observation hook function based on the function data, wherein the function code includes code for the indicator observation function for determining the performance indicator and code representing the return to the target function after the indicator observation function is executed; combining the replacement code and the function code to obtain the code for the indicator observation hook.

[0159] In some optional implementations of this embodiment, the first determination module 503 is further configured to: in response to calling the target function, call the indicator observation hook function according to the jump instruction to determine the performance indicator.

[0160] In some optional implementations of this embodiment, the above-mentioned device also includes: a configuration module (not shown in the figure) configured to: display a visual configuration page; and determine function data according to the received configuration instructions.

[0161] In some optional implementations of this embodiment, the target function is a function in a dynamic library; the above-mentioned device also includes: a loading module (not shown in the figure) configured to load the dynamic library.

[0162] In this embodiment, a non-intrusive performance indicator monitoring device is provided, which can monitor the target function only according to the function data of the target function provided by the user, thereby improving the flexibility and convenience of the monitoring operation.

[0163] In addition, the present application also provides a device for determining a performance indicator, the structure of which is as follows: Figure 6 shown.

[0164] A device for determining performance indicators, including: a calling module 601 is configured to use hook technology to intercept the calling operation of the target function and call the indicator observation hook function instead; a second determining module 602 is configured to determine the performance indicators during the operation of the target function through the indicator observation hook function.

[0165] In some optional implementations of this embodiment, the calling module 601 is further configured to: in response to the target function being an exported function, determine the target function address of the target function in the procedure linkage table; update the target function address to the function address of the indicator observation hook function; in response to calling the target function, call the indicator observation hook function according to the updated target function address.

[0166] In some optional implementations of this embodiment, the calling module 601 is further configured to: in response to the target function being an internal function, determine the jump instruction of the starting part of the target function in the memory; in response to calling the target function, call the indicator observation hook function according to the jump instruction.

[0167] In this embodiment, hook technology is used to convert the call of the target function into a call to the indicator observation hook function. The indicator observation hook function achieves the acquisition of performance indicators without affecting the operation of the target function, and the flexibility and convenience of monitoring operations are improved by using a non-invasive method.

[0168] Based on the same inventive concept, an electronic device is also provided in an embodiment of the present application, and the method corresponding to the electronic device may be the method for determining performance indicators in the aforementioned embodiment, and its principle of solving the problem is similar to that of the method. The electronic device provided in an embodiment of the present application includes: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the methods and / or technical solutions of the aforementioned multiple embodiments of the present application.

[0169] The electronic device may be a user device, or a device formed by integrating a user device and a network device through a network, or may be an application running on the above device. The user device includes but is not limited to various terminal devices such as computers, mobile phones, tablet computers, smart watches, and bracelets. The network device includes but is not limited to network hosts, single network servers, multiple network server sets, or cloud computing-based computer sets, which can be used to implement some processing functions when setting an alarm. Here, the cloud is composed of a large number of hosts or network servers based on cloud computing, where cloud computing is a type of distributed computing, a virtual computer composed of a group of loosely coupled computer sets.

[0170] Figure 7 The structure of a device suitable for implementing the method and / or technical solution in the embodiment of the present application is shown, and the device 700 includes a central processing unit (CPU, Central Processing Unit) 701, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM, Read Only Memory) 702 or the program loaded from the storage part 708 to the random access memory (RAM, Random Access Memory) 703. In RAM 703, various programs and data required for system operation are also stored. CPU 701, ROM 702 and RAM 703 are connected to each other through a bus 704. An input / output (I / O, Input / Output) interface 705 is also connected to the bus 704.

[0171] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, a touch screen, a microphone, an infrared sensor, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), an LED display, an OLED display, etc., and a speaker, etc.; a storage section 708 including one or more computer-readable media such as a hard disk, an optical disk, a magnetic disk, a semiconductor memory, etc.; and a communication section 709 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet.

[0172] In particular, the methods and / or embodiments in the embodiments of the present application may be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. When the computer program is executed by the central processing unit (CPU) 701, the above functions defined in the method of the present application are executed.

[0173] Another embodiment of the present application further provides a computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions can be executed by a processor to implement the methods and / or technical solutions of any one or more embodiments of the present application described above.

[0174] Specifically, the present embodiment may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device, or device.

[0175] Computer readable signal media may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer readable program code. Such propagated data signals may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than a computer readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0176] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0177] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0178] The flow chart or block diagram in the accompanying drawings shows the possible architecture, function and operation of the equipment, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated system for hardware that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0179] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0180] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or page components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0181] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0182] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0183] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0184] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

[0185] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in a device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

Claims

1. A method for determining a performance indicator, wherein: The method comprises: Generate the code of the indicator observation hook according to the function data of the target function, wherein the indicator observation hook is used to intercept the calling operation of the target function and call the indicator observation hook function instead to determine the performance indicator of the running process of the target function; Compile the code of the indicator observation hook, generate and load the indicator observation dynamic library; The performance indicator is determined based on the indicator observation hook function in the indicator observation dynamic library.

2. The method according to claim 1, wherein: The code for generating the indicator observation hook according to the function data of the target function includes: Determining the hook type of the indicator observation hook according to the function type of the objective function; According to the function data, the code of the indicator observation hook under the hook type is generated.

3. The method according to claim 2, wherein: The step of determining the hook type of the indicator observation hook according to the function type of the objective function includes: In response to determining that the function type is an exported function, determining that the hook type is a procedure linkage table hook; and The step of generating the code of the indicator observation hook under the hook type according to the function data includes: Generate an interception code according to the function data, wherein the interception code is used to represent the interception of the target function by using the indicator observation hook function; Generate a function code of the indicator observation hook function according to the function data, wherein the function code includes a code for calling the target function and a code for determining the indicator observation function of the performance indicator; The interception code and the function code are combined to obtain the code of the indicator observation hook.

4. The method according to claim 3, wherein: The determining the performance indicator based on the indicator observation hook function in the indicator observation dynamic library includes: Determine the target function address of the target function in the procedure linkage table; Update the target function address to the function address of the indicator observation hook function; In response to calling the target function, the indicator observation hook function is called according to the updated target function address to determine the performance indicator.

5. The method according to claim 2, wherein: Determining the hook type of the indicator function hook according to the function type of the target function includes: In response to determining that the function type is an internal function, determining that the hook type is an inline hook; and The step of generating the code of the indicator observation hook under the hook type according to the function data includes: Generate a replacement code according to the function data, wherein the replacement code is used to represent that the starting part of the target function in the memory is replaced with a jump instruction for the indicator observation hook function; Generate a function code of the indicator observation hook function according to the function data, wherein the function code includes a code for determining the indicator observation function of the performance indicator and a code representing that the indicator observation function returns to the target function after being executed; The replacement code and the function code are combined to obtain the code of the indicator observation hook.

6. The method according to claim 5, wherein: The determining the performance indicator based on the indicator observation hook function in the indicator observation dynamic library includes: In response to calling the target function, the indicator observation hook function is called according to the jump instruction to determine the performance indicator.

7. The method according to any one of claims 1 to 6, wherein: Before the code for generating the indicator observation hook according to the function data of the target function, it also includes: Display the visualization configuration page; The function data is determined according to the received configuration instruction.

8. The method according to any one of claims 1 to 6, wherein: The target function is a function in a dynamic library; as well as Before determining the performance indicator based on the indicator observation hook function in the indicator observation dynamic library, the method further includes: Load the dynamic library.

9. A method for determining a performance indicator, wherein: The method comprises: Adopt hook technology to intercept the call operation of the target function and call the indicator observation hook function instead; The performance index of the target function during its operation is determined by observing the index hook function.

10. The method according to claim 9, wherein: The interception of the call operation of the target function and the call of the indicator observation hook function instead include: In response to the target function being a derived function, determining a target function address of the target function in a procedure linkage table; Update the target function address to the function address of the indicator observation hook function; In response to calling the target function, the indicator observation hook function is called according to the updated target function address.

11. The method according to claim 9, wherein: The interception of the call operation of the target function and the call of the indicator observation hook function instead include: In response to the target function being an internal function, determining a jump instruction of a starting portion of the target function in the memory; In response to calling the target function, calling the pointer observation hook function according to the jump instruction.

12. A device for determining a performance indicator, wherein: The device comprises: A generation module is configured to generate a code of an indicator observation hook according to function data of the target function, wherein the indicator observation hook is used to intercept a call operation to the target function and call the indicator observation hook function instead to determine a performance indicator during the operation of the target function; A compiling module, configured to compile the code of the indicator observation hook, generate and load the indicator observation dynamic library; The first determination module is configured to determine the performance indicator based on the indicator observation hook function in the indicator observation dynamic library.

13. A device for determining a performance indicator, wherein: The device comprises: The calling module is configured to use hook technology to intercept the calling operation of the target function and call the indicator observation hook function instead; The second determination module is configured to determine the performance index during the operation of the target function through the index observation hook function.

14. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 11.

15. A computer readable medium having computer program instructions stored thereon, wherein the computer program instructions can be executed by a processor to implement the method according to any one of claims 1 to 11.

16. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.