Stack information processing method, device, electronic device and storage medium

By loading the hook function in the target information sending function, monitoring and updating the crash stack, the problem of cumbersome crash cause analysis in the existing technology is solved, and the rapid positioning of crash causes without the need for dSYM files and symbolic tools is achieved, which improves development efficiency.

CN113535143BActive Publication Date: 2025-02-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010320627.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-21
Publication Date
2025-02-25
Estimated Expiration
2040-04-21

AI Technical Summary

Technical Problem

When handling application crashes, the existing technology requires developers to manually operate and rely on dSYM files and symbolic tools. The steps are cumbersome and affect development efficiency.

Method used

By preloading the hook function in the target information sending function, monitoring and obtaining the function call information in the function call event, and updating the crash stack, the symbolized stack information is obtained based on the crash stack when the application runs a crash stack.

Benefits of technology

No need to rely on dSYM files and symbolization tools, simplifying the crash cause analysis process and improving software development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113535143B_ABST
    Figure CN113535143B_ABST
Patent Text Reader

Abstract

The present application relates to a stack information processing method, device, electronic device and storage medium. By pre-loading a hook function in a target information sending function, the function call information of an application when a function call event is performed can be obtained, and the crash stack can be updated. When a problem occurs in the function call, causing the application to crash, the symbolized stack information can be obtained based on the function call information saved in the crash stack. Since the symbolized stack information includes the function call information corresponding to the ongoing function call event, and the ongoing function call event causes the application to crash, the developer can directly determine the specific cause of the application crash based on the symbolized stack information without relying on dSYM files and symbolization tools, etc., thereby helping to improve software development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the improvement of science and technology, various types of applications (Application, APP) have emerged. APP is widely used in user's device terminals, such as mobile phones, tablets, etc. After the developer completes the development of the APP, the APP will be released to the Internet, and users can download and use it by themselves. When users use the APP, the application may report an error, the corresponding process may disappear, or the corresponding service may stop automatically, that is, the APP may crash.

[0003] When an APP crashes, developers need to determine the cause of the APP crash. In the prior art, developers usually first obtain the dSYM file generated when compiling the APP, then use a symbolization tool to perform symbolization processing based on the dSYM file, and then perform analysis based on the result of the symbolization processing to determine the cause of the crash.

[0004] However, the above processing process in the prior art requires manual operation by developers and requires the use of other files and tools, and the steps are cumbersome, thereby affecting development efficiency. Summary of the invention

[0005] Based on this, it is necessary to provide a stack information processing method, device, electronic device and storage medium that can help improve development efficiency in response to the above technical problems.

[0006] A stack information processing method, the method comprising:

[0007] When a function call event is detected by the application through the target information sending function, a hook function pre-loaded in the target information sending function is executed;

[0008] Obtaining, through the hook function, function call information in the function call event, wherein the function call information includes function related information of the called function;

[0009] Update the crash stack according to the function related information in the function call information;

[0010] When the application crashes, symbolic stack information is obtained based on the crash stack.

[0011] A stack information processing device, the device comprising:

[0012] A hook execution module, for executing a hook function preloaded in the target information sending function when detecting that the application program performs a function call event through the target information sending function;

[0013] An information acquisition module, used to acquire function call information in the function call event through the hook function, wherein the function call information includes function related information of the called function;

[0014] A stack update module, used for updating the crash stack according to the function related information in the function call information;

[0015] The information processing module is used to obtain symbolic stack information based on the crash stack when the application crashes.

[0016] An electronic device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0017] When a function call event is detected by the application through the target information sending function, a hook function pre-loaded in the target information sending function is executed;

[0018] Obtaining, through the hook function, function call information in the function call event, wherein the function call information includes function related information of the called function;

[0019] Update the crash stack according to the function related information in the function call information;

[0020] When the application crashes, symbolic stack information is obtained based on the crash stack.

[0021] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0022] When a function call event is detected by the application through the target information sending function, a hook function pre-loaded in the target information sending function is executed;

[0023] Obtaining, through the hook function, function call information in the function call event, wherein the function call information includes function related information of the called function;

[0024] Update the crash stack according to the function related information in the function call information;

[0025] When the application crashes, symbolic stack information is obtained based on the crash stack.

[0026] The stack information processing method, device, electronic device and storage medium described above, when monitoring an application program to make a function call event through a target information sending function, execute a hook function pre-loaded in the target information sending function; obtain function call information in the function call event through the hook function, the function call information includes function-related information of the called function; update the crash stack according to the function-related information in the function call information; and obtain symbolic stack information based on the crash stack when the application program crashes.

