Application lag positioning method and related device

By controlling the pop-up of application functions and uploading the call tree, accurate stuck positioning is achieved, which solves the problem of inability to accurately locate stuck application functions in the existing technology and improves the runtime smoothness of the application.

CN118550740APending Publication Date: 2024-08-27GUANGZHOU TENCENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310174539.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-24
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Existing technology cannot accurately locate stucks in application functions, resulting in limited smoothness when the application is running.

Method used

Through the pop-out control of the function, the target parent function in the initial function is used to call the target function, the function information of the target function is added to the main thread stack, the function call tree is determined based on the execution time and call relationship, and it is uploaded to the to-be-processed Queue to achieve precise stuck positioning.

Benefits of technology

It improves the runtime fluency of the application, can accurately identify functions that cause lags and their calling relationships, reduces multiple applications and releases of memory space, and improves function calling efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550740A
    Figure CN118550740A
Patent Text Reader

Abstract

The invention discloses a jamming positioning method of an application program and a related device, in the process that a main thread of the application program calls an initial function contained in the application program, a child function of the application program can be called through a parent function in the initial function, that is, a target function in the initial function can be called through a target parent function in the initial function, and the jamming positioning accuracy of the application program is improved. And adding the function information of the target function into a stack corresponding to the main thread so as to execute the target function according to the function information in the stack. After the target function is executed, whether the function information of the target function is removed from the stack or not can be determined according to the execution time consumption of the target function, if the execution time consumption of the target function meets a first preset condition, whether the called current function is a root function or not can be continuously determined, and if yes, the total execution time length of the root function meets a second preset condition, and if not, the function information of the target function is removed. Therefore, the function call tree can be determined according to the function information in the stack, accurate jamming positioning aiming at the function is realized, and the fluency of the application program during operation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a method and related device for locating a freeze in an application program. Background Art

[0002] For client applications that provide services to the general public, their performance is an essential reference indicator, and the fluency of the application is an important factor in its performance. The fluency of the application includes four aspects: installation fluency, startup fluency, runtime fluency, and exit fluency. Improving runtime fluency is an important way to improve the performance of software applications. The functions of an application are implemented by calling functions. Locating the functions that cause the application to freeze can help improve the runtime fluency of the application. However, it is currently impossible to accurately locate the freeze of a function. Summary of the invention

[0003] In order to solve the above technical problems, the present application provides a method and related device for locating the jam of an application program, which realizes accurate jam locating of a function by controlling the popping of the function.

[0004] The embodiments of the present application disclose the following technical solutions:

[0005] On the one hand, an embodiment of the present application provides a method for locating a freeze of an application program, the method comprising:

[0006] The main thread of the application calls the target function in the initial function through the target parent function in the initial function, the initial function is a function included in the application, and the target parent function is the parent function of the target function;

[0007] Adding function information of the target function to the stack corresponding to the main thread, and executing the target function according to the function information;

[0008] After the execution of the target function is completed, if the execution time of the target function meets the first preset condition, determining the current function being called;

[0009] If the current function is a root function, and the total execution time of the root function meets a second preset condition, determining a function call tree according to the function information in the stack;

[0010] The function call tree is added to a queue to be uploaded to upload the function call tree.

[0011] On the other hand, the present application provides a device for locating a jam of an application program, the device comprising:

[0012] A function calling unit, used to call a target function in an initial function through a target parent function in the initial function through a main thread of the application, wherein the initial function is a function included in the application, and the target parent function is a parent function of the target function;

[0013] A function execution unit, used to add function information of the target function to a stack corresponding to the main thread, and execute the target function according to the function information;

[0014] A current function determination unit, configured to determine a current function to be called after the execution of the target function is completed if the execution time of the target function satisfies a first preset condition;

[0015] a function call tree determining unit, configured to determine a function call tree according to the function information in the stack if the current function is a root function and the total execution time of the root function satisfies a second preset condition;

[0016] The adding unit is used to add the function call tree to the queue to be uploaded so as to upload the function call tree.

[0017] In another aspect, the present application provides a computer device, the device comprising a processor and a memory:

[0018] The memory is used to store a computer program and transmit the computer program to the processor;

[0019] The processor is used to execute the method for locating the jamming of the application program described in the above aspect according to the instructions in the computer program.

[0020] On the other hand, an embodiment of the present application provides a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the method for locating a jam in an application program described in the above aspects.

[0021] On the other hand, an embodiment of the present application provides a computer program product including a computer program, which, when executed on a computer device, enables the computer device to execute the method for locating a jam of an application program.

[0022] It can be seen from the above technical solution that in the process of the main thread of the application calling the initial function contained in the application, its child function can be called through the parent function in the initial function, that is, the target function in the initial function can be called through the target parent function in the initial function, and the function information of the target function can be added to the stack corresponding to the main thread, so as to execute the target function according to the function information in the stack. After the execution of the target function is completed, it can be determined whether to remove the function information of the target function from the stack based on the execution time of the target function. If the execution time of the target function meets the first preset condition, it means that its execution may cause the application to freeze. Then it can be determined whether the current function being called is a root function. If so, and the total execution time of the root function meets the second preset condition, it means that the root function takes a long time to call other functions. At this time, since the function information of the target function that may cause freezes has not been removed from the stack, the function call tree can be determined based on the function information in the stack. In this way, through the pop-up control of the function, the function call tree can include function call chains that may cause freezes and have a long total execution time. The execution of functions in the function call tree is more likely to cause the application to freeze. In this way, the function call tree is added to the queue to be uploaded to upload the function call tree, so as to achieve accurate positioning of the function freeze. The background can analyze the uploaded function call tree to determine the function that causes the freeze and the calling relationship of the function, which is beneficial to improving the runtime smoothness of the application. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0024] Figure 1 A schematic diagram of an application scenario of a method for locating a freeze of an application program provided in an embodiment of the present application;

[0025] Figure 2 A flowchart of a method for locating a freeze in an application program provided in an embodiment of the present application;

[0026] Figure 3 A schematic diagram of a function call relationship provided in an embodiment of the present application;

[0027] Figure 4 A schematic diagram of a tree structure provided in an embodiment of the present application;

[0028] Figure 5 A schematic diagram of a determined tree structure provided in an embodiment of the present application;

[0029] Figure 6 A process of another method for locating a jam of an application provided in an embodiment of the present application;

[0030] Figure 7 A flowchart of another method for locating a freeze of an application program provided in an embodiment of the present application;

[0031] Figure 8 A flowchart of another method for locating a freeze of an application program provided in an embodiment of the present application;

[0032] Fig. 9 A schematic diagram of function call information provided in an embodiment of the present application;

[0033] Fig.10 A schematic diagram of a jamming positioning effect provided in an embodiment of the present application;

[0034] Fig.11 A structural block diagram of a device for locating a jam of an application provided in an embodiment of the present application;

[0035] Fig.12 A structural diagram of a terminal device provided in an embodiment of the present application;

[0036] Fig.13 A structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0037] The embodiments of the present application are described below in conjunction with the accompanying drawings.

[0038] Currently, the function that causes the application to freeze can be located to help improve the runtime fluency of the application. However, it is currently impossible to accurately locate the freeze of the function. In order to solve the above technical problems, in the embodiment of the present application, accurate freeze positioning of the function can be achieved by controlling the popping of the function, which is conducive to improving the runtime fluency of the application.

[0039] The method for locating the jamming of an application provided in the embodiment of the present application can be implemented by a computer device, which can be a terminal device or a server, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Terminal devices include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.

[0040] In order to facilitate the understanding of the technical solution provided by the present application, the following will introduce a method for locating a freeze of an application program provided in an embodiment of the present application in combination with an actual application scenario.

[0041] Figure 1 A schematic diagram of an application scenario of a method for locating a jam of an application provided by an embodiment of the present application is shown. In the scenario, a server 10 and a terminal device 20 are included. An application is installed in the terminal device 20, and the server corresponding to the application and the terminal device 20 can interact through a network. When the application is executed, the aforementioned jam locating method can be monitored, and the aforementioned jam locating method can be implemented by an application for jam locating, and the server 10 corresponding to the jam locating application and the terminal device 20 can interact through a network. The terminal device 20 can be used as the aforementioned computer device to locate the jam of the application, and after determining the function call tree, the function call tree can be sent to the server 10, so that the server 10 can further locate the jam of the application through the function call tree.

[0042] In the terminal device 20, during the process of the main thread of the application calling the initial function contained in the application, the child function can be called through the parent function in the initial function, that is, the target function in the initial function can be called through the target parent function in the initial function, and the function information of the target function is added to the stack corresponding to the main thread, so as to execute the target function according to the function information in the stack.

[0043] After the execution of the target function is completed, it can be determined whether to move the function information of the target function out of the stack based on the execution time of the target function. If the execution time of the target function meets the first preset condition, it means that its execution may cause the application to freeze. Then, it can be determined whether the current function being called is the root function. If so, and the total execution time of the root function meets the second preset condition, it means that the root function takes a long time to call other functions. At this time, since the function information of the target function that may cause freezes has not been moved out of the stack, the function call tree can be determined based on the function information in the stack.

[0044] In this way, through the function pop-up control, the function call tree can include function call chains that may cause jams and have a long total execution time. The execution of functions in the function call tree is more likely to cause application jams. In this way, the function call tree is added to the upload queue to upload the function call tree, so as to achieve accurate jam location for the function. The background can analyze the uploaded function call tree to determine the function that causes the jam and the calling relationship of the function, which is conducive to improving the runtime smoothness of the application.

[0045] Figure 2The flowchart of a method for locating a jam of an application provided in an embodiment of the present application. In this embodiment, a terminal device is used as the aforementioned computer device for illustration. The method for locating a jam of the application may include:

[0046] S101, the main thread of the application program calls the target function in the initial function through the target parent function in the initial function.

[0047] S102, adding function information of the target function to the stack corresponding to the main thread, and executing the target function according to the function information.

[0048] In the embodiment of the present application, the application can be run by a computer device, and the application can include a PC client program, a mobile client program, a background program, etc. The computer device allocates computing resources to the application to execute the data processing logic related to the application. The computing resources may include processes, each process may include multiple threads, and each thread may be used to execute the corresponding data processing logic. The computer device can also allocate memory space for the application, and the memory space may include a heap allocated for the application and a stack allocated for the thread. The heap is used to store data during the operation of the application, and the stack is used to store parameters, local variables, etc. of the function executed by the thread. The stack has a first-in, last-out feature.

[0049] In the embodiment of the present application, the initial function contained in the application can be called through the main thread of the application. The initial function can include multiple functions. Some functions in the multiple initial functions can nest other functions, so that some functions can call other functions in the multiple initial functions. For example, a function can call another function. The function that calls other functions is the parent function, and the function called by the parent function is the child function of the parent function, that is, the parent function in the initial function can be used to call the child function of the parent function when called. According to the calling relationship between functions, multiple initial function processes can be made into a tree structure, and each node in the tree structure is an initial function. Other initial functions connected to the initial function are the parent function or child function of the initial function. Starting from the root node, each initial function can be nested step by step according to the tree structure. The function corresponding to the root node is the root function. There are only child functions of the root function in the initial function, and there is no parent function of the root function. A function can call multiple child functions and can also be called by multiple functions.

[0050] refer to Figure 3As shown, a schematic diagram of a function call relationship provided by an embodiment of the present application is shown. Function A is a root function. When it is called, it can call its sub-functions: function B, function C and function D; when function B is called, it can call its sub-functions: function E and function F; when function C is called, it can call its sub-functions: function G, function H and function I; when function G is called, it can call its sub-functions: function M and function N; when function D is called, it can call its sub-functions: function J, function K and function L; when function K is called, it can call its sub-function: function P; when function P is called, it can call its sub-function: function Q. In this way, the initial functions A to Q can be called in sequence according to the function call relationship when function A is called, and thus executed in sequence.

[0051] refer to Figure 4 As shown, it is a schematic diagram of a tree structure provided in an embodiment of the present application, wherein function A is the root function, functions B, C and D are the first-level sub-functions, functions E, F, G, H, I, J, K and L are the second-level sub-functions, functions M, N and P are the third-level sub-functions, function Q is the fourth-level sub-function, and the upper-level sub-function can call the lower-level sub-function connected to it.

[0052] In the process of calling the initial function, any function in the initial function can be used as the target function, and the parent function of the target function can be used as the target parent function, and the target function can be called through the target parent function. Specifically, the main thread of the application calls the target parent function, and the target parent function calls the target function. When the target function is called, the function information of the target function can be added to the stack corresponding to the main thread, so that the target function is executed according to the function information. The function information of the target function can include parameters, local variables, etc. of the target function.

[0053] Among them, the target function can be called according to its function name pointer (string pointer). When the main thread of the application calls the parent function of the target function (i.e., the target parent function), the function name pointer of the target function in the initial function can be determined according to the function call relationship, and then the target function is called according to the determined function name pointer. Since the function name pointer has a smaller number of bytes than the function name, calling the target function through the function name pointer has a faster calling speed than calling the target function through the function name, and also improves the stacking speed of the target function, improves the calling efficiency, and realizes the lightweight of the jam location method. The function name pointer of the target function can be found from the heap according to the function information.

[0054] The memory space corresponding to the target function can be applied for in advance, and there is no need to temporarily apply for the corresponding memory space when the target function is called, thereby further improving the calling speed of the target function. Specifically, before calling the target function, after the execution of other functions in the initial function is completed, the function information of other functions can be moved out of the stack corresponding to the main thread, and the memory space used when other functions are executed is reserved. When the main thread of the application calls the target parent function, the target function in the initial function is determined according to the function call relationship, so that when the target function is executed, the target function can be executed based on the aforementioned memory space and function information. Here, other functions refer to the initial function called before the target function. In other words, after the function runs, the stack space corresponding to the function can be released without releasing the heap space corresponding to the function, thereby reducing the time consumed by multiple applications and releases of memory space, improving the calling speed of the function, improving its stacking speed, improving the function calling efficiency, and realizing the lightweight of the jam location method of the application. Fast stack access can be achieved through function name pointers and pre-allocation of memory space. Actual measurements show that 1 million stack accesses take 20 milliseconds (ms), with an average of 260 nanoseconds (ns) per access.

