CN113535143A - Stack information processing method and device, electronic equipment and storage medium - Google Patents

Stack information processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113535143A
CN113535143A CN202010320627.0A CN202010320627A CN113535143A CN 113535143 A CN113535143 A CN 113535143A CN 202010320627 A CN202010320627 A CN 202010320627A CN 113535143 A CN113535143 A CN 113535143A
Authority
CN
China
Prior art keywords
function
stack
information
crash
application program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010320627.0A
Other languages
Chinese (zh)
Inventor
陈智
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010320627.0A priority Critical patent/CN113535143A/en
Publication of CN113535143A publication Critical patent/CN113535143A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Abstract

The application relates to a stack information processing method, a device, an electronic device and a storage medium, wherein function calling information of an application program during function calling events can be acquired by loading a hook function in a target information sending function in advance, and a collapsed stack is updated. When the function call has a problem and causes the operation of the application program to crash, symbolic stack information can be obtained according to the function call information stored in the crash stack. Because the symbolic stack information comprises the function calling information corresponding to the ongoing function calling event, and the ongoing function calling event causes the application program to crash, developers can directly determine the specific reason causing the application program to crash according to the symbolic stack information without depending on a dSYM file, a symbolic tool and the like, and therefore the software development efficiency is improved.

Description

Stack information processing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of information processing technologies, and in particular, to a stack information processing method and apparatus, an electronic device, and a storage medium.
Background
With the improvement of the technology level, various types of Application programs (APPs) appear, and the APPs are widely applied to device terminals of users, such as mobile phones, tablets and the like. After the development of the APP is completed by a developer, the APP is released to a network, and a user can download and use the APP by himself. In the process of using the APP, a situation that an application program reports an error, a corresponding process disappears, or a corresponding service automatically stops, that is, a situation that the APP crashes (Crash) occurs, may occur.
In the event of an APP crash, the developer needs to determine the cause of the APP crash. In the prior art, a developer generally obtains a dSYM file generated when compiling the APP, performs symbolization processing by using a symbolization tool based on the dSYM file, and then performs analysis according to a result of the symbolization processing, so as to determine a cause of a crash.
However, the above processes in the prior art all require manual operations of developers, and require the help of other files and tools, which results in complicated steps and thus affects development efficiency.
Disclosure of Invention
In view of the above, it is desirable to provide a stack information processing method, apparatus, electronic device, and storage medium that can contribute to improvement in development efficiency.
A stack information processing method, the method comprising:
when it is monitored that the application program carries out a function call event through a target information sending function, executing a hook function which is pre-loaded in the target information sending function;
acquiring function calling information in the function calling event through the hook function, wherein the function calling information comprises function related information of a called function;
updating a crash stack according to the function related information in the function calling information;
and when the application program is crashed in operation, symbolic stack information is obtained based on the crashed stack.
A stack information processing apparatus, the apparatus comprising:
the hook execution module is used for executing a hook function which is pre-loaded in the target information sending function when the condition that the application program carries out a function calling event through the target information sending function is monitored;
the information acquisition module is used for acquiring function calling information in the function calling event through the hook function, wherein the function calling information comprises function related information of a called function;
the stack updating module is used for updating the crash stack according to the function related information in the function calling information;
and the information processing module is used for obtaining symbolic stack information based on the crash stack when the application program is crashed.
An electronic device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
when it is monitored that the application program carries out a function call event through a target information sending function, executing a hook function which is pre-loaded in the target information sending function;
acquiring function calling information in the function calling event through the hook function, wherein the function calling information comprises function related information of a called function;
updating a crash stack according to the function related information in the function calling information;
and when the application program is crashed in operation, symbolic stack information is obtained based on the crashed stack.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
when it is monitored that the application program carries out a function call event through a target information sending function, executing a hook function which is pre-loaded in the target information sending function;
acquiring function calling information in the function calling event through the hook function, wherein the function calling information comprises function related information of a called function;
updating a crash stack according to the function related information in the function calling information;
and when the application program is crashed in operation, symbolic stack information is obtained based on the crashed stack.
According to the stack information processing method, the stack information processing device, the electronic equipment and the storage medium, when it is monitored that the application program carries out a function call event through the target information sending function, a hook function which is pre-loaded in the target information sending function is executed; acquiring function calling information in a function calling event through a hook function, wherein the function calling information comprises function related information of a called function; updating the crash stack according to function related information in the function calling information; when the application program runs and crashes, symbolic stack information is obtained based on the crashed stack.
According to the method and the device, the hook function is loaded in the target information sending function in advance, so that the function calling information of the application program during the function calling event can be obtained, and the collapse stack is updated. When the function call has a problem and causes the operation of the application program to crash, symbolic stack information can be obtained according to the function call information stored in the crash stack. Because the symbolic stack information comprises the function calling information corresponding to the ongoing function calling event, and the ongoing function calling event causes the application program to crash, developers can directly determine the specific reason causing the application program to crash according to the symbolic stack information without depending on a dSYM file, a symbolic tool and the like, and therefore the software development efficiency is improved.
Drawings
FIG. 1 is a flow diagram illustrating a method for processing stack information in one embodiment;
FIG. 2 is a diagram of an example of unsigned stack information in one embodiment;
FIG. 3 is a diagram of an example of symbolized stack information in another embodiment;
FIG. 4 is a diagram of information associated with a crash stack save function in one embodiment;
FIG. 5 is a diagram that illustrates the deletion of function-related information in a crash stack, in one embodiment;
FIG. 6 is a flow diagram illustrating a process for obtaining tokenized stack information based on a collapsed stack, according to one embodiment;
FIG. 7 is a flowchart illustrating a method for processing stack information according to another embodiment;
FIG. 8 is a diagram of a screen interface displaying symbolized stack information in one embodiment;
FIG. 9(a) is a diagram illustrating a function call flow in the prior art in one embodiment;
FIG. 9(b) is a diagram illustrating a function call flow in the present application, according to an embodiment;
FIG. 10 is a diagram illustrating the management of the contents of a collapsed stack during a function call in one embodiment;
FIG. 11 is a diagram showing a structure of a stack information processing apparatus according to an embodiment;
FIG. 12 is a diagram showing the construction of a stack information processing apparatus according to another embodiment;
FIG. 13 is a diagram illustrating the internal architecture of an electronic device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
First, terms related to the present application will be explained.
1. And (3) crashing the stack: and when the APP breaks down, the data structure is used for recording the current function call information.
2. Symbolization treatment: before symbolization, the contents of the stack are memory address information, and symbolization refers to the conversion of the memory address information into symbols which can be understood by developers.
2. Target information transmission function: for calling functions to pass messages during application execution. Illustratively, for APP in an IOS system, the target information transfer function may be the objc _ msgSend function. The format of the objc _ msgSend function when transferring messages is: objc _ msgSend (id self, SEL cmd.). The objc _ msgSend function is a variable number of parameters function that can receive two or more parameters. The first parameter "id self" indicates the recipient of the message; the second parameter "SEL cmd" represents the selector type; the subsequent parameters may be parameters in the message. The selector refers to the name of the function called by the objc _ msgSend function, and of course, the selector may also be referred to as a method, and the naming method of the selector is not limited in this embodiment.
The target information sending function calls an appropriate function according to the type of the receiver and the selector when passing the message. To do this, the target messaging function needs to search its "method lists" in the class to which the recipient belongs, and jump to its actual code if a function matching the selected sub-name can be found. If the function can not be found, the user continues to search upwards along the inheritance system, and jumps after finding the proper function. If no matching function is finally found, a message forwarding operation is performed.
3. Hook (hook) function: is a program used to process system messages. Through system call, the hook function can be hung in the application program of the system. The hook function allows a program to intercept messages or specific events of the system. The hooks are of various types, each hook can intercept and process corresponding messages, for example, a keyboard hook can intercept keyboard messages, a mouse hook can intercept mouse messages, a shell hook can intercept messages for starting and closing applications, and a log hook can monitor and record input events. In the application, the hook function can intercept a function call event performed by a target information sending function in the system, that is, function call information can be acquired.
4. Objective-C: Objective-C used for application development based on the iOS system is a dynamic language by providing class definitions, methods, and attributes, which does not have the concept of object calling methods, but implements various functions by methods that send corresponding information to respective object methods. All the operations of sending corresponding information to each object method are realized by a target information sending (such as objc-msgSend) function. Therefore, in the development of the application program of the iOS system, all the function call information of the application program can be intercepted only by taking hook on the target information sending function.
5. Thread (thread): is the smallest unit that the operating system can perform operation scheduling. It is included in the process, and is the actual unit of operation in the process, and a single thread corresponds to a single sequential control flow.
In an embodiment, as shown in fig. 1, a stack information processing method is provided, which is explained by taking an example that the method is applied to a processor capable of performing stack information processing in a device terminal, and the method mainly includes the following steps:
step S100, when it is monitored that the application program carries out a function call event through the target information sending function, executing a hook function pre-loaded in the target information sending function.
The application program refers to a software program which is installed in the device terminal and used for realizing one or more functions, and the device terminal comprises various mobile terminals provided with systems such as iOS (internet operating system), Android (Android) and the like. Various running applications in the mobile terminal are written using corresponding programming languages. For example, in a mobile terminal (e.g., an iPhone series mobile phone) manufactured by Apple (Apple) corporation, the running application is generally written using the objective _ c language. The objective _ c language is an object-oriented language in which there is no concept of an object calling method, but various functions are implemented by a method of transmitting corresponding information to each object method. All the operations of transmitting the corresponding information to the respective object methods are implemented by an object information transmission (objc _ msgSend) function. Therefore, for the application program of the iOS system, when the corresponding function is realized, it is necessary to perform a function call event by the target information transmission (objc _ msgSend) function.
In this step, the target information sending function is pre-loaded with a hook function, and specifically, after the application program is successfully started, a hook is installed on the target information sending function. By hooking the target information sending function, the processor can monitor various message passing performed by the target information sending function in the system. When the application program is monitored to carry out a function call event through the target information sending function, the application program is indicated to start running, and at the moment, the function of the hook function can be executed.
It should be noted that, when an application of the iOS system makes a function call event, the application does not directly make a function call, but transmits information of a function to be called to the target information transmission (objc _ msgSend) function, and then executes the function to be called by the target information transmission (objc _ msgSend) function. In this step, it is monitored that the application performs a function call event through the target information sending function, specifically, it may be monitored that the application sends information of a function to be called to the target information sending function, that is, when it is monitored that the application requests to call the function, a hook function is executed to intercept a function call request sent by the application.
Step S200, acquiring function calling information in the function calling event through the hook function, wherein the function calling information comprises function related information of the called function.
When the application program carries out a function calling event, the application program does not directly call the function of the corresponding function, but sends the relevant parameters of the function calling event to the target information sending function, and then the target information sending function calls the corresponding function according to the relevant parameters.
Because the hook function is loaded in the target information sending function in advance, when the application program sends the relevant parameters of the function calling event to the target information sending function, the relevant parameters of the function calling event can be intercepted through the hook function, and the function calling information is obtained. The function calling information includes function related information of the called function.
Step S300, updating the crash stack according to the function related information in the function calling information.
After the processor obtains the function call information of the function call event through the hook function, the processor updates the content of the crash stack based on the function related information in the obtained function call information so as to ensure that the current function call information of the application program is recorded in the crash stack in real time, wherein the current function call information comprises the function related information of the current called function.
In step S400, when the application program crashes, symbolic stack information is obtained based on the crashed stack.
The application running crash specifically refers to the situation that, for example, the application reports an error, the corresponding process disappears, or the corresponding service automatically stops. In the prior art, when an application program crashes, although a corresponding stack is saved, the information contained in the stack is not symbolized, and developers cannot acquire effective information from the stack. For example, as shown in fig. 2, the exemplary graph of un-symbolized stack information includes information related to a memory call, and a developer cannot identify a cause of a crash of an application based on the information related to the memory call.
In the implementation, when the application program runs and crashes, because the current function calling information of the application program is stored in the crash stack, the processor can obtain the function related information of the called function in the ongoing function calling event of the application program based on the crash stack, namely, obtain the symbolized stack information, and based on the symbolized stack information, a developer can directly identify the reason of the crash of the application program, so that the application program can be developed and improved. For example, as shown in fig. 3, which is an example diagram of the symbolized stack information including the function-related information of the called function, the developer may determine the cause of the crash based on the function-related information of the called function.
In this embodiment, by loading the hook function in the target information sending function in advance, the function call information of the application program during the function call event can be obtained, and the crash stack is updated. When the function call has a problem and causes the operation of the application program to crash, symbolic stack information can be obtained according to the function call information stored in the crash stack. Because the symbolic stack information comprises the function calling information corresponding to the ongoing function calling event, and the ongoing function calling event causes the application program to crash, developers can directly determine the specific reason causing the application program to crash according to the symbolic stack information without depending on a dSYM file, a symbolic tool and the like, and therefore the software development efficiency is improved.
In one embodiment, updating the crash stack based on function-related information in the function call information includes: and when a new function calling event is carried out, saving the function related information of the first function to the crash stack.
The first function is a function called by the target information sending function in a newly-performed function calling event. When the application program sends a new function call event through the target information sending function, the processor acquires the function related information of the first function through the hook function and stores the function related information of the first function to the crash stack. Specifically, when the application program sends a request for calling a first function to the target information sending function, the processor intercepts the function calling request through the hook function, saves function-related information of the first function, and then the target information sending function executes the first function.
When function-related information is saved to a collapsed stack, newly-saved information is saved at the top of the stack. For example, as shown in fig. 4, which is a schematic diagram of saving function-related information for a crashed stack, for an initial crashed stack (i.e., a stack without saved information), when function-related information Info _1 of a function called in a first function call event is saved, Info _1 is saved at the top position of the crashed stack. When function related information Info _2 of the function called in the second function calling event is stored, the Info _2 is saved at the top of the stack of the corrupted stack again, and the Info _1 is saved in the next column of the Info _ 2. The storage principle of other function-related information is the same as that of Info _1 and Info _2, and is not described herein again.
Optionally, the function related information includes a class name and a function name corresponding to the function. Wherein, a class name can be understood as a function set, and a function name can be understood as a specific function. For example, when the class name is "operation", the function name may be "add, subtract, multiply, divide"; when the class name is "image processing", the function name may be "convolution, pooling, hole convolution" or the like. The function-related information may be obtained by intercepting, by a hook function, a relevant parameter of a function call event.
Different classes typically contain multiple functions, and the same function name may occur between different classes. For example, the class names Name _1 and Name _2 both contain the function Func _ a, the class Name _1 also contains the function Func _ B, and the class Name _2 also contains the function Func _ C. In the symbolized stack information, if the function-related information only contains a class Name, for example, only contains Name _1, a developer cannot determine whether a problem occurs in the function Func _ a or the function Func _ B; if the function-related information only includes a function Name, such as Func _ a, the developer cannot determine whether the function Func _ a in the Name _1 is in question or the function Func _ a in the Name _2 is in question.
Therefore, in the implementation, the function related information simultaneously comprises the class name and the function name corresponding to the function, and a developer can accurately judge which function has a problem, so that the cause of program crash can be quickly located, and subsequent optimization development processing of the application program is facilitated.
Optionally, before saving the function related information of the first function to the crash stack, the method further includes: and if the crash stack does not exist, creating a crash stack for storing the function related information. Therefore, by newly building the crash stack, the function related information can be conveniently stored.
In one embodiment, updating the crash stack based on function-related information in the function call information includes: after the function call event is completed, the function related information of the second function is deleted from the crash stack.
The second function is a function called by the target information sending function in the completed function calling event. Since the information about the function called in the ongoing function call event is stored in the crash stack, the function whose call is completed needs to be deleted from the crash stack after the function call event is completed. Specifically, after the call of a single function is completed, the target information sending function stops calling the single function, and at this time, the function related information of the single function may be deleted from the crash stack.
Specifically, as shown in fig. 5, a schematic diagram of deleting function-related information in a crash stack is shown. For an initial collapsed stack (i.e. a stack storing i pieces of function-related information), after an ith function call event is completed, deleting function-related information Info _ i at the top of the stack from the collapsed stack, wherein at this time, the function-related information at the top of the stack is Info _ i-1; and after the i-1 st function call event is completed, deleting the function related information Info _ i-1 at the top of the stack from the crash stack, wherein the function related information at the top of the stack is Info _ i-2 at the time. The principle of deleting other function-related information is the same as that of Info _ i and Info _ i-1, and is not described herein again.
In one embodiment, when an application corresponds to only a single thread, the application also corresponds to only a single crashed stack based on the correspondence of the single thread to the single crashed stack. A single thread corresponds to a single sequential control flow and thus the tokenized stack information is available based on a single crashed stack corresponding to the single thread.
In one embodiment, the application program may have multiple threads executing concurrently, that is, the application program has at least two threads in operation, and each thread executes different tasks in parallel. Correspondingly, as shown in fig. 6, when the application program crashes, if the number of threads corresponding to the application program is at least two, the symbolic stack information is obtained based on the crashed stack, which includes steps S420 to S440.
Step S420, determining a problem thread in at least two threads, wherein the problem thread is a thread causing the running breakdown of the application program;
step S440, obtaining symbolic stack information based on the crashed stack corresponding to the problem thread, where the symbolic stack information includes function-related information of the called function in the ongoing function-calling event corresponding to the problem thread.
Specifically, in the case of multi-thread concurrent execution, when an application program crashes, the system may automatically output prompt information specifically indicating which thread has a problem, and therefore, the present embodiment may determine a problem thread in the multi-thread based on the system information, that is, determine a thread causing the application program to run crashed based on the system prompt information. It is to be understood that, in practical applications, the problem thread may also be determined in other ways, and is not limited herein.
After the problem thread is determined, symbolic stack information can be obtained based on the crashed stack corresponding to the problem thread, and the symbolic stack information comprises function related information of a called function in an ongoing function calling 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.
In one embodiment, as shown in fig. 7, the stack information processing method further includes step S510: outputting the symbolized stack information.
After the symbolic stack information is obtained, the processor can output the symbolic stack information, so that information which can be output by a developer can determine the cause of the program crash.
Specifically, the output of the symbolized stack information may be realized in a display manner. For example, as shown in fig. 8, when the user opens the application again after the application crashes, the symbolized stack information may be displayed on the screen of the terminal, and the user may directly present the screen on which the symbolized stack information is displayed to the developer for viewing. Alternatively, the user may send the symbolized stack information to the developer in a screenshot or copy format.
In addition, the output of the symbolized stack information may be realized by means of data transmission. For example, after the application program crashes, the processor obtains the 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 a target server, and the like, so that a user does not need to perform any operation, and a developer can obtain the symbolized stack information through the target terminal or the target server.
In the embodiment, the symbolic stack information is output, so that developers can quickly locate the cause of program crash based on the symbolic stack information, and the development efficiency is improved.
In one embodiment, referring to fig. 7, the stack information processing method further includes step S520: and outputting function related information of the problem function corresponding to the application program. The problem function is a function which causes the running of the application program to crash, and the problem function is determined based on the symbolized stack information.
Specifically, when an application program crashes, the following situations may exist as the reasons for the crash:
(1) the function of the top position of the stack is a system function. The function at the top of the stack, that is, the function that the application called last time, when the function is a system function, the crash of the application is usually caused by the calling problem of the system function. At this point, it can be said that a function located at a position next to the top of the stack calls the system function, causing the application to crash. At this time, the problem function may include the system function and other functions located at a position next to the top position of the stack. For example, referring to fig. 3, if the function in the second line in the figure is a system function (the function at the beginning of NS is a system function), it can be considered that a problem occurs when the function in the third line calls the system function, the class name of the function in the third line is readin joyaddinfo, and the function name is getReportInfoWithFeedbackTag.
(2) The function of the top position of the stack is a non-systematic function. At this time, the reason for the crash of the application program operation may be caused by the function at the top of the stack, i.e., the non-system function is a problem function.
In addition, application crashes may also be caused by calling problems with the non-system functions. That is, the problem function may also be another function that includes the non-system function and a position of a next layer located at the top position of the stack.
It is to be understood that, in practical applications, the manner of determining the problem function is not limited to the above two manners, and other determining manners may be used to determine the problem function, which is not limited herein.
After determining the cause of the crash, the processor can adopt display, data transmission and other modes to achieve the purpose of outputting function related information of the problem function.
In the embodiment, the problem function is determined based on the symbolized stack information, and then the function related information of the problem function is output, so that developers do not need to manually locate the cause of the crash, and the development efficiency of the developers is further improved.
In one embodiment, referring to fig. 7, the stack information processing method further includes step S530: and outputting the symbolized stack information and function related information of the problem function corresponding to the application program.
In this embodiment, the processor may implement the purpose of outputting the symbolized stack information and the function-related information of the problem function by using display, data transmission, and other manners, and the output manners of different information may be the same or different. Therefore, by outputting the function-related information of the problem function, it is possible to contribute to improvement of development efficiency of developers. By outputting the symbolic stack information, developers can verify the problem function, so that the accuracy of the program crash reason is guaranteed.
In one embodiment, an application example of the stack information processing method of the present application is provided, where the application example mainly includes the following processing flows:
(1) an APP is installed on IOS equipment of a user, and after the user successfully starts the APP, a hook function is installed on a target information sending (obj _ msgSend) function by a processor.
(2) When the APP is monitored to perform a function call event (send a function call request to the target information sending function) through the target information sending function, executing a hook function in the target information sending function to acquire function call information in the function call event, wherein the function call information comprises function related information of a called function.
(3) Defining a first management function before _ obj _ msgSend of the function, wherein the first management function is used for creating a crash stack for storing relevant information of the function when the crash stack does not exist; when the crash stack exists, storing function related information of a first function to the crash stack, wherein the first function is a function called by a target information sending function in a newly-performed function calling event;
and defining a second management function after _ obj _ jc _ msgSend, wherein the second management function is used for deleting the function related information of the second function from the crash stack after the function calling event is completed, and the second function is a function called by the target information sending function in the completed function calling event.
After acquiring function call information, if a crash stack does not exist, establishing a crash stack through a first management function before _ obj _ msgSend, and storing function related information of the first function to the crash stack; if the crash stack exists, directly saving the function related information of the first function to the crash stack through the first management function before _ obj _ msgSend. The newly stored function-related information is saved at the top of the collapsed stack.
(4) The function is called by the target information send (objc _ msgSend) function.
(5) After the function call is completed, if the program normally runs, deleting function related information of a second function in the crash stack through a second management function (after _ obj _ msgSend); if the application crashes, the crash stack still holds the function-related information.
As shown in fig. 9(a) and 9(b), taking a function with a calling class name of sfeedview and a function name of playAnimation as an example, the function call flows in the prior art and the present application are respectively schematic diagrams.
Referring to fig. 9(a), in the prior art, after the APP sends a request for calling the function sfeedview planning to the target information sending (objc _ msgSend) function, the function objc _ msgSend directly calls the execution function sfeedview planning until the function call is completed. In the process, if the program crashes, a developer cannot know that the program crashes due to the calling function [ SFeedsView planning ].
Referring to fig. 9(b), in the technical solution of the present application, after the APP sends a request for calling a function SFeedsViewplayAnimation to a target information sending (objc _ msgSend) function, a processor intercepts the function calling information (function calling request) through a hook function. Before the function obj c msgSend makes a function call, the processor adds function-related information to the crash stack through the first management function before object _ obj c msgSend. Then, the function obj c _ msgSend recalls the execute function sfeedview playAnimation. After the call is completed, the processor deletes the function-related information of the function sfeeds viewplayanimation from the crash stack through the second management function after _ obj _ msgSend, and the function call is completed.
In addition, if the function [ sfeedtview planning ] is called, if the application program crashes, at this time, since the function-related information of the function [ sfeedtview planning ] is still stored in the crashed stack, the processor can obtain the symbolized stack information based on the crashed stack, and thus, a developer can determine that the program crashes due to the calling of the function [ sfeedsviedview planning ] according to the symbolized stack information.
(6) After the application program is run and crashed, if the application program is run by a single thread, symbolic stack information is obtained based on a crashed stack corresponding to the single thread.
If the application program is executed in a multi-thread concurrent mode, firstly, a problem thread in the multi-thread is determined, and then symbolic stack information is obtained based on a crashed stack corresponding to the problem thread.
(7) Outputting the symbolized stack information and/or outputting function related information of a problem function corresponding to the application program. Therefore, the developer of the application program can determine the cause of the program crash based on the output information, so as to perform subsequent development and research.
In one embodiment, the management of the contents of a crashed stack is explained.
The following is a specific code example of function call, and in this embodiment, the called function includes a function one, a function two, and a function three, which are named Test in sequence.
1.@implementation Test
2.-(void)one{
3.[selftwo];
4.}
5.
6.-(void)two{
7.[selfthree];
8.}
9.
10.-(void)three{
11.NSLog(@"hello world!");
12.}
13.@end
As shown in fig. 10, when the APP needs to call the function [ Test one ], the APP first sends a request for calling the function [ Test one ], at this time, the processor acquires function call information (i.e., the request for calling 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 _ obj _ msgSend (if there is no crash stack, the function is created and stored again), at this time, the function at the top of the crash stack is the function [ Test one ].
Then, the function [ Test one ] is called by the function objc _ msgSend, i.e., the function [ Test one ] is executed by the function objc _ msgSend. In this process, the function [ Test two ] needs to be called further, and then the function related information of the function [ Test two ] is stored into the crash stack by the first management function before _ obj _ 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 ].
Then, the function [ Test two ] is called by the function objc _ msgSend, i.e., the function [ Test two ] is executed by the function objc _ msgSend. In this process, a function [ Testthree ] needs to be called further, and then the function related information of the function [ Testthree ] is stored in the crash stack by the first management function before _ obj _ msgSend, at this time, the function at the top of the crash stack becomes the function [ Testthree ], the function [ testtwo ] is located at the next layer of the function [ Testthree ], and the function [ testone ] is located at the next layer of the function [ testtwo ].
Then, the function obj jc _ msgSend calls the function [ Test three ], i.e., the function [ Test three ] is executed by the function obj jc _ msgSend.
If the function [ Test three ] is called normally, the function related information of the function [ Test three ] is deleted from the crash stack through a second management function after _ obj _ msgSend, at this time, the function at the top of the crash stack becomes the function [ Test two ], and the function [ Test one ] is positioned at the next layer of the function [ Test two ].
After the call of the function [ Test three ] is completed, if the call of the function [ Test two ] is normal, the function related information of the function [ Test two ] is deleted from the crash stack by the second management function after _ obj _ msgSend, and at this time, the function at the top of the crash stack becomes the function [ Test one ].
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 _ obj _ msgSend, and at this time, the content in the crash stack is empty.
In the process of calling the function, for example, when the function obj c _ msgSend calls the function [ Test three ], if an exception occurs, causing an application to crash, at this time, the crash stack stores the function related information of the function [ Test three ], the function [ Test two ], and the function [ Test one ], and at this time, the function [ Test three ] is located at the top of the stack. Based on the crash stack, the symbolic stack information containing the three functions can be obtained, and therefore, a developer can quickly locate the cause of the crash based on the symbolic stack information.
It should be understood that, under reasonable circumstances, although the steps in the flowcharts referred to in the foregoing embodiments are shown in sequence as indicated by the arrows, the steps are not necessarily executed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps in each flowchart may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 11, there is provided a stack information processing apparatus mainly including the following modules:
the hook execution module 100 is configured to execute a hook function preloaded in a target information sending function when it is monitored that an application program performs a function call event through the target information sending function;
an information obtaining module 200, configured to obtain function call information in a function call event through a hook function, where the function call information includes function-related information of a called function;
a stack update module 300, configured to update the collapsed stack according to function-related information in the function call information;
the information processing module 400 is configured to obtain the symbolic stack information based on the crash stack when the application program runs into a crash.
According to the method and the device, the hook function is loaded in the target information sending function in advance, so that the function calling information of the application program during the function calling event can be obtained, and the collapse stack is updated. When the function call has a problem and causes the operation of the application program to crash, symbolic stack information can be obtained according to the function call information stored in the crash stack. Because the symbolic stack information comprises the function calling information corresponding to the ongoing function calling event, and the ongoing function calling event causes the application program to crash, developers can directly determine the specific reason causing the application program to crash according to the symbolic stack information without depending on a dSYM file, a symbolic tool and the like, and therefore the software development efficiency is improved.
In one embodiment, the stack update module 300 includes an information logging unit; the information storage unit is used for storing the function related information of a first function to the crash stack when a new function calling event is carried out, wherein the first function is a function called by the target information sending function in the new function calling event.
In one embodiment, the stack update module 300 further comprises a stack establishment unit: the stack establishing unit is used for establishing a crash stack for storing the function related information when the crash stack does not exist.
In one embodiment, the stack update module 300 further includes an information deletion unit; and the information deleting unit is used for deleting the function related information of a second function from the crash stack after the function calling event is completed, wherein the second function is a function called by the target information sending function in the completed function calling event.
In one embodiment, the information processing module 400 further includes a problem thread determination unit and a stack information symbolization unit; the problem thread determining unit is used for determining a problem thread in at least two threads, wherein the problem thread is a thread causing the running crash of the application program; the stack information symbolization unit is used for obtaining symbolized stack information based on the crashed stack corresponding to the problem thread, and the symbolized stack information comprises function related information of a called function in an ongoing function calling event corresponding to the problem thread.
In one embodiment, as shown in fig. 12, the stack information processing apparatus further includes: an information output module 500, configured to output the symbolized stack information; and/or outputting function related information of a problem function corresponding to the application program, wherein the problem function is a function causing the operation crash of the application program, and the problem function is determined and obtained based on the symbolized stack information.
In one embodiment, the function-related information includes a class name and a function name corresponding to the function.
For specific limitations of the stack information processing apparatus, reference may be made to the above limitations of the stack information processing method, which are not described herein again. The respective modules in the above-described stack information processing apparatus may be entirely or partially implemented by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent of a processor in the electronic device, or can be stored in a memory in the electronic device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, an electronic device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 13. The electronic device comprises a processor, a memory, a communication interface, a display screen and an input device which are connected through a system bus. Wherein the processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic equipment comprises a nonvolatile 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 an operating system and computer programs in the non-volatile storage medium. The communication interface of the electronic device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a stack information processing method. The display screen of the electronic equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the electronic equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the structure shown in fig. 13 is a block diagram of only a portion of the structure relevant to the present application, and does not constitute a limitation on the electronic device to which the present application is applied, and a particular electronic device may include more or less components than those shown in the drawings, or combine certain components, or have a different arrangement of components.
In one embodiment, an electronic device is further provided, which includes a memory and a processor, where the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, in which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), for example.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A stack information processing method, characterized by comprising:
when it is monitored that the application program carries out a function call event through a target information sending function, executing a hook function which is pre-loaded in the target information sending function;
acquiring function calling information in the function calling event through the hook function, wherein the function calling information comprises function related information of a called function;
updating a crash stack according to the function related information in the function calling information;
and when the application program is crashed in operation, symbolic stack information is obtained based on the crashed stack.
2. The stack information processing method according to claim 1, wherein said updating the collapsed stack according to the function-related information in the function call information includes:
and when a new function calling event is carried out, storing the function related information of a first function to the crash stack, wherein the first function is a function called by the target information sending function in the newly carried function calling event.
3. The stack information processing method according to claim 2, wherein before saving the function-related information of the first function to the crashed stack, the method further comprises:
and if the crash stack does not exist, creating a crash stack for storing the function related information.
4. The stack information processing method according to claim 1, wherein said updating the collapsed stack according to the function-related information in the function call information includes:
and after the function calling event is completed, deleting the function related information of a second function from the crash stack, wherein the second function is a function called by the target information sending function in the completed function calling event.
5. The method for processing stack information according to claim 1, wherein when the application program crashes, if the number of threads corresponding to the application program is at least two, the obtaining of the symbolic stack information based on the crashed stack includes:
determining a problem thread in at least two threads, wherein the problem thread is a thread causing the running of the application program to crash;
and obtaining symbolic stack information based on the crashed stack corresponding to the problem thread, wherein the symbolic stack information comprises function related information of a called function in an ongoing function calling event corresponding to the problem thread.
6. The stack information processing method according to claim 1, further comprising at least one of:
the first item: outputting the symbolized stack information;
the second term is: and outputting function related information of a problem function corresponding to the application program, wherein the problem function is a function causing the operation of the application program to crash, and the problem function is determined and obtained based on the symbolized stack information.
7. The stack information processing method according to any one of claims 1 to 6, wherein the function-related information includes a class name and a function name corresponding to the function.
8. A stack information processing apparatus characterized by comprising:
the hook execution module is used for executing a hook function which is pre-loaded in the target information sending function when the condition that the application program carries out a function calling event through the target information sending function is monitored;
the information acquisition module is used for acquiring function calling information in the function calling event through the hook function, wherein the function calling information comprises function related information of a called function;
the stack updating module is used for updating the crash stack according to the function related information in the function calling information;
and the information processing module is used for obtaining symbolic stack information based on the crash stack when the application program is crashed.
9. An electronic device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor realizes the steps of the method of any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202010320627.0A 2020-04-21 2020-04-21 Stack information processing method and device, electronic equipment and storage medium Pending CN113535143A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010320627.0A CN113535143A (en) 2020-04-21 2020-04-21 Stack information processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010320627.0A CN113535143A (en) 2020-04-21 2020-04-21 Stack information processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113535143A true CN113535143A (en) 2021-10-22