[0027] In the present application, by loading a hook function in the target information sending function in advance, the function call information of the application when a function call event is performed can be obtained, and the crash stack can be updated. When a problem occurs in the function call, causing the application to crash, the symbolic stack information can be obtained based on the function call information saved in the crash stack. Since the symbolic stack information includes the function call information corresponding to the ongoing function call event, and the ongoing function call event causes the application to crash, the developer can directly determine the specific cause of the application crash based on the symbolic stack information without relying on dSYM files and symbolic tools, etc., which helps to improve software development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 A schematic diagram of a flow chart of a stack information processing method in one embodiment;

[0029] Figure 2 is a diagram showing an example of unsymbolized stack information in one embodiment;

[0030] Figure 3 is a diagram showing an example of symbolized stack information in another embodiment;

[0031] Figure 4 A schematic diagram of a crash stack storing function-related information in one embodiment;

[0032] Figure 5 A schematic diagram of deleting function-related information in a crash stack in one embodiment;

[0033] Figure 6 A schematic diagram of a process of obtaining symbolized stack information based on a crash stack in one embodiment;

[0034] Figure 7 is a flowchart of a stack information processing method in another embodiment;

[0035] Figure 8 A schematic diagram of a screen interface showing symbolized stack information in one embodiment;

[0036] FIG9( a) is a schematic diagram of a function call flow in the prior art in one embodiment;

[0037] FIG9( b ) is a schematic diagram of a function call flow in the present application in one embodiment;

[0038] Fig.10 A schematic diagram of content management of a crash stack during a function call in one embodiment;

[0039] Fig.11 A schematic diagram of the structure of a stack information processing device in one embodiment;

[0040] Fig.12 is a schematic diagram of the structure of a stack information processing device in another embodiment;

[0041] Fig.13 FIG. 4 is a diagram showing the internal structure of an electronic device in one embodiment. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0043] First, the professional terms involved in this application are explained.

[0044] 1. Crash stack: A data structure used to record the current function call information when the app crashes.

[0045] 2. Symbolization: Before symbolization, the stack content is memory address information. Symbolization refers to converting memory address information into symbols that developers can understand.

[0046] 2. Target information sending function: used to call functions to pass messages during the running of the application. Schematically, for the APP of the IOS system, the target information sending function can be the objc_msgSend function. The format of the objc_msgSend function when passing a message is: objc_msgSend(id self, SEL cmd, ...). The objc_msgSend function is a function with a variable number of parameters, which can receive two or more parameters. The first parameter "id self" indicates the recipient of the message; the second parameter "SEL cmd" indicates the type of selector; subsequent parameters can be parameters in the message. Among them, the selector refers to the name of the function called by the objc_msgSend function. Of course, the selector can also be called a method, etc. This embodiment does not limit the naming method of the selector.

[0047] The target message sending function will call the appropriate function according to the type of the receiver and the selector when passing the message. To complete this operation, the target message sending function needs to search the "list of methods" in the class to which the receiver belongs. If a function matching the selector name is found, it will jump to its implementation code. If it cannot be found, it will continue to search upward along the inheritance hierarchy and jump after finding the appropriate function. If it still cannot find a matching function, it will perform the "message forwarding" operation.

[0048] 3. Hook function: It is a program for processing system messages. Through system calls, the hook function can be hung into the system's application. The hook function allows the program to intercept system messages or specific events. There are many types of hooks, and each hook can intercept and process corresponding messages, such as keyboard hooks can intercept keyboard messages, mouse hooks can intercept mouse messages, shell hooks can intercept messages for starting and closing applications, and log hooks can monitor and record input events. In this application, the hook function can intercept the function call event performed by the target information sending function in the system, that is, it can obtain function call information.

[0049] 4. Objective-C: Objective-C, used in iOS application development, is a dynamic language that provides class definitions, methods, and properties. There is no concept of object calling methods in this language. Instead, various functions are implemented by sending corresponding information to various object methods. Among them, all operations of sending corresponding information to various object methods are implemented through the target information sending (such as objc-msgSend) function. Therefore, in iOS system application development, you only need to hook the target information sending function to intercept all function call information of the application.

[0050] 5. Thread: It is the smallest unit that the operating system can schedule operations on. It is contained in the process and is the actual operation unit in the process. A single thread corresponds to a single sequential control flow.

[0051] In one embodiment, Figure 1 As shown, a stack information processing method is provided, and the method is explained by taking the application of the method to a processor in a device terminal that can perform stack information processing as an example. The method mainly includes the following steps:

[0052] Step S100, when it is detected that the application program performs a function call event through the target information sending function, the hook function pre-loaded in the target information sending function is executed.

[0053] An application program refers to a software program installed in a device terminal and used to implement one or more functions. The device terminal includes various mobile terminals installed with iOS, Android and other systems. Various running applications in the mobile terminal are written in corresponding programming languages. For example, in mobile terminals produced by Apple (for example, iPhone series of mobile phones), the running applications are generally written in objective_c language. Objective_c language is an object-oriented language. There is no concept of object calling method in this language, but various functions are realized by sending corresponding information to each object method. Among them, all operations of sending corresponding information to each object method are realized through the target information sending (objc_msgSend) function. Therefore, for applications of the iOS system, when realizing the corresponding functions, it is necessary to use the target information sending (objc_msgSend) function to perform function call events.

[0054] In this step, the target information sending function is preloaded with a hook function, and specifically, after the application is successfully started, the hook is installed in the target information sending function. By installing the hook in the target information sending function, the processor can monitor various message transmissions performed by the target information sending function in the system. When the application is monitored to perform a function call event through the target information sending function, it indicates that the application has started to run, and the function of the hook function can be executed at this time.

[0055] It should be noted that for iOS system applications, when a function call event is made, the application does not directly make a function call, but sends the information of the function to be called to the target information sending (objc_msgSend) function, and then executes the function to be called through the target information sending (objc_msgSend) function. In this step, monitoring the application to make a function call event through the target information sending function can specifically refer to monitoring the application sending the information of the function to be called to the target information sending function, that is, when monitoring the application requesting to call a function, the hook function is executed to intercept the function call request sent by the application.

[0056] Step S200, obtaining function call information in a function call event through a hook function, where the function call information includes function related information of the called function.

[0057] When an application performs a function call event, the application does not directly call the function of the corresponding function, but sends the relevant parameters of the function call event to the target information sending function, and then the target information sending function calls the corresponding function according to the relevant parameters.

[0058] Since the hook function is pre-loaded in the target information sending function, when the application sends the relevant parameters of the function call event to the target information sending function, the hook function can intercept the relevant parameters of the function call event to obtain the function call information, wherein the function call information includes the function related information of the called function.

[0059] Step S300: updating the crash stack according to the function related information in the function call information.

[0060] After the processor obtains the function call information of the function call event through the hook function, it updates the contents of the crash stack based on the function related information in the obtained function call information to ensure that the crash stack records the current function call information of the application in real time, and the current function call information contains function related information of the currently called function.

[0061] Step S400: when the application crashes, symbolized stack information is obtained based on the crash stack.

[0062] The application crash specifically refers to situations such as application error reporting, corresponding process disappearance, or corresponding service automatic stop. In the prior art, when an application crashes, although a corresponding stack is saved, the information contained in the stack is not symbolized, and developers cannot obtain valid information from the stack. Figure 2 As shown, it is an example diagram of unsymbolized stack information, which contains relevant information of memory calls. Developers cannot identify the cause of the application crash based on the relevant information of the memory calls.

[0063] In this implementation, when an application crashes, since the crash stack stores the current function call information of the application, the processor can obtain function-related information of the called function in the function call event of the application based on the crash stack, that is, obtain symbolic stack information. Based on the symbolic stack information, the developer can directly identify the cause of the application crash, and thus can develop and improve the application. For example, Figure 3 As shown, it is an example diagram of symbolized stack information, and the symbolized stack information includes function-related information of the called function, so that the developer can determine the cause of the crash based on the function-related information of the called function.

[0064] In this embodiment, by loading the hook function in the target information sending function in advance, the function call information of the application when the function call event is performed can be obtained, and the crash stack can be updated. When a problem occurs in the function call, causing the application to crash, the symbolic stack information can be obtained based on the function call information saved in the crash stack. Since the symbolic stack information includes the function call information corresponding to the ongoing function call event, and the ongoing function call event caused the application to crash, the developer can directly determine the specific cause of the application crash based on the symbolic stack information without relying on dSYM files and symbolization tools, etc., which helps to improve software development efficiency.

[0065] In one embodiment, updating the crash stack according to the function related information in the function call information includes: when a new function call event is performed, saving the function related information of the first function to the crash stack.

[0066] The first function is a function called by the target information sending function in a new function call event. When the application performs a new function call event through the target information sending function, the processor obtains function-related information of the first function through the hook function, and saves the function-related information of the first function to the crash stack. Specifically, when the application sends a request to call the first function to the target information sending function, the processor intercepts the function call request through the hook function, saves the function-related information of the first function, and then the target information sending function executes the first function.

[0067] When saving function-related information to the crash stack, the newly stored information is saved at the top of the stack. For example, Figure 4 As shown, it is a schematic diagram of saving function-related information in the crash stack. For the initial crash stack (i.e., a stack without saved information), when storing function-related information Info_1 of the function called in the first function call event, Info_1 is saved at the top of the crash stack. When storing function-related information Info_2 of the function called in the second function call event, Info_2 is saved again at the top of the crash stack, and Info_1 is saved in the next column of Info_2. The principle of storing other function-related information is the same as that of Info_1 and Info_2, which will not be repeated here.

[0068] Optionally, the function-related information includes the class name and function name corresponding to the function. The class name can be understood as a set of functions, and the function name can be understood as a specific function. For example, when the class name is "operation", the function name can be "addition, subtraction, multiplication and division"; when the class name is "image processing", the function name can be "convolution, pooling, dilated convolution", etc. The function-related information can be obtained through the relevant parameters of the function call event intercepted by the hook function.

[0069] Different classes usually contain multiple functions, and different classes may have the same function name. For example, both class names Name_1 and Name_2 contain function Func_A. In addition, class name Name_1 also contains function Func_B, and class name Name_2 also contains function Func_C. In the symbolized stack information, if the function-related information only contains the class name, such as Name_1, the developer cannot determine whether the problem occurs in function Func_A or function Func_B; if the function-related information only contains the function name, such as Func_A, the developer cannot determine whether the problem occurs in function Func_A in Name_1 or function Func_A in Name_2.

[0070] Therefore, in this implementation, function-related information includes both the class name and function name corresponding to the function. Developers can accurately determine which function has a problem, thereby quickly locating the cause of the program crash and facilitating subsequent application optimization and development processing.

[0071] Optionally, before saving the function-related information of the first function to the crash stack, the method further includes: if the crash stack does not exist, creating a crash stack for saving the function-related information. Thus, by creating a crash stack, it is convenient to save the function-related information.

[0072] In one embodiment, updating the crash stack according to the function related information in the function call information includes: after the function call event is completed, deleting the function related information of the second function from the crash stack.

[0073] The second function is a function called by the target information sending function in the completed function call event. Since the crash stack stores the function-related information of the called function in the ongoing function call event, the function that has been called needs to be deleted from the crash stack after the function call event is completed. Specifically, after a single function is called, the target information sending function stops calling the single function. At this time, the function-related information of the single function can be deleted from the crash stack.

[0074] Specifically, Figure 5As shown, it is a schematic diagram of deleting function-related information in the crash stack. For the initial crash stack (i.e., a stack storing information related to i functions), after the i-th function call event is completed, the function-related information Info_i at the top of the stack is deleted from the crash stack. At this time, the function-related information at the top of the stack is Info_i-1; after the i-1-th function call event is completed, the function-related information Info_i-1 at the top of the stack is deleted from the crash stack. At this time, the function-related information at the top of the stack is Info_i-2. The principles for deleting other function-related information are the same as those for Info_i and Info_i-1, and will not be repeated here.

[0075] In one embodiment, when the application corresponds to only a single thread, based on the correspondence between the single thread and the single crash stack, the application also corresponds to only a single crash stack. A single thread corresponds to a single sequential control flow, so symbolized stack information can be obtained based on the single crash stack corresponding to the single thread.

[0076] In one embodiment, the application may have multiple threads executing concurrently, that is, during the running of the application, there are at least two threads, each thread executing different tasks in parallel. Figure 6 As shown, when the application crashes, if the number of threads corresponding to the application is at least two, symbolic stack information is obtained based on the crash stack, including steps S420 to S440.

[0077] Step S420, determining a problem thread among the at least two threads, where the problem thread is a thread that causes the application to crash;

[0078] Step S440: obtaining symbolic stack information based on the crash stack corresponding to the problem thread, wherein the symbolic stack information includes function-related information of the called function in the ongoing function call event corresponding to the problem thread.

[0079] Specifically, in the case of concurrent execution of multiple threads, when the application crashes, the system will automatically output a prompt message indicating which thread has a problem. Therefore, this embodiment can determine the problem thread in the multiple threads based on the system information, that is, determine the thread that caused the application to crash based on the system prompt message. It can be understood that in actual applications, the problem thread can also be determined by other methods, which are not limited here.

[0080] After the problem thread is determined, symbolic stack information can be obtained based on the crash stack corresponding to the problem thread. The symbolic stack information includes function-related information of the called function in the ongoing function call event corresponding to the problem thread. Therefore, the developer can determine the cause of the program crash based on the function-related information corresponding to the problem thread.

[0081] In one embodiment, Figure 7 As shown, the stack information processing method further includes step S510: outputting symbolic stack information.

[0082] After obtaining the symbolic stack information, the processor may output the symbolic stack information, so that the developer may determine the cause of the program crash based on the output information.

[0083] Specifically, the output of the symbolic stack information may be implemented in a display manner. Figure 8 As shown, after the application crashes, when the user opens the application again, the symbolized stack information can be displayed on the terminal screen, and the user can directly show the screen showing the symbolized stack information to the developer for review. Alternatively, the user can also take a screenshot or copy and send the symbolized stack information to the developer.

[0084] In addition, the output of symbolized stack information can be implemented by data transmission. For example, after the application crashes, the processor obtains symbolized stack information through the stack information processing method of the present application, and then automatically sends the symbolized stack information to a preset target terminal or target server, etc., so that the user does not need to perform any operation, and the developer can obtain the symbolized stack information through the target terminal or target server.

[0085] This embodiment outputs symbolic stack information, which can help developers quickly locate the cause of program crash based on the symbolic stack information, thereby improving development efficiency.

[0086] In one embodiment, reference Figure 7 The stack information processing method further includes step S520: outputting function-related information of a problem function corresponding to the application, wherein the problem function is a function that causes the application to crash, and the problem function is determined based on the symbolized stack information.

[0087] Specifically, when an application crashes, the crash may be caused by the following reasons:

[0088] (1) The function at the top of the stack is a system function. The function at the top of the stack is the function most recently called by the application. When the function is a system function, the application crash is usually caused by a problem with the call to the system function. In this case, it can be considered that the function at the next level below the top of the stack called the system function, causing the application crash. In this case, the problem function may include the system function and other functions at the next level below the top of the stack. For example, refer to Figure 3, the function in the second line of the figure is a system function (functions starting with NS are system functions), so it can be considered that there is a problem with the function in the third line calling the system function. The class name of the function in the third line is ReadInJoyAdInfo, and the function name is getReportInfoWithFeedbackTag.

[0089] (2) The function at the top of the stack is a non-system function. In this case, the cause of the application crash may be caused by the function at the top of the stack, that is, the non-system function is a problem function.

[0090] In addition, the crash of the application may also be caused by a call problem of the non-system function. That is, the problem function may also be other functions that include the non-system function and are located at the next layer of the top position of the stack.

[0091] It can be understood that in practical applications, the methods for determining the problem function are not limited to the above two methods, and the problem function may also be determined by other determination methods, which are not limited here.

[0092] After determining the cause of the crash, the processor may output function-related information of the problematic function by display, data transmission, or the like.

[0093] In this embodiment, by determining the problem function based on the symbolic stack information and then outputting the function-related information of the problem function, the developer does not need to manually locate the cause of the crash, thereby further improving the development efficiency of the developer.

[0094] In one embodiment, reference Figure 7 The stack information processing method further includes step S530: outputting symbolic stack information and function-related information of the problem function corresponding to the application.

[0095] In this embodiment, the processor can achieve the purpose of outputting symbolic stack information and outputting function-related information of the problem function by display, data transmission, etc., and the output methods of different information can be the same or different. Therefore, by outputting function-related information of the problem function, it can help improve the development efficiency of developers. By outputting symbolic stack information, developers can also verify the problem function, thereby ensuring the accuracy of the cause of the program crash.

[0096] In one embodiment, an application example of the stack information processing method of the present application is provided, and the application example mainly includes the following processing flow:

[0097] (1) An APP is installed on the user's iOS device. After the user successfully launches the APP, the processor installs a hook function in the target message sending (objc_msgSend) function.

[0098] (2) When it is detected that the APP performs a function call event through the target information sending function (sends a function call request to the target information sending function), the hook function in the target information sending function is executed to obtain the function call information in the function call event, and the function call information includes function-related information of the called function.

[0099] (3) defining a first management function before_objc_msgSend, the first management function being used to create a crash stack for storing function-related information when a crash stack does not exist; and to save function-related information of a first function to the crash stack when a crash stack exists, wherein the first function is a function called by the target information sending function in a newly performed function call event;

[0100] A second management function after_objc_msgSend is defined. The second management function is used to delete function-related information of a second function from the crash stack after the function call event is completed. The second function is the function called by the target information sending function in the completed function call event.

[0101] After obtaining the function call information, if there is no crash stack, a new crash stack is created through the first management function before_objc_msgSend, and the function-related information of the first function is saved to the crash stack; if there is a crash stack, the function-related information of the first function is directly saved to the crash stack through the first management function before_objc_msgSend. The newly stored function-related information is saved at the top of the crash stack.

[0102] (4) Call the function through the target message sending (objc_msgSend) function.

[0103] (5) After the function call is completed, if the program runs normally, the function-related information of the second function in the crash stack is deleted through the second management function after_objc_msgSend; if the application crashes, the crash stack still saves the function-related information.

[0104] As shown in FIG. 9( a ) and FIG. 9( b ), taking the calling of a function with a class name of SFeedsView and a function name of playAnimation as an example, they are schematic diagrams of the function calling process in the prior art and the present application, respectively.

[0105] Referring to FIG. 9(a), in the prior art, after the APP sends a request to call the function [SFeedsView playAnimation] to the target information sending (objc_msgSend) function, the function objc_msgSend directly calls the execution function [SFeedsView playAnimation] until the function call is completed. In this process, if the program crashes, the developer cannot know that the program crashed due to calling the function [SFeedsView playAnimation].

[0106] Referring to Figure 9(b), in the technical solution of the present application, after the APP sends a request to call the function [SFeedsView playAnimation] to the target information sending (objc_msgSend) function, the processor intercepts the function call information (function call request) through the hook function. Before the function objc_msgSend makes a function call, the processor adds function-related information to the crash stack through the first management function before_objc_msgSend. Then, the function objc_msgSend calls the execution function [SFeedsView playAnimation]. After the call is completed, the processor deletes the function-related information of the function [SFeedsView playAnimation] from the crash stack through the second management function after_objc_msgSend, and the function call is completed.

[0107] In addition, if the function [SFeedsView playAnimation] is called and causes the application to crash, at this time, since the function-related information of the function [SFeedsView playAnimation] is still saved in the crash stack, the processor can obtain symbolic stack information based on the crash stack. Therefore, the developer can determine that the program crash was caused by calling the function [SFeedsView playAnimation] based on the symbolic stack information.

[0108] (6) After the application crashes, if the application is running in a single thread, symbolic stack information is obtained based on the crash stack corresponding to the single thread.

[0109] If the application is executed in multiple threads concurrently, the problem thread in the multiple threads is first determined, and then symbolized stack information is obtained based on the crash stack corresponding to the problem thread.

[0110] (7) Outputting symbolic stack information and / or outputting function-related information of the problem function corresponding to the application program. Thus, the application developer can determine the cause of the program crash based on the output information and conduct subsequent development research.

[0111] In one embodiment, management of the contents of a crash stack is accounted for.

[0112] The following is a specific code example of function calling. In this embodiment, the called functions include function one, function two, and function three, each of which has a class name of Test.

[0113]

[0114] like Fig.10 As shown, when the APP needs to call the function [Test one], the APP first sends a request to call the function [Test one]. At this time, the processor obtains the function call information (i.e., the request to call the function [Test one]) through the hook function, and then stores the function-related information of the function [Test one] into the crash stack through the first management function before_objc_msgSend (if the crash stack does not exist, create a new one and then store it). At this time, the function at the top of the crash stack is the function [Test one].

[0115] Then, the function objc_msgSend calls the function [Test one], that is, the function [Test one] is executed through the function objc_msgSend. In this process, the function [Test two] needs to be further called, and the function-related information of the function [Test two] is stored in the crash stack through the first management function before_objc_msgSend. At this time, the function at the top of the crash stack becomes the function [Test two], and the function [Test one] is located at the next layer of the function [Test two].

[0116] Then, the function objc_msgSend calls the function [Test two], that is, the function [Test two] is executed through the function objc_msgSend. In this process, the function [Test three] needs to be further called, and the function-related information of the function [Test three] is stored in the crash stack through the first management function before_objc_msgSend. At this time, the function at the top of the crash stack becomes the function [Test three], the function [Test two] is located at the next level of the function [Test three], and the function [Test one] is located at the next level of the function [Test two].

[0117] Then, the function objc_msgSend calls the function [Test three], that is, the function [Test three] is executed through the function objc_msgSend.

[0118] If the function [Test three] is called normally, the function-related information of function [Test three] is deleted from the crash stack through the second management function after_objc_msgSend. At this time, the function at the top of the crash stack becomes function [Test two], and function [Test one] is located at the next layer of function [Test two].

[0119] After the call of function [Test three] is completed, if the call of function [Test two] is normal, the function-related information of function [Test two] is deleted from the crash stack through the second management function after_objc_msgSend. At this time, the function at the top of the crash stack becomes function [Test one].

[0120] After the function [Test two] is called, if the function [Test one] is called normally, the function related information of the function [Test one] is deleted from the crash stack through the second management function after_objc_msgSend. At this time, the content in the crash stack is empty.

[0121] During the function call process, for example, when the function objc_msgSend calls the function [Test three], if an exception occurs and causes the application to crash, the crash stack will store information related to the functions [Test three], [Test two], and [Test one], and the function [Test three] is at the top of the stack. Based on the crash stack, the symbolic stack information containing the above three functions can be obtained, so that the developer can quickly locate the cause of the crash based on the symbolic stack information.

[0122] It should be understood under reasonable conditions that although the various steps in the flowcharts involved in the foregoing embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in each flowchart may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0123] In one embodiment, Fig.11 As shown, a stack information processing device is provided, which mainly includes the following modules:

[0124] The hook execution module 100 is used to execute the hook function pre-loaded in the target information sending function when detecting that the application program performs a function call event through the target information sending function;

[0125] The information acquisition module 200 is used to acquire the function call information in the function call event through the hook function, and the function call information includes function related information of the called function;

[0126] The stack update module 300 is used to update the crash stack according to the function related information in the function call information;

[0127] The information processing module 400 is used to obtain symbolic stack information based on the crash stack when the application crashes.

[0128] In the present application, by loading a hook function in the target information sending function in advance, the function call information of the application when a function call event is performed can be obtained, and the crash stack can be updated. When a problem occurs in the function call, causing the application to crash, the symbolic stack information can be obtained based on the function call information saved in the crash stack. Since the symbolic stack information includes the function call information corresponding to the ongoing function call event, and the ongoing function call event causes the application to crash, the developer can directly determine the specific cause of the application crash based on the symbolic stack information without relying on dSYM files and symbolic tools, etc., which helps to improve software development efficiency.

[0129] In one embodiment, the stack update module 300 includes an information storage unit; the information storage unit is used to save function-related information of a first function to the crash stack when a new function call event is performed, wherein the first function is the function called by the target information sending function in the new function call event.

[0130] In one embodiment, the stack update module 300 further includes a stack creation unit: the stack creation unit is used to create a crash stack for storing function related information when a crash stack does not exist.

[0131] In one embodiment, the stack update module 300 also includes an information deletion unit; the information deletion unit is used to delete function-related information of a second function from the crash stack after a function call event is completed, wherein the second function is a function called by the target information sending function in the completed function call event.

[0132] In one embodiment, the information processing module 400 also includes a problem thread determination unit and a stack information symbolization unit; the problem thread determination unit is used to determine a problem thread among at least two threads, wherein the problem thread is a thread that causes the application to crash; the stack information symbolization unit is used to obtain symbolized stack information based on the crash stack corresponding to the problem thread, wherein the symbolized stack information includes function-related information of the called function in the ongoing function call event corresponding to the problem thread.

[0133] In one embodiment, Fig.12 As shown, the stack information processing device also includes: an information output module 500, used to output the symbolized stack information; and / or output function-related information of the problem function corresponding to the application, the problem function is a function that causes the application to crash, and the problem function is determined based on the symbolized stack information.

[0134] In one embodiment, the function-related information includes the class name and function name corresponding to the function.

[0135] For the specific definition of the stack information processing device, please refer to the definition of the stack information processing method above, which will not be repeated here. Each module in the above-mentioned stack information processing device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0136] In one embodiment, an electronic device is provided. The electronic device may be a terminal, and its internal structure diagram may be as follows: Fig.13As shown. The electronic device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the electronic device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a stack information processing method is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.

[0137] Those skilled in the art will understand that Fig.13 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0138] In one embodiment, an electronic device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0139] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0140] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0141] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0142] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A stack information processing method, characterized in that: The method comprises: When an application in the IOS system performs a function call event through a target information sending function, a hook function preloaded in the target information sending function is executed, and the target information sending function is the objc_msgSend function in the IOS system; Obtaining, through the hook function, the class name and function name corresponding to the called function in the function call event; Before calling the called function through the target information sending function, creating a crash stack through a first management function, and saving the class name and the function name to the crash stack through the first management function; When the call to the called function does not cause the application to crash and the call is completed, the class name and the function name are deleted from the crash stack through the second management function; when a problem occurs in the call to the called function and causes the application to crash, the class name and the function name are retained in the crash stack; When the application crashes, symbolized stack information is obtained based on the crash stack corresponding to the problem thread, and the class name and function name corresponding to the problem function that caused the application crash are output, the symbolized stack information includes the class name and function name corresponding to the called function in the ongoing function call event corresponding to the problem thread, when the function at the top of the crash stack is a system function, the system function and other functions at the next layer of the top of the stack are the problem functions, when the function at the top of the crash stack is a non-system function, the non-system function is the problem function; After the application crashes, when the application is opened again, the symbolized stack information is displayed.

2. The stack information processing method according to claim 1, characterized in that: The method further comprises: When a new function call event is performed, the class name and function name corresponding to the first function are saved in the crash stack, and the first function is the function called by the target information sending function in the new function call event.

3. The stack information processing method according to claim 2, characterized in that: Before the class name and function name corresponding to the first function are saved to the crash stack, the method further includes: If a crash stack does not exist, a new crash stack is created to save the class name and function name.

4. The stack information processing method according to claim 1, characterized in that: The method further comprises: After the function call event is completed, the class name and function name corresponding to the second function are deleted from the crash stack, and the second function is the function called by the target information sending function in the completed function call event.

5. The stack information processing method according to claim 1, characterized in that: When the application crashes, if the number of threads corresponding to the application is at least two, before obtaining symbolized stack information based on the crash stack corresponding to the problem thread, the method further includes: A problem thread among at least two threads is determined, where the problem thread is a thread that causes the application program to crash.

6. The stack information processing method according to claim 1, characterized in that: Also includes at least one of the following: Item 1: output the symbolized stack information; The second item: outputting the class name and function name corresponding to the problem function corresponding to the application, wherein the problem function is the function that causes the application to crash, and the problem function is determined based on the symbolized stack information.

7. A stack information processing device, characterized in that: The device comprises: A hook execution module, for executing a hook function preloaded in the target information sending function when detecting a function call event performed by an application in the IOS system through the target information sending function, wherein the target information sending function is the objc_msgSend function in the IOS system; An information acquisition module, used to acquire the class name and function name corresponding to the called function in the function call event through the hook function; A stack update module, used for creating a crash stack through a first management function before calling the called function through the target information sending function, and saving the class name and the function name to the crash stack through the first management function; when the call to the called function does not cause the application to crash and the call is completed, deleting the class name and the function name from the crash stack through a second management function; when a problem occurs in the call to the called function and causes the application to crash, retaining the class name and the function name in the crash stack; an information processing module, for obtaining symbolic stack information based on a crash stack corresponding to a problem thread when the application crashes, and outputting a class name and a function name corresponding to a problem function causing the application crash, wherein the symbolic stack information includes a class name and a function name corresponding to a called function in an ongoing function call event corresponding to the problem thread, and in a case where the function at the top of the crash stack is a system function, the system function and other functions at a layer below the top of the stack are problem functions, and in a case where the function at the top of the crash stack is a non-system function, the non-system function is the problem function; The device is also used for: after the application crashes, when the application is opened again, displaying the symbolized stack information.

8. The stack information processing device according to claim 7, characterized in that: The stack update module is further used to: When a new function call event is performed, the class name and function name corresponding to the first function are saved in the crash stack, and the first function is the function called by the target information sending function in the new function call event.

9. The stack information processing device according to claim 8, characterized in that: The stack update module is further used to: If a crash stack does not exist, a new crash stack is created to save the class name and function name.

10. The stack information processing device according to claim 7, characterized in that: The stack update module is further used to: After the function call event is completed, the class name and function name corresponding to the second function are deleted from the crash stack, and the second function is the function called by the target information sending function in the completed function call event.

11. The stack information processing device according to claim 7, characterized in that: When the application crashes, if the number of threads corresponding to the application is at least two, the information processing module is further configured to: A problem thread among at least two threads is determined, where the problem thread is a thread that causes the application program to crash.

12. The stack information processing device according to claim 7, characterized in that: The device is also used for at least one of the following: Item 1: output the symbolized stack information; The second item: outputting the class name and function name corresponding to the problem function corresponding to the application, wherein the problem function is the function that causes the application to crash, and the problem function is determined based on the symbolized stack information.

13. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

14. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Method and device for determining operation information of application program in iOS system

    CN109783161A

  • Method for positioning malfunction of application program

    CN1728106A