[0055] In an embodiment of the present application, the main thread of the application calls the initial function contained in the application by executing a monitoring function. The root function in the initial function is nested in the monitoring function, so the monitoring function can be used as the parent function of the root function, and the initial function can be called by executing the monitoring function. Specifically, the main thread of the application can call the root function in the initial function by executing the monitoring function, so as to call the target function in the initial function through the target parent function in the initial function. In actual operation, if the target parent function is the root function, the target function can be called through the root function. If the target parent function is a child function of the root function, the target parent function can be called through the root function, and then the target function can be called through the target parent function, and so on.

[0056] The monitoring function can be based on Hook (hook technology). Hook is a mechanism similar to interruption under Windows platform. The HooK mechanism allows applications to intercept and process Windows messages or specified events. When the specified message is sent, the HooK program can capture the message before it reaches the target window, thereby gaining control over the message, and then processing or modifying the message to add the required functions. The monitoring function can be a message dispatching (DispatchMessage) function based on Hook. By nesting the root function in the initial function in the monitoring function, making the monitoring function the parent function of the root function in the initial function, the root function of the initial function can be called.

[0057] Based on this, in the embodiment of the present application, before the main thread of the application calls the root function in the initial function by executing the monitoring function, a macro for class object initialization can also be added to the monitoring function so that the parameters of the class object are used for indication. In the process of calling the target function by the monitoring function, the monitoring function adds the function information of the target function to the stack by calling the constructor, that is, the push of the target function is realized, and the monitoring function removes the function information of the target function from the stack by calling the destructor, that is, the pop of the target function is realized. In actual operation, the calling timing of the constructor and the destructor can be controlled according to other conditions, and other conditions can be indicated by the parameters of the class object. Among them, the corresponding code can be added to the monitoring function through the macro, so as to realize the configuration of the calling timing. That is to say, compared with the default push of the target function by the parameters of the class object when the target function is called, the pop of the target function is performed at the end of the execution of the target function. In the embodiment of the present application, the monitoring function can be set by the macro to realize the push and pop of the target function when certain conditions are met.

[0058] The parameters of the class object can indicate that the destructor should be automatically called to pop the function after the function is executed. Therefore, the calling timing of the constructor and destructor can be configured through the settings of the same class object, so as to control the function's stacking and popping timing, that is, to add a macro to the entry of the monitoring function, so as to implement the entry dotting of the monitoring function. If the parameters of the class object do not indicate that the destructor should be automatically called to pop the function after the function is executed, the calling timing of the constructor and destructor can be configured through the settings of two class objects, so as to control the function's stacking and popping timing, that is, to configure macros for both the entry and exit of the monitoring function, so as to implement the entry and exit dotting.

[0059] When the target function is pushed into the stack, its calling information can be saved, such as the function name of the target function, the calling start time, etc. When the target function is executed, its execution end time can be saved, so that the execution time of the target function can be calculated by the calling start time and the calling end time.

[0060] refer to Figure 3 and Figure 4As shown, the execution time of functions E, F, M, N, H, I, J, Q and L are 2ms, 3ms, 11ms, 15ms, 3ms, 5ms, 3ms, 62ms and 5ms respectively; the execution time of function G is the sum of the execution times of its two sub-functions M and N, which is 26ms; the execution time of function K is the execution time of its sub-function P, and the execution time of function P is the execution time of function Q, both of which are 62ms; the execution time of function B is the sum of the execution times of its sub-functions E and F, which is 5ms; the execution time of function C is the sum of the execution times of its sub-functions G, H and I, which is 34ms; the execution time of function D is the sum of the execution times of its sub-functions J, K and L, which is 70ms; and the execution time of function A is the sum of the execution times of its sub-functions B, C and D, which is 118ms.

[0061] S103, after the target function is executed, if the execution time of the target function satisfies a first preset condition, determining the current function being called.

[0062] Since the stack allocated for the thread is used to store the function information of the function, usually when the function is called, its function information is pushed into the stack, and after the function is executed, its function information is popped from the top of the stack. The jamming of the application is usually caused by the execution time of individual functions being too long, affecting the execution of other functions. The main idea of ​​the current jamming location method is to determine whether the main thread is jammed by having the auxiliary thread periodically send a message to the main thread (SendMessageTimeOut) to determine whether the main thread is jammed. If the main thread does not reply to the message within the time limit, it is considered that the main thread is jammed. At this time, the stack corresponding to the main thread can be used to upload the information in the stack to the background for information analysis, thereby locating the jam. However, in this way, frequently sending messages and sending functions will impose a burden on the main thread. The frequency of sending messages determines the accuracy of main thread monitoring, and there is a lack of objective measurement of jams. In addition, the time of stack capture during jams is also critical. When the accuracy of main thread monitoring is insufficient, the stack of the main thread jam may be popped after execution is completed, which may easily lead to the inability to obtain the function that causes the main thread jam in time, and even the captured function error may affect the subsequent analysis. Therefore, function-based jam location cannot be achieved.

[0063] In an embodiment of the present application, after the execution of the target function is completed, the execution time of the target function can be determined according to the call start time and execution end time of the target function. The execution time of the target function is the time required to execute itself, or the time required to call its sub-function. If the execution time of the target function meets the first preset condition, the first preset condition is, for example, greater than or equal to the first time threshold, indicating that the execution time of the target function is long, and the possibility of causing the application to freeze is high. The target function can be determined without popping the stack first; if the execution time of the target function does not meet the first preset condition, for example, less than the first time threshold, it means that the execution time of the target function is short, and basically will not cause the application to freeze. Therefore, the function information of the target function can be removed from the stack, that is, the target function is popped, and the target function is excluded from the list of functions that cause freezes. The first preset condition can also be other conditions, such as greater than the ratio threshold of the execution time of the preset function, etc. The first time threshold can be determined according to the actual situation. As an example, the first time threshold can be 4ms. In other scenarios, the first time threshold can also be set to other durations, such as 5ms. Reference Figure 3 and Figure 4 As shown, the execution time of functions E, F, H and J is less than 4 ms, so they can be filtered out and not used as monitoring objects for jamming location. They are popped out of the stack after execution.