Family

ID=78123887

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010320627.0A Pending CN113535143A (en) 2020-04-21 2020-04-21 Stack information processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113535143A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113900910A (en) * 2021-12-08 2022-01-07 北京新唐思创教育科技有限公司 Application program monitoring method and device, storage medium and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1728106A (en) * 2004-07-26 2006-02-01 中兴通讯股份有限公司 Method for positioning malfunction of application program
CN106557300A (en) * 2015-09-24 2017-04-05 腾讯科技(深圳)有限公司 A kind of function stack information of wild pointer determines method, device and electronic equipment
CN106649084A (en) * 2016-09-14 2017-05-10 腾讯科技(深圳)有限公司 Function call information obtaining method and apparatus, and test device
US20170132024A1 (en) * 2015-11-06 2017-05-11 Quixey, Inc. Deep Linking to Mobile Application States Through Programmatic Replay of User Interface Events
CN109783161A (en) * 2018-12-11 2019-05-21 北京三快在线科技有限公司 The operation information of application program determines method, apparatus in iOS system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1728106A (en) * 2004-07-26 2006-02-01 中兴通讯股份有限公司 Method for positioning malfunction of application program
CN106557300A (en) * 2015-09-24 2017-04-05 腾讯科技(深圳)有限公司 A kind of function stack information of wild pointer determines method, device and electronic equipment
US20170132024A1 (en) * 2015-11-06 2017-05-11 Quixey, Inc. Deep Linking to Mobile Application States Through Programmatic Replay of User Interface Events
CN106649084A (en) * 2016-09-14 2017-05-10 腾讯科技(深圳)有限公司 Function call information obtaining method and apparatus, and test device
CN109783161A (en) * 2018-12-11 2019-05-21 北京三快在线科技有限公司 The operation information of application program determines method, apparatus in iOS system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113900910A (en) * 2021-12-08 2022-01-07 北京新唐思创教育科技有限公司 Application program monitoring method and device, storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
US10545775B2 (en) Hook framework
CN106708557B (en) Update processing method and device for terminal application
CN106844136B (en) Method and system for collecting program crash information
CN108399132B (en) Scheduling test method, device and storage medium
US11853820B2 (en) Cross-process communication method, apparatus, and device
CN110427258B (en) Resource scheduling control method and device based on cloud platform
US11704139B2 (en) Service processing method and apparatus, electronic device, and storage medium
WO2018171195A1 (en) Dependency-injection-based android application semi-automatization test method
CN112214388A (en) Memory monitoring method, device, equipment and computer readable storage medium
CN110968331A (en) Method and device for running application program
CN111459541A (en) Application program packaging method and device, computer equipment and storage medium
CN114168179A (en) Micro-service management method, device, computer equipment and storage medium
CN113535143A (en) Stack information processing method and device, electronic equipment and storage medium
CN111562952B (en) Dynamic loading method and dynamic loading device for double-core intelligent ammeter management unit
CN113050984A (en) Resource calling method and device, electronic equipment and storage medium
CN111949529A (en) System debugging method and device, computer equipment and storage medium
CN112988277B (en) Rule file loading method, device, server and medium
CN109783261A (en) The collapse processing method and processing device of terminal applies, electronic equipment, storage medium
US10165074B2 (en) Asynchronous custom exit points
CN112558975B (en) Method and device for switching codes of components, electronic equipment and readable storage medium
CN110955445B (en) Personal information updating method and device based on quick application and computer equipment
CN113986138A (en) Resource deleting method and device, electronic equipment and storage medium
CN117421249A (en) Loading test method and device for dynamic link library
CN116450192A (en) Page publishing prompting method, device, equipment and storage medium
CN116996586A (en) Method, device, architecture, equipment and medium for calling object in micro-service architecture

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination