Function call processing method and device, electronic equipment and storage medium

By storing function source information in the preset storage space, the problem of complex function call relationship in the so library in Android development is solved, and the analysis and optimization of function call status is realized.

CN119311337APending Publication Date: 2025-01-14BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310871330.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-14
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

In Android development, due to the large number of So libraries in electronic devices, it is difficult to optimize the call relationship between various So library functions, which makes it difficult to obtain or incompletely obtain the function call chain.

Method used

By storing the information from the function source in the preset storage space, writing and reading the information during function calls, analyzing the function call status and optimizing the function call status.

Benefits of technology

By reading information from the preset storage space, the source of the function caller and the purpose of the call is obtained, which facilitates the analysis and optimization of the function call situation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311337A_ABST
    Figure CN119311337A_ABST
Patent Text Reader

Abstract

The invention provides a function calling processing method and device, electronic equipment and a storage medium, the method is executed by the electronic equipment, and the method comprises the steps that when a first function calls a second function, first information of calling the second function by the first function is written into a first preset storage space according to the source of the first function, the first preset storage space stores second information, and the second information at least indicates a first function source; the first information and the second information are read from the first preset storage space, and the first information and the second information are used for analyzing the calling condition of the second function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of electronics, and in particular to a function call processing method, device, electronic device and storage medium. Background Art

[0002] In Android development, Java is usually used to encapsulate common code into a so library (dynamic name library) for other modules to call in order to increase the reuse rate.

[0003] However, since there are a large number of so libraries in electronic devices, it is difficult to optimize the functions in each so library without understanding the calling relationship between the functions in each so library. Summary of the invention

[0004] Embodiments of the present application provide a method, device, electronic device, and storage medium for processing a function call.

[0005] According to a first aspect of an embodiment of the present application, a method for processing a function call is provided, which is executed by an electronic device, and the method includes:

[0006] When a first function calls a second function, first information of the first function calling the second function is written into a first preset storage space according to the source of the first function, wherein the first preset storage space stores second information, wherein the second information at least indicates the source of the first function;

[0007] The first information and the second information are read from the first preset storage space, wherein the first information and the second information are used for analyzing the calling status of the second function.

[0008] Optionally, when the first function calls the second function, writing first information of the first function calling the second function into a first preset storage space according to a source of the first function includes:

[0009] When the first function calls the second function, a first preset storage space storing the second information is determined from a plurality of preset storage spaces according to a source of the first function; wherein different function sources correspond to different preset storage spaces;

[0010] The first information that the first function calls the second function is written into the first preset storage space.

[0011] Optionally, when the first function calls the second function, writing first information of the first function calling the second function into a first preset storage space according to a source of the first function, further includes:

[0012] When the first function calls the second function, the first function writes first information into a first register;

[0013] The preset function module reads the first information from the first register, and writes the first information into the first preset storage space.

[0014] Optionally, the method further comprises:

[0015] In response to there being no inserted function between the second function and the first function, the second function reads the first information and the second information from the first preset storage space, and stores the first information and the second information correspondingly in a second preset storage space.

[0016] Optionally, the method further comprises:

[0017] In response to the presence of the stub function between the second function and the first function, the stub function reads the first information and the second information from the first preset storage space, and transmits the first information and the second information to the second function.

[0018] Optionally, the method further comprises:

[0019] The instrumentation function stores the first information and the second information correspondingly in a second preset storage space.

[0020] Optionally, the method further comprises:

[0021] In response to the second function being a memory request function, the second function determines the source of the first information according to the second information, and configures corresponding memory space for the first function according to the first information; wherein the memory space is used for use by the first function.

[0022] Optionally, the method further comprises:

[0023] Based on the second information, reading the first information stored in the second function or the plugged function within a preset time period from the second preset storage space;

[0024] Based on the first information, memory request information of the first function within a preset duration is determined, and the memory request information is used for optimizing the execution configuration of the first function.

[0025] Optionally, the method further comprises:

[0026] In response to the electronic device including a plurality of function libraries, a preset storage space is configured for each of the function libraries, wherein the preset storage space corresponding to each of the function libraries stores second information for identifying the corresponding function library.

[0027] Optionally, the step of writing, according to the source of the first function, first information of the first function calling the second function into a first preset storage space further includes:

[0028] In response to the first function being a library function in the first function library, first information that the first function calls the second function is written into a first preset storage space corresponding to the first function library.

[0029] Optionally, the first preset storage space includes a plurality of sub-storage spaces, wherein different sub-storage spaces correspond to different called functions;

[0030] The step of writing the first information of the first function calling the second function into the first preset storage space also includes:

[0031] The first information of calling the second function by the first function is written into the first preset storage space, into the sub-storage space corresponding to the second function.

[0032] In a second aspect of an embodiment of the present application, a function call processing device is provided, the device comprising:

[0033] a writing module, configured to write first information of the first function calling the second function into a first preset storage space when the first function calls the second function, according to the source of the first function, wherein the first preset storage space stores second information, wherein the second information at least indicates the source of the first function;

[0034] The first reading module is used to read the first information and the second information from the first preset storage space, wherein the first information and the second information are used for analyzing the calling status of the second function.

[0035] Optionally, the writing module is used to:

[0036] When the first function calls the second function, a first preset storage space storing the second information is determined from a plurality of preset storage spaces according to a source of the first function; wherein different function sources correspond to different preset storage spaces;

[0037] The first information that the first function calls the second function is written into the first preset storage space.

[0038] Optionally, the writing module is further used for:

[0039] When the first function calls the second function, the first function writes first information into a first register;

[0040] The preset function module reads the first information from the first register, and writes the first information into the first preset storage space.

[0041] Optionally, the device further comprises:

[0042] The first storage module is used for, in response to there being no plug-in function between the second function and the first function, the second function reading the first information and the second information from the first preset storage space, and storing the first information and the second information correspondingly in a second preset storage space.

[0043] Optionally, the device further comprises:

[0044] A transfer module is used for responding to a stub function between the second function and the first function, wherein the stub function reads the first information and the second information from the first preset storage space and transfers the first information and the second information to the second function.

[0045] Optionally, the device further comprises:

[0046] The second storage module is used for the plug-in function to store the first information and the second information correspondingly in the second preset storage space.

[0047] Optionally, the device further comprises:

[0048] The first determination module is used to respond to the second function being a memory request function, the second function determining the source of the first information according to the second information, and configuring a corresponding memory space for the first function according to the first information; wherein the memory space is used for use by the first function.

[0049] Optionally, the device further comprises:

[0050] A second reading module, configured to read, based on the second information, the first information stored in the second function or the plugged function within a preset time period from the second preset storage space;

[0051] The second determination module is used to determine the memory request information of the first function within a preset time period based on the first information, and the memory request information is used to optimize the execution configuration of the first function.

[0052] Optionally, the device further comprises:

[0053] The configuration module is used for configuring a preset storage space for each function library in response to the electronic device including multiple function libraries, wherein the preset storage space corresponding to each function library stores second information for identifying the corresponding function library.

[0054] Optionally, the written module is also used to:

[0055] In response to the first function being a library function in the first function library, first information that the first function calls the second function is written into a first preset storage space corresponding to the first function library.

[0056] Optionally, the first preset storage space includes a plurality of sub-storage spaces, wherein different sub-storage spaces correspond to different called functions;

[0057] The writing module is also used for:

[0058] The first information of calling the second function by the first function is written into the first preset storage space, into the sub-storage space corresponding to the second function.

[0059] According to a third aspect of the present application, an electronic device is provided, including:

[0060] a memory for storing processor-executable instructions;

[0061] A processor connected to the memory;

[0062] Wherein, the processor is used to execute the function call processing method as described in any one of the above items.

[0063] In a fourth aspect of an embodiment of the present application, a non-temporary computer-readable storage medium is provided, which, when instructions in the storage medium are executed by a processor of a computer, enables the computer to execute any of the above-mentioned function call processing methods.

[0064] The technical solution provided by the embodiments of the present application may have the following beneficial effects:

[0065] In the embodiment of the present application, since the second information indicating the source of the first function is pre-stored in the first preset storage space, when the first function calls the second function, the first information will also be written in the first preset storage space. Therefore, based on the second information stored in the first preset storage space, the source of the second function caller can be obtained, and based on the first information stored in the first preset storage space, the purpose of the first function calling the second function can be determined. That is, by reading the first information and the second information from the first preset storage space, a relatively complete calling situation of the second function being called by the first function can be obtained, thereby facilitating the analysis of the first information and the second information, and optimizing the calling situation of the second function.

[0066] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0068] Figure 1 is a flow chart of an intra-device communication method;

[0069] Figure 2 is a flow chart of a function call according to an exemplary embodiment;

[0070] Figure 3 is a flowchart of a method for processing a function call according to another exemplary embodiment;

[0071] Figure 4 is a flowchart of a method for processing a function call according to another exemplary embodiment;

[0072] Figure 5 is a flowchart of a method for processing a function call according to another exemplary embodiment;

[0073] Figure 6 is a flowchart of a method for processing a function call according to another exemplary embodiment;

[0074] Figure 7 is a flowchart of a method for processing a function call according to another exemplary embodiment;

[0075] Figure 8 is a structural schematic diagram of a function call processing device according to another exemplary embodiment;

[0076] Fig. 9The diagram is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0077] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the appended claims.

[0078] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the embodiments of the present application. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0079] It should be understood that, although the terms first, second, third, etc. may be used to describe various information in the embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the embodiments of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at..." or "when..." or "in response to determination".

[0080] Before explaining the embodiments of the present application in detail, the application scenarios involved in the embodiments of the present application are first explained.