[0064] refer to Figure 3 and Figure 4 As shown, after function A is called, function A calls function B. When function B is used as the target function, since its execution time is greater than the first time threshold, it will not be popped from the stack immediately after execution. Functions E and F called by function B will be popped from the stack after execution. Therefore, the function information of function B is retained in the stack. Similarly, when functions C and D are used as target functions, they will not be popped from the stack immediately after execution. Functions G, I, K, and L will not be popped from the stack immediately after execution. Functions M, N, P, and Q will not be popped from the stack immediately after execution. However, functions H and J will be popped from the stack immediately after execution. In this way, after each function is called, the function information of functions A, B, C, D, G, I, K, L, M, N, P, and Q is retained in the stack. The positions of these functions in the stack are related to the time when they are called. Therefore, the calling relationship between these functions can be determined according to the position of the function in the stack. Refer to Figure 5 As shown, it is a schematic diagram of a tree structure determined in an embodiment of the present application. Figure 4 In particular, functions that take a shorter time to execute are filtered.

[0065] S104: If the current function is a root function and the total execution time of the root function meets a second preset condition, a function call tree is determined according to the function information in the stack.

[0066] After the target function is executed, the next initial function is called as the current function being called. When the current function is called, if the current function is the root function, it means that all sub-functions of the root function have been called, and the local call starting from the monitoring function is completed. Then the total execution time of the root function can be determined. The longer the total execution time of the root function, the greater the possibility that the root function and its sub-functions will cause jamming, and vice versa. The total execution time of the root function is the sum of the execution time of the sub-functions of the root function. For example, the total execution time of root function A is the sum of the execution time of sub-functions B, C and D, which is 118ms.

[0067] After the target function is executed and the current function is called, if the current function is not the root function, it means that the initial function has not been fully executed, and the current function can be pushed and executed. At this time, the current function is the target function, and its stacking and execution can refer to the aforementioned description of the target function. After the current execution function is executed, the pop strategy of the target function can be referred to, which will not be repeated here.

[0068] In an embodiment of the present application, if the total execution time of the root function meets the second preset condition, and the second preset condition is, for example, greater than or equal to the second time threshold, it means that the call time of the root function is relatively long, and there is a risk of causing application freezes. Therefore, the function call tree can be determined based on the function information in the stack. The function call tree is a function call chain with a relatively large total time consumption, which may cause application freezes. Since the position of the function information in the stack is related to the start time of the function call, the function call tree can be determined based on the position of the function information. The function call tree includes the call relationships of multiple functions. The second preset condition can also be other conditions that can indicate that the total execution time of the root function is relatively long. The second time threshold can be determined based on actual conditions. For example, the second time threshold can be 50ms. According to Figure 5 As shown in the figure, function A is the root function, and the total execution time exceeds 50ms, so we can Figure 5 The tree structure shown is a function call tree.

[0069] If the total execution time does not meet the second preset condition, for example, it is less than the second time threshold, it means that the root function call time is short and the possibility of causing application freezes is small. Therefore, the function information in the stack can be moved out of the stack. This can rule out the possibility that the function called by the main thread causes the application freezes, so that the background can locate the function that causes the application freeze based on the function call tree uploaded by the main thread of other processes.

[0070] S105, adding the function call tree to a queue to be uploaded, so as to upload the function call tree.

[0071] In an embodiment of the present application, the pushing and popping of functions can be controlled by the main thread of the application. After determining the function call tree, the main thread of the application can add the function call tree to the queue to be uploaded to upload the function call tree. The uploading of the function call tree can be performed by the main thread or by the auxiliary thread of the application.

[0072] refer to Figure 6 As shown, it is a flowchart of another method for locating a jam of an application provided in an embodiment of the present application. The main thread of the application calls the root function in the initial function by executing the monitoring function, and calls the target function in the initial function through the target parent function in the initial function. At this time, the called function serves as the target function, and the function information of the target function is added to the stack corresponding to the main thread. The target function can be executed according to the function information. After the execution of the target function is completed, it can be determined whether the execution time of the target function meets the first preset condition. If not, the function information of the target function can be controlled to be moved out of the stack. By reserving the memory space used when the target function is executed, the stacking rate of subsequent functions can be increased.

[0073] If the execution time of the target function meets the first preset condition, it can be determined whether the current function called after the target function is the root function. If not, the current function can be used as the target function, and the function information of the new target function can be added to the stack corresponding to the main thread. At this time, the function information of the new target function is located above the function information of the previous target function, and then the new target function is executed according to the function information of the new target function.

[0074] If the current function is a root function, it can be determined whether the total execution time of the root function meets the second preset condition. If so, the function call tree can be determined based on the function information in the stack, and then the function call tree can be added to the queue to be uploaded. If not, the function information in the stack can be removed from the stack to reserve the memory space used when the target function is executed, thereby improving the stacking efficiency for subsequent function calls.

[0075] After adding the function call tree to the queue to be uploaded, the function information can be removed from the stack, indicating that the initial function call called by the aforementioned root function has ended, and a new set of initial function calls can be started. For example, the monitoring function can be executed again to call the next set of initial functions through the monitoring function.

[0076] The function call tree can be serialized before being uploaded. The serialization can be performed by the main thread, that is, the function call tree in the queue to be uploaded can be serialized. The serialization can also be performed by the auxiliary thread, that is, the function call tree in the queue to be uploaded can be unserialized. After the main thread adds the function call tree to the queue to be uploaded, the auxiliary thread obtains the function call tree from the queue to be uploaded and then uploads it after serializing it.

[0077] Specifically, after the main thread adds the function call tree to the queue to be uploaded, the auxiliary thread can obtain the function call tree from the queue to be uploaded, serialize the function call tree to obtain a serialized call tree, and then upload the serialized call tree. Among them, the serialization of the function call tree can reduce the number of bytes of the function call tree, save the size of the uploaded data packet as much as possible, and save bandwidth. Serialization is a dump operation performed on the function call tree to facilitate the transfer of the function call tree to the background. The serialized call tree obtained after serialization can be stored in binary form, thereby reducing the number of bytes.

[0078] The method of serializing the function call tree may include: converting data in the first format into data in the second format, or performing a compression algorithm on data in the third format to obtain data in the fourth format. The first format may be, for example, a Unicode string, and the second format may be, for example, Utf8. By converting the first format to the second format, 50% of the storage space may be saved; the third format may be, for example, a DWORD format, and the data in the third format may be, for example, length data, message data, or time data, and the compression algorithm may include a ZigZag compression algorithm, and the fourth format may be a compressed file format, so that 75% of the storage space may be saved by the compression algorithm.

[0079] The auxiliary thread obtains the function call tree from the queue to be uploaded. Specifically, the auxiliary thread obtains the function call tree from the queue to be uploaded according to a preset period or based on an event trigger message of the main thread. Figure 7 As shown, it is a flowchart of another method for locating jams in an application provided by an embodiment of the present application. That is, when the main thread adds the function call tree to the queue to be uploaded, it can generate an event trigger message, so that the auxiliary thread obtains the function call tree from the queue to be uploaded according to the event trigger message; or, the auxiliary thread can obtain the function call tree from the queue to be uploaded regularly according to a preset period. In this case, the main thread can generate an event trigger message, but may not generate an event trigger message. The preset period can be, for example, 60 seconds.

[0080] Before obtaining the function call tree, the auxiliary thread can also determine whether there is a function call tree to be uploaded in the upload queue. If so, the function call tree can be obtained. Figure 7 As shown, the auxiliary function can determine whether there is a function call tree in the queue to be uploaded after determining that the current moment meets the preset cycle conditions or obtains the event trigger message. If so, the function call tree is the function call tree to be uploaded, and the function call tree can be obtained from the queue to be uploaded.

[0081] The queue to be uploaded can be a multi-threaded lock-free read-write queue. The main thread can add a function call tree to assist the downstream in obtaining the function call tree. The queue to be uploaded can be a circular queue, so that more function call trees can be uploaded with less memory space. Through multi-threaded lock-free and circular design, it can be ensured that multi-threaded reading and writing will not have read and write errors.

[0082] Before the auxiliary thread serializes the function call tree to obtain the serialized call tree, the preset function can be removed from the function call tree according to the function list containing the preset function to obtain an updated function call tree, and then the updated function call tree is serialized to obtain the serialized call tree, and then the serialized call tree is uploaded. This is because not all functions that exceed the first time threshold need to be screened out. The execution of some functions takes a long time, which is normal. Therefore, these functions that take a long time to execute can be used as preset functions. The function list containing the preset function is equivalent to the function whitelist. Deleting the preset function from the function call tree can reduce the number of unnecessary functions that need to be processed in the background. For example, for a pop-up message dialog box, the parent window of the message dialog box has a message loop, and there is also a message loop in the message dialog box. Obviously, due to the existence of the message loop, the function call tree of the parent window will eventually exceed the second time threshold with a high probability, that is, meet the second preset condition. However, this situation is normal, so this function call tree can be filtered out without uploading, reducing the number of unnecessary functions that need to be processed the day after tomorrow.

[0083] refer to Figure 8 As shown, it is a flowchart of another method for locating jams in an application provided by an embodiment of the present application. After the auxiliary thread determines that there is a preset function in the function call tree according to the function list containing the preset function, it can remove the preset function from the function call tree to obtain an updated function call tree, and then serialize the updated function call tree to obtain a serialized call tree, and then upload the serialized call tree. Of course, if there is no preset function in the function call tree, the function call tree can be processed without being processed, and the original function call tree can be serialized to obtain a serialized call tree, and then the serialized call tree can be uploaded.

[0084] The preset function can be a single called function, or a parent function that calls its child function, and of course, it can also be a root function in the initial function. In addition, if the preset function is not a root function, then after deleting the preset function, the execution time of the parent function of the preset function can be ignored. The execution time of the parent function is re-determined, and then the functions whose execution time meets the first preset condition are removed from the function call tree to obtain the latest function call tree, and the total execution time of the root function after the preset function is not considered is determined again. If the total execution time of the root function still meets the second preset condition, the latest function call tree is uploaded, thereby further reducing the number of unnecessary functions that need to be processed in the background.

[0085] After the main thread adds the function call tree to the queue to be uploaded, the auxiliary thread can also calculate at least one of the first parameter and the second parameter of the function call tree according to the function call tree and the execution time of the initial function in the function call tree, wherein the first parameter is calculated according to all the initial functions in the function call tree, and the second parameter is calculated according to the key function in the function call tree, and the key function is the initial function whose execution time exceeds the preset proportion of the execution time of the parent function; the auxiliary function of the application uploads the first parameter and the second parameter to assist in locating the jam through the first parameter and the second parameter. Reference Figure 8 As shown, when the function call tree is updated to obtain an updated function call tree, the first parameter and the second parameter are determined according to the updated function call tree.

[0086] The key function is the function that takes a relatively long time to execute in the function call tree, and is also the function that directly causes the total execution time of the function call tree to be longer. In this way, the first parameter can characterize the characteristics of all initial functions in the function call tree, and of course the parameter can characterize the characteristics of the key functions in the function call tree, which is conducive to the background to determine the function that really causes the application to freeze according to the first parameter and the second parameter.

[0087] The first parameter can be obtained by performing a preset operation on the function names and module names of all the initial functions in the function call tree, and the second parameter can be obtained by performing a preset operation on the function names and module names of the key functions in the function call tree. The preset operation can be, for example, CRC4. The first parameter obtained can be recorded as StackCrc, and the second parameter can be recorded as KeyCrc. The first parameter and the second parameter can be used as identifiers of the function call tree and can be used for statistics and aggregation of the function call tree. The key function is an initial function whose execution time exceeds the preset proportion of the execution time of the parent function. The preset proportion can be half, that is, the execution time of the key function exceeds half of the execution time of the parent function of the execution function, indicating that the key function is the factor that causes the execution time of its parent function to be longer. The module name of the initial function refers to the name of the module described by the initial function. The module is usually a functional module that can achieve independent goals. The module usually contains multiple functions. The initial functions called by the same main thread can belong to the same module or different modules.

[0088] refer to Figure 5 As shown, all initial functions in the function call tree may include: A, B, C, G, M, N, I, D, K, P, Q, L, then StackCrc can be expressed as: StackCrc = CRC64(A, B, C, G, M, N, I, D, K, P, Q, L), and the key functions in the function call tree may include: A, D, K, P, Q, then KeyCrc can be expressed as KeyCrc = CRC64(A, D, K, P, Q).

[0089] After the background obtains the function call tree, it can parse the function call tree. The serialized function call tree can be restored by the background. By aggregating the function call trees corresponding to different threads, the aggregation of stuck functions can be achieved, and the call relationship where the stuck occurs can be determined. As a way to quickly determine the call relationship of stuck, the second parameters uploaded by each thread can be counted. If the second parameters uploaded by a preset number of threads are consistent, it means that the thread corresponding to the second parameter has a high probability of stuck due to the key function corresponding to the second parameter. The function call relationship formed by these key functions is likely to cause the application to be stuck.

[0090] In the embodiment of the present application, the stack may reflect the function name of the initial function, or may reflect other identifiers of the initial function, so that the function name of the initial function is determined based on the other identifiers. However, when the initial function is a system function, since the system function often has more encapsulation, its function name is not easy to obtain, and it is also impossible to determine which system function the initial function is. In this way, even if it is determined that the application freezes due to a certain initial function, it is impossible to obtain the relevant information of the initial function. Specifically, the system function refers to a system function specific to the Hook, as shown in Figure 1, which is an example of a system function.

[0091] Therefore, in an embodiment of the present application, before adding the function call tree to the queue to be uploaded, the system function can be marked to determine the calling time of the system function; according to the calling time of the system function and the calling time of the initial function in the function call tree, the system function corresponding to the initial function in the function call tree is determined; the function name of the initial function corresponding to the system function in the function call tree is determined as the function name of the system function. In other words, the initial function corresponding to the system function may have an unknown function name. In this case, the function name of the corresponding coefficient function can be used as the function name of the initial function. Among them, marking the system function can also be called setting a probe for the system function. By adding a jam mark to the system function in the Detours function, a probe can be added to the system function to determine the calling time of the system function.

