Function call information analysis method and device and storage medium
By obtaining configuration information and performing hook operations, the problem that existing tools cannot meet customizability and global analysis is solved, and function call information analysis in large-scale and high-complexity programs is realized, with low intrusion and universality , able to analyze logic problems and performance bottlenecks.
Patent Information
- Application Number
- CN202411210311.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-17
AI Technical Summary
Existing function call information analysis tools cannot meet both customizability and globality, and it is difficult to analyze logical problems and performance bottlenecks in large-scale and high-complex programs.
By obtaining configuration information, specifying the objective function and performing hook operations, collecting rich function call information, and performing global analysis at the end of the target program's run, all breakpoints are analyzed.
It realizes customizable and global function call information analysis in large-scale and high-complex programs, with low intrusion and universality, and can analyze program logic problems and performance bottlenecks.
Smart Images

Figure CN119149089A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer software technology, and in particular to a function call information analysis method, device and storage medium. Background Art
[0002] Function call information analysis is an important method for analyzing programs and improving program execution efficiency. The current method for obtaining function call information is usually to use tools such as GDB and Valgrind, or to add log information to the source program code. GDB can only view stack information through manual debugging commands, and cannot perform global analysis for all breakpoints; Valgrind cannot specify functions and the collected function call information is not rich enough; and the log method requires adding a large amount of additional log code to the source program code, which is not only not universal but also difficult to analyze. It can be seen that although there are some tools that assist in function call information analysis, they can only meet some needs and have various shortcomings. They cannot meet both customizability and globality at the same time. Once the program reaches a certain scale and complexity, these auxiliary analysis tools are difficult to analyze the logic problems and performance bottlenecks of the program code. Summary of the invention
[0003] In view of this, the present disclosure proposes a function call information analysis method, device and storage medium.
[0004] According to one aspect of the present disclosure, a method for analyzing function call information is provided. The method comprises:
[0005] Acquire configuration information, where the configuration information is used to indicate one or more first target functions for which function call information is to be acquired;
[0006] Running the target program according to the configuration information, and obtaining function call information of the first target function in response to calling the first target function during the running of the target program;
[0007] In response to the target program running being finished, the function call information of the second target function is analyzed to obtain the function call information analysis result, and the second target function is part or all of one or more first target functions.
[0008] In a possible implementation, running the target program according to the configuration information, and obtaining function call information of the first target function in response to calling the first target function during the running of the target program, includes:
[0009] The target program is run according to the configuration information, and in the process of running the target program, in response to calling the first target function, a hook operation corresponding to the first target function is executed to obtain function call information of the first target function.
[0010] In a possible implementation, the target program is run according to the configuration information, and in response to calling the first target function during the running of the target program, a hook operation corresponding to the first target function is executed to obtain function call information of the first target function, including:
[0011] In response to calling the first target function in the target process for running the target program, a custom function associated with the first target function in the custom function library is run to obtain function call information of the first target function.
[0012] In a possible implementation, the target process is started in the child process through a preset preloaded environment variable, and the child process is created in the main process through a system call.
[0013] In a possible implementation, the configuration information is further used to indicate the type of function call information to be obtained, and the target program is run according to the configuration information, and in response to calling the first target function during the running of the target program, the function call information of the first target function is obtained, including:
[0014] The target program is run according to the configuration information, and in response to calling the first target function during the running of the target program, function call information of the first target function corresponding to the type of function call information to be obtained is obtained.
[0015] In a possible implementation, the type of function call information to be obtained includes one or more of the following: process ID, thread ID, function call stack information, and function execution time.
[0016] In a possible implementation, the configuration information is further used to indicate the second target function and an analysis method for function call information of the second target function. In response to the end of the target program running, the function call information of the second target function is analyzed to obtain a function call information analysis result, including:
[0017] In response to the target program running being finished, the function call information of the second target function is analyzed based on the analysis method for the function call information to obtain a function call information analysis result.
[0018] In a possible implementation, the method further includes:
[0019] In the process of running the custom function associated with the first target function in the custom function library, obtaining a pointer to the first target function to call the first target function;
[0020] Writing the obtained function call information of the first target function into the storage system via a file in a custom format;
[0021] In response to the target program running being finished, the function call information of the second target function is analyzed to obtain the function call information analysis result, including:
[0022] In response to the target program running being finished, a file in a custom format including function call information of the second target function is obtained from the storage system for analysis to obtain a function call information analysis result.
[0023] According to another aspect of the present disclosure, a function call information analysis device is provided. The device comprises:
[0024] A first acquisition module, used for acquiring configuration information, where the configuration information is used for indicating one or more first target functions whose function call information is to be acquired;
[0025] A determination module, configured to run the target program according to the configuration information, and obtain function call information of the first target function in response to calling the first target function during the running of the target program;
[0026] The analysis module is used to analyze the function call information of the second target function in response to the end of the target program running, and obtain the function call information analysis result, wherein the second target function is part or all of one or more first target functions.
[0027] In a possible implementation, a module is determined to:
[0028] The target program is run according to the configuration information, and in the process of running the target program, in response to calling the first target function, a hook operation corresponding to the first target function is executed to obtain function call information of the first target function.
[0029] In a possible implementation, the target program is run according to the configuration information, and in response to calling the first target function during the running of the target program, a hook operation corresponding to the first target function is executed to obtain function call information of the first target function, including:
[0030] In response to calling the first target function in the target process for running the target program, a custom function associated with the first target function in the custom function library is run to obtain function call information of the first target function.
[0031] In a possible implementation, the target process is started in the child process through a preset preloaded environment variable, and the child process is created in the main process through a system call.
[0032] In a possible implementation, the configuration information is further used to indicate the type of function call information to be obtained, and the determination module is used to:
[0033] The target program is run according to the configuration information, and in response to calling the first target function during the running of the target program, function call information of the first target function corresponding to the type of function call information to be obtained is obtained.
[0034] In a possible implementation manner, the type of function call information to be obtained includes one or more of the following: process ID, thread ID, function call stack information, and function execution time.
[0035] In a possible implementation manner, the configuration information is further used to indicate the second target function and an analysis method for the function call information of the second target function, and the analysis module is used to:
[0036] In response to the target program running being finished, the function call information of the second target function is analyzed based on the analysis method for the function call information to obtain a function call information analysis result.
[0037] In a possible implementation, the device further includes:
[0038] A second acquisition module is used to acquire a pointer of the first target function to call the first target function during the process of running the custom function associated with the first target function in the custom function library;
[0039] A writing module, used for writing the obtained function call information of the first target function into a storage system via a file in a custom format;
[0040] Analysis modules for:
[0041] In response to the target program running being finished, a file in a custom format including function call information of the second target function is obtained from the storage system for analysis to obtain a function call information analysis result.
[0042] According to another aspect of the present disclosure, a function call information analysis device is provided, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.
[0043] According to another aspect of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, wherein the computer program instructions implement the above method when executed by a processor.
[0044] According to another aspect of the present disclosure, a computer program product is provided, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.
[0045] According to an embodiment of the present application, by obtaining configuration information of one or more first target functions for indicating function call information to be obtained, it is possible to specify a function in the process of obtaining function call information and collect call information of the specified function, which is customizable. By running the target program according to the configuration information, in the process of running the target program, in response to calling the first target function, the function call information of the first target function is obtained, and rich function call information can be obtained. By analyzing the function call information of the second target function in response to the end of the target program, the function call information analysis result can be obtained, and global analysis can be performed for all breakpoints, which is global. In this process, there is no need to add additional code to the target program, which is low-invasive and universal, suitable for large-scale and highly complex programs, and can analyze the logical problems and performance bottlenecks of the target program code for various programs.
[0046] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.
[0048] Figure 1 A schematic diagram showing a system hierarchy according to an embodiment of the present application.
[0049] Figure 2 A schematic diagram of the overall design of a function call information analysis system according to an embodiment of the present application is shown.
[0050] Figure 3 A flow chart of a method for analyzing function call information according to an embodiment of the present application is shown.
[0051] Figure 4 A schematic diagram of a first visualization interface according to an embodiment of the present application is shown.
[0052] Figure 5 A schematic diagram of the overall process of a method for analyzing function call information according to an embodiment of the present application is shown.
[0053] Figure 6 A schematic diagram of a process for collecting function call information according to an embodiment of the present application is shown.
[0054] Figure 7 A schematic diagram of a second visualization interface according to an embodiment of the present application is shown.
[0055] Figure 8 A schematic diagram of a second visualization interface according to an embodiment of the present application is shown.
[0056] Fig. 9 A schematic diagram of a process for analyzing and displaying function call information according to an embodiment of the present application is shown.
[0057] Fig.10 A structural diagram of a function call information analysis device according to an embodiment of the present application is shown.
[0058] Fig.11 It is a block diagram of a device 1900 for analyzing function call information according to an exemplary embodiment. DETAILED DESCRIPTION
[0059] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0060] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0061] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.
[0062] Function call information analysis is an important method for analyzing source programs and improving program execution efficiency. The current method for obtaining function call information is usually to use tools such as GDB and Valgrind, or to add log information to the source program code. GDB can only view stack information through manual debugging commands, and cannot perform global analysis for all breakpoints; Valgrind cannot specify functions and the collected function call information is not rich enough; and the log method requires adding a large amount of additional log code to the source program code, which is not only not universal but also difficult to analyze. It can be seen that although there are some tools that assist in function call information analysis, they can only meet some needs and have various shortcomings. They cannot meet both customizability and globality at the same time. Once the program reaches a certain scale and complexity, these auxiliary analysis tools are difficult to analyze the logic problems and performance bottlenecks of the program code.
[0063] In view of this, the present application provides a method, device and storage medium for analyzing function call information. The method of the embodiment of the present application can realize that a function can be specified in the process of obtaining function call information, and the call information of the specified function can be collected by obtaining the configuration information of one or more first target functions for indicating the function call information to be obtained, and it is customizable. By running the target program according to the configuration information, in the process of running the target program, in response to calling the first target function, the function call information of the first target function is obtained, and rich function call information can be obtained. By responding to the end of the target program, the function call information of part or all (i.e., the second target function) in the first target function is analyzed to obtain the function call information analysis result, and global analysis can be achieved for all breakpoints, which is global. And in this process, there is no need to add additional code to the target program, it has low intrusion and versatility, is suitable for large-scale and high-complexity programs, and can analyze the logical problems and performance bottlenecks of the target program code for various programs.
[0064] Figure 1 A schematic diagram of a system hierarchy according to an embodiment of the present application is shown. Figure 1 As shown, the function call information analysis system of the embodiment of the present application can run in a Linux system, and the Linux system can be installed in computer hardware.
[0065] The function call information analysis system can include a configuration subsystem, an information analysis subsystem, an information collection subsystem, and a persistence subsystem. Figure 2 , shows a schematic diagram of the overall design of a function call information analysis system according to an embodiment of the present application. Figure 2 As shown, in the function call information analysis system, the configuration subsystem can be used to configure the collection behavior and the analysis behavior. The collection behavior and the analysis behavior can be input by the user, and are used to collect function call information and analyze the collected function call information respectively; the information analysis subsystem can be used to collect function call information when the target program is running based on the collection behavior configured by the configuration subsystem, and write the collected function call information into the persistence subsystem through the storage interface provided by the persistence subsystem (i.e., writing data in the figure); the persistence subsystem can be used to persist data using a file or database in a custom format to save the collected function call information. The file in the custom format can be a text file, and the data stored in the database can be stored in a table form. The persistence subsystem can provide two interfaces, storage and parsing; the information analysis subsystem can be used to read the function call information from the persistence subsystem through the parsing interface provided by the persistence subsystem based on the analysis behavior configured by the configuration subsystem (i.e., taking out the data in the figure), and analyze the read function call information to obtain the function call information analysis result.
[0066] The computer hardware may be a terminal device or a server. The terminal device may be any one or more of a mobile phone, a foldable electronic device, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), and a vehicle-mounted device. The embodiments of the present disclosure do not impose any special restrictions on the specific type of the terminal device, and the terminal device may have a wired or wireless communication function.
[0067] The server can be located locally or in the cloud, and can be a physical device or a virtual device, such as a virtual machine, a container, etc., and has a wireless communication function, wherein the wireless communication function can be set in the chip (system) or other parts or components of the server. The wireless communication function can be realized, for example, through mobile communication technologies such as 2G / 3G / 4G / 5G, as well as Wi-Fi, Bluetooth, frequency modulation (FM), digital radio, satellite communication, etc. Communication can also be carried out through wired connection to achieve interaction with other devices.
[0068] The following Figure 2 Based on this, the function call information analysis method of this application is introduced.
[0069] Figure 3 FIG. 1 is a flow chart showing a method for analyzing function call information according to an embodiment of the present application. The method can be used in the above-mentioned function call information analysis system, such as Figure 3 As shown, the method may include:
[0070] Step S301, obtaining configuration information.
[0071] This step can be performed by the above configuration subsystem.
[0072] The configuration information may be used to indicate one or more first target functions for which function call information is to be obtained. The configuration information may include a function name of the first target function. The first target function may be a system function supported by the system.
[0073] The user can input configuration information through the first visual interface. Figure 4 FIG. 1 is a schematic diagram showing a first visualization interface according to an embodiment of the present application. Figure 4As shown, QT can be used to implement the first visualization interface (such as the function call analysis system (configuration end) in the figure), and the user can input the configuration through the first visualization interface. Taking the user configuring the collection behavior in the first visualization interface as an example, the user can import the executable file of the corresponding process in the first visualization interface (such as the executable file "a.out" under the path " / home / user / code / a.out" in the figure) as the target program, and can select the function name to obtain function call information in the first visualization interface (such as the "func1" corresponding to the backtrace function in the figure), and one or more function names can be selected. In the first visualization interface, the user can also set the startup parameters (i.e., the parameters required to start the process) according to the system process requirements and choose whether to start the program with the authority of the super user (root user) in the Linux system (i.e., the "whether to start as root" corresponding to the selection box in the figure).
[0074] Figure 4 The first visual interface shown only shows a part of the configuration information that can be input by the user as an example, and the user can also input other configuration information.
[0075] For example, the configuration information may also be used to indicate the type of function call information to be obtained, and the type of function call information to be obtained may include one or more of the following: process identifier (PID), thread identifier (TID), function call stack information, and function execution time. The function call stack information may include the function name, module name, and number of calls of the first target function called.
[0076] The configuration information can also be used to indicate the second target function and the analysis method of the function call information for the second target function. The configuration information may include the function name of the second target function, and the second target function may be part or all of the one or more first target functions. The analysis method for the function call information may indicate the type of report generated after analyzing the function call information, such as a visual function call chart, a flame chart, etc. Thus, the user can freely select the function call information to be analyzed and the analysis method according to the needs, and can filter and analyze the information for the specified function during the analysis to further achieve customization.
[0077] Figure 5 FIG. 2 is a schematic diagram showing the overall process of a method for analyzing function call information according to an embodiment of the present application. Figure 5 As shown, the overall process of the unit testing method in the embodiment of the present application includes:
[0078] Step S51, obtaining user configuration; this step may refer to the above step S301.
[0079] Step S52, injection and hook preprocessing;
[0080] Among them, injection can be achieved through dynamic link library injection technology, etc., to insert the dynamic link library into the address space of the target process; preprocessing operations can also be performed before the target process is started (such as determining the function address that needs to be hooked, etc.).
[0081] Step S53, configure the preload environment variable and start the target process;
[0082] The preload environment variable can be used to load a custom function library (ie, a hook library) when starting a target process (ie, during the process of running a target program) to control the behavior of the first target function.
[0083] In step S53, after the target process is started in the main process, the dynamic library specified by preload (i.e., the hook library) can be loaded through the configured preload environment variable, and the target process can be executed. In the process of executing the target process, when the specified hooked function (i.e., the first target function) is run, the function call information specified by the user, such as the call stack information, is collected and stored in the persistence module (i.e., the above-mentioned persistence subsystem) through a file in a custom format. In response to the completion of the target program, the target process can be terminated.
[0084] Step S54, waiting for the target process to finish execution;
[0085] Step S55: Analyze the collected function call information based on the user configuration and output an analysis report.
[0086] Analysis reports can be presented in a visual way.
[0087] Then the main process can be terminated.
[0088] exist Figure 5 Based on the overall process introduced, you can continue to refer to Figure 3 :
[0089] Step S302: running the target program according to the configuration information, and obtaining function call information of the first target function in response to calling the first target function during the running of the target program.
[0090] In step S302, the operations of step S52 and configuring the preload environment variables may be performed.
[0091] Step S302 may be executed by the above-mentioned information collection subsystem.
[0092] In step S302, it is possible to:
[0093] The target program is run according to the configuration information, and in the process of running the target program, in response to calling the first target function, a hook operation corresponding to the first target function is executed to obtain function call information of the first target function.
[0094] Among them, taking the hook operation in the Linux system as an example, a child process can be created through a system call in the main process; in the child process, a target process is started through preset preloaded environment variables to run the target program; in the target process used to run the target program, in response to calling the first target function, a custom function associated with the first target function in the custom function library is run to obtain function call information of the first target function.
[0095] The target process is the process that runs the target program, and the custom function library (ie the above-mentioned hook library) may include one or more custom functions.
[0096] For example, a child process can be created through the fork system call in the main process, an execve system call can be performed in the child process, and the target process can be started through the preset preload environment variable, so that a custom function library (i.e., the above-mentioned hook library) can be loaded in the target process. When the first target function is called in the target process, the custom function associated with the first target function can be run to obtain the function call information of the first target function.
[0097] Since the configuration information can also be used to indicate the type of function call information to be obtained, in step S302, it is possible to:
[0098] The target program is run according to the configuration information, and in response to calling the first target function during the running of the target program, function call information of the first target function corresponding to the type of function call information to be obtained is obtained.
[0099] For example, by calling a system function in a custom function to collect a process identifier (PID) and a thread identifier (TID), the function call stack information of the first target function can be collected through the libunwind library function; the timestamp of when the first target function starts running and the timestamp of when the first target function ends can be recorded separately to determine the function execution time.
[0100] After step S302, the method may further include:
[0101] In the process of running the custom function associated with the first target function in the custom function library, a pointer of the first target function is obtained to call the first target function; and the obtained function call information of the first target function is written into the storage system through a file in a custom format.
[0102] The storage system may be the above-mentioned persistence subsystem. The file in the custom format may be a text file, a table file, etc. in any format.
[0103] That is to say, running the custom function does not affect the execution of the first target function in the target program. In each custom function in the hook library, it can be implemented to execute the following when running the custom function: 1. Collect the function call information of the corresponding first target function, 2. Get the pointer of the corresponding first target function and call and execute the first target function based on the pointer, 3. Call the storage interface of the persistence subsystem to write the collected function call information into the persistence subsystem through a file in a custom format.
[0104] Figure 6 A schematic diagram of a process for collecting function call information according to an embodiment of the present application is shown. Figure 1 and Figure 2 Under the structure of the function call information analysis system shown in Figure 6 As shown, the configuration subsystem of the embodiment of the present application can collect the configuration input by the user (i.e., behavior configuration) and process the user configuration. This part of the process may correspond to the above-mentioned step S301; the configuration subsystem may also set the preload environment variable of the target process and start the target process. During the running of the target process, a custom function library (hook library) may be loaded based on the preset preload environment variable.
[0105] During the process of running the target process, when the hooked function (i.e., the first target function) is reached, the information collection subsystem can be called. The information collection subsystem can collect function call information through the above-mentioned hook method, and call the interface of the persistence subsystem to write the collected function call information into the persistence subsystem.
[0106] The persistence subsystem can store the collected function call information. In response to the message indicating that the writing is completed returned by the persistence subsystem, the information collection subsystem can return a notification of the completion of collecting the call information to the target process to continue running the target program. When the target program is finished running, the target process can be terminated.
[0107] Return to see Figure 3 :
[0108] Step S303, in response to the target program running being finished, analyzing the function call information of the second target function to obtain a function call information analysis result.
[0109] This step can be performed by the above-mentioned information analysis subsystem, corresponding to Figure 5Step S55 in the configuration subsystem. The information analysis subsystem may determine the second target function in the first target function and the method of performing function call information analysis based on the analysis behavior of the user configuration sent by the configuration subsystem, analyze the function call information of the second target function, and obtain the function call analysis result.
[0110] According to an embodiment of the present application, by obtaining configuration information of one or more first target functions for indicating function call information to be obtained, it is possible to specify a function in the process of obtaining function call information and collect call information of the specified function, which is customizable. By running the target program according to the configuration information, in the process of running the target program, in response to calling the first target function, the function call information of the first target function is obtained, and rich function call information can be obtained. By analyzing the function call information of the second target function in response to the end of the target program, the function call information analysis result can be obtained, and global analysis can be performed for all breakpoints, which is global. In this process, there is no need to add additional code to the target program, which is low-invasive and universal, suitable for large-scale and highly complex programs, and can analyze the logical problems and performance bottlenecks of the target program code for various programs.
[0111] In step S303, you can:
[0112] In response to the target program running being finished, a file in a custom format including function call information of the second target function is obtained from the storage system for analysis to obtain a function call information analysis result.
[0113] The storage system may be the above-mentioned persistence subsystem. The function call information of the second target function may be obtained from the persistence subsystem by calling the parsing interface of the persistence subsystem for analysis to obtain the function call information analysis result.
[0114] Among them, since the configuration information can also be used to indicate the analysis method for function call information, in step S303, in response to the end of the target program running, the function call information of the second target function is analyzed based on the analysis method for function call information to obtain the function call information analysis result.
[0115] Thus, the function call information can be analyzed for the function selected by the user in the manner selected by the user.
[0116] The function call information analysis results can be displayed through the second visualization interface. For example, when the user configuration indicates to analyze the function call information by means of a function call graph, the function call information analysis results displayed through the second visualization interface can be seen in Figure 7 and Figure 8 , showing a schematic diagram of a second visualization interface according to an embodiment of the present application. Figure 7 and Figure 8 As shown, QT can be used to implement the second visual interface (such as the function call analysis system (analysis end) in the figure). Figure 7 and Figure 8 The function call information analysis results in the list view and the graph view are displayed respectively.
[0117] like Figure 7 As shown, the list view may include the function name, module name, process ID (such as tid in the figure), thread ID (such as pid in the figure), function execution time (such as cost time in the figure), and function call stack information (such as call stack in the figure) of the second target function. By expanding the call stack, the second target function name and module name, as well as the function name and module name that calls the second target function can be obtained.
[0118] like Figure 8 As shown, in the graphical view, the calling relationship between the second target function and the function that calls the second target function can be displayed. It can be seen from the figure that the function "main()" calls the second target function "func1".
[0119] The collected function call information can be integrated through the visual interface to provide users with a holistic, clear, easy-to-read and concise analysis report with the goal of "program logic" and "program performance".
[0120] Fig. 9 A schematic diagram of a process for analyzing and displaying function call information according to an embodiment of the present application is shown. Fig. 9 As shown, in the function call information analysis method of the embodiment of the present application, the process of analyzing and displaying function call information may include: the configuration subsystem collects and processes the behavior configuration input by the user; the configuration subsystem may call the information analysis subsystem to start the analysis of the function call information; the information analysis subsystem may load the corresponding function call information (i.e., call data information) from the persistence subsystem; after the persistence subsystem sends the function call information to the information analysis subsystem, the information analysis subsystem may perform data processing on the received function call information based on the user configuration to obtain the function call information analysis results; the information analysis subsystem may also visualize the function call information analysis results by calling the interface.
[0121] Fig.10 FIG. 2 shows a structural diagram of a function call information analysis device according to an embodiment of the present application. Fig.10 As shown, the device comprises:
[0122] A first acquisition module 1001 is used to acquire configuration information, where the configuration information is used to indicate one or more first target functions whose function call information is to be acquired;
[0123] A determination module 1002 is used to run the target program according to the configuration information, and obtain function call information of the first target function in response to calling the first target function during the running of the target program;
[0124] The analysis module 1003 is used to analyze the function call information of the second target function in response to the end of the target program running, and obtain the function call information analysis result, where the second target function is part or all of one or more first target functions.
[0125] In a possible implementation, the determining module 1002 is configured to:
[0126] The target program is run according to the configuration information, and in the process of running the target program, in response to calling the first target function, a hook operation corresponding to the first target function is executed to obtain function call information of the first target function.
[0127] In a possible implementation, the target program is run according to the configuration information, and in response to calling the first target function during the running of the target program, a hook operation corresponding to the first target function is executed to obtain function call information of the first target function, including:
[0128] In response to calling the first target function in the target process for running the target program, a custom function associated with the first target function in the custom function library is run to obtain function call information of the first target function.
[0129] In a possible implementation, the target process is started in the child process through a preset preloaded environment variable, and the child process is created in the main process through a system call.
[0130] In a possible implementation, the configuration information is further used to indicate the type of function call information to be obtained, and the determination module 1002 is used to:
[0131] The target program is run according to the configuration information, and in response to calling the first target function during the running of the target program, function call information of the first target function corresponding to the type of function call information to be obtained is obtained.
[0132] In a possible implementation manner, the type of function call information to be obtained includes one or more of the following: process ID, thread ID, function call stack information, and function execution time.
[0133] In a possible implementation manner, the configuration information is further used to indicate the second target function and an analysis method for the function call information of the second target function, and the analysis module 1003 is used to:
[0134] In response to the target program running being finished, the function call information of the second target function is analyzed based on the analysis method for the function call information to obtain a function call information analysis result.
[0135] In a possible implementation, the device further includes:
[0136] A second acquisition module is used to acquire a pointer of the first target function to call the first target function during the process of running the custom function associated with the first target function in the custom function library;
[0137] A writing module, used for writing the obtained function call information of the first target function into a storage system via a file in a custom format;
[0138] The analysis module 1003 is used to:
[0139] In response to the target program running being finished, a file in a custom format including function call information of the second target function is obtained from the storage system for analysis to obtain a function call information analysis result.
[0140] According to an embodiment of the present application, by obtaining configuration information of one or more first target functions for indicating function call information to be obtained, it is possible to specify a function in the process of obtaining function call information and collect call information of the specified function, which is customizable. By running the target program according to the configuration information, in the process of running the target program, in response to calling the first target function, the function call information of the first target function is obtained, and rich function call information can be obtained. By analyzing the function call information of the second target function in response to the end of the target program, the function call information analysis result can be obtained, and global analysis can be performed for all breakpoints, which is global. In this process, there is no need to add additional code to the target program, which is low-invasive and universal, suitable for large-scale and highly complex programs, and can analyze the logical problems and performance bottlenecks of the target program code for various programs.
[0141] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0142] The embodiment of the present disclosure also provides a computer-readable storage medium on which computer program instructions are stored, and the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium can be a volatile or non-volatile computer-readable storage medium.
[0143] The embodiment of the present disclosure also proposes a function call information analysis device, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.
[0144] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.
[0145] Fig.11 1 is a block diagram of an apparatus 1900 for analyzing function call information according to an exemplary embodiment. For example, the apparatus 1900 may be provided as a server or a terminal device. Fig.11 , the apparatus 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions, such as an application, that can be executed by the processing component 1922. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.
[0146] The device 1900 may also include a power supply component 1926 configured to perform power management of the device 1900, a wired or wireless network interface 1950 configured to connect the device 1900 to a network, and an input / output interface 1958 (I / O interface). The device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server 2000. TM , MacOS X TM , Unix TM ,Linux TM , FreeBSD TM or similar.
[0147] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the device 1900 to perform the above method.
[0148] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0149] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: 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), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0150] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0151] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via 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., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0152] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0153] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0154] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0155] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse 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 hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0156] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A method for analyzing function call information, characterized in that: The method comprises: Acquire configuration information, where the configuration information is used to indicate one or more first target functions for which function call information is to be acquired; Running the target program according to the configuration information, and obtaining function call information of the first target function in response to calling the first target function during the running of the target program; In response to the target program running being finished, the function call information of the second target function is analyzed to obtain a function call information analysis result, wherein the second target function is part or all of the one or more first target functions.
2. The method according to claim 1, characterized in that Running the target program according to the configuration information, and obtaining function call information of the first target function in response to calling the first target function during the running of the target program, including: The target program is run according to the configuration information, and in the process of running the target program, in response to calling the first target function, a hook operation corresponding to the first target function is executed to obtain function call information of the first target function.
3. The method according to claim 2, characterized in that The step of running the target program according to the configuration information, and executing a hook operation corresponding to the first target function in response to calling the first target function during the running of the target program, to obtain function call information of the first target function, includes: In response to calling the first target function in a target process for running a target program, a custom function associated with the first target function in a custom function library is run to obtain function call information of the first target function.
4. The method according to claim 3, characterized in that The target process is started in the child process through a preset preloaded environment variable, and the child process is created in the main process through a system call.
5. The method according to claim 1, characterized in that The configuration information is also used to indicate the type of function call information to be obtained, and the running of the target program according to the configuration information, and obtaining the function call information of the first target function in response to calling the first target function during the running of the target program, includes: The target program is run according to the configuration information, and in response to calling the first target function during the running of the target program, function call information of the first target function corresponding to the type of the function call information to be obtained is obtained.
6. The method according to claim 5, characterized in that The type of the function call information to be obtained includes one or more of the following: process ID, thread ID, function call stack information, and function execution time.
7. The method according to claim 1, characterized in that The configuration information is further used to indicate a second target function and an analysis method for function call information of the second target function. In response to the target program running being finished, the function call information of the second target function is analyzed to obtain a function call information analysis result, including: In response to the target program being finished running, the function call information of the second target function is analyzed based on the analysis method for the function call information to obtain a function call information analysis result.
8. The method according to claim 3, characterized in that The method further comprises: In the process of running the custom function associated with the first target function in the custom function library, obtaining a pointer to the first target function to call the first target function; Writing the obtained function call information of the first target function into a storage system via a file in a custom format; In response to the target program running being finished, analyzing the function call information of the second target function to obtain the function call information analysis result, including: In response to the target program running being finished, a file in a custom format including function call information of the second target function is acquired from the storage system for analysis to obtain a function call information analysis result.
9. A function call information analysis device, characterized in that: The device comprises: A first acquisition module, used to acquire configuration information, where the configuration information is used to indicate one or more first target functions whose function call information is to be acquired; a determination module, configured to run a target program according to the configuration information, and obtain function call information of the first target function in response to calling the first target function during the running of the target program; The analysis module is used to analyze the function call information of the second target function in response to the end of the target program to obtain the function call information analysis result, wherein the second target function is part or all of the one or more first target functions.
10. A function call information analysis device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to implement the method described in any one of claims 1 to 8 when executing the instructions stored in the memory.
11. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.