[0081] refer to Figure 1 , since there are multiple function libraries in the electronic device, and there are multiple functions in each function library, functions in different function libraries can call each other to achieve function reuse. Based on this, function A ( Figure 1 funcA) in the second function library (so2) calls function B ( Figure 1 When calling funcB in function A, if function B has a hook function, function A will first call the hook function of function B ( Figure 1 HookB in the function, and then the hook function calls the B function. If there is no Hook function in function B, when function A calls function B, it can directly call function B.

[0082] However, during the entire calling process of function B, it is difficult to obtain the calling chain of function A calling function B, or to obtain it completely.

[0083] For example, refer to Figure 2 In an electronic device, a function library related to camera operation may include camera1.so, camera2.so to cameraN.so, wherein the functions in camera1.so, camera2.so to cameraN.so can all call function B in libc.so ( Figure 2 It is difficult to obtain the information about which function libraries in camera1.so, camera2.so to cameraN.so called funcB and the number of times each function library called funcB in a period of time.

[0084] In order to solve the above problems, in the embodiment of the present application, a method for processing a function call is provided, referring to Figure 3 , Figure 3 It is a flowchart of a function call processing method, such as Figure 3 As shown, the function call processing method of the embodiment of the present application is executed by an electronic device, and the method includes:

[0085] S301: when a first function calls a second function, write first information of the first function calling the second function into a first preset storage space according to the source of the first function, wherein the first preset storage space stores second information, wherein the second information at least indicates the source of the first function;

[0086] S302: Read the first information and the second information from the first preset storage space, wherein the first information and the second information are used for analyzing the calling status of the second function.

[0087] It should be noted that the functions mentioned in the embodiments of the present application may be functional modules for implementing different functions in an electronic device. For example, the first function in the embodiments of the present application may be a functional module for implementing a first function in an electronic device, and the second function in the embodiments of the present application may be a functional module for implementing a second function in an electronic device.

[0088] The above-mentioned electronic devices are electronic devices using the Android system, such as smart phones, tablet computers, smart watches, learning machines, smart refrigerators and other devices.

[0089] The first function mentioned above may be any function in the electronic device.

[0090] Different functions in an electronic device may have different sources. For example, different functions may come from different function libraries.

[0091] In an embodiment of the present application, for possible sources of the first function, multiple preset storage spaces are pre-applied in the electronic device, wherein each preset storage space corresponds to a source of the first function, and a source identifier, i.e., the second information, is stored in each preset storage space.

[0092] Based on this, when the first function calls the second function, the first information of the first function calling the second function can be written into a preset storage space that can indicate the source of the first function based on the source of the first function.

[0093] Exemplarily, when the first function is a library function, in the electronic device, a preset storage space may be pre-configured for each of the N function libraries in the electronic device, and identification information of the corresponding function library is stored in each preset storage space. In some embodiments, the second information may include but is not limited to identification information of the function library. Wherein N is an integer greater than 1.

[0094] For example, the identification information of the first function library is stored in the preset storage space configured for the first function library, the identification information of the second function library is stored in the preset storage space configured for the second function library, and so on, the identification information of the Nth function library is stored in the preset storage space configured for the Nth function library.

[0095] Exemplarily, the function library may be a dynamic library.

[0096] Based on this, if the first function comes from the first function library, the first information generated when the first function calls the second function is stored in the preset storage space configured for the first function library. If the first function comes from the second function library, the first information generated when the first function calls the second function is stored in the preset storage space configured for the second function library, and so on. If the first function comes from the Nth function library, the first information generated when the first function calls the second function is stored in the preset storage space configured for the Nth function library.

[0097] For example, if the electronic device stores function libraries such as camera1.so, camera2.so to cameraN.so, N storage spaces can be applied for in advance in the electronic device, and the identification information of camera1.so can be stored in the first preset storage space, and the identification information of camera2.so can be stored in the second storage space, and so on, and the relevant information of cameraN.so can be stored in the Nth storage space.

[0098] Based on this, when the first function calls the second function, the source of the first function can be determined first. If the first function comes from the function library camera1.so, the first information of the first function calling the second function is stored in the first preset storage space with the camera1.so identifier. If the first function comes from the function library camera2.so, the call information of the first function calling the second function is stored in the second preset storage space with the camera.so identifier. And so on. If the first function comes from the function library cameraN.so, the first information is stored in the preset storage space with cameraN.so.

[0099] Among them, the identification information of the function library can be the library name of the function library, or it can be other identification information that can uniquely identify the corresponding function library, and the embodiment of the present application is not limited to this.

[0100] The first information when the first function calls the second function may be parameter information generated by the first function when the first function calls the second function.

[0101] For example, when the second function is a memory allocation function, the first information generated when the first function calls the second function includes at least information such as the memory allocation amount and memory type required by the first function.

[0102] When the second function is a memory release function, the first information generated when the first function calls the second function includes at least the released amount of memory and the released memory address.

[0103] In the embodiment of the present application, since the second information indicating the source of the first function is pre-stored in the first preset storage space, when the first function calls the second function, the first information will also be written in the first preset storage space. Therefore, based on the second information stored in the first preset storage space, the source of the second function caller can be obtained, and based on the first information stored in the first preset storage space, the purpose of the first function calling the second function can be determined. That is, by reading the first information and the second information from the first preset storage space, the calling situation of the second function being called by the first function can be obtained, which makes it convenient for developers to parse the calling situation of the second function.

[0104] In one embodiment, when the first function calls the second function, writing first information of the first function calling the second function into the first preset storage space according to the source of the first function includes:

[0105] When the first function calls the second function, a first preset storage space storing the second information is determined from a plurality of preset storage spaces according to a source of the first function; wherein different function sources correspond to different preset storage spaces;

[0106] The first information that the first function calls the second function is written into the first preset storage space.

[0107] Exemplarily, if it is determined that the first function that calls the second function may have N sources, N preset storage spaces may be pre-applied in the electronic device, and second information indicating the source of the first function may be stored in each storage space.

[0108] Based on this, when the first function calls the second function, if the first function comes from the nth source, based on the second information stored in the N preset storage spaces, a preset storage space configured for the nth source is determined from the N preset storage spaces. For the convenience of explanation, it is referred to as the first preset storage space, and the first information of the first function calling the second function is written into the first preset storage space, where n is an integer greater than 1 and less than or equal to N.

[0109] For example, when the first function is a library function, if the source of the first function may be one of the N function libraries in the electronic device, N preset storage spaces may be applied for in advance in the electronic device, and identification information of a function library may be stored in each preset storage space. Based on this, when the first function calls the second function, if the first function comes from the nth function library, based on the second information stored in the N preset storage spaces, the preset storage space configured for the nth function library is determined from the N preset storage spaces, and the first information of the first function calling the second function is written into the preset storage space configured for the nth function.

[0110] In one embodiment, when the first function calls the second function, writing first information of the first function calling the second function into the first preset storage space according to the source of the first function, further includes:

[0111] When the first function calls the second function, the first function writes first information into a first register;

[0112] The preset function module reads the first information from the first register, and writes the first information into the first preset storage space.

[0113] For example, reference Figure 4 and Figure 5 In the electronic device of an embodiment of the present application, when a first function calls a second function, there is also a preset function module. After the first function writes the first information that the first function calls the second function into the first register, the preset function module reads the first information from the first register and writes the first information into the first preset storage space.

[0114] The preset function module may include but is not limited to Figure 4The code block shown.

[0115] For example, reference Figure 4 and Figure 5 After the first function writes the first information that the first function calls the second function into the first register, the preset function module can also read the second information from the first preset storage space and write the second information into the first register, so that the second function or the hook function of the second function can read the first information and the second information from the first register.

[0116] Exemplarily, after the first function writes the first information that the first function calls the second function into the first register, the preset function module can also read the second information from the first preset storage space and write the second information into the second register, so that the second function or the hook function of the second function can read the first information from the first register and read the second information from the second register.

[0117] Exemplarily, the second register may be, but is not limited to, an X16 or X17 register.

[0118] In one embodiment, the method further comprises:

[0119] In response to there being no inserted function between the second function and the first function, the second function reads the first information and the second information from the first preset storage space, and stores the first information and the second information correspondingly in a second preset storage space.

[0120] In the embodiment of the present application, in some cases, there may be an insert function between the first function and the second function, or there may not be an insert function. If there is no insert function between the first function and the second function, the first function can directly call the second function.

[0121] Based on this, after the preset function module writes the first information read from the first register into the first preset storage space, the second function reads the first information and the second information from the first preset storage space and stores the first information and the second information into the second preset storage space accordingly.

[0122] In another embodiment, if after the first function writes the first information into the first register, the preset function module does not read the first information from the first register, but reads the second information from the first preset storage space and writes the second information into the first register, then the second function can read the first information and the second information from the first register, and store the first information and the second information correspondingly in the second preset storage space.

[0123] If the preset function module writes the second information into the second register, the stub function reads the first information from the first register and reads the second information from the second register.

[0124] It should be noted that the above-mentioned stub function may also be a Hook function of the second function.

[0125] In the embodiment of the present application, each time the first function or other functions in the function library where the first function is located calls the second function, the first information and the second information are stored in the second preset storage space accordingly. Based on this, the number of times the second function is called by the first function within the preset time length and the purpose of each call to the second function can be known through the first information and the second information stored in the second preset storage space. Based on the first information and the second information obtained from the second preset storage space, the call situation of the first function calling the second function can be easily analyzed.

[0126] In one embodiment, the method further comprises:

[0127] In response to an inserted function being provided between the second function and the first function, the inserted function reads the first information and the second information from the first preset storage space, and transmits the first information and the second information to the second function.

[0128] Exemplarily, after the preset function module reads the first information from the first register and writes the first information into the first preset storage space, in response to the presence of a stub function between the first function and the second function, the stub function reads the first information and the second information from the first preset storage space and passes the first information and the second information to the second function.

[0129] The method in which the stub function transmits the first information and the second information to the second function includes:

[0130] The stub function writes the first information and the second information into the third register, and the second function reads the first information and the second information from the third register.

[0131] It should be noted that the stub function may also transmit the first information and the second information to the second function in other ways, which is not limited in this embodiment of the present application.

[0132] In another embodiment, if the preset function module reads the second information from the first preset storage space and writes the second information into the first register, the stub function reads the first information and the second information from the first register and passes the read first information and the second information to the second function.

[0133] In one embodiment, the method further comprises:

[0134] The plug-in function stores the first information and the second information correspondingly in the second preset storage space.

[0135] Exemplarily, each time the stub function reads the first information and the second information from the first preset storage space or the first register, the first information and the second information are stored in the second storage space accordingly. Based on this, the calling situation of the first function to the second function can be determined from the first information and the second information stored in the second preset storage space, so as to facilitate the analysis of the calling situation of the second function by the first function.

[0136] In one embodiment, the method further comprises:

[0137] In response to the second function being a memory request function, the second function determines the source of the first information according to the second information, and configures corresponding memory space for the first function according to the first information; wherein the memory space is used for use by the first function.

[0138] From the above introduction, it can be known that the second function can be a function used to implement a certain function in an electronic device. When the second function is a memory application function used to implement the memory application function in an electronic device, the first function will call the second function every time it needs to apply for memory. Based on this, after the second function obtains the first information and the second information from the plug-in function or the first preset storage space, the source of the first function can be determined according to the second information, and the memory application information such as the memory application amount and memory type required by the first function can be determined according to the first information, and the corresponding memory space is configured for the first function based on the memory application information indicated by the first information for use by the first function.

[0139] In one embodiment, the method further comprises:

[0140] Based on the second information, reading the first information stored in the second function or the plugged function within a preset time period from the second preset storage space;

[0141] Based on the first information, memory request information of the first function within a preset duration is determined, and the memory request information is used for optimizing the execution configuration of the first function.

[0142] For example, considering that in an electronic device, each function in each function library will call the second function when it needs to apply for memory, based on this, the second preset storage space stores relevant information generated when functions from different sources call the second function and the source information of the caller. Therefore, if it is necessary to obtain memory application information when the first function calls the second function to apply for memory, it is necessary to first determine the first information corresponding to the second information stored in the second preset storage space based on the second information, and then determine the memory application information when the first function calls the second function to apply for memory within a preset time period based on the first information corresponding to the second information.

[0143] After obtaining the memory request information, the memory request amount each time the first function calls the second function and the total memory request amount within a preset time length can be determined based on the memory request information. When the total memory request amount when the first function calls the second function within the preset time length is greater than a preset threshold, it is determined that the execution configuration of the first function needs to be optimized.

[0144] If the first function is a library function, the total amount of memory requested by all functions in the function library where the first function is located within a preset time length can be determined based on the first information and the second information correspondingly stored in the second preset storage space. When it is determined that the total amount of memory requested by all functions in the function library where the first function is located within the preset time length is greater than a preset threshold, it is determined that the function library where the first function is located needs to be configured for optimization.

[0145] Among them, the preset threshold can be set as needed, and the embodiments of the present application are not limited to this.

[0146] In one embodiment, when it is determined that the first function or the function library where the first function is located needs to be optimized in configuration, first prompt information may also be sent, where the first prompt information is used to prompt that the first function or the function library where the first function is located needs to be optimized.

[0147] In one embodiment, the method further comprises:

[0148] In response to the electronic device including a plurality of function libraries, a preset storage space is configured for each of the function libraries, wherein the preset storage space corresponding to each of the function libraries stores second information for identifying the corresponding function library.

[0149] Exemplarily, if there are N function libraries in the electronic device, a preset storage space is pre-configured for each of the N function libraries in the electronic device, and identification information of the corresponding function library, that is, the second information, is stored in each preset storage space.

[0150] For example, the identification information of the first function library is stored in the preset storage space configured for the first function library, the identification information of the second function library is stored in the preset storage space configured for the second function library, and so on, the identification information of the Nth function library is stored in the preset storage space configured for the Nth function library.

[0151] For example, reference Figure 6 In the electronic device, there are function libraries camera1.so, camera2.so to cameraN.so related to the camera. Then, N preset storage spaces can be applied for in advance in the electronic device, and the identification information of camera1.so is stored in the first preset storage space, and the identification information of camera2.so is stored in the second storage space. And so on, the relevant information of cameraN.so is stored in the Nth storage space.

[0152] In one embodiment, the step of writing, according to the source of the first function, first information of the first function calling the second function into the first preset storage space further includes:

[0153] In response to the first function being a library function in the first function library, first information that the first function calls the second function is written into a first preset storage space corresponding to the first function library.

[0154] When the first function is a library function in a first function library, a preset storage space with identification information of the first function library is searched from multiple preset storage spaces. If it is determined that the preset storage space with identification information of the first function library is the first preset storage space among the multiple preset storage spaces, the first information of the first function calling the second function is written into the first preset storage space.

[0155] In one embodiment, the first preset storage space includes a plurality of sub-storage spaces, wherein different sub-storage spaces correspond to different called functions;

[0156] The step of writing the first information of the first function calling the second function into the first preset storage space also includes:

[0157] The first information of calling the second function by the first function is written into the first preset storage space, into the sub-storage space corresponding to the second function.

[0158] In the embodiment of the present application, considering that the first function not only calls the second function, but may also call other functions such as the third function, the fourth function and the fifth function to implement other functions, the first preset storage space configured for the first function library can also be divided into multiple sub-storage spaces, and different sub-storage spaces correspond to different called functions.

[0159] Based on this, when the first function calls the second function, the first information that the first function calls the second function can be written into the sub-storage space corresponding to the second function.

[0160] For example, reference Figure 7 , the first function in camera1.so can call function B ( Figure 7 funcB) in, calling the C function ( Figure 7 funcC in , you can also call D functions ( Figure 7 In the first preset storage space, there is a first sub-storage space corresponding to the B function, a second sub-storage space corresponding to the C function, and a third sub-storage space corresponding to the C function.

[0161] Based on this, when the first function calls function B, the first information generated when the first function calls function B is stored in the first sub-storage space corresponding to function B; when the first function calls function C, the third information generated when the first function calls function C is stored in the sub-storage space corresponding to function C; and the fourth information generated when the first function calls function D is stored in the sub-storage space corresponding to function D.

[0162] The present application also provides a method for processing a function call, including:

[0163] Hook technology is also called hook technology in Chinese. It is to rewrite a method in the program during its operation, and add our own custom code before and after the original method. It is equivalent to the hook program capturing the message before the system calls the function, and can get the control first. At this time, the hook function can process (change) the execution behavior of the function.

[0164] refer to Figure 1 By hooking, the execution flow of funcA is changed so that the original calling relationship (funcA calls funcB) becomes (funcA→HookB→funcB). This is the case for most hook processes.

[0165] Since the parameters of HookB come from funcB, the number and type of parameters of HookB and funcB are the same, but the following design can achieve an effect of expanding parameters for HookB:

[0166] Modify the assembly code of funcA "Call funcB" to "store additional parameters to the uncommon second register X16X17", and get the additional parameters from the second register when calling HookB. The calling relationship becomes (funcA→store additional parameters→HookB→funcB).

[0167] The runtime statistics of each so's calls to funcB include:

[0168] When the framework is initialized, a memory space is allocated for each so to store relevant information;

[0169] When entering the hook code, get the relevant parameter information of so from X16;

[0170] Use this information to do some data analysis at runtime.

[0171] refer to Figure 8 The embodiment of the present application further provides a function call processing device, the device comprising:

[0172] The writing module 801 is used for writing first information of the first function calling the second function into a first preset storage space according to the source of the first function when the first function calls the second function, wherein the first preset storage space stores second information, wherein the second information at least indicates the source of the first function;

[0173] The first reading module 802 is used to read the first information and the second information from the first preset storage space, wherein the first information and the second information are used for analyzing the calling status of the second function.

[0174] Optionally, the writing module 801 is used to:

[0175] When the first function calls the second function, a first preset storage space storing the second information is determined from a plurality of preset storage spaces according to a source of the first function; wherein different function sources correspond to different preset storage spaces;

[0176] The first information that the first function calls the second function is written into the first preset storage space.

[0177] Optionally, the writing module 801 is further used for:

[0178] When the first function calls the second function, the first function writes first information into a first register;

[0179] The preset function module reads the first information from the first register, and writes the first information into the first preset storage space.

[0180] Optionally, the device further comprises:

[0181] The first storage module is used for, in response to there being no plug-in function between the second function and the first function, the second function reading the first information and the second information from the first preset storage space, and storing the first information and the second information correspondingly in a second preset storage space.

[0182] Optionally, the device further comprises:

[0183] A transfer module is used for responding to a stub function between the second function and the first function, wherein the stub function reads the first information and the second information from the first preset storage space and transfers the first information and the second information to the second function.

[0184] Optionally, the device further comprises:

[0185] The second storage module is used for the plug-in function to store the first information and the second information correspondingly in the second preset storage space.

[0186] Optionally, the device further comprises:

[0187] The first determination module is used to respond to the second function being a memory request function, the second function determining the source of the first information according to the second information, and configuring a corresponding memory space for the first function according to the first information; wherein the memory space is used for use by the first function.

[0188] Optionally, the device further comprises:

[0189] A second reading module, configured to read, based on the second information, the first information stored in the second function or the plugged function within a preset time period from the second preset storage space;

[0190] The second determination module is used to determine the memory request information of the first function within a preset time period based on the first information, and the memory request information is used to optimize the execution configuration of the first function.

[0191] Optionally, the device further comprises:

[0192] The configuration module is used for configuring a preset storage space for each function library in response to the electronic device including multiple function libraries, wherein the preset storage space corresponding to each function library stores second information for identifying the corresponding function library.

[0193] Optionally, the written module 801 is also used for:

[0194] In response to the first function being a library function in the first function library, first information that the first function calls the second function is written into a first preset storage space corresponding to the first function library.

[0195] Optionally, the first preset storage space includes a plurality of sub-storage spaces, wherein different sub-storage spaces correspond to different called functions;

[0196] The writing module 801 is also used for:

[0197] The first information of calling the second function by the first function is written into the first preset storage space, into the sub-storage space corresponding to the second function.

[0198] refer to Fig. 9 In an embodiment of the present application, an electronic device 900 is provided, the electronic device comprising:

[0199] Memory 904 for storing processor executable instructions;

[0200] A processor 920 connected to the memory 904;

[0201] Among them, the processor 920 is configured to execute the function call processing method provided by any of the aforementioned technical solutions.

[0202] A block diagram of an electronic device 900 is shown according to an exemplary embodiment. For example, the electronic device 900 may be a mobile phone, a tablet computer, a notebook computer, a portable learning machine, etc.

[0203] refer to Fig. 9 , the electronic device 900 may include one or more of the following components: a processing component 902 , a memory 904 , a power component 906 , a multimedia component 908 , an audio component 910 , an input / output (I / O) interface 912 , a sensor component 914 , and a communication component 918 .

[0204] The processing component 902 generally controls the overall operation of the electronic device 900, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 902 may include one or more processors 920 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 902 may include one or more modules to facilitate the interaction between the processing component 902 and other components. For example, the processing component 902 may include a multimedia module to facilitate the interaction between the multimedia component 908 and the processing component 902.

[0205] The memory 904 is configured to store various types of data to support operations on the electronic device 900. Examples of such data include instructions for any application or method operating on the electronic device 900, contact data, phone book data, messages, pictures, videos, etc. The memory 904 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0206] The power supply component 906 provides power to the various components of the electronic device 900. The power supply component 906 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 900.

[0207] The multimedia component 908 includes a screen that provides an output interface between the electronic device 900 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 908 includes a front camera and / or a rear camera. When the electronic device 900 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0208] The audio component 910 is configured to output and / or input audio signals. For example, the audio component 910 includes a microphone (MIC), and when the electronic device 900 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 904 or sent via the communication component 918. In some embodiments, the audio component 910 also includes a speaker for outputting audio signals.

[0209] I / O interface 912 provides an interface between processing component 902 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0210] The sensor assembly 914 includes one or more sensors for providing various aspects of status assessment for the electronic device 900. For example, the sensor assembly 914 can detect the open / closed state of the electronic device 900, the relative positioning of the components, such as the display and keypad of the electronic device 900, and the sensor assembly 914 can also detect the position change of the electronic device 900 or a component of the electronic device 900, the presence or absence of contact between the user and the electronic device 900, the orientation or acceleration / deceleration of the electronic device 900, and the temperature change of the electronic device 900. The sensor assembly 914 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 914 may also include an optical sensor, such as a CMOS or CCD biometric information sensor, for use in imaging applications. In some embodiments, the sensor assembly 914 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0211] The communication component 918 is configured to facilitate wired or wireless communication between the electronic device 900 and other devices. The electronic device 900 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 918 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 918 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0212] In an exemplary embodiment, the electronic device 900 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0213] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 904 including instructions, and the instructions can be executed by a processor 920 of an electronic device 900 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0214] An embodiment of the present application provides a non-temporary computer-readable storage medium. When the instructions in the storage medium are executed by a processor of a computer, the computer can execute the function call processing method described in one or more of the aforementioned technical solutions.