[0092] Table 1 Examples of system functions

[0093]

[0094] In actual operation, the location of the jam can be determined based on the function name, but the specific cause of the jam cannot be determined. Therefore, after determining the function call tree, the parameter type of the initial function in the function call tree can be determined based on the function call tree. The data format for the initial function in the function call tree can be determined based on the parameter type. Function data is generated based on the data format and the execution parameters of the initial function, and then the function data is uploaded. Function data can be generated by the main thread or by the auxiliary thread. The execution parameters of the initial function can be obtained from the stack or from the heap. The main thread can add the function data to the list to be uploaded, or the auxiliary thread can upload the function data.

[0095] Table 2 Correspondence between parameter types and data formats

[0096]

[0097] Refer to Table 2, which is an example of the correspondence between parameter types and data formats, where x1, x2, x3 and x4 represent execution parameters respectively. The corresponding data format can be determined based on the parameter type and the number of execution parameters. The specific data format can include important execution parameters of the function, so that the function data generated according to the data format has a specific format, and can also include sufficient execution parameters, which facilitates the unified processing of function data and the accurate positioning of the jamming problem.

[0098] In the jam location method, if the module to which the function belongs is deleted, the function name and module name of the function cannot be obtained based on the function information in the stack. The uploaded function call tree cannot locate the jammed thread and the function that causes the jam due to incomplete information. Fig. 9 As shown, it is a function call information diagram provided in an embodiment of the present application, wherein function A1 can call functions AA, BB, and CC, and function CC calls other functions. When the module is not deleted, the function name is determined based on the Dll_unload information. After the module is deleted, the function name of function CC1 cannot be confirmed, nor can its module name be confirmed.

[0099] Based on this, in an embodiment of the present application, when a module included in an application is uninstalled, the module information of the uninstalled module can be recorded, the module to which the unknown function belongs can be determined according to the function name pointer address of the unknown function in the function call tree, the module information of the module to which the unknown function belongs can be determined according to the module information of the uninstalled module, the executable file corresponding to the unknown function can be loaded according to the function name pointer address and the module information of the module to which the unknown function belongs, and the function name of the unknown function can be determined from the executable file. The module name of the unknown function can also be determined according to the executable file, or the module name of the module to which the located function belongs can be determined according to the function name pointer address of the unknown function, thereby locating the function that causes the jam.

[0100] Specifically, the module information of the unloaded module can be recorded by hooking the FreeLibrary function. The module information may include a handle, module size, module path, etc. The executable file may be, for example, a portable executable file (PE). The function address may be determined based on the function call tree, the function name pointer address may be determined based on the function address, and the function name of the unknown function may be obtained in the executable file based on the function name pointer address.

[0101] The aforementioned method for locating the jam of an application can be implemented within the process without cross-process monitoring. The jam monitoring of the application can be realized without affecting the running of the application. The method for locating the jam of an application can be implemented by using the jam locating application. The jam locating application is used as a computer manager. Fig.10 FIG. 1 is a schematic diagram of a stuttering positioning effect provided in an embodiment of the present application, wherein Fig.10 A is a schematic diagram showing the effect of locating the jams by other means on the number of jams. Fig.10 B is a schematic diagram of the effect of freeze positioning on the number of freezes achieved through the embodiment of the present application. It can be seen from the external network data of the freeze positioning application that after the freeze positioning method provided by the embodiment of the present application is used, the average number of freezes is greatly reduced, which is better than that of competing products.

[0102] Based on a method for locating a jam of an application provided in an embodiment of the present application, an embodiment of the present application also provides a device for locating a jam of an application, referring to Fig.11 As shown, it is a structural block diagram of a device for locating a jam of an application provided in an embodiment of the present application, and the recognition device 1300 includes:

[0103] A function calling unit 1301 is used to call a target function in an initial function through a target parent function in the initial function through a main thread of the application program, wherein the initial function is a function included in the application program, and the target parent function is a parent function of the target function;

[0104] A function execution unit 1302 is used to add the function information of the target function to the stack corresponding to the main thread, and execute the target function according to the function information;

[0105] The current function determination unit 1303 is used to determine the called current function after the execution of the target function is completed if the execution time of the target function meets the first preset condition;

[0106] A function call tree determining unit 1304 is configured to determine a function call tree according to the function information in the stack if the current function is a root function and the total execution time of the root function satisfies a second preset condition;

[0107] The adding unit 1305 is used to add the function call tree to the queue to be uploaded to upload the function call tree.

[0108] Optionally, the device further comprises:

[0109] A popping unit is used to move the function information of the target function out of the stack if the execution time of the target function does not meet the first preset condition; or, if the total execution time of the root function does not meet the second preset condition, move the function information in the stack out of the stack.

[0110] Optionally, the function calling unit 1301 is specifically used for:

[0111] The main thread of the application program calls the root function in the initial function by executing the monitoring function, so as to call the target function in the initial function through the target parent function in the initial function;

[0112] The device also includes:

[0113] A macro adding unit is used to add a macro for initializing a class object to the monitoring function before the main thread of the application calls the root function in the initial function by executing the monitoring function, so that the parameters of the class object are used to indicate that in the process of calling the target function through the monitoring function, the monitoring function adds the function information of the target function to the stack by calling the constructor, and the monitoring function removes the function information of the target function from the stack by calling the destructor.

[0114] Optionally, the function calling unit 1301 includes:

[0115] A function name pointer determination unit, configured to determine a function name pointer of a target function in the initial function according to a function call relationship when the main thread of the application program calls a target parent function in the initial function;

[0116] A calling unit is used to call the target function according to the function name pointer.

[0117] Optionally, the device further comprises:

[0118] A control unit, configured to move function information of other functions out of the stack after other functions in the initial function are executed, and reserve memory space used when the other functions are executed, before the main thread of the application program calls the target function in the initial function through the target parent function in the initial function;

[0119] The function calling unit 1301 is specifically used for:

[0120] When the main thread of the application program calls the target parent function, the target function in the initial function is determined according to the function calling relationship;

[0121] The function execution unit 1302 is specifically used for:

[0122] The function information of the target function is added to the stack corresponding to the main thread, and the target function is executed based on the memory space and the function information.

[0123] Optionally, the device further comprises:

[0124] A function call tree acquisition unit, configured to acquire the function call tree from the queue to be uploaded through an auxiliary thread of the application program after adding the function call tree to the queue to be uploaded;

[0125] A serialization processing unit, used for performing serialization processing on the function call tree through the auxiliary thread to obtain a serialized call tree;

[0126] An uploading unit is used to upload the serialized call tree through the auxiliary thread.

[0127] Optionally, the device further comprises:

[0128] an updating unit, configured to remove a preset function from the function call tree by the auxiliary thread according to a function list including the preset function, before the auxiliary thread performs serialization processing on the function call tree to obtain a serialized call tree, so as to obtain an updated function call tree;

[0129] The serialization processing unit is specifically used for:

[0130] The updated function call tree is serialized by the auxiliary thread to obtain a serialized call tree.

[0131] Optionally, the device further comprises:

[0132] a parameter calculation unit, configured to calculate at least one of a first parameter and a second parameter of the function call tree according to the function call tree and the execution time of the initial function in the function call tree through the auxiliary thread of the application program after adding the function call tree to the queue to be uploaded, wherein the first parameter is calculated according to all the initial functions in the function call tree, and the second parameter is calculated according to the key function in the function call tree, and the key function is an initial function whose execution time exceeds a preset proportion of the execution time of a parent function;

[0133] A parameter uploading unit is used to upload the first parameter and the second parameter through an auxiliary function of the application.

[0134] Optionally, the device further comprises:

[0135] A dotting unit, used for dotting the system function before adding the function call tree to the queue to be uploaded, so as to determine the calling time of the system function;

[0136] A system function determination unit, configured to determine the system function corresponding to the initial function in the function call tree according to the calling time of the system function and the calling time of the initial function in the function call tree;

[0137] The function name determining unit is used to determine the function name of the initial function corresponding to the system function in the function call tree as the function name of the system function.

[0138] Optionally, the device further comprises:

[0139] a parameter type determining unit, configured to determine, after determining the function call tree according to the function information in the stack, a parameter type of an initial function in the function call tree according to the function call tree;

[0140] a data format determination unit, configured to determine a data format for an initial function in the function call tree according to the parameter type;

[0141] A function data generating unit, used for generating function data according to the data format and the execution parameters of the initial function;

[0142] A data uploading unit is used to upload the function data.

[0143] Optionally, the device further comprises:

[0144] A recording unit, used for recording module information of the uninstalled module when the module included in the application is uninstalled;

[0145] A module determination unit, used for determining the module to which the unknown function belongs according to the function name pointer of the unknown function in the function call tree;

[0146] A module information determining unit, configured to determine the module information of the module to which the unknown function belongs according to the module information of the uninstalled module;

[0147] A function name determination unit is used to load the executable file corresponding to the unknown function according to the function name pointer and the module information of the module to which the unknown function belongs, and determine the function name of the unknown function from the executable file.

[0148] It can be seen from the above technical solution that in the process of the main thread of the application calling the initial function contained in the application, its child function can be called through the parent function in the initial function, that is, the target function in the initial function can be called through the target parent function in the initial function, and the function information of the target function can be added to the stack corresponding to the main thread, so as to execute the target function according to the function information in the stack. After the execution of the target function is completed, it can be determined whether to remove the function information of the target function from the stack based on the execution time of the target function. If the execution time of the target function meets the first preset condition, it means that its execution may cause the application to freeze. Then it can be determined whether the current function being called is a root function. If so, and the total execution time of the root function meets the second preset condition, it means that the root function takes a long time to call other functions. At this time, since the function information of the target function that may cause freezes has not been removed from the stack, the function call tree can be determined based on the function information in the stack. In this way, through the pop-up control of the function, the function call tree can include function call chains that may cause freezes and have a long total execution time. The execution of functions in the function call tree is more likely to cause the application to freeze. In this way, the function call tree is added to the queue to be uploaded to upload the function call tree, so as to achieve accurate positioning of the function freeze. The background can analyze the uploaded function call tree to determine the function that causes the freeze and the calling relationship of the function, which is beneficial to improving the runtime smoothness of the application.

[0149] The embodiment of the present application further provides a computer device, which is the computer device described above and may include a terminal device or a server, and the aforementioned application freeze location device may be configured in the computer device. The computer device is described below in conjunction with the accompanying drawings.

[0150] If the computer device is a terminal device, see Fig.12 As shown, the embodiment of the present application provides a terminal device, taking the terminal device as a mobile phone as an example:

[0151] Fig.12 FIG. 1 is a block diagram showing a partial structure of a mobile phone related to a terminal device provided in an embodiment of the present application. Fig.12 The mobile phone includes: a radio frequency (RF) circuit 1410, a memory 1420, an input unit 1430, a display unit 1440, a sensor 1450, an audio circuit 1460, a wireless fidelity (WiFi) module 1470, a processor 1480, and a power supply 1490. Those skilled in the art can understand that Fig.12 The mobile phone structure shown in the figure does not constitute a limitation on the mobile phone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0152] Combine the following Fig.12 A detailed introduction to the various components of the mobile phone:

[0153] The RF circuit 1410 may be used for receiving and sending signals during information transmission or communication or during a call. In particular, after receiving downlink information from a base station, the information is sent to the processor 1480 for processing. In addition, the uplink data is sent to the base station.

[0154] The memory 1420 can be used to store software programs and modules. The processor 1480 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 1420. The memory 1420 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 1420 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0155] The input unit 1430 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the mobile phone. Specifically, the input unit 1430 may include a touch panel 1431 and other input devices 1432 .

[0156] The display unit 1440 may be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 1440 may include a display panel 1441.

[0157] The mobile phone may also include at least one sensor 1450, such as a light sensor, a motion sensor, and other sensors.

[0158] The audio circuit 1460 , the speaker 1461 , and the microphone 1462 can provide an audio interface between the user and the mobile phone.

[0159] WiFi is a short-range wireless transmission technology. The mobile phone can help users send and receive emails, browse web pages and access streaming media through the WiFi module 1470. It provides users with wireless broadband Internet access.

[0160] Processor 1480 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. It executes various functions of the mobile phone and processes data by running or executing software programs and / or modules stored in memory 1420 and calling data stored in memory 1420.

[0161] The mobile phone also includes a power source 1490 (such as a battery) for supplying power to various components.

[0162] In this embodiment, the processor 1480 included in the terminal device also has the following functions:

[0163] The main thread of the application calls the target function in the initial function through the target parent function in the initial function, the initial function is a function included in the application, and the target parent function is the parent function of the target function;

[0164] Adding function information of the target function to the stack corresponding to the main thread, and executing the target function according to the function information;

[0165] After the execution of the target function is completed, if the execution time of the target function meets the first preset condition, determining the current function being called;

[0166] If the current function is a root function, and the total execution time of the root function meets a second preset condition, determining a function call tree according to the function information in the stack;

[0167] The function call tree is added to a queue to be uploaded to upload the function call tree.

[0168] If the computer device is a server, the present application embodiment also provides a server, see Fig.13 As shown, Fig.13 The structural diagram of the server 1500 provided in the embodiment of the present application, the server 1500 may have relatively large differences due to different configurations or performances, and may include one or more processors 1522, such as a central processing unit (CPU), a memory 1532, and one or more storage media 1530 (e.g., one or more mass storage devices) storing application programs 1542 or data 1544. Among them, the memory 1532 and the storage medium 1530 can be short-term storage or permanent storage. The program stored in the storage medium 1530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server. Furthermore, the processor 1522 can be configured to communicate with the storage medium 1530 and execute a series of instruction operations in the storage medium 1530 on the server 1500.

[0169] The server 1500 may also include one or more power supplies 1526, one or more wired or wireless network interfaces 1550, one or more input and output interfaces 1558, and / or one or more operating systems 1541, such as Windows Server 2003 or Windows Server 2008. TM, Mac OS X TM , Unix TM ,Linux TM , FreeBSD TM etc.

[0170] The steps performed by the server in the above embodiment can be based on Fig.13 The server structure shown.

[0171] In addition, an embodiment of the present application further provides a storage medium, wherein the storage medium is used to store a computer program, and the computer program is used to execute the method provided in the above embodiment.

[0172] The embodiments of the present application also provide a computer program product including instructions, which, when executed on a computer, enables the computer to execute the method provided in the above embodiments.

[0173] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium can be at least one of the following media: read-only memory (English: Read-only Memory, abbreviated: ROM), RAM, magnetic disk or optical disk, etc. Various media that can store program codes.

[0174] It should be noted that each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, in which the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.

[0175] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a technician familiar with the technical field within the technical scope disclosed in the present application should be included in the protection scope of the present application. Moreover, based on the implementation methods provided in the above aspects, the present application can also be further combined to provide more implementation methods. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for locating a jam in an application, characterized in that: The method comprises: The main thread of the application calls the target function in the initial function through the target parent function in the initial function, the initial function is a function included in the application, and the target parent function is the parent function of the target function; Adding function information of the target function to the stack corresponding to the main thread, and executing the target function according to the function information; After the execution of the target function is completed, if the execution time of the target function meets the first preset condition, determining the current function being called; If the current function is a root function, and the total execution time of the root function meets a second preset condition, determining a function call tree according to the function information in the stack; The function call tree is added to a queue to be uploaded to upload the function call tree.

2. The method according to claim 1, characterized in that The method further comprises: If the execution time of the target function does not meet the first preset condition, the function information of the target function is removed from the stack; Or, if the total execution time of the root function does not meet the second preset condition, the function information in the stack is moved out of the stack.

3. The method according to claim 1, characterized in that The main thread of the application program calls the target function in the initial function through the target parent function in the initial function, including: The main thread of the application program calls the root function in the initial function by executing the monitoring function, so as to call the target function in the initial function through the target parent function in the initial function; Before the main thread of the application program calls the root function in the initial function by executing the monitoring function, the method further includes: A macro for initializing a class object is added to the monitoring function, so that the parameters of the class object are used to indicate that in the process of calling the target function through the monitoring function, the monitoring function adds the function information of the target function to the stack by calling the constructor, and the monitoring function removes the function information of the target function from the stack by calling the destructor.

4. The method according to claim 1, characterized in that: The main thread of the application program calls the target function in the initial function through the target parent function in the initial function, including: When the main thread of the application program calls the target parent function in the initial function, determining the function name pointer of the target function in the initial function according to the function calling relationship; The target function is called according to the function name pointer.

5. The method according to claim 1, characterized in that Before the main thread of the application program calls the target function in the initial function through the target parent function in the initial function, the method further includes: After the execution of other functions in the initial function is completed, the function information of the other functions is removed from the stack, and the memory space used when the other functions are executed is reserved; The main thread of the application program calls the target function in the initial function through the target parent function in the initial function, including: When the main thread of the application program calls the target parent function, determining the target function in the initial function according to the function calling relationship; The executing the target function according to the function information comprises: The target function is executed based on the memory space and the function information.

6. The method according to any one of claims 1 to 5, characterized in that: After adding the function call tree to the queue to be uploaded, the method further includes: The auxiliary thread of the application program obtains the function call tree from the queue to be uploaded; The auxiliary thread performs serialization processing on the function call tree to obtain a serialized call tree; The auxiliary thread uploads the serialized call tree.

7. The method according to claim 6, characterized in that Before the auxiliary thread performs serialization processing on the function call tree to obtain a serialized call tree, the method further includes: The auxiliary thread removes the preset function from the function call tree according to the function list including the preset function, so as to obtain an updated function call tree; The auxiliary thread serializes the function call tree to obtain a serialized call tree, including: The auxiliary thread performs serialization processing on the updated function call tree to obtain a serialized call tree.

8. The method according to any one of claims 1 to 5, characterized in that: After adding the function call tree to the queue to be uploaded, the method further includes: The auxiliary thread of the application calculates at least one of a first parameter and a second parameter of the function call tree according to the function call tree and the execution time of the initial function in the function call tree, wherein the first parameter is calculated according to all the initial functions in the function call tree, and the second parameter is calculated according to the key function in the function call tree, wherein the key function is an initial function whose execution time exceeds a preset proportion of the execution time of the parent function; The auxiliary function of the application uploads the first parameter and the second parameter.

9. The method according to any one of claims 1 to 5, characterized in that: Before adding the function call tree to the queue to be uploaded, the method further includes: Marking a system function to determine the calling time of the system function; Determine the system function corresponding to the initial function in the function call tree according to the calling time of the system function and the calling time of the initial function in the function call tree; The function name of the initial function corresponding to the system function in the function call tree is determined as the function name of the system function.

10. The method according to any one of claims 1 to 5, characterized in that: After determining the function call tree according to the function information in the stack, the method further includes: Determine, according to the function call tree, a parameter type of an initial function in the function call tree; Determining a data format for an initial function in the function call tree according to the parameter type; Generate function data according to the data format and the execution parameters of the initial function; Upload the function data.

11. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: When a module included in an application is uninstalled, the module information of the uninstalled module is recorded; Determine the module to which the unknown function belongs according to the function name pointer of the unknown function in the function call tree; Determine the module information of the module to which the unknown function belongs according to the module information of the uninstalled module; According to the function name pointer and the module information of the module to which the unknown function belongs, the executable file corresponding to the unknown function is loaded, and the function name of the unknown function is determined from the executable file.

12. A device for locating a stuck application, characterized in that: The device comprises: A function calling unit, used to call a target function in an initial function through a target parent function in the initial function through a main thread of the application, wherein the initial function is a function included in the application, and the target parent function is a parent function of the target function; A function execution unit, used to add function information of the target function to a stack corresponding to the main thread, and execute the target function according to the function information; A current function determination unit, configured to determine a current function to be called after the execution of the target function is completed if the execution time of the target function satisfies a first preset condition; a function call tree determining unit, configured to determine a function call tree according to the function information in the stack if the current function is a root function and the total execution time of the root function satisfies a second preset condition; The adding unit is used to add the function call tree to the queue to be uploaded so as to upload the function call tree.

13. A computer device, characterized in that: The computer device comprises a processor and a memory: The memory is used to store a computer program and transmit the computer program to the processor; The processor is used to execute the jamming location method of the application program described in any one of claims 1-11 according to the instructions in the computer program.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method for locating a jam in an application program as described in any one of claims 1-11.

15. A computer program product comprising a computer program, characterized in that When it is run on a computer device, the computer device executes the method for locating the jamming of an application program as described in any one of claims 1-11.