Stack restoration method and device, equipment and storage medium
By obtaining and parsing symbol files in advance during application development and generating structured mapping relationships, the problems of low stack restoration efficiency and large system load are solved, and fast and efficient stack information conversion and system performance improvement are achieved.
Patent Information
- Application Number
- CN202411007614.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-12-20
AI Technical Summary
The existing stack restore method is inefficient and has a large system load, which affects system performance, mainly due to the low efficiency of symbol files acquisition and use, and the need to frequently read and match a large amount of data during stack restore.
When developing an application, the symbol files are obtained in advance and their structured mapping relationships are parsed, so that the source code symbol information can be quickly positioned during subsequent stack restoration, reducing the real-time acquisition and matching process.
Improve the efficiency and accuracy of stack restoration, reduce system load, ensure system performance, and achieve fast and efficient stack information conversion by parsing symbol files in advance and generating structured mapping relationships.
Smart Images

Figure CN119166414A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of terminal technology, and in particular to a stack restoration method, apparatus, device and storage medium. Background Art
[0002] A stack is a data storage structure that is usually composed of multiple stack frames. When an operating system or application is running, it generally creates a stack frame to store information related to function calls and returns. Therefore, the stack is often used to troubleshoot system or program operation anomalies. Since the created frame stack, i.e., the original frame stack, stores memory addresses, which are machine code addresses and do not directly correspond to information such as function names, file names, or line numbers in the source code, it is necessary to convert the original stack into a readable source code level stack based on stack restoration (or, also known as stack symbolization). Specifically, the above conversion can be achieved through a symbol file, which includes a mapping relationship between addresses and source code symbol information (e.g., function names, file names, or line numbers in the source code).
[0003] However, since symbol files are usually large, each stack restore needs to open and read the symbol file, which will generate a large amount of file input and output, which not only affects the stack restore efficiency, but also increases the system load and affects the system performance. Summary of the invention
[0004] The present application provides a stack restoration method, apparatus, device and storage medium to improve stack restoration efficiency, reduce system load during stack restoration, and improve system operating performance.
[0005] In a first aspect, the present application provides a stack restoration method, the method comprising: in response to a development operation for an application, obtaining a symbol file generated corresponding to the development application; parsing the symbol file to obtain multiple symbol addresses and multiple source code symbol information in the symbol file, and generating a structured mapping relationship between multiple symbol addresses and multiple source code symbol information based on the multiple symbol addresses and the multiple source code symbol information; in response to a stack restoration request, obtaining original stack information during application execution, the original stack information including stack frame address information; determining target source code symbol information corresponding to the stack frame address information from multiple source code symbol information based on the structured mapping relationship and the stack frame address information; and performing stack restoration on the original stack information based on the target source code symbol information to obtain source code stack information.
[0006] In a second aspect, the present application provides a stack restoration device, comprising: a first acquisition module, used to: in response to a development operation for an application, obtain a symbol file generated corresponding to the development application; a parsing and generating module, used to: parse the symbol file, obtain multiple symbol addresses and multiple source code symbol information in the symbol file, and generate a structured mapping relationship between multiple symbol addresses and multiple source code symbol information based on the multiple symbol addresses and the multiple source code symbol information; a second acquisition module, used to: in response to a stack restoration request, obtain original stack information in the running application, the original stack information including stack frame address information; a first determination module, used to: determine the target source code symbol information corresponding to the stack frame address information from the multiple source code symbol information based on the structured mapping relationship and the stack frame address information; a stack restoration module, used to: perform stack restoration on the original stack information based on the target source code symbol information to obtain the source code stack information.
[0007] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory, and executing the method in the first aspect or its various implementations.
[0008] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program enables a computer to execute the method in the first aspect or its various implementations.
[0009] In a fifth aspect, the present application provides a computer program product, comprising computer program instructions, which enable a computer to execute the method in the first aspect or its various implementations.
[0010] In a sixth aspect, the present application provides a computer program, which enables a computer to execute the method in the first aspect or its various implementations.
[0011] Through the technical solution of the present application, the electronic device can obtain the symbol file of the application when the application is developed, that is, the symbol file is read before the stack is restored, and then each subsequent stack restoration can use the symbol file obtained this time, thereby avoiding the problem of low efficiency in symbol file acquisition and use caused by obtaining the symbol file only when an online problem occurs in the application, and can reduce the system load and ensure system performance; moreover, because the electronic device parses the symbol file and determines the structured mapping relationship between the symbol address and the source code symbol information in the symbol file before the stack restoration request, it can determine the target source code symbol information corresponding to the stack frame address information at a higher speed, higher accuracy and more convenience according to the structured mapping relationship and the original stack information in the running application when the stack is restored, and perform stack restoration according to the target source code symbol information, thereby improving the convenience, accuracy and efficiency of stack restoration. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0013] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application;
[0014] Figure 2 A flowchart of a stack restoration method provided in an embodiment of the present application;
[0015] Figure 3 A schematic diagram of a stack restoration method provided in an embodiment of the present application;
[0016] Figure 4 A schematic diagram of another stack restoration method provided in an embodiment of the present application;
[0017] Figure 5 A schematic diagram of another stack restoration method provided in an embodiment of the present application;
[0018] Figure 6 A schematic diagram of another stack restoration method provided in an embodiment of the present application;
[0019] Figure 7 A schematic diagram of a stack restoration device 700 provided in an embodiment of the present application;
[0020] Figure 8 A schematic block diagram of an electronic device 800 provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0022] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0024] As mentioned above, the existing stack restoration method has the problems of low efficiency in symbol file acquisition and low efficiency in stack restoration, and the system load is large and the system performance is low.
[0025] In order to solve the above technical problems, the present application obtains the symbol file of the application when the application is developed, and then the symbol file obtained this time can be used each subsequent time the stack is restored, thereby avoiding the problem of low efficiency in symbol file acquisition and use caused by obtaining the symbol file only when the application has online problems, reducing system load and ensuring system performance; moreover, since the electronic device parses the symbol file and determines the structured mapping relationship between the symbol address and the source code symbol information in the symbol file before the stack restoration request, it can determine the target source code symbol information corresponding to the stack frame address information at a higher speed, higher accuracy and more convenience according to the structured mapping relationship and the original stack information in the application running, and perform stack restoration according to the target source code symbol information, thereby improving the convenience, accuracy and efficiency of stack restoration.
[0026] It should be understood that the technical solution of the present application can be applied to the following scenarios, but is not limited to:
[0027] In one embodiment, the present application can be applied to determine a stack restoration scenario, and specifically can be applied to: a stack restoration scenario for checking online problems of an application.
[0028] Exemplarily, the application in the embodiments of the present application may be an application corresponding to the client, or may be an application corresponding to the mini-program, and the present application does not impose any restrictions on this.
[0029] In one embodiment, if Figure 1 As shown, the application scenario may include a terminal device 110 and a server 120, and the terminal device 110 and the server 120 may be connected via a wired network or a wireless network.
[0030] Exemplarily, an application can be installed on the terminal device 110, and the server 120 can obtain the symbol file of the application when the application is developed, and parse the symbol file to determine the structured mapping relationship between multiple symbol addresses and multiple source code symbol information in the symbol file. Afterwards, when the above application has an online problem, the server 120 can obtain the original stack information of the application during operation, and determine the target source code symbol information corresponding to the stack frame address information based on the original stack information and the above structured mapping relationship, and perform stack restoration on the original stack information based on the target source code symbol information to obtain the source code stack information.
[0031] The server 120 may be a server. The server may be a single server, a server cluster consisting of multiple servers, or a cloud platform control center, but is not limited thereto. The terminal device 110 may be a mobile phone, a tablet computer, a laptop computer, or a desktop computer, but is not limited thereto.
[0032] It should be noted that Figure 1 The terminal devices and servers in the example are merely exemplary. Specifically, other numbers or types of terminal devices or servers may also be included.
[0033] In addition, the technical solution of the present application can also be executed only through a server or a terminal device. To avoid repetition, this application will not elaborate on this.
[0034] After introducing the application scenarios of the embodiments of the present application, the technical solution of the present application will be described in detail below:
[0035] Figure 2 This is a flowchart of a stack restoration method provided in an embodiment of the present application. The method can be executed by the server 120 in the above application scenario, but is not limited thereto. Figure 2 As shown, the method may include the following steps:
[0036] S210: In response to the development operation for the application, obtaining a symbol file generated corresponding to the development application;
[0037] S220: parsing the symbol file to obtain a plurality of symbol addresses and a plurality of source code symbol information in the symbol file, and generating a structured mapping relationship between the plurality of symbol addresses and the plurality of source code symbol information according to the plurality of symbol addresses and the plurality of source code symbol information;
[0038] S230: In response to the stack restoration request, obtaining original stack information during the running of the application, where the original stack information includes stack frame address information;
[0039] S240: determining target source code symbol information corresponding to the stack frame address information from a plurality of source code symbol information according to the structured mapping relationship and the stack frame address information;
[0040] S250: Perform stack restoration on the original stack information according to the target source code symbol information to obtain source code stack information.
[0041] In one embodiment, the application in this application can be an application corresponding to a client such as a desktop or web page, or it can be an application corresponding to a mini-program or a browser web page. This application does not impose any restrictions on this.
[0042] It should be noted that the above-mentioned development operation for the application may also be referred to as a construction operation or a creation operation for the application.
[0043] In addition, the development operation may be the first development operation for the application, or may be a development operation corresponding to updating or upgrading the application after the application is developed.
[0044] In one embodiment, since the symbol file is generated when the application is developed, a new step can be added to the application development process: after the symbol file is generated, the symbol file is uploaded to the server; thus, the server can obtain the symbol file generated corresponding to the development application in response to the development operation for the application.
[0045] For example, the above steps can be added to the application development process through continuous integration / continuous delivery (CI / CD) tools, but not limited to this. Among them, CI / CD tools can accelerate and optimize the software building, testing and deployment process through automated processes. CI / CD tools can be Jenkins or Azure Pipelines.
[0046] In another embodiment, the above-mentioned processing step for the symbol file "uploading the symbol file to the server after the symbol file is generated" can be integrated into the application development environment, so that after the application is developed and the symbol file is generated, the symbol file can be sent to the server, so that the server obtains the symbol file.
[0047] Alternatively, the server can write an automation script, which can be used to detect the development process of the application. When it is detected that a symbol file has been generated, the automation script can send a generation message to the server. After the server obtains the generation message, it can obtain the symbol file generated corresponding to the development application.
[0048] In one embodiment, the server in the present application may be a server corresponding to Application Performance Management (APM).
[0049] Among them, APM is a method and tool set for monitoring, diagnosing and optimizing application performance. In the application, APM can be used to monitor the running status of the application, obtain online problems of the application, and perform stack restoration on the original stack information corresponding to the online problems of the application to obtain source code symbol information.
[0050] The following is an introduction to symbol files:
[0051] It is understandable that the formats of symbol files under different systems are generally different. This application will take the symbol files under the iOS (Internetworking Operating System) platform as an example to introduce the symbol files. The symbol files under other system platforms such as Android, Linux, and Unix are similar to this, and this application will not go into details.
[0052] On the iOS platform, symbol files usually refer to debugger symbols (DSYM) files. DSYM files contain debugging information. The debugging information contains the correspondence between symbol addresses and source code symbol information. Therefore, the original stack information (the original stack information includes stack frame address information) of the running application can be restored to the source code level stack, that is, source code stack information or source code symbol information, through the symbol file.
[0053] Specifically, the symbol file includes: recording source code symbol information, such as recording the correspondence between function symbols and their symbol addresses, and the correspondence between line number symbols and their symbol addresses; in addition, the symbol file also records the offset address (text_vm_addr) of the code segment relative to the executable file.
[0054] The symbol address, including the starting address and the ending address, refers to the address range of the source code symbol information (that is, the function called when the application is running).
[0055] Source code symbol information generally includes two types of symbols: function symbol type and line number symbol type. The source code symbol information under the function symbol type (subprogram, i.e. function symbol information) includes: the function name of the function called when the application is running; the source code symbol information under the line number symbol type (de bug_line, i.e. line number symbol information) includes: the line number of the function called when the application is running in the corresponding source code file.
[0056] The offset address of the code segment relative to the executable file refers to the offset address of the source code file to which the called function belongs relative to the executable file. It exists in the header of the symbol file and is used for conversion between stack frame address information and symbolic address. This application will introduce this in subsequent embodiments.
[0057] It is understandable that, due to the large amount of stack restoration requests and the large amount of data in the symbol file, if the symbol file is opened and matched with the original stack information in the running application only when the stack restoration request is obtained, the stack restoration efficiency will be low. Therefore, after obtaining the symbol file, the server can parse the symbol file first, obtain the symbol address and source code symbol information in the symbol file, and generate a structured mapping relationship between the symbol address and the source code symbol information. The structured mapping relationship can meet a higher matching efficiency, so that the target source code symbol information in the source code symbol information that matches the stack frame address information of each stack frame in the original stack information can be determined more efficiently, so that the stack restoration efficiency can be improved.
[0058] Furthermore, the original stack information actually refers to the return address of each layer of function call in the memory stack space, and stack restoration actually refers to converting the return address of the function call in the stack space into the function name and corresponding line number of the called function in the source code file. Therefore, the source code symbol information may include but is not limited to: function symbol information and line number symbol information of the called function, wherein the function symbol information includes: the function name of the called function, and the line number symbol information includes: the line number of the called function in the source code file to which it belongs.
[0059] After obtaining the symbol file, the symbol file can be interpreted to extract the symbolic addresses, function names and line numbers in the source code file corresponding to different functions (i.e., function symbols) from the symbol file, and then construct a structured mapping relationship between the symbolic addresses of different functions and their function names and line numbers in the source code file, so that the corresponding source code symbol information can be quickly found in the structured mapping relationship during subsequent stack restoration.
[0060] The following describes how to generate a structured mapping relationship between multiple symbol addresses and multiple source code symbol information based on multiple symbol addresses and multiple source code symbol information in a symbol file:
[0061] In one embodiment, the structured mapping relationship may be a structured mapping relationship based on a Key-Value (keyword-value) format, but is not limited thereto.
[0062] In one embodiment, the above-mentioned generating a structured mapping relationship between a plurality of symbol addresses and a plurality of source code symbol information according to a plurality of symbol addresses and a plurality of source code symbol information may include the following steps:
[0063] S220-1: Classifying the plurality of source code symbol information according to the symbol types to which the plurality of source code symbol information belongs, and obtaining source code symbol information of different symbol types;
[0064] S220-2: for any target symbol type among the different symbol types, bucketing the source symbol information under the target symbol type according to the target symbol address corresponding to the source symbol information under the target symbol type, and determining a plurality of target symbol information buckets and respective bucket identifiers of the plurality of target symbol information buckets;
[0065] S220-3: Obtaining the executable file identifier corresponding to the source code symbol information under the target symbol type from the symbol file;
[0066] S220-4: Determine the executable file identifier corresponding to the source code symbol information under the target symbol type and the bucket identifiers of the multiple target symbol information buckets as the keyword key corresponding to each target symbol information bucket under the target symbol type;
[0067] S220-5: Determine the source code symbol information under the target symbol type as the value value of the keyword corresponding to each target symbol information bucket under the target symbol type;
[0068] S220-6: Generate a structured mapping relationship corresponding to the source code symbol information under the target symbol type according to the keywords and values corresponding to the source code symbol information under the target symbol type.
[0069] The above S220-1 to S220-6 will be introduced in turn below:
[0070] Exemplarily, for S220-1, combined with the above introduction to source code symbol information, it can be seen that the server can divide the source code symbol information into two categories according to the symbol type to which the source code symbol information belongs: source code symbol information under the function symbol type (i.e., function symbol information, such as the function name), and source code symbol information under the line number symbol type (i.e., line number symbol information, such as the line number of the function in the corresponding source code file).
[0071] Specifically, the server can first obtain source code symbol information from the symbol file, which may include the symbol addresses, function names and line numbers of different functions in the symbol file, and then, according to the symbol type, determine the source code symbol information of different functions in the symbol file under the function symbol type and the source code symbol information under the line number symbol type.
[0072] Furthermore, the source code symbol information corresponding to each symbol type may be serialized, and the source code symbol information may be stored in a serialized byte sequence.
[0073] After determining the source code symbol information corresponding to different symbol types, for multiple source code symbol information under any symbol type, a structured mapping relationship between the source code symbol information and the symbol address can be constructed according to each source code symbol information and the symbol address corresponding to each source code symbol information. Specifically, a first structured mapping relationship between each source code symbol information under the function symbol type and its corresponding symbol address, and a second structured mapping relationship between each source code symbol information under the line number symbol type and its corresponding symbol address can be constructed.
[0074] Furthermore, combined with the above explanation of the symbol file, it can be seen that the symbol address in the symbol file is not a fixed address, but an address range. Therefore, the stack frame address information in the original stack information cannot be directly matched with the symbol address. For any target symbol type in different symbol types, the server can further bucket the source code symbol information according to the symbol address of each source code symbol information under the target symbol type, and obtain the symbol information bucket and the bucket identifier of the symbol information bucket. In other words, the bucket identifier and the symbol information bucket are both obtained based on the symbol address, which not only facilitates the matching of stack frame address information, but also improves the efficiency and accuracy of searching for the corresponding source code symbol information.
[0075] Exemplarily, for S220-2, the source code symbol information under the target symbol type is bucketed according to the target symbol address corresponding to the source code symbol information under the target symbol type, and multiple target symbol information buckets and the bucket identifiers of the multiple target symbol information buckets are determined. Specifically, it may include: first determining the maximum number of source code symbol information corresponding to a single symbol information bucket, and obtaining the bucketing performance and the performance of generating a structured mapping relationship; then, the server may determine the bucket range value of the single symbol information bucket according to the above-mentioned maximum number of source code symbol information, the bucketing performance and the performance of generating a structured mapping relationship; thereafter, the server may bucket the source code symbol information under the target symbol type according to the bucket range value and the target symbol address corresponding to each source code symbol information under the target symbol type, and determine multiple target symbol information buckets and the bucket identifiers of the multiple target symbol information buckets.
[0076] It can be understood that a bucket refers to a logical or physical grouping method for storing elements, and each bucket can be regarded as a container that can be used to store elements with the same rules.
[0077] It can be understood that if the number of source code symbol information in a single symbol information bucket is large, the address range corresponding to the symbol address corresponding to each symbol information bucket will be larger, which will increase the matching complexity with the stack frame address information; if the number of source code symbol information in a single symbol information bucket is small, more symbol information buckets will be generated, which will require higher bucketing performance and structured mapping relationship generation performance. Therefore, the server can determine the number of source code symbol information in a single symbol information bucket after bucketing based on the maximum number of source code symbol information corresponding to a single symbol information bucket, as well as the bucketing performance and structured mapping relationship generation performance.
[0078] Among them, the bucket range value (bucket_range) can indicate the address range size corresponding to the symbol address corresponding to a single symbol information bucket after bucketing, and can also be used to indicate the number of source code symbol information in a single symbol information bucket after bucketing. Therefore, the bucket range value of a single symbol information bucket can be determined based on the maximum number of source code symbol information, bucketing performance, and performance of generating structured mapping relationships, so that more reasonable bucketing can be achieved based on the bucket range value.
[0079] Bucketing performance refers to the server's ability to bucket source code symbol information of any symbol type, and structured mapping relationship performance refers to the server's ability to generate structured mapping relationships between multiple symbol addresses and multiple source code symbol information.
[0080] Optionally, the server may determine bucketing performance and structured mapping relationship generation performance based on system resources such as file parsing capability, memory, and network bandwidth, but is not limited thereto.
[0081] In one embodiment, the symbol address corresponding to the source code symbol information includes the starting address and the ending address corresponding to the source code symbol information. For any target symbol type among different symbol types, the server can obtain the bucket address results of the source code symbol information under the target symbol type according to the starting address and the bucket range value in the target symbol address corresponding to the source code symbol information under the target symbol type; then, the server can classify the source code symbol information with the same bucket address results into the same target symbol information bucket to obtain multiple target symbol information buckets; thereafter, the server can determine the bucket address results corresponding to each of the multiple target symbol information buckets as the bucket identifiers corresponding to each of the multiple target symbol information buckets.
[0082] Specifically, for each source code symbol information under the target symbol type, after obtaining the bucket range value, the server can perform a right shift operation on the starting address in the target symbol address corresponding to each source code symbol information according to the bucket range value, so as to determine the operation result of the right shift operation of the starting address as the bucket address result, and then divide each source code symbol information into buckets according to the bucket address results corresponding to each source code symbol information to obtain multiple symbol information buckets.
[0083] For example, if the bucket range value is used as the address right shift value, such as the bucket range value is 16 bits, the server can right shift the starting address in the target symbol address corresponding to the source code symbol information by 16 bits to obtain the bucket address result corresponding to the source code symbol information.
[0084] It is understandable that when stack restoration is performed subsequently, the stack frame address information can be converted into a bucket identifier, and then the bucket address corresponding to the starting address can be searched for multiple source code symbol information whose result is the same as the bucket identifier, so as to obtain the target source code symbol information corresponding to the stack frame address information from these source code symbol information.
[0085] Furthermore, for any target symbol type among different symbol types, the original symbol address corresponding to each source code symbol information under the target symbol type can be obtained, and the original symbol address can be determined as the target symbol address to construct a structured mapping relationship based on the target symbol address.
[0086] In addition, for any target symbol type among different symbol types, the original symbol address corresponding to the source code symbol information under the target symbol type can be first obtained, and based on the original symbol address and the offset address of the code segment recorded in the symbol file relative to the executable file, the index symbol address corresponding to each source code symbol information under the target symbol type can be determined, and then the index symbol address can be determined as the target symbol address to construct a structured mapping relationship based on the target symbol address.
[0087] For S220-3 and S220-4, since the corresponding original stack information and symbol file include the executable file identifier of the same executable file, that is, include the same executable file identifier, therefore, determining the executable file identifier as part of the keyword in the structured mapping relationship can ensure that the structured mapping relationship under the symbol file corresponding to the original stack information can be accurately found, thereby ensuring the accuracy of stack restoration.
[0088] Exemplarily, the executable file identifier may be a universally unique identifier (UUID) of the executable file, but is not limited thereto.
[0089] Exemplarily, combined with the above classification of source code symbol information, it can be known that symbol information buckets can correspond to two categories: symbol information buckets under function symbol type and symbol information buckets under line number symbol type. The server can determine the keys corresponding to each of these two types of symbol information buckets, where the key corresponding to the symbol information bucket under the function symbol type is: dwarf_subprogram:{macho_uuid}:{bucket_id}; the key corresponding to the symbol information bucket under the line number symbol type is: dwarf_debug_line:{macho_uuid}:{bucket_id}. bucket_id refers to the bucket identifier, and macho_uuid refers to the executable file identifier.
[0090] As mentioned above, for the source code symbol information under any symbol type, after each source code symbol information is bucketed according to the starting address in the target symbol address corresponding to each source code symbol information, the source code symbol information and its symbol address divided into the same symbol information bucket (i.e., the target symbol information bucket) can be stored in the corresponding target symbol information bucket as the value of the keyword key corresponding to the target symbol information bucket under the target symbol type.
[0091] Specifically, in one embodiment, for S220-5, the server can adjust the source code symbol information under the target symbol type to the source code symbol information of the structure type according to the symbol name of each symbol information in the source code symbol information, and the symbol name includes at least one of the following: function name, line number name; then, the server can combine multiple source code symbol information of structure type into source code symbol information of array type; then, the server can serialize the source code symbol information of array type to obtain the source code symbol information under the target symbol type in string form; finally, the server can determine the source code symbol information under the target symbol type in string form as the value corresponding to the source code symbol information under the target symbol type.
[0092] It can be understood that information of structure type has clear fields and types, which can reduce data confusion and improve data readability; information of array type can facilitate batch processing and centralized management such as data traversal, search, and sorting; information in string form can facilitate data transmission and storage. Therefore, the above embodiments can achieve more efficient and reasonable processing of source code symbol information.
[0093] Specifically, for any target symbol information bucket under any target symbol type in different symbol types, multiple source code symbol information divided into the target symbol information bucket from each source code symbol information under the target symbol type can be obtained, and then based on these source code symbol information and their target symbol addresses, the source code symbol information of the corresponding structure type can be constructed respectively.
[0094] Exemplarily, the server may adjust the source code symbol information under the function symbol type into the following structure to obtain the source code symbol information of the corresponding structure type:
[0095] {
[0096] MachoUUID (executable file identifier): 000;
[0097] LowPC (starting address of the function): 0x12345678;
[0098] HighPC (the end address of the function): 0x22345678;
[0099] FileName (source code file name to which the function belongs): file 1;
[0100] FuncName(function name): function 1
[0101] }
[0102] Exemplarily, the server may adjust the source code symbol information under the line number symbol type into the following structure to obtain the source code symbol information of the corresponding structure type:
[0103] {
[0104] MachoUUID (executable file identifier): 000;
[0105] StartAddress (starting address of the row): 0x32345678;
[0106] EndAddress (end address of the line): 0x42345678;
[0107] FileName (source code file name to which the line belongs): file 2;
[0108] Line: 1
[0109] }
[0110] After obtaining the source code symbol information of the structure type, the source code symbol information of each structure type divided into the target symbol information bucket can be constructed into an array to obtain the source code symbol information of the array type corresponding to the target symbol information bucket. Then, the source code symbol information of the array type is serialized to obtain the source code symbol information in string form corresponding to the target symbol information bucket; finally, the source code symbol information in string form corresponding to the target symbol information bucket is determined as the value value of the keyword key corresponding to the target symbol information bucket; it can be understood that the keywords and values of all target symbol information buckets under the target symbol type are the structured mapping relationship of the source code symbol information under the target symbol type.
[0111] For S220-6, in the structured mapping relationship, the server can determine that the value corresponding to each key is: the source code symbol information in the symbol information bucket corresponding to the bucket identifier included in the key.
[0112] Taking the construction of the first structured mapping relationship between each source code symbol information and its corresponding symbol address under the function symbol type as an example, the target symbol address can be obtained based on the original symbol address (including the start address and the end address of the function) corresponding to the function symbol information under the function symbol type, and then based on the start address in the target symbol address, different function symbol information is bucketed to obtain the first symbol information bucket under the function symbol type; for each function symbol information and its target symbol address, the function symbol information of the structure type is constructed according to the preset structure type; then, for the function symbol information divided into the same first symbol information bucket, the function symbol information of the structure type corresponding to it can be constructed as an array to obtain the function symbol information of the array type corresponding to the first symbol information bucket, and then, the function symbol information of the array type is serialized to obtain the function symbol information in the string form corresponding to the first symbol information bucket; finally, the function symbol information in the string form corresponding to each first symbol information bucket is determined as the value value of the keyword ke y corresponding to the first symbol information bucket. It can be understood that the keywords and values of all first symbol information buckets under the function symbol type are the structured mapping relationship of the source code symbol information under the function symbol type.
[0113] Similarly, for the second structured mapping relationship between each source code symbol information and its corresponding symbol address under the line number symbol type, the target symbol address can be obtained based on the original symbol address (including the starting address and the ending address of the line) corresponding to the line number symbol information under the line number symbol type, and then based on the starting address in the target symbol address, different line number symbol information can be bucketed to obtain the second symbol information bucket under the line number symbol type; for each line number symbol information and its target symbol address, a structure type of line number symbol information is constructed according to a preset structure type; and then, for the function symbol information divided into the same second symbol information bucket, the corresponding structure type of line number symbol information can be constructed into an array to obtain the array type of line number symbol information corresponding to the second symbol information bucket, and then, the array type of line number symbol information is serialized to obtain the string form of line number symbol information corresponding to the second symbol information bucket; finally, the string form of line number symbol information corresponding to each second symbol information bucket is determined as the value value of the keyword key corresponding to the second symbol information bucket. It can be understood that the keywords and values of all second symbol information buckets under the line number symbol type are the structured mapping relationship of the source code symbol information under the line number symbol type.
[0114] In one embodiment, the server may store the above structured mapping relationship so that it can be read when needed.
[0115] Exemplarily, the server can obtain the number of visits to multiple source code symbol information; then, based on the number of visits to each source code symbol information, determine the number of visits to each symbol information bucket, and then determine the symbol information bucket with a visit volume greater than an access threshold as a specific symbol information bucket, that is, a specific structured mapping relationship; finally, store all symbol information buckets in a hard disk-based persistent storage, and store the specific symbol information bucket as hot data in a memory-based cache.
[0116] It is understandable that, since the memory has a faster reading speed, storing frequently accessed structured mapping relationships in the memory can improve access efficiency; storing all structured mapping relationships in a storage space other than the memory can provide persistent storage capabilities and reduce storage costs. The storage space can be a local database on the server, such as a disk, or a cloud database, and this application does not limit this.
[0117] In one embodiment, in combination with the above, Figure 3As shown, the CI pipeline can monitor the development process of the application. When the generated symbol file is detected, the symbol file and the development identifier of the application (build_id, one development operation corresponds to one development identifier, that is, one development identifier corresponds to one symbol file) can be uploaded to the symbol manager (SymbolManager) of the server. The symbol manager can read the symbol file and store the symbol file in the storage space of the server (for example, FO SS), and record the status of the symbol file as "being parsed" in MySQL. After that, after successfully uploading the symbol file, the symbol manager sends the above development identifier to the CI pipeline. The CI pipeline can inject the development identifier into the application before the end of development (needed for subsequent stack restoration); the symbol manager can asynchronously parse the symbol file to obtain the above structured mapping relationship, and store the structured mapping relationship in the form of key-value in the Redis of the server, and record the status of the symbol file as "parsed" in MySQL.
[0118] In one embodiment, in combination with the above embodiments, the server can be a server corresponding to APM, and can monitor the running status of the application through the SDK installed on the client. When an online problem is detected in the application, an abnormal event can be reported to the server. The abnormal event includes the original stack information. After the server obtains the abnormal event reported by the SDK, it will extract the original stack information and call the stack restoration service. Using the structured mapping relationship in the stack restoration service, the original stack information in the running application is restored to obtain the source code stack information; then, the source code stack information is saved as the event information of the abnormal event and written into the database for subsequent R&D personnel to locate the abnormal event, etc.
[0119] Specifically, the server needs to first obtain the stack frame address information from the original stack information; then, based on the stack frame address information and the above-mentioned structured mapping relationship, determine the matching symbol information buckets under different symbol types from the symbol information buckets of different symbol types recorded in the structured mapping relationship, and then, determine the target source code symbol information corresponding to the stack frame address information of the target stack frame from the matching symbol information buckets under different symbol types.
[0120] The following is an introduction to the original stack information and stack frame address information:
[0121] The original stack information includes the complete context of the function call at a certain moment in the running of the application. The stack corresponding to the original stack information is composed of many stack frames, and the stack frame is the context information of a certain layer of function call. The original stack information may contain at least the following fields: the name of the executable file, the executable file identifier, the instruction address of the stack frame (runtime_addr, that is, the instruction address in the frame stack), the base address of the executable file in the memory (load_addr), and the offset of the instruction address corresponding to the stack frame relative to the base address of the executable file loaded in the memory.
[0122] When running an application, you need to first load the application's executable file into the corresponding memory space, and then call each function in the executable file to implement the application's operation; among them, the base address of the executable file in the memory refers to the starting address of the executable file when it is loaded into the memory space, and the instruction address of the stack frame refers to the address in the memory space when a function is called.
[0123] The stack frame address information may include: the instruction address of the stack frame and the base address of the executable file. The stack frame address information may also include: the offset of the instruction address corresponding to the stack frame relative to the base address of the executable file loaded in the memory.
[0124] In one embodiment, the server may obtain stack frame address information from the original stack information; then, according to the structured mapping relationship and the stack frame address information, determine the target source code symbol information corresponding to the stack frame address information from the plurality of source code symbol information. Specifically, the server may implement the following steps:
[0125] S240-1: Determine the bucket identifier to be matched and the symbol address to be matched according to the stack frame address information and the bucket range value;
[0126] S240-2: Obtaining the executable file identifier from the original stack information;
[0127] S240-3: According to the structured mapping relationship corresponding to the bucket identifier to be matched, the executable file identifier, and the source code symbol information under each symbol type, determine the matching symbol information bucket corresponding to the bucket identifier to be matched from the symbol information buckets under each symbol type;
[0128] S240 - 4 : According to the address of the symbol to be matched, obtain the target source code symbol information matching the address of the symbol to be matched from the matching symbol information buckets corresponding to each symbol type.
[0129] The above steps are described below:
[0130] For S240-1, since the keywords in the above structured mapping relationship include bucket identifiers, the server needs to first determine the bucket identifier to be matched based on the stack frame address information and the bucket range value, so as to match the corresponding source code symbol information, namely the target source code symbol information.
[0131] In addition, combined with the above content, it can be seen that the symbol address in the symbol file is fixed, while during the running of the application, the address where the executable file is loaded in the memory is not fixed. Therefore, the stack frame address information in the original stack information cannot be directly associated with the symbol address. It is necessary to determine the symbol address corresponding to the stack frame address information, that is, the symbol address to be matched, based on the relationship between the stack frame address information and the symbol address, and then determine the target source code symbol information used for stack restoration of the original stack information based on the symbol address to be matched and the structured mapping relationship.
[0132] The relationship between the stack frame address information and the symbol address is as follows: Combining the above content, such as Figure 4 For a clearer understanding, let's first Figure 4 The addresses are explained again:
[0133] aslr_offset refers to the random offset generated by the Address Space Layout Randomization (ASLR) mechanism of the operating system, which is randomly generated each time the program runs;
[0134] file_addr refers to the symbol address;
[0135] text_vm_addr refers to the offset address of the code segment in the symbol file relative to the executable file;
[0136] runtime_addr refers to the instruction address of the stack frame in the original stack information;
[0137] load_addr refers to the base address where the executable file is loaded in memory in the original stack information.
[0138] in, Figure 4 The multiple addresses satisfy the relationship shown in formula (1) and formula (2):
[0139] runtime_addr=file_addr+aslr_offset formula (1)
[0140] aslr_offset=load_addr-text_vm_addr formula (2)
[0141] Combining and simplifying formula (1) and formula (2), we get the following formula (3):
[0142] file_addr=runtime_addr-load_addr+text_vm_addr formula (3)
[0143] It is understandable that aslr_offset is a random value and cannot be obtained from the symbol file or the original stack information. Therefore, the corresponding symbol address can be determined according to the stack frame address information without using aslr_offset in formula (3).
[0144] In addition, by transforming formula (3), we get the following formula (4):
[0145] file_addr-text_vm_addr=runtime_addr-load_addr formula (4)
[0146] Obviously, the right side of formula (4) is the difference between the instruction address in the stack frame address information and the base address; the left side of formula (4) is the difference between the symbol address in the symbol file and the offset address of the code segment relative to the executable file.
[0147] Among them, when the above-mentioned target symbol address is the original symbol address of the source code symbol information, when performing stack restoration, the server can determine the symbol address to be matched corresponding to the stack frame address information according to the instruction address (runtime_addr) and the base address (load_addr) in the stack frame address information, and the offset address (text_vm_addr) of the code segment in the symbol file relative to the executable file. Specifically, the server can calculate the difference between the instruction address and the base address in the stack frame address information to obtain a first difference; obtain the offset address of the code segment relative to the executable file from the symbol file; and determine the sum of the first difference and the offset address as the symbol address to be matched. At the same time, the symbol address to be matched can be right-shifted by the bucket range value to obtain the bucket identifier to be matched corresponding to the symbol address to be matched.
[0148] In addition, since the difference between the instruction address and the base address in the stack frame address information is essentially equal to the offset of the stack frame address in the original stack information relative to the starting point of the executable file, the server can also obtain the offset of the instruction address corresponding to the stack frame recorded in the original stack information relative to the base address of the executable file loaded in the memory, and then determine the corresponding symbol address to be matched based on the offset and the sum of the offset address (text_vm_addr) of the code segment recorded in the symbol file relative to the executable file, and shift the symbol address to be matched right by the bucket range value to obtain the bucket identifier to be matched corresponding to the symbol address to be matched.
[0149] Furthermore, when the above-mentioned target symbol address is the index symbol address of the source code symbol information, when performing stack restoration, the server determines the symbol address to be matched corresponding to the stack frame address information, which may specifically include: calculating the difference between the instruction address and the base address in the stack frame address information to obtain a first difference value, and determining the first difference value as the symbol address to be matched; at the same time, shifting the symbol address to be matched right by the bucket range value to obtain the bucket identifier to be matched corresponding to the symbol address to be matched.
[0150] In addition, the stack frame address information may also include: the offset of the instruction address corresponding to the stack frame relative to the base address of the executable file loaded in the memory; the server may also directly obtain the offset from the stack frame address information, determine the offset as the symbol address to be matched, shift the symbol address to be matched right by the bucket range value, and obtain the bucket identifier to be matched corresponding to the symbol address to be matched.
[0151] After determining the to-be-matched symbol address, to-be-matched bucket identifier and executable file identifier corresponding to the stack frame address information, the first matching symbol information bucket corresponding to the to-be-matched bucket identifier and the executable file identifier can be determined from the structured mapping relationship corresponding to the source code symbol information under the function symbol type, that is, from each first symbol information bucket under the function symbol type, according to the stack frame address information, the to-be-matched bucket identifier and the executable file identifier; at the same time, the second matching symbol information bucket corresponding to the to-be-matched bucket identifier can be determined from the structured mapping relationship corresponding to the source code symbol information under the line number symbol type, that is, from each second symbol information bucket under the line number symbol type, according to the stack frame address information, the to-be-matched bucket identifier and the executable file identifier.
[0152] For S240-4, in the symbol information bucket, the target symbol address and the source code symbol information are generally one-to-one corresponding. Therefore, the server compares the symbol address to be matched with the target symbol address in the source code symbol information in the matching symbol information bucket (combined with the above content, it can be seen that: the source code symbol information includes the symbol address); the source code symbol information in the matching symbol information bucket corresponding to the target symbol address in the matching symbol information bucket that is consistent with the symbol address to be matched is determined as the target source code symbol information.
[0153] Exemplarily, corresponding to the above-mentioned process of structuring, arraying and serializing the source code symbol information, after determining the matching symbol information bucket, the server can deserialize the source code symbol information in the matching symbol information bucket (the source code symbol information at this time is in the form of a string) to obtain the source code symbol information of the array type, and the source code symbol information of the numerical type includes the source code symbol information of multiple structure types; then, traverse the source code symbol information of each structure type under the source code symbol information of the array type, and compare the symbol address to be matched with the target symbol address in the source code symbol information of each structure type to determine the symbol address that matches the symbol address to be matched from the source code symbol information of the array type; specifically, for the source code symbol information of any structure type, the address range corresponding to the source code symbol information of the structure type can be determined according to the target symbol address in the source code symbol information of the structure type, and then determine whether the symbol address to be matched falls within the address range. If so, it is determined that the source code symbol information of the structure type matches the symbol address to be matched, otherwise, the source code symbol information of the structure type does not match the symbol address to be matched. After the source code symbol information of the structure type matching the symbol address to be matched is determined, the target source code symbol information can be determined from the source code symbol information of the structure type.
[0154] Taking the structured mapping relationship corresponding to the source code symbol information of the function symbol type as an example, the server determines the to-be-matched symbol address corresponding to the stack frame address information, and right-shifts the to-be-matched symbol address by the bucket range value to obtain the to-be-matched bucket identifier corresponding to the to-be-matched symbol address; then, according to the to-be-matched bucket identifier and the executable file identifier, the first matching symbol information bucket corresponding to the to-be-matched bucket identifier and the executable file identifier is determined from the structured mapping relationship corresponding to the source code symbol information of the function symbol type; after deserializing the source code symbol information in the first matching symbol information bucket, the source code symbol information of the array type in the first matching symbol information bucket is obtained; for the source code symbol information of each structure type under the source code symbol information of the array type, the address range corresponding to the source code symbol information of the structure type can be determined according to the starting address (LowPC) and the ending address (HighPC) of the function in the source code symbol information of the structure type, and then it is determined whether the to-be-matched symbol address falls within the address range, so as to determine the source code symbol information of the structure type that matches the to-be-matched symbol address, and obtain the function name from the source code symbol information of the structure type to obtain the target source code symbol information of the function symbol type.
[0155] Taking the structured mapping relationship corresponding to the source code symbol information of the line number symbol type as an example, the server determines the to-be-matched symbol address corresponding to the stack frame address information, and right-shifts the to-be-matched symbol address by the bucket range value to obtain the to-be-matched bucket identifier corresponding to the to-be-matched symbol address; then, according to the to-be-matched bucket identifier and the executable file identifier, the second matching symbol information bucket corresponding to the to-be-matched bucket identifier and the executable file identifier is determined from the structured mapping relationship corresponding to the source code symbol information of the line number symbol type; after deserializing the source code symbol information in the second matching symbol information bucket, the array type in the second matching symbol information bucket is obtained. Source code symbol information; for the source code symbol information of each structure type under the source code symbol information of the array type, the address range corresponding to the source code symbol information of the structure type can be determined according to the starting address (StartAddress) of the row and the ending address (EndAddress) of the row in the source code symbol information of the structure type, and then it is determined whether the address of the symbol to be matched falls within the address range, so as to determine the source code symbol information of the structure type that matches the address of the symbol to be matched, and obtain the specific line number from the source code symbol information of the structure type to obtain the line number symbol type target source code symbol information.
[0156] In one embodiment, since the stack restoration methods of different system platforms are different, after obtaining the above-mentioned target source code symbol information, the server can first determine the system platform running the application; then, based on the stack restoration method supported by the system platform, the original stack information is restored according to the target source code symbol information to obtain the source code stack information.
[0157] Specifically, the server may assemble the target source code symbol information based on the stack restoration method supported by the system platform to obtain a source code level stack, namely, source code stack information.
[0158] Specifically, corresponding to the above-mentioned process of structuring, arraying and serializing the source code symbol information, the server can directly perform stack restoration based on the target source code symbol information in string form, or directly perform stack restoration based on the target source code symbol information of the array type obtained during the matching in the above S240-4; the target source code symbol information of the array type can also be restored to the target source code symbol information before structuring processing, and stack restoration can be performed accordingly, and the present application does not impose any restrictions on this.
[0159] Exemplarily, the restored source code level stack frame, ie, source code stack information, may include the following fields: source code file name, function name, line number in the source file, and offset of the stack frame address relative to the function base address.
[0160] Furthermore, the original stack information usually includes multiple stack frames, and the server can perform stack restoration one by one; specifically, the server can obtain the stack frame address information of the target stack frame one by one according to the stacking order of each stack frame in the original stack information, and determine the matching symbol information bucket corresponding to the stack frame address information of the target stack frame from multiple symbol information buckets based on the structured mapping relationship and the stack frame address information of the target stack frame, and determine the target source code symbol information corresponding to the stack frame address information of the target stack frame from the matching symbol information bucket, and perform stack restoration on the target stack frame in the original stack information according to the target source code symbol information of the target stack frame, until stack restoration is completed for all stack frames in the original stack information.
[0161] In addition, in one embodiment, the server may first obtain the stack frame address information and executable file identifiers of all stack frames in the original stack information, and obtain the to-be-matched symbol address and to-be-matched bucket identifier corresponding to each stack frame according to the stack frame address information and bucket range value of each stack frame; then, according to the to-be-matched bucket identifier and executable file identifier corresponding to each stack frame, obtain the stack restoration queue, wherein the stack restoration queue includes at least one to-be-matched symbol address corresponding to a stack frame, and the to-be-matched bucket identifier and executable file identifier corresponding to the stack frames in the same stack restoration queue are the same. After determining the stack restoration queue, the matching symbol information bucket that matches the stack restoration queue under each symbol type can be obtained from the structured mapping relationship corresponding to the source code symbol information under each symbol type based on the to-be-matched bucket identifier and the executable file identifier corresponding to the stack restoration queue; after deserializing the source code symbol information in the matching symbol information bucket under each symbol type to obtain the source code symbol information of the array type, the to-be-matched symbol addresses corresponding to each stack frame in the stack restoration queue can be compared with the target symbol addresses in the source code symbol information of each structure type under the source code symbol information of the array type, so as to determine the source code symbol information of the structure type that matches each stack frame in the stack restoration queue from the source code symbol information of the array type.
[0162] Furthermore, for each stack restoration queue, the matching symbol information bucket that matches the stack restoration queue under each symbol type can be obtained from the structured mapping relationship corresponding to each symbol type stored in the database according to the to-be-matched bucket identifier and the executable file identifier corresponding to the stack restoration queue, and the matching symbol information can be deserialized and stored in the local cache, and then compared with the target symbol address in the source code symbol information of each structure type in the local cache based on the to-be-matched symbol address corresponding to each stack frame in the stack restoration queue, so as to determine the source code symbol information of the structure type that matches each stack frame in the stack restoration queue.
[0163] The stack restoration queue is determined by the stack frame address information of different stack frames in the original stack information, so that the stack frames whose stack frame address information is matched to the same symbol information bucket are concentrated in the same queue. Then, the symbol information bucket matched by the stack restoration queue is obtained from the structured mapping relationship based on the stack restoration queue. There is no need to repeatedly perform steps such as determining the symbol information bucket from the structured mapping relationship based on the stack frame address information of the stack frame and deserializing the symbol information bucket. This avoids multiple data searches in the structured mapping relationship when massive original stack information is reported, reduces server communication pressure, and improves the stack restoration performance of the server in the scenario where massive original stack information is reported.
[0164] Since the stack also contains a large number of system stacks and stack frames generated by third-party library calls, these stack frames cannot be restored normally when the system symbol files and third-party library symbol files are missing. If a stack frame fails to be restored, the server can use the original stack frame information (such as stack frame address information) of the stack frame as the restoration result of the stack frame, and then continue to restore other stack frames in the original stack information until all stack frames in the original stack information are traversed and the restoration process ends.
[0165] In one embodiment, in combination with the above, Figure 5As shown, when the analysis service receives a report event about stack restoration, for example, when it receives a report event about an online problem, it can extract the original stack information and the development identifier of the application from the application (introduced in the above embodiment); then, the original stack information and the development identifier are sent to the symbol manager of the server; the symbol manager can format each stack frame in the original stack information separately, and determine the to-be-matched symbol address and the to-be-matched bucket identifier corresponding to the stack frame address information in each stack frame in the original stack information; then, the symbol management can obtain the executable file identifier from the original stack information; according to the to-be-matched bucket identifier, the executable file identifier and the structured mapping relationship corresponding to the source code symbol information under each symbol type, from the storage unit storing the structured mapping relationship, in the target symbol information bucket under each symbol type (for example, the subprogram bucket corresponding to the function symbol type and the debugl bucket corresponding to the line number symbol type). ine bucket) to pull the matching symbol information bucket corresponding to the development identifier, executable file identifier and bucket identifier to be matched; then, the symbol manager can obtain the target source code symbol information matching the symbol address to be matched from the matching symbol information bucket corresponding to each symbol type according to the symbol address to be matched; then, after determining the target source code symbol information corresponding to the symbol address to be matched in all stack frames, the server can assemble the target source code symbol information to obtain the restored stack, i.e., the source code stack information. After that, the source code stack information can be sent to the analysis service; the analysis service can perform logical analysis on the source code stack information and store the analysis results in the storage unit Clickhouse.
[0166] In one embodiment, in combination with the above, Figure 6 As shown, the intranet-based CI / CD pipeline can upload symbol files to the symbol file management service; the symbol manager of the symbol file management service can determine the structured mapping relationship between the symbol address and the source code symbol information in the symbol file, and store the symbol file in the storage space of the server, record the status of the symbol file in MySQL, and store the structured mapping relationship in the server's database (such as KeewiDB) in the form of KV. Afterwards, when an online problem occurs in the application, the online problem can be sent to the analysis service through the SDK (Software Development Kit) in the application; the analysis service can send the original stack information to the stack restoration service, and the stack restoration service can restore the original stack information to the source code stack information according to the above structured mapping relationship, and return the source code stack information to the analysis service; the analysis service can perform logical analysis on the source code stack information and store the analysis results in the storage unit Clickhouse.
[0167] It should be noted that all the above technical solutions can be combined in any way to form optional embodiments of the present application, which will not be described one by one here.
[0168] It should be noted that in the specific implementation of the present application, related data such as symbol files, original stack information, and the number of visits to symbol addresses and source code symbol information are involved. When the embodiments of the present application are applied to specific products or technologies, user permission, consent or authorization is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0169] Figure 7 A schematic diagram of a stack restoration device 700 provided in an embodiment of the present application.
[0170] like Figure 7 As shown, the apparatus 700 includes: a first acquisition module 710 , a parsing and generating module 720 , a second acquisition module 730 , a first determination module 740 , a stack restoration module 750 , a third acquisition module 760 , a second determination module 770 , and a relationship storage module 780 .
[0171] In one embodiment, a first acquisition module 710 is used to: in response to a development operation for an application, obtain a symbol file generated corresponding to the development application; a parsing generation module 720 is used to: parse the symbol file to obtain multiple symbol addresses and multiple source code symbol information in the symbol file, and generate a structured mapping relationship between multiple symbol addresses and multiple source code symbol information based on the multiple symbol addresses and multiple source code symbol information; a second acquisition module 730 is used to: in response to a stack restoration request, obtain the original stack information in the running application, the original stack information including stack frame address information; a first determination module 740 is used to: determine the target source code symbol information corresponding to the stack frame address information from the multiple source code symbol information based on the structured mapping relationship and the stack frame address information; a stack restoration module 750 is used to: perform stack restoration on the original stack information based on the target source code symbol information to obtain the source code stack information.
[0172] In one embodiment, the parsing generation module 720 is specifically used to: classify multiple source code symbol information according to the symbol types to which the multiple source code symbol information belongs, and obtain source code symbol information under different symbol types; for any target symbol type in different symbol types, bucket the source code symbol information under the target symbol type according to the target symbol address corresponding to the source code symbol information under the target symbol type, and determine multiple target symbol information buckets and the bucket identifiers of the multiple target symbol information buckets; obtain the executable file identifier corresponding to the source code symbol information under the target symbol type from the symbol file; determine the executable file identifier corresponding to the source code symbol information under the target symbol type and the bucket identifiers of the multiple target symbol information buckets as the keywords key corresponding to the multiple target symbol information buckets under the target symbol type; determine the source code symbol information under the target symbol type as the values value of the keywords corresponding to the multiple target symbol information buckets under the target symbol type; and generate a structured mapping relationship corresponding to the source code symbol information under the target symbol type according to the keywords and values corresponding to the source code symbol information under the target symbol type.
[0173] In one embodiment, the parsing generation module 720 is specifically used to: determine the maximum amount of source code symbol information corresponding to a single symbol information bucket, obtain bucketing performance and structured mapping relationship generation performance; determine the bucket range value of a single symbol information bucket based on the maximum amount of source code symbol information, bucketing performance and structured mapping relationship generation performance; bucketize the source code symbol information under the target symbol type based on the bucket range value and the target symbol address corresponding to the source code symbol information under the target symbol type, and determine multiple target symbol information buckets and the bucket identifiers of the multiple target symbol information buckets.
[0174] In one embodiment, the parsing generation module 720 is specifically used to: obtain the bucket address results of the source code symbol information under the target symbol type according to the starting address and the bucket range value in the target symbol address corresponding to the source code symbol information under the target symbol type, the target symbol address including the starting address and the ending address corresponding to the source code symbol information under the target symbol type; classify the source code symbol information with the same bucket address results into the same target symbol information bucket to obtain multiple target symbol information buckets; and determine the bucket address results corresponding to each of the multiple target symbol information buckets as the bucket identifiers corresponding to each of the multiple target symbol information buckets.
[0175] In one embodiment, the first determination module 740 is specifically used to: determine the bucket identifier to be matched and the symbol address to be matched according to the stack frame address information and the bucket range value; obtain the executable file identifier from the original stack information; determine the matching symbol information bucket corresponding to the bucket identifier to be matched from the target symbol information bucket under each symbol type according to the structured mapping relationship corresponding to the bucket identifier to be matched, the executable file identifier and the source code symbol information under each symbol type; according to the symbol address to be matched, obtain the target source code symbol information matching the symbol address to be matched from the matching symbol information buckets corresponding to each symbol type.
[0176] In one embodiment, the stack frame address information includes: the instruction address of the stack frame and the base address of the executable file; the first determination module 740 is specifically used to: calculate the difference between the instruction address and the base address to obtain a first difference; obtain the offset address of the code segment relative to the executable file from the symbol file; determine the sum of the first difference and the offset address as the symbol address to be matched; shift the symbol address to be matched right by the bucket range value to obtain the bucket identifier to be matched corresponding to the symbol address to be matched.
[0177] In one embodiment, the parsing generation module 720 is specifically used to: adjust the source code symbol information under the target symbol type into source code symbol information of multiple structure types according to the symbol name, and the symbol name includes at least one of the following: function name, line number name; combine the source code symbol information of multiple structure types into source code symbol information of array type; serialize the source code symbol information of array type to obtain the source code symbol information under the target symbol type in string form; determine the source code symbol information under the target symbol type in string form as the value of the keyword corresponding to each of the multiple target symbol information buckets under the target symbol type.
[0178] In one embodiment, the third acquisition module 760 is used to obtain the access volume for multiple symbol addresses and multiple source code symbol information; the second determination module 770 is used to determine the structured mapping relationship corresponding to the symbol address and source code symbol information whose access volume is greater than the access threshold as a specific structured mapping relationship; the relationship storage module 780 is used to store the structured mapping relationship in a storage space other than the memory, and store the specific structured mapping relationship in the memory.
[0179] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, Figure 7 The device 700 shown can execute the above method embodiments, and the above and other operations and / or functions of each module in the device 700 are respectively for implementing the corresponding processes in the above methods, which will not be repeated here for the sake of brevity.
[0180] The above describes the device 700 of the embodiment of the present application from the perspective of the functional module in conjunction with the accompanying drawings. It should be understood that the functional module can be implemented in hardware form, can be implemented by instructions in software form, and can also be implemented by a combination of hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software form instructions in the processor, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or a combination of hardware and software modules in the decoding processor to perform. Optionally, the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the steps in the above method embodiment in conjunction with its hardware.
[0181] Figure 8 A schematic block diagram of an electronic device 800 provided in an embodiment of the present application.
[0182] like Figure 8 As shown, the electronic device 800 may include:
[0183] The memory 810 and the processor 820, the memory 810 is used to store the computer program and transmit the program code to the processor 820. In other words, the processor 820 can call and run the computer program from the memory 810 to implement the method in the embodiment of the present application.
[0184] For example, the processor 820 may be configured to execute the above method embodiments according to instructions in the computer program.
[0185] In some embodiments of the present application, the processor 820 may include but is not limited to:
[0186] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
[0187] In some embodiments of the present application, the memory 810 includes but is not limited to:
[0188] Volatile memory and / or non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SL DRAM) and direct memory bus random access memory (DR RAM).
[0189] In some embodiments of the present application, the computer program may be divided into one or more modules, which are stored in the memory 810 and executed by the processor 820 to complete the method provided by the present application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.
[0190] like Figure 8 As shown, the electronic device may also include:
[0191] The transceiver 830 may be connected to the processor 820 or the memory 810 .
[0192] The processor 820 may control the transceiver 830 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 830 may include a transmitter and a receiver. The transceiver 830 may further include an antenna, and the number of antennas may be one or more.
[0193] It should be understood that the various components in the electronic device are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0194] The present application also provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a computer, the computer can perform the method of the above method embodiment. In other words, the present application embodiment also provides a computer program product containing instructions, and when the instructions are executed by a computer, the computer can perform the method of the above method embodiment.
[0195] When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instruction is loaded and executed on a computer, the computer can be made to perform the corresponding flow in each method in the embodiment of the present application in whole or in part, and generate the functions that can be realized by each method in the embodiment of the present application. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instruction can be transmitted from a website site, computer, server or data center by wired (such as coaxial cable, optical fiber, digital subscriber line (Digital Subscriber Line, DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that contains one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital video disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0196] Those of ordinary skill in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0197] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the module is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0198] The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. For example, each functional module in each embodiment of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0199] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A stack restoration method, characterized in that: include: In response to a development operation for an application, obtaining a symbol file generated corresponding to the development of the application; Parsing the symbol file to obtain a plurality of symbol addresses and a plurality of source code symbol information in the symbol file, and generating a structured mapping relationship between the plurality of symbol addresses and the plurality of source code symbol information according to the plurality of symbol addresses and the plurality of source code symbol information; In response to a stack restoration request, obtaining original stack information of the application during execution, the original stack information including stack frame address information; Determining target source code symbol information corresponding to the stack frame address information from the plurality of source code symbol information according to the structured mapping relationship and the stack frame address information; The original stack information is stack restored according to the target source code symbol information to obtain source code stack information.
2. The method according to claim 1, characterized in that The generating a structured mapping relationship between the multiple symbol addresses and the multiple source code symbol information according to the multiple symbol addresses and the multiple source code symbol information includes: Classifying the plurality of source code symbol information according to the symbol types to which the plurality of source code symbol information belongs, to obtain source code symbol information of different symbol types; For any target symbol type among the different symbol types, bucketing the source symbol information under the target symbol type according to the target symbol address corresponding to the source symbol information under the target symbol type, and determining a plurality of target symbol information buckets and respective bucket identifiers of the plurality of target symbol information buckets; Obtaining an executable file identifier corresponding to the source code symbol information under the target symbol type from the symbol file; Determine the executable file identifier corresponding to the source code symbol information under the target symbol type and the bucket identifiers of the multiple target symbol information buckets as the keywords key corresponding to the multiple target symbol information buckets under the target symbol type; Determine the source code symbol information under the target symbol type as the value value of the keyword corresponding to each of the multiple target symbol information buckets under the target symbol type; According to the keywords and values corresponding to the source code symbol information under the target symbol type, a structured mapping relationship corresponding to the source code symbol information under the target symbol type is generated.
3. The method according to claim 2, characterized in that The step of bucketing the source code symbol information under the target symbol type according to the target symbol address corresponding to the source code symbol information under the target symbol type in the multiple symbol addresses, and determining multiple target symbol information buckets and bucket identifiers of the multiple target symbol information buckets, includes: Determine the maximum amount of source code symbol information corresponding to a single symbol information bucket, obtain bucketing performance and generate structured mapping relationship performance; Determining a bucket range value of a single symbol information bucket according to the maximum value of the source code symbol information quantity, the bucketing performance, and the performance of generating a structured mapping relationship; According to the bucket range value and the target symbol address corresponding to the source code symbol information under the target symbol type, the source code symbol information under the target symbol type is bucketed to determine the multiple target symbol information buckets and the bucket identifiers of the multiple target symbol information buckets.
4. The method according to claim 3, characterized in that The step of bucketing the source code symbol information under the target symbol type according to the bucket range value and the target symbol address corresponding to the source code symbol information under the target symbol type, and determining the multiple target symbol information buckets and the bucket identifiers of the multiple target symbol information buckets, includes: According to the starting address in the target symbol address corresponding to the source code symbol information under the target symbol type and the bucket range value, obtaining the bucket address results of the source code symbol information under the target symbol type, wherein the target symbol address includes the starting address and the ending address corresponding to the source code symbol information under the target symbol type; Classify the source code symbol information with the same bucket address result into the same target symbol information bucket to obtain the multiple target symbol information buckets; The bucket address results corresponding to each of the multiple target symbol information buckets are respectively determined as the bucket identifiers corresponding to each of the multiple target symbol information buckets.
5. The method according to claim 4, characterized in that The step of determining target source code symbol information corresponding to the stack frame address information from the plurality of source code symbol information according to the structured mapping relationship and the stack frame address information comprises: Determine a to-be-matched bucket identifier and a to-be-matched symbol address according to the stack frame address information and the bucket range value; Obtaining an executable file identifier from the original stack information; According to the to-be-matched bucket identifier, the executable file identifier, and the structured mapping relationship corresponding to the source code symbol information under each symbol type, determining a matching symbol information bucket corresponding to the to-be-matched bucket identifier from the target symbol information bucket under each symbol type; According to the to-be-matched symbol address, target source code symbol information matching the to-be-matched symbol address is obtained from the matching symbol information buckets corresponding to the symbol types.
6. The method according to claim 5, characterized in that The stack frame address information includes: the instruction address of the stack frame and the base address of the executable file; The step of determining a bucket identifier to be matched and a symbol address to be matched according to the stack frame address information and the bucket range value includes: Calculating a difference between the instruction address and the base address to obtain a first difference value; Obtaining the offset address of the code segment relative to the executable file from the symbol file; Determine the sum of the first difference and the offset address as the address of the symbol to be matched; The to-be-matched symbol address is right-shifted by the bucket range value to obtain a to-be-matched bucket identifier corresponding to the to-be-matched symbol address.
7. The method according to claim 2, characterized in that The step of determining the source code symbol information under the target symbol type as the value of the keyword corresponding to each of the plurality of target symbol information buckets under the target symbol type includes: According to the symbol name, adjusting the source code symbol information under the target symbol type to source code symbol information of multiple structure types, wherein the symbol name includes at least one of the following: a function name and a line number name; Combining the source code symbol information of the plurality of structure types into source code symbol information of array type; Serializing the source code symbol information of the array type to obtain the source code symbol information of the target symbol type in a string form; The source code symbol information under the target symbol type in the string form is determined as the value of the keyword corresponding to each of the multiple target symbol information buckets under the target symbol type.
8. A stack restoration device, characterized in that: include: A first acquisition module is used to: in response to a development operation on an application, acquire a symbol file generated corresponding to the development of the application; A parsing and generating module, used to: parse the symbol file to obtain a plurality of symbol addresses and a plurality of source code symbol information in the symbol file, and generate a structured mapping relationship between the plurality of symbol addresses and the plurality of source code symbol information according to the plurality of symbol addresses and the plurality of source code symbol information; A second acquisition module is used to: in response to a stack restoration request, acquire original stack information of the application in operation, wherein the original stack information includes stack frame address information; A first determining module is used to: determine target source code symbol information corresponding to the stack frame address information from the plurality of source code symbol information according to the structured mapping relationship and the stack frame address information; The stack restoration module is used to perform stack restoration on the original stack information according to the target source code symbol information to obtain source code stack information.
9. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 7 by executing the executable instructions.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
