Information restoration method and device, storage medium and electronic equipment
By combining the first segment mapping table and the second segment mapping table, the problem of source code location caused by stack information offset after front-end code compression is solved, realizing accurate restoration of error code and context tracing, and improving the efficiency and accuracy of error handling.
Patent Information
- Application Number
- CN202511950972.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-23
- Publication Date
- 2026-04-17
AI Technical Summary
Front-end code compression causes line and column number offsets in the stack trace, making it difficult to locate erroneous lines of code or logical segments in the source code.
The first segment mapping table establishes a mapping relationship between compressed code and source code. The error code is reconstructed by calculating the offset. The second segment mapping table is used to trace the scope context of the error code and generate readable error messages.
It enables precise location and contextual tracing of front-end errors, improving the efficiency and accuracy of error handling and adapting to the versatility of different compression scenarios.
Smart Images

Figure CN121879819A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an information restoration method, apparatus, storage medium and electronic device. Background Technology
[0002] Due to the rigid requirements of network transmission efficiency, front-end code in production environments is typically packaged and compressed to reduce file size and the number of requests, thereby optimizing the loading speed of the front-end code. During compression, variable and function names in the front-end code are shortened, original comments and spaces are removed, and the positional information (such as line and column numbers) of the compressed front-end code is offset. These changes result in the complete loss of the original code's structure, naming semantics, and line number information. When the front-end device runs or encounters errors, it can only generate stack information based on the compressed code. At this time, the line numbers in the stack information correspond to the code positions in the compressed file, and the column numbers point to the offset of a character within a single line after merging. However, this information is not directly related to the source code logic, module division, or variable meanings during the development phase. Therefore, it is difficult to directly locate the specific line of code or logical segment in the source code that caused the error based on the stack information captured by the front-end device. Summary of the Invention
[0003] In view of the above problems, this application provides an information restoration method, apparatus, storage medium and electronic device.
[0004] To solve the above-mentioned technical problems, this application proposes the following solution:
[0005] In a first aspect, this application provides an information restoration method. The method is applied to a monitoring device, which stores a first segment mapping table. The first segment mapping table indicates the mapping relationship between the compression start position information of the compressed segment in the compressed file and the position information of the source code in the source code file and the source code file identifier. The method includes: when a device error is detected, extracting error information from the device, the error information including the error type, error code, and the position information of the error code in the corresponding compressed code segment; determining the target compressed segment corresponding to the compressed code segment and the offset of the error code in the target compressed segment based on the position information of the error code in the corresponding compressed code segment and the first segment mapping table; and restoring the error code based on the target compressed segment, the offset, and the first segment mapping table.
[0006] This application captures front-end error information, establishes a bridge between compressed code and source code based on a first segment mapping table, accurately restores the erroneous code through offset calculation, and then traces the scope context link of the erroneous code through a second segment mapping table. Finally, it generates readable error information containing the error type, restored source code, and scope link. This effectively solves the problem of difficult source code location caused by row and column number offsets and loss of original logic after front-end compressed code errors. It transforms error investigation from relying on vague compressed stack information to accurate source code and context tracing, greatly improving the efficiency and accuracy of front-end error handling.
[0007] In conjunction with the first aspect, in one possible implementation, candidate compressed segments corresponding to the compressed code segment are selected based on the location information of the error code in the corresponding compressed code segment and the first segment mapping table; the target compressed segment is determined from the candidate compressed segments, and the position offset of the error code relative to the target compressed segment is calculated based on the location information of the error code and the compression start position information of the target compressed segment; the source code location corresponding to the error code is determined by combining the source code association information recorded in the first segment mapping table of the target compressed segment and the position offset.
[0008] This application provides a unified execution path for error recovery for different compression types, such as single-line and multi-line compression, through a standardized process of screening candidate segments, determining target segments, calculating position offsets, and matching source code positions. The core is to extract common operations for various compression scenarios, allowing the same core logic to adapt to different compression situations, thus improving the versatility of the technical solution.
[0009] In conjunction with the first aspect, in another possible implementation, when the compressed segment in the first segmentation mapping table is a single row, the candidate compressed segment whose compression start column number is less than or equal to the column number of the error code and whose compression start column number is the maximum value is selected as the target compressed segment; based on the location information of the error code and the compression start position information of the target compressed segment, the position offset of the error code relative to the target compressed segment is determined; based on the source code start position information and position offset of the target compressed segment in the first segmentation mapping table, the location information of the source code corresponding to the error code is determined to restore the error code.
[0010] This application refines the implementation logic for single-line compression segmentation scenarios. It accurately locates the target compression segment through a progressive filtering strategy and combines linear calculation of row and column offsets to achieve accurate restoration of error code in extreme single-line compression scenarios. This avoids mapping deviations caused by column number misalignment in single-line compression, ensures the accuracy and efficiency of error location in single-line compression code, and improves the error parsing mechanism for single-line compression scenarios.
[0011] In conjunction with the first aspect, in another possible implementation, when the compressed segment in the first segment mapping table is multiple rows, the candidate compressed segment whose compression start line number is less than or equal to the line number of the error code and whose compression end line number is greater than or equal to the line number of the error code is selected as the target compressed segment; the relative position type between the line number of the error code and the compression start line number and compression end line number of the target compressed segment is determined, and the position offset corresponding to the error code is determined based on the relative position type; the position information of the source code corresponding to the error code is determined by combining the source code start position information or source code end position information corresponding to the target compressed segment and the position offset, so as to restore the error code.
[0012] This application focuses on the common processing logic of multi-line compression segments. By selecting target compression segments that meet the line number range, it dynamically calculates the offset based on the relative position type of the error code in the segment. This adapts to the characteristics of code logic block splitting and reorganization in multi-line compression, solves the structural breakage problem caused by cross-line compression, and provides a stable and reliable implementation path for error restoration in complex multi-line compression scenarios.
[0013] In conjunction with the first aspect, in another possible implementation, when the line number of the error code is greater than or equal to the compression start line number of the target compression segment and less than or equal to the compression end line number of the target compression segment, the line offset of the error code is determined based on the line number of the error code and the compression start line number of the target compression segment; the line number of the source code corresponding to the error code is determined based on the starting line number of the source code of the target compression segment and the line offset; and the column number of the source code corresponding to the error code is determined based on the starting column number of the source code of the target compression segment and the column number of the error code.
[0014] This application optimizes the calculation method for scenarios where erroneous code is located in the middle of a complete line in a multi-line compressed segment. It is in line with the linear mapping characteristics of code compression tools for continuous middle lines. By using the method of stacking row offsets and directly mapping column numbers, the source code location can be quickly located without complex column offset calculations. While ensuring the accuracy of restoration, it improves processing efficiency, making error parsing in the high-frequency scenario of middle lines more efficient and simpler.
[0015] In conjunction with the first aspect, in another possible implementation, when the line number of the error code is equal to the compression start line number of the target compression segment, and the column number of the error code is greater than or equal to the compression start column number of the target compression segment, the source code line number of the target compression segment is the line number of the source code corresponding to the error code; the column offset of the error code is determined based on the column number of the error code and the compression start column number of the target compression segment, and the column number of the source code corresponding to the error code is determined based on the source code start column number of the target compression segment and the column offset.
[0016] This application refines the processing strategy for scenarios where error codes are located at the beginning of multi-line compressed segments. By limiting the effective column range, it avoids the problem of line number misalignment caused by the compression tool inserting wrapper code at the beginning of the line. It adopts the method of "row offset is 0 + column offset calculation" to accurately handle the scenario where some column numbers in the first line are occupied by non-mapped code, thereby improving the restoration accuracy of the first line partial coverage scenario.
[0017] In conjunction with the first aspect, in another possible implementation, when the line number of the error code is equal to the compression end line number of the target compression segment, and the column number of the error code is less than or equal to the compression end column number of the target compression segment, the line offset of the error code is determined based on the line number of the error code and the compression start line number of the target compression segment; the line number of the source code corresponding to the error code is determined based on the source code start line number of the target compression segment and the line offset; the column offset of the error code is determined based on the column number of the error code and the compression end column number of the target compression segment; and the column number of the source code corresponding to the error code is determined based on the source code end column number of the target compression segment and the column offset.
[0018] This application designs a combined calculation strategy for scenarios where error codes are located at the end of multi-line compressed segments. It ensures the integrity of cross-line structure mapping through forward row offset calculation and eliminates column number deviations caused by the compression tool adding closing symbols at the end of the line by using a reverse column compensation strategy. This ensures the accurate restoration of the business logic position at the end of the line, enabling accurate tracing of error codes even in scenarios where the end of the line is easily affected by additional operations of the compression tool, and further improves the error parsing mechanism for multi-line compressed segments.
[0019] In conjunction with the first aspect, in another possible implementation, the parent scope link relationship of the error code is determined based on the source code location information after the error code is restored and the second segment mapping table. The second segment mapping table includes at least: the location information of the scope and the index identifier of the parent scope; readable error information is generated based on the error type, the source code after the error code is restored, and the parent scope link relationship.
[0020] This application combines the second segment mapping table with source code location information, providing a foundation for contextual tracing of error codes. By constructing a scope hierarchy link, the error message not only includes the restored source code but also its execution context, helping developers quickly understand the logical environment in which the error occurred. This further improves the comprehensiveness and efficiency of error troubleshooting, upgrading error parsing from locating code lines to restoring the execution context.
[0021] In conjunction with the first aspect, in another possible implementation, the source code location information is selected from the second segmented mapping table for scopes between the start and end locations of the scope, and the parent scope index of the scope is not empty, to obtain at least one target scope; when there are multiple target scopes, the parent scope index of each target scope is compared, and the target scope whose parent scope index meets the preset conditions is selected as the final target scope; starting from the final target scope, the parent scope index stored in the second segmented mapping table is traced upwards level by level to obtain the direct outer parent scope of the final target scope, the outer parent scope of the direct outer parent scope, and so on, until the global scope is reached to obtain the parent scope chain relationship of the error code.
[0022] This application refines the specific construction logic of the parent scope chain. By filtering valid scopes, determining the final target scope, and tracing the outer parent scope level by level, it accurately locates the deep logic block where the error occurs. The tracing mechanism based on the parent scope index ensures the integrity and coherence of the scope chain, allowing developers to clearly understand the calling hierarchy of the erroneous code, reducing the difficulty of error debugging in nested scope scenarios, and making error parsing of complex nested code more targeted.
[0023] Secondly, this application provides an information restoration apparatus, which stores a first segment mapping table. The first segment mapping table is used to indicate the mapping relationship between the compression start position information of compressed segments in the compressed file and the position information of the source code in the source code file and the source code file identifier. The apparatus includes:
[0024] The extraction module is used to extract error information from the device when a device error is detected. The error information includes the error type, error code, and the location information of the error code in the corresponding compressed code segment.
[0025] The restoration module is used to determine the target compressed segment corresponding to the compressed code segment and the offset of the error code in the target compressed segment based on the location information of the error code in the corresponding compressed code segment and the first segment mapping table, and restore the error code based on the target compressed segment, the offset and the first segment mapping table.
[0026] To achieve the above objectives, according to a third aspect of this application, a storage medium is provided, the storage medium including a stored program, wherein, when the program is executed, the device where the storage medium is located is controlled to perform the information restoration method of the first aspect described above.
[0027] To achieve the above objectives, according to a fourth aspect of this application, an electronic device is provided, the device including at least one processor, and at least one memory and bus connected to the processor; wherein the processor and memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the information restoration method of the first aspect described above.
[0028] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0029] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0030] Figure 1 This paper shows a schematic diagram of the structure of an information restoration system provided in an embodiment of this application;
[0031] Figure 2 A flowchart illustrating an information restoration method provided in an embodiment of this application is shown.
[0032] Figure 3 A flowchart illustrating another information restoration method provided in an embodiment of this application is shown;
[0033] Figure 4 This paper shows a schematic diagram of the structure of an information restoration device provided in an embodiment of this application;
[0034] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0035] Exemplary embodiments of the present application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the scope of the present application to those skilled in the art.
[0036] The user data, data acquisition, and / or use involved in the embodiments of this application strictly comply with the laws, regulations, and industry standards of relevant countries and regions. The collection and acquisition of data involved in the embodiments of this application are all done in advance by actively prompting or prominently displaying information to inform users and obtaining authorization, or by obtaining full authorization from all parties. The processing, manipulation, forwarding, and use of data involved in the embodiments of this application are all carried out on the premise that the user or relevant party is fully informed and authorized. In implementing the various embodiments of this application, the types of data or information, scope of use, and usage scenarios that may be involved are informed to users or relevant parties and authorization is obtained through appropriate means. The specific methods of notification and authorization may vary according to actual circumstances, and this application is not limited in this regard. The processing of personal information involved in the embodiments of this application is carried out under the premise of having a legal basis (such as obtaining the consent of the personal information subject or being necessary for the performance of a contract), and is only processed within the scope stipulated or agreed. Sensitive personal information such as biometric information, medical and health information, financial account information, and precise location information involved in the embodiments of this application are all processed under the premise of having a specific purpose and sufficient necessity, and with the separate authorization and consent of the user or relevant party. In some embodiments of this application, if the user or related party refuses to process personal information other than the information necessary for the basic functions, it will not affect the use of the basic functions of the embodiments of this application.
[0037] In the embodiments of this application, the terms "first," "second," etc., do not have a logical or temporal dependency, nor do they limit the quantity or execution order. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms. These terms are merely used to distinguish one element from another.
[0038] In this application, the term "at least one" means one or more, and the term "multiple" means two or more.
[0039] It should also be understood that the term “if” can be interpreted as “when” or “upon”, or “in response to determination” or “in response to detection”. Similarly, depending on the context, the phrase “if determination…” or “if detection [the stated condition or event]” can be interpreted as “when determination…” or “in response to determination…” or “when detection [the stated condition or event]” or “in response to detection [the stated condition or event]”.
[0040] Figure 1This is a schematic diagram of an information restoration system provided in an embodiment of this application. The information restoration system 100 includes a front-end device 110 and a monitoring device 120. The front-end device 110 and the monitoring device 120 communicate with each other via a network. For example, they communicate via a network 130, which can be a wired connection such as a serial cable or a Universal Asynchronous Receiver / Transmitter (UART), or a wireless connection such as a wireless signal.
[0041] Front-end device 110 is used to run front-end application code and integrates a global error interception mechanism to capture various runtime errors, including JavaScript execution errors, network request errors, and resource loading errors. Simultaneously, front-end device 110 collects complete error-related information, specifically including the error type, error stack, the line and column position of the error code in the compressed code, and device environment information (such as browser version and operating system type). This structured error information is then reported to monitoring device 120 via network 130. In the event of network interruption or other offline scenarios, front-end device 110 temporarily stores the error information and automatically resends it after the network is restored, ensuring that error data is not lost.
[0042] The monitoring device 120 receives error information reported by the front-end device 110 and, based on a preset first segment mapping table, reconstructs the error location in the compressed code. Specifically, it matches the target compressed segment with the error row and column number in the first segment mapping table and calculates the source code location corresponding to the error code using the offset. Furthermore, the monitoring device 120 aggregates, stores, and categorizes the reported error information, and allows developers to query error details and locate the root cause of the problem through a visual interface. It can also trigger alarm notifications according to preset rules to facilitate rapid response and error repair.
[0043] It should be noted that, in this embodiment, the front-end device 110 and the monitoring device 120 can be terminal devices such as smartphones, tablets, and personal computers. Alternatively, they can be computing devices of a cloud service platform, such as servers or server clusters of a cloud service platform. This embodiment does not limit the specific devices used in this application.
[0044] Figure 2 This is a flowchart illustrating an information restoration method provided in this application. It specifically includes the following steps:
[0045] Step 210: When a device error is detected, extract the error information from the device.
[0046] In some embodiments of this application, a global error interception layer is integrated into the code of the monitored device (hereinafter, the example is a front-end device) to capture exceptions and resource loading errors during the monitoring device's runtime. For example, by overriding the global error events and unhandled Promise rejection events of the front-end device's window object, synchronous code exceptions (such as syntax errors and type errors) and asynchronous operation errors (such as network request failures and broken Promise chains) that are not manually caught by the developer are proactively intercepted. Structured error information is extracted from the front-end device, including the error type, error code, and the location information of the error code in the corresponding compressed code segment.
[0047] Step 220: Determine the target compressed segment corresponding to the compressed code segment and the offset of the error code in the target compressed segment based on the location information of the error code in the corresponding compressed code segment and the first segment mapping table. Reconstruct the error code based on the target compressed segment, the offset, and the first segment mapping table.
[0048] To ensure the universality and accuracy of compressed code restoration, this application first clarifies the execution logic of compressed segment processing, specifically: based on the position information of the erroneous code in the corresponding compressed code segment and the first segment mapping table, candidate compressed segments corresponding to the compressed code segment are selected; the target compressed segment is determined from the candidate compressed segments, and the position offset of the erroneous code relative to the target compressed segment is calculated based on the position information of the erroneous code and the compression start position information of the target compressed segment; combining the source code association information recorded in the first segment mapping table of the target compressed segment, and the position offset, the source code position corresponding to the erroneous code is determined. This logical framework provides a unified execution standard for different compression scenarios such as single-line and multi-line compression, ensuring that all compression situations follow the orderly process of "selection-determination-calculation-restoration".
[0049] In scenarios where code is extremely compressed into a single line, the entire logical structure of the original code (such as functions, conditional branches, and modules) is folded into a single long string. Traditional line numbering mechanisms become completely ineffective, necessitating a fine-grained segmented mapping of column numbers to reconstruct the error location. The first segmented mapping table records the starting column number of different logical blocks within a single line (e.g., function A starts at column 200, function B starts at column 800), breaking down the compressed physical single line into multiple virtual segments. Each segment corresponds to an independent unit in the original code (such as a function, conditional branch, or module).
[0050] When the source code is compressed into a single line (i.e., the compressed segment in the first segmentation mapping table is a single line), the following specific rules are followed: Candidate compressed segments with a compression start column number less than or equal to the error code's column number and whose compression start column number is the maximum value are selected as target compressed segments; based on the error code's location information and the compression start position information of the target compressed segment, the position offset of the error code relative to the target compressed segment is determined; based on the source code start position information and position offset corresponding to the target compressed segment in the first segmentation mapping table, the location information of the source code corresponding to the error code is determined to restore the error code.
[0051] Specifically, after determining the target compression segment, the row offset and column offset of the error code relative to the target compression segment are calculated based on the row number and column number of the error code in the error message, and the compression start row number (the starting row number of the segment's coverage area within the compressed code segment) and compression start column number (the starting column number of the segment's coverage area within the corresponding compressed row). Specifically, the difference between the row number of the error code and the compression start row number of the target compression segment is used as the row offset of the error code relative to the target compression segment. The difference between the column number of the error code and the compression start column number of the target compression segment is used as the column offset of the error code relative to the target compression segment.
[0052] Based on the source code line number, source code column number, row offset, and column offset in the first segment mapping table for the target compression segment, determine the file identifier, line number, and column number of the source code corresponding to the error code. Reconstruct the error code based on the file identifier, line number, and column number of the source code corresponding to the error code.
[0053] The following example, using Table 1, illustrates the case where the compressed segment in the first segmentation mapping table is a single row.
[0054] Table 1 Mapping Table for the First Segment
[0055]
[0056] Assume the error code has line number 15 and column number 28. First, filter all compression segments with a starting line number less than or equal to 15 in the first segment mapping table to obtain a candidate set {S1, S2, S3}. Select the compression segment corresponding to the largest starting line number 15 from the candidate set, i.e., {S2, S3}. Next, among the compression segments with a starting line number of 15, filter the final target segment based on the error code's column number 28. In S2 and S3, the compression starting column number of S3 is less than the error code's column number 28, and the compression starting column number of S3 is the segment with the largest column number in the candidate set. Therefore, select S3 as the final target segment. Finally, the compressed coordinates are converted to source code coordinates through coordinate offset calculation. Specifically, the line offset is determined by the difference between the line number of the error code and the starting line number of S3 compression (15-15=0), the column offset is determined by the difference between the column number of the error code and the starting column number of S3 compression (28-20=8), the line number of the error code in the source code is determined by the line offset and the S3 source code line number (30+0=30), and the column number of the error code in the source code is determined by the column offset and the S3 source code column number (15+8=23). Finally, the error code is located in line 30 and column 23 of the source code utils.ts.
[0057] In another implementation, when the compression segment in the first segmentation mapping table consists of multiple rows, the candidate compression segment whose compression start line number is less than or equal to the error code line number and whose compression end line number is greater than or equal to the error code line number is selected as the target compression segment. This ensures that the error code falls entirely within the cross-line mapping range of the segment, avoiding the failure of line offset calculation due to the fragmentation of single-line mapping.
[0058] Furthermore, the relative position type between the line number of the error code and the compression start line number and compression end line number of the target compression segment is determined, and the position offset corresponding to the error code is determined based on the relative position type; combined with the source code start position information or source code end position information corresponding to the target compression segment, and the position offset, the position information of the source code corresponding to the error code is determined, so as to restore the error code.
[0059] The relative position types include the following three: first line partial coverage (the line number of the error code is equal to the compression start line number of the target compression segment, and the column number of the error code is greater than or equal to the compression start column number of the target compression segment), middle complete line coverage (the line number of the error code is greater than or equal to the compression start line number of the target compression segment, and less than or equal to the compression end line number of the target compression segment), and last line partial coverage (the line number of the error code is equal to the compression end line number of the target compression segment, and the column number of the error code is less than or equal to the compression end column number of the target compression segment).
[0060] When an error code hits the starting row of a compressed segment and its column number is within the mapped range, the compression tool often inserts wrapper code (such as IIFE brackets) into the starting row. Therefore, during error code restoration, the column number of the error code must be strictly greater than or equal to the starting column of the compressed segment to ensure accurate location of the mapped area. In this case, directly using the starting line number of the source code instead of calculating the line offset avoids line number misalignment caused by the compression tool adding extra code to the starting row. The column offset calculation mechanism (the column number of the error code and the starting column number of the compression) precisely handles scenarios where some column numbers within the starting row are occupied by non-mapped code. For example, when parameter validation code before a function call is removed by compression, it can skip invalid column areas and directly point to the core logic location.
[0061] Therefore, when the positional relationship between the line number of the error code and the compression start line number and compression end line number of the target compression segment is such that the first line partially overlaps, the source code line number of the target compression segment is the same as the source code line number corresponding to the error code. The column offset of the error code is determined based on the column number of the error code and the compression start column number of the target compression segment, and the column number of the source code corresponding to the error code is determined based on the source code start column number and column offset of the target compression segment.
[0062] Assume the error code's location is at row 14, column 35. The target compression segment's compression start position, determined by the first mapping table, is at row 14, column 30, and its compression end position is at row 16, column 5. The target compression segment's source code start position is at row 5, column 8, and its source code end position is at row 7, column 15. The source code file identifier for this target compression segment is src / app.ts. Since the error code's line number equals the target compression segment's compression start line number, it enters the first-line processing mode. That is, based on the segment's starting column 30, the valid column range is determined to be from 30 to the end of the line (assuming the compressed code in this line has 50 columns). At this point, the target column 35 is within the valid range. By calculating the row offset (14-14=0), the original line number 5 of the source code line that maintains the segment record is determined. Then, based on the column offset (35-30=5), it is superimposed on the source code's starting column 8, finally locating to the 5th row, 13th column of the original project file src / app.ts.
[0063] When the line number of the error code is located between the start and end lines of the compression segment, since code compression tools usually maintain a linear mapping characteristic for consecutive lines in the middle, the line offset superposition mechanism (the line number of the error code and the line number of the compression start) is directly used to determine the line number of the source code, which can effectively deal with the scenario where multiple lines of source code logic are compressed into consecutive lines.
[0064] Therefore, when the positional relationship between the line number of the error code and the compression start line number and compression end line number of the target compression segment is that the middle complete line overlaps, the line offset of the error code is determined according to the line number of the error code and the compression start line number of the target compression segment; the line number of the source code corresponding to the error code is determined according to the starting line number of the source code of the target compression segment and the line offset; and the column number of the source code corresponding to the error code is determined according to the starting column number of the source code of the target compression segment and the column number of the error code.
[0065] Assume the error code's location is at row 12, column 15. The target compression segment, determined by the first mapping table, has a compression start position at row 10, column 20, and a compression end position at row 13, column 8. The target compression segment's source code start position is at row 20, column 5, and the source code end position is at row 23, column 18. The source code file for this target compression segment is identified as src / utils.js. Since the error code's line number lies between the target compression segment's compression start line number (10) and compression end line number (13), it enters intermediate line processing mode. That is, the difference between the error code's line number and the target compression segment's compression start line number is determined as the error code's line offset (12-10=2). Based on the target compression segment's source code start line number and line offset, the corresponding source code line number is determined (20+2=22). Since the entire row in the middle is mapped continuously by default, there is no need to calculate the column offset. The column number of the error code is directly added to the starting column number of the source code to get the column number of the source code corresponding to the error code (15+5=20), which finally locates the 22nd row and 20th column of the original project file src / utils.js.
[0066] For handling the end line of compressed segments, since compression tools often append closing symbols (such as curly braces at the end of functions) to the last line, a reverse column compensation strategy is required. By subtracting the compression end line number from the error code line number from the source code end line number, the influence of non-source code corresponding characters added to the last line can be eliminated. For example, symbols such as "}", ";", etc., added by the compression tool to the last line do not participate in the source code mapping. Reverse calculation can penetrate this interference and accurately locate the actual end position of the business logic. Keeping the line offset calculated in the forward direction ensures the integrity of the overall structural mapping across multiple lines and avoids the special handling of the last line from disrupting the consistency of global line numbers.
[0067] Therefore, when the positional relationship between the line number of the error code and the compression start line number and compression end line number of the target compression segment is such that the last line partially overlaps with the line number of the error code, the line offset of the error code is determined based on the line number of the error code and the compression start line number of the target compression segment; the line number of the source code corresponding to the error code is determined based on the start line number of the source code of the target compression segment and the line offset; the column offset of the error code is determined based on the column number of the error code and the compression end column number of the target compression segment; and the column number of the source code corresponding to the error code is determined based on the end column number of the source code of the target compression segment and the column offset.
[0068] Assume the error code's location is at row 10, column 18. The target compression segment, determined by the first mapping table, has a compression start position at row 8, column 15 and a compression end position at row 10, column 25. The target compression segment's source code start position is at row 12, column 10 and the source code end position is at row 14, column 40. The source code file identifier for this target compression segment is src / lib.ts. Since the error code's line number is at the end line (row 10) of the target compression segment, it enters the last-row processing mode, limiting the valid column range to the beginning of the target compression segment's compression end line and column 25 of the target compression start line, ensuring the error code's column number 18 is within the valid mapping range. The line offset of the error code is determined based on its line number and the target compression segment's compression start line number (10-8=2). The line number of the corresponding source code is determined based on the target compression segment's source code start line number and the line offset (12+2=14). Subsequently, a reverse mapping strategy is employed. Based on the column number of the error code and the end column number of the target compression segment, the column offset of the error code (25-18=7) is determined. Using the end column 40 of the source code as a baseline, the unused remaining column space (7 columns) of the compression segment is subtracted, ultimately locating the error code at line 14, column 33 of the source file src / lib.ts. This mechanism effectively eliminates the cumulative column number deviation caused by the truncation of the last line of compressed code through reverse compensation calculation, ensuring accurate restoration of the original position of the last line of code even in complex compression scenarios spanning multiple lines.
[0069] In summary, when processing single-line compressed segments, since the code is not split and reorganized, a strategy of progressively filtering the maximum line and column numbers can accurately match the starting point of the compressed segment closest to the error code location. By locking the maximum value of the starting line number less than or equal to the error code line number, it ensures that the error code line is within the coverage of that segment. When multiple compressed segments exist on the same line, the maximum value of the starting column number less than or equal to the error code column number is further selected to avoid mapping deviations caused by column number misalignment. This linear progressive filtering mechanism fully utilizes the continuity and order of single-line compressed code, accurately restoring the source code coordinates through relative offset calculation, without needing to handle cross-line cumulative errors, balancing efficiency and accuracy. However, when processing multi-line compressed segments, since the original code logic block is split into multiple lines by the compression tool, it is necessary to first confirm that the error line number falls within the start and end line range of the segment, thereby ensuring the correctness of the baseline for line offset calculation. The column number calculation strategy is dynamically switched based on the relative position of the line number of the error code in the segment (first line, middle line, last line). For example, the first line only calculates the offset after the starting column of the segment, the middle line inherits the complete column mapping, and the last line is calculated in reverse compensation. This layered processing mechanism effectively solves the problem of cross-line structure breakage caused by code compression. Through the dual guarantee of row-level range locking and column-level dynamic calibration, lossless restoration in complex multi-line scenarios can be achieved.
[0070] After accurately reconstructing the error code from the compressed code segment to the source code, simply identifying the source code location of the error code is still insufficient for developers to fully grasp the logical context and call hierarchy of the error. To further trace the scope hierarchy of the error code and clearly present its execution environment, this application also provides another information reconstruction method, the specific process of which is as follows: Figure 3 As shown. Figure 3 This is a flowchart illustrating an information restoration method provided in this application.
[0071] Step 310: Determine the parent scope link relationship of the error code based on the source code location information after the error code is restored and the second segment mapping table.
[0072] The parent scope chain refers to the nested scope hierarchy chain corresponding to the source code location of the error code. This chain starts from the innermost scope directly belonging to the error code and traces upwards level by level to the global scope, fully presenting the execution context and logical nesting relationship of the error code. Here, "scope" refers to the valid access range of identifiers such as variables and functions in the source code, including the global scope, function scope, and block scope (such as if / for blocks). The parent scope is the outer scope that contains the current scope. For example, the parent of the if block scope might be the function scope, and the parent of the function scope might be the global scope. This hierarchical relationship forms the basis of the scope chain.
[0073] For example, if the source code contains the following nested structure: a function `getUserInfo` is defined in the global scope (function scope); inside the function, the variable `userId` is declared; then, a `fetch` request is executed through an `if` conditional statement (block scope); and the `then` callback function (function scope) contains a `console.log` statement, which is the location of the error code, then the parent scope chain relationship corresponding to the error code is: global scope → `getUserInfo` function scope → `if` block scope → `then` callback function scope. This chain clearly shows the logical attribution of the error code, from the global entry point (global scope) to the outer function (`getUserInfo` function scope), then to the conditional block (`if` block scope), and finally to the asynchronous callback function (`then` callback function scope), providing developers with a crucial basis for understanding the context in which the error occurred.
[0074] To determine this link relationship, the source code location information after the error code is restored is the core basis. Therefore, after determining the source code location information after the error code is restored according to step 120 (e.g., row 15, column 10 of src / utils.js), the process of determining the parent scope link relationship begins. Specifically, the operation is carried out in conjunction with the source code location information and the second segment mapping table. The structure of the second segment mapping table includes core fields such as scope identifier, scope type (e.g., function scope, block scope, global scope), start position information (start line number, start column number), end position information (end line number, end column number), parent scope index identifier, and the identifier of the source code file to which it belongs. The parent scope index identifier uses a numerical sequence encoding (e.g., the global scope index is 0, its direct child scope indexes are 1 and 2, and the nested scope indexes of the child scopes are 11 and 12, etc.) to ensure that the index and the scope hierarchy form a unique correspondence.
[0075] First, based on the row and column numbers of the restored source code, traverse all scope records in the second segment mapping table, and filter out scopes whose source code location information is within a scope whose start row number ≤ target row number ≤ end row number and whose start column number ≤ target column number ≤ end column number, thus obtaining at least one target scope. For example, if the error code is located at row 15, column 10 of src / utils.js, after traversal, scope A (function scope, start row 12, column 5, end row 28, column 30, parent index 0) and scope B (block scope, start row 14, column 8, end row 20, column 25, parent index 1) are selected, then the candidate target scope set is {A, B}.
[0076] When multiple target scopes are selected, the final target scope is determined based on the "definition context association" rule. The logic of this rule is that the execution of error code depends on the syntactic environment in which it is defined, rather than the runtime nesting level. By analyzing the syntactic binding relationship between each target scope and the error code, including variable declaration location, function definition context, and code block affiliation, scopes with a direct syntactic association with the error code are selected. Continuing the example above, the parent index of scope A is 0, and the parent index of scope B is 1. Therefore, scope B is selected as the final target scope, precisely pinpointing that the error occurred within the block-level logic inside the function, rather than the entire function body.
[0077] Finally, starting from the final target scope, the process traces upwards level by level using the parent scope indexes stored in the second segmented mapping table. First, the direct outer parent scope is found through the parent index of the final target scope. Then, the next-highest outer parent scope is found through the index of the direct outer parent scope. This process is repeated until the global scope, with a parent index of 0, is reached. Using the example above, starting from scope B (parent index 1), the direct parent scope A (parent index 0) is found through index 1. Then, index 0 confirms that the global scope has been reached, ultimately constructing a complete parent scope chain of "global scope → scope A (function) → scope B (block level)," clearly showing the execution context and call hierarchy of the error code.
[0078] Step 320: Generate readable error messages based on the error type, the source code restored from the error code, and the parent scope chain relationship.
[0079] For example, after restoring the erroneous code (e.g., 'c') in the compressed code to its source code (e.g., axios.get) through step 120, the error type (e.g., TypeError) is mapped to a semantic description (e.g., type validation exception). At this point, an intuitive error summary can be formed (e.g., "Type exception: 'axios.get' is undefined"). Subsequently, by combining the parent scope chain relationship, the complete call hierarchy from the global entry point to the current scope is traced back (e.g., main() → initializeApp() → checkAPIStatus()), finally outputting structured and readable information. For example: "Type exception: 'axios.get' is undefined, occurred in the checkAPIStatus function on line 15 of src / utils.js, the call chain is main() → initializeApp() → checkAPIStatus()."
[0080] In summary, this application establishes a bidirectional mapping relationship between the compressed code and the source code location information through the first segment mapping table. Combined with the calculation of the compression segment offset, it can accurately trace back the error location in the compressed environment to the original source code location. At the same time, by using the scope hierarchy structure recorded by the second segment mapping table, by comparing the location information of the error point with the start and end range of each scope, it traces back the parent scope level by level to form a complete context call chain. Finally, through the dual mapping mechanism, it achieves accurate three-dimensional positioning from the compressed code error point to the specific location of the source code and its execution context.
[0081] It is understood that, in order to achieve the functions in the above embodiments, the computer device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and method steps described in conjunction with the embodiments disclosed in this application, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application scenario and design constraints of the technical solution.
[0082] Furthermore, as a response to the above Figure 2 The implementation of the method embodiment shown in this application provides an information restoration device. The embodiment of this device corresponds to the foregoing method embodiment. For ease of reading, this embodiment will not repeat the details of the foregoing method embodiment, but it should be understood that the device in this embodiment can correspondingly implement all the contents of the foregoing method embodiment.
[0083] Specifically, such as Figure 4 As shown, the information restoration device 400 includes:
[0084] The extraction module 410 is used to extract error information from the front-end device when an error is detected. The error information includes the error type, error code, and the location information of the error code in the corresponding compressed code segment.
[0085] The restoration module 420 is used to determine the target compressed segment corresponding to the compressed code segment and the offset of the error code in the target compressed segment based on the position information of the error code in the corresponding compressed code segment and the first segment mapping table, and restore the error code based on the target compressed segment, the offset and the first segment mapping table.
[0086] Furthermore, such as Figure 4As shown, the restoration module 420 is specifically used for: filtering candidate compressed segments corresponding to the compressed code segment based on the position information of the error code in the corresponding compressed code segment and the first segment mapping table; determining the target compressed segment from the candidate compressed segments, and calculating the position offset of the error code relative to the target compressed segment based on the position information of the error code and the compression start position information of the target compressed segment; and determining the source code position corresponding to the error code by combining the source code association information recorded in the first segment mapping table of the target compressed segment and the position offset.
[0087] Furthermore, such as Figure 4 As shown, the restoration module 420 is specifically used for: when the compressed segment in the first segment mapping table is a single row, selecting the candidate compressed segment whose compression start column number is less than or equal to the column number of the error code and whose compression start column number is the maximum value as the target compressed segment; determining the position offset of the error code relative to the target compressed segment based on the position information of the error code and the compression start position information of the target compressed segment; and determining the position information of the source code corresponding to the error code based on the source code start position information and position offset of the target compressed segment in the first segment mapping table, so as to restore the error code.
[0088] Furthermore, such as Figure 4 As shown, the restoration module 420 is specifically used for: when the compressed segment in the first segment mapping table has multiple rows, taking the candidate compressed segment whose compression start line number is less than or equal to the line number of the error code and whose compression end line number is greater than or equal to the line number of the error code as the target compressed segment; determining the relative position type between the line number of the error code and the compression start line number and compression end line number of the target compressed segment, and determining the position offset corresponding to the error code based on the relative position type; combining the source code start position information or source code end position information corresponding to the target compressed segment, and the position offset, determining the position information of the source code corresponding to the error code, so as to restore the error code.
[0089] Furthermore, such as Figure 4 As shown, the restoration module 420 is specifically used for: determining the line offset of the error code based on the line number of the error code and the compression start line number of the target compressed segment when the line number of the error code is greater than or equal to the compression start line number of the target compressed segment and less than or equal to the compression end line number of the target compressed segment; determining the line number of the source code corresponding to the error code based on the source code start line number of the target compressed segment and the line offset; and determining the column number of the source code corresponding to the error code based on the source code start column number of the target compressed segment and the column number of the error code.
[0090] Furthermore, such as Figure 4As shown, the restoration module 420 is specifically used for: when the line number of the error code is equal to the compression start line number of the target compressed segment, and the column number of the error code is greater than or equal to the compression start column number of the target compressed segment, the source code line number of the target compressed segment is the line number of the source code corresponding to the error code; determining the column offset of the error code based on the column number of the error code and the compression start column number of the target compressed segment, and determining the column number of the source code corresponding to the error code based on the source code start column number and the column offset of the target compressed segment.
[0091] Furthermore, such as Figure 4 As shown, the restoration module 420 is specifically used for: when the line number of the error code is equal to the compression end line number of the target compressed segment, and the column number of the error code is less than or equal to the compression end column number of the target compressed segment, determining the line offset of the error code based on the line number of the error code and the compression start line number of the target compressed segment; determining the line number of the source code corresponding to the error code based on the source code start line number of the target compressed segment and the line offset; determining the column offset of the error code based on the column number of the error code and the compression end column number of the target compressed segment; and determining the column number of the source code corresponding to the error code based on the source code end column number of the target compressed segment and the column offset.
[0092] Furthermore, such as Figure 4 As shown, the information restoration device 400 further includes: a parent link relationship determination module 430, used to determine the parent scope link relationship of the error code based on the source code location information after the error code is restored and the second segment mapping table, wherein the second segment mapping table includes at least: the location information of the scope and the index identifier of the parent scope; and a readable error information generation module 440, used to generate readable error information based on the error type, the source code after the error code is restored, and the parent scope link relationship.
[0093] Furthermore, such as Figure 4 As shown, the parent scope relationship determination module 430 is specifically used to: filter the scopes whose source code location information is between the start and end information of the scope from the second segmented mapping table, and whose parent scope index identifier is not empty, to obtain at least one target scope; when there are multiple target scopes, compare the parent scope index identifiers of each target scope, and select the target scope whose parent scope index identifier meets the preset conditions as the final target scope; starting from the final target scope, trace upwards level by level through the parent scope index identifiers stored in the second segmented mapping table, and sequentially obtain the direct outer parent scope of the final target scope, the outer parent scope of the direct outer parent scope, until tracing back to the global scope, to obtain the parent scope relationship of the error code.
[0094] Optionally, the information restoration device may be an electronic device with data processing capabilities, or a functional module within the electronic device, without limitation.
[0095] For example, the electronic device can be a server, which can be a single server or a server cluster consisting of multiple servers. As another example, the electronic device can be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, as well as cellular phones, personal digital assistants (PDAs), augmented reality (AR) devices, virtual reality (VR) devices, and other terminal devices. As yet another example, the electronic device can also be a recording device, video surveillance equipment, etc. This application does not impose any special limitations on the specific form of the electronic device.
[0096] The following example uses an electronic device as the information restoration device. Figure 5 As shown, Figure 5 The hardware structure of an electronic device 500 provided in this application.
[0097] like Figure 5 As shown, the electronic device 500 includes a processor 510, a communication line 520, and a communication interface 530.
[0098] Optionally, the electronic device 500 may also include a memory 540. The processor 510, memory 540, and communication interface 530 can be connected via a communication line 520.
[0099] The processor 510 can be a central processing unit (CPU), a general-purpose processor, a network processor (NP), a digital signal processor (DSP), a microprocessor, a microcontroller, a programmable logic device (PLD), or any combination thereof. The processor 510 can also be any other device with processing capabilities, such as a circuit, device, or software module, without limitation.
[0100] In one example, processor 510 may include one or more CPUs, for example Figure 5 CPU0 and CPU1 in the CPU.
[0101] As an optional implementation, the electronic device 500 may include multiple processors; for example, in addition to processor 510, it may also include processor 570. A communication line 520 is used to transmit information between the components included in the electronic device 500.
[0102] Communication interface 530 is used for communication with other devices or other communication networks. This other communication network can be Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc. Communication interface 530 can be a module, circuit, transceiver, or any device capable of enabling communication.
[0103] Memory 540 is used to store instructions. These instructions can be computer programs.
[0104] The memory 540 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and / or instructions; it may also be a random access memory (RAM) or other type of dynamic storage device capable of storing information and / or instructions; it may also be an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, etc., without limitation.
[0105] It should be noted that the memory 540 can exist independently of the processor 510 or can be integrated with the processor 510. The memory 540 can be used to store instructions, program code, or some data, etc. The memory 540 can be located inside or outside the electronic device 500, without restriction.
[0106] The processor 510 is configured to execute instructions stored in the memory 540 to implement the communication method provided in the following embodiments of this application. For example, when the electronic device 500 is a terminal or a chip in a terminal, the processor 510 can execute instructions stored in the memory 540 to implement the steps performed by the transmitting end in the following embodiments of this application.
[0107] As an optional implementation, the electronic device 500 also includes an output device 550 and an input device 560. The output device 550 can be a display screen, speaker, or other device capable of outputting data from the electronic device 500 to the user. The input device 560 can be a keyboard, mouse, microphone, joystick, or other device capable of inputting data into the electronic device 500.
[0108] It should be pointed out that, Figure 5 The structure shown does not constitute a limitation on the electronic device, except... Figure 5 In addition to the components shown, the electronic device may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.
[0109] The information restoration apparatus and application scenarios described in this application are for the purpose of more clearly illustrating the technical solutions of this application, and do not constitute a limitation on the technical solutions provided in this application. As those skilled in the art will know, with the evolution of information restoration apparatus and the emergence of new business scenarios, the technical solutions provided in this application are also applicable to similar technical problems.
[0110] This application provides a storage medium storing a program that, when executed by a processor, implements the information restoration method.
[0111] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0112] In a typical configuration, the device includes one or more processors (CPUs), memory, and a bus. The device may also include input / output interfaces, network interfaces, etc.
[0113] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, like read-only memory (ROM) or flash RAM, and memory includes at least one memory chip. Memory is an example of computer-readable media.
[0114] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0115] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0116] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0117] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. An information restoration method, characterized in that, Applied to monitoring equipment, the monitoring equipment stores a first segment mapping table, which is used to indicate the mapping relationship between the compression start position information of compressed segments in the compressed file, the position information of source code in the source code file, and the source code file identifier. The method includes: When a device error is detected, the error information is extracted from the device. The error information includes the error code and the position information of the error code in the corresponding compressed code segment. Based on the location information of the error code in the corresponding compressed code segment and the first segment mapping table, the target compressed segment corresponding to the compressed code segment and the offset of the error code in the target compressed segment are determined, and the error code is restored based on the target compressed segment, the offset and the first segment mapping table.
2. The method according to claim 1, characterized in that, Based on the position information of the error code in the corresponding compressed code segment and the first segment mapping table, determine the target compressed segment corresponding to the compressed code segment and the offset of the error code in the target compressed segment. Reconstruct the error code based on the target compressed segment, the offset, and the first segment mapping table, including: Based on the location information of the error code in the corresponding compressed code segment and the first segment mapping table, candidate compressed segments corresponding to the compressed code segment are selected; The target compression segment is determined from the candidate compression segments, and the position offset of the error code relative to the target compression segment is calculated based on the position information of the error code and the compression start position information of the target compression segment. By combining the source code association information recorded in the first segment mapping table for the target compression segment, and the position offset, the source code location corresponding to the error code is determined.
3. The method according to claim 2, characterized in that, The target compression segment is determined from the candidate compression segments. Based on the location information of the error code and the compression start position information of the target compression segment, the position offset of the error code relative to the target compression segment is calculated. Combining this with the source code association information recorded in the first segment mapping table for the target compression segment and the position offset, the source code location corresponding to the error code is determined, including: When the compressed segment in the first segmentation mapping table is a single row, the candidate compressed segment whose compression start column number is less than or equal to the column number of the error code and whose compression start column number is the maximum value is taken as the target compressed segment; Based on the location information of the error code and the compression start position information of the target compression segment, determine the position offset of the error code relative to the target compression segment; Based on the source code start position information corresponding to the target compressed segment in the first segment mapping table and the position offset, the position information of the source code corresponding to the error code is determined so as to restore the error code.
4. The method according to claim 2, characterized in that, The process involves determining a target compression segment from the candidate compression segments, calculating the positional offset of the error code relative to the target compression segment based on the error code's position information and the compression start position information of the target compression segment, and determining the source code position corresponding to the error code by combining the source code association information recorded in the first segment mapping table of the target compression segment with the positional offset. The method further includes: When the compressed segment in the first segment mapping table is multiple rows, the candidate compressed segment whose compression start line number is less than or equal to the line number of the error code and whose compression end line number is greater than or equal to the line number of the error code is taken as the target compressed segment. Determine the relative position type between the line number of the error code and the compression start line number and compression end line number of the target compression segment, and determine the position offset corresponding to the error code based on the relative position type; By combining the source code start position information or source code end position information corresponding to the target compressed segment, and the position offset, the position information of the source code corresponding to the error code is determined, so as to restore the error code.
5. The method according to claim 4, characterized in that, The relative position type between the line number of the error code and the compression start line number and compression end line number of the target compression segment is determined. Based on the relative position type, the position offset corresponding to the error code is determined. Combining the source code start position information or source code end position information corresponding to the target compression segment, and the position offset, the position information of the source code corresponding to the error code is determined, including: When the line number of the error code is greater than or equal to the compression start line number of the target compression segment and less than or equal to the compression end line number of the target compression segment, the line offset of the error code is determined based on the line number of the error code and the compression start line number of the target compression segment. The line number of the source code corresponding to the error code is determined based on the starting line number of the source code of the target compressed segment and the line offset; The column number of the source code corresponding to the error code is determined based on the starting column number of the source code of the target compressed segment and the column number of the error code.
6. The method according to claim 4, characterized in that, The relative position type between the line number of the error code and the compression start line number and compression end line number of the target compression segment is determined. Based on the relative position type, the position offset corresponding to the error code is determined. Combining the source code start position information or source code end position information corresponding to the target compression segment, and the position offset, the position information of the source code corresponding to the error code is determined, including: When the line number of the error code is equal to the compression start line number of the target compression segment, and the column number of the error code is greater than or equal to the compression start column number of the target compression segment, the source code line number of the target compression segment is the source code line number corresponding to the error code. The column offset of the error code is determined based on the column number of the error code and the starting column number of the target compression segment. The column number of the source code corresponding to the error code is determined based on the starting column number of the source code of the target compression segment and the column offset.
7. The method according to claim 4, characterized in that, The relative position type between the line number of the error code and the compression start line number and compression end line number of the target compression segment is determined. Based on the relative position type, the position offset corresponding to the error code is determined. Combining the source code start position information or source code end position information corresponding to the target compression segment, and the position offset, the position information of the source code corresponding to the error code is determined, including: When the line number of the error code is equal to the compression end line number of the target compression segment, and the column number of the error code is less than or equal to the compression end column number of the target compression segment, the line offset of the error code is determined based on the line number of the error code and the compression start line number of the target compression segment, and the line number of the source code corresponding to the error code is determined based on the source code start line number of the target compression segment and the line offset; The column offset of the error code is determined based on the column number of the error code and the compression end column number of the target compressed segment. The column number of the source code corresponding to the error code is determined based on the source code end column number of the target compressed segment and the column offset.
8. The method according to claim 1, characterized in that, The method further includes: The parent scope link relationship of the error code is determined based on the source code location information after the error code is restored and the second segment mapping table. The second segment mapping table includes at least: the location information of the scope and the index identifier of the parent scope. Based on the error type, the source code restored from the error code, and the parent scope link relationship, readable error information is generated.
9. The method according to claim 8, characterized in that, The parent scope link relationship of the error code is determined based on the source code location information after the error code is restored and the second segment mapping table, including: From the second segmented mapping table, filter the scopes whose source code location information is between the start and end location information of the scope, and whose parent scope index is not empty, to obtain at least one target scope. When multiple target scopes exist, the parent scope index identifiers of each target scope are compared, and the target scope whose parent scope index identifier meets the preset conditions is selected as the final target scope. Starting from the final target scope, the parent scope index identifier stored in the second segmented mapping table is traced upwards level by level to obtain the direct outer parent scope of the final target scope, the outer parent scope of the direct outer parent scope, and so on, until the global scope is reached, thus obtaining the parent scope link relationship of the error code.
10. An information restoration device, characterized in that, The device stores a first segment mapping table, which indicates the mapping relationship between the compression start position information of compressed segments in the compressed file and the position information and source code file identifier of the source code in the source code file. The device includes: The extraction module is used to extract error information from the front-end device when an error is detected. The error information includes the error type, the error code, and the position information of the error code in the corresponding compressed code segment. The restoration module is used to determine the target compressed segment corresponding to the compressed code segment and the offset of the error code in the target compressed segment based on the position information of the error code in the corresponding compressed code segment and the first segment mapping table, and to restore the error code based on the target compressed segment, the offset and the first segment mapping table.
11. A storage medium, characterized in that, The storage medium includes a stored program, wherein the program, when running, controls the device where the storage medium is located to execute the information restoration method as described in any one of claims 1-9.
12. An electronic device, characterized in that, The device includes at least one processor, at least one memory connected to the processor, and a bus; wherein the processor and the memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the information restoration method as described in any one of claims 1-9.