[0215] When the processor executes the instruction, it can at least perform the following steps:

[0216] When a first function calls a second function, first information of the first function calling the second function is written into a first preset storage space according to the source of the first function, wherein the first preset storage space stores second information, wherein the second information at least indicates the source of the first function;

[0217] The first information and the second information are read from the first preset storage space, wherein the first information and the second information are used for analyzing the calling status of the second function.

[0218] Optionally, when the first function calls the second function, writing first information of the first function calling the second function into a first preset storage space according to a source of the first function includes:

[0219] When the first function calls the second function, a first preset storage space storing the second information is determined from a plurality of preset storage spaces according to a source of the first function; wherein different function sources correspond to different preset storage spaces;

[0220] The first information that the first function calls the second function is written into the first preset storage space.

[0221] Optionally, when the first function calls the second function, writing first information of the first function calling the second function into a first preset storage space according to a source of the first function, further includes:

[0222] When the first function calls the second function, the first function writes first information into a first register;

[0223] The preset function module reads the first information from the first register, and writes the first information into the first preset storage space.

[0224] Optionally, the method further comprises:

[0225] In response to there being no inserted function between the second function and the first function, the second function reads the first information and the second information from the first preset storage space, and stores the first information and the second information correspondingly in a second preset storage space.

[0226] Optionally, the method further comprises:

[0227] In response to the presence of the stub function between the second function and the first function, the stub function reads the first information and the second information from the first preset storage space, and transmits the first information and the second information to the second function.

[0228] Optionally, the method further comprises:

[0229] The instrumentation function stores the first information and the second information correspondingly in a second preset storage space.

[0230] Optionally, the method further comprises:

[0231] In response to the second function being a memory request function, the second function determines the source of the first information according to the second information, and configures corresponding memory space for the first function according to the first information; wherein the memory space is used for use by the first function.

[0232] Optionally, the method further comprises:

[0233] Based on the second information, reading the first information stored in the second function or the plugged function within a preset time period from the second preset storage space;

[0234] Based on the first information, memory request information of the first function within a preset duration is determined, and the memory request information is used for optimizing the execution configuration of the first function.

[0235] Optionally, the method further comprises:

[0236] In response to the electronic device including a plurality of function libraries, a preset storage space is configured for each of the function libraries, wherein the preset storage space corresponding to each of the function libraries stores second information for identifying the corresponding function library.

[0237] Optionally, the step of writing, according to the source of the first function, first information of the first function calling the second function into a first preset storage space further includes:

[0238] In response to the first function being a library function in the first function library, first information that the first function calls the second function is written into a first preset storage space corresponding to the first function library.

[0239] Optionally, the first preset storage space includes a plurality of sub-storage spaces, wherein different sub-storage spaces correspond to different called functions;

[0240] The step of writing the first information of the first function calling the second function into the first preset storage space also includes:

[0241] The first information of calling the second function by the first function is written into the first preset storage space, into the sub-storage space corresponding to the second function.

[0242] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the claims.

[0243] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A method for processing a function call, characterized in that: Executed by an electronic device, the method includes: When a first function calls a second function, first information of the first function calling the second function is written into a first preset storage space according to the source of the first function, wherein the first preset storage space stores second information, wherein the second information at least indicates the source of the first function; The first information and the second information are read from the first preset storage space, wherein the first information and the second information are used for analyzing the calling status of the second function.

2. The method according to claim 1, characterized in that When the first function calls the second function, writing first information of the first function calling the second function into the first preset storage space according to the source of the first function includes: When the first function calls the second function, a first preset storage space storing the second information is determined from a plurality of preset storage spaces according to a source of the first function; wherein different function sources correspond to different preset storage spaces; The first information that the first function calls the second function is written into the first preset storage space.

3. The method according to claim 1, characterized in that When the first function calls the second function, first information of the first function calling the second function is written into the first preset storage space according to the source of the first function, and further includes: When the first function calls the second function, the first function writes first information into a first register; The preset function module reads the first information from the first register, and writes the first information into the first preset storage space.

4. The method according to claim 1, characterized in that The method further comprises: In response to there being no inserted function between the second function and the first function, the second function reads the first information and the second information from the first preset storage space, and stores the first information and the second information correspondingly in a second preset storage space.

5. The method according to claim 4, characterized in that The method further comprises: In response to the presence of the stub function between the second function and the first function, the stub function reads the first information and the second information from the first preset storage space, and transmits the first information and the second information to the second function.

6. The method according to claim 5, characterized in that The method further comprises: The instrumentation function stores the first information and the second information correspondingly in a second preset storage space.

7. The method according to any one of claims 4 to 6, characterized in that: The method further comprises: In response to the second function being a memory request function, the second function determines the source of the first information according to the second information, and configures corresponding memory space for the first function according to the first information; wherein the memory space is used for use by the first function.

8. The method according to claim 7, characterized in that The method further comprises: Based on the second information, reading the first information stored in the second function or the plugged function within a preset time period from the second preset storage space; Based on the first information, memory request information of the first function within a preset duration is determined, and the memory request information is used for optimizing the execution configuration of the first function.

9. The method according to claim 1, characterized in that: The method further comprises: In response to the electronic device including a plurality of function libraries, a preset storage space is configured for each of the function libraries, wherein the preset storage space corresponding to each of the function libraries stores second information for identifying the corresponding function library.

10. The method according to claim 9, characterized in that The step of writing first information of calling a second function by the first function into a first preset storage space according to a source of the first function further includes: In response to the first function being a library function in the first function library, first information that the first function calls the second function is written into a first preset storage space corresponding to the first function library.

11. The method according to claim 1, characterized in that: The first preset storage space includes a plurality of sub-storage spaces, wherein different sub-storage spaces correspond to different called functions; The step of writing the first information of the first function calling the second function into the first preset storage space also includes: The first information of the first function calling the second function is written into the first preset storage space, into the sub-storage space corresponding to the second function.

12. A function call processing device, characterized in that: The device comprises: a writing module, configured to write first information of the first function calling the second function into a first preset storage space when the first function calls the second function, according to the source of the first function, wherein the first preset storage space stores second information, wherein the second information at least indicates the source of the first function; The first reading module is used to read the first information and the second information from the first preset storage space, wherein the first information and the second information are used for analyzing the calling status of the second function.

13. An electronic device, characterized in that: include: a memory for storing processor-executable instructions; A processor connected to the memory; The processor is used to execute the function call processing method as described in any one of claims 1 to 11.

14. A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a computer, enables the computer to execute the function call processing method according to any one of claims 1 to 11.