Code exception tracking method and system based on dynamic execution path
By combining dynamic execution path tracking and deep learning technology, an efficient and accurate code exception tracking system was built, which solved the problems of low accuracy, low efficiency and poor real-time performance in the existing technology, and realized automated and intelligent abnormal detection and positioning.
Patent Information
- Application Number
- CN202411307643.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-01-10
AI Technical Summary
When facing large-scale, high-complex software systems, existing code exception tracking methods have low accuracy, low efficiency and poor real-time performance, and cannot effectively identify abnormal patterns in complex codes and conduct real-time detection.
Combining dynamic execution path tracing and deep learning technology, a dynamic execution tracker and deep learning model is built, and execution path data is collected through instrumentation, preprocessing and feature extraction is performed, and anomaly detection and positioning is used to generate detailed exception information. Report.
It realizes efficient and accurate code exception tracking, automation and intelligence, reduces manual intervention, improves the accuracy and real-timeness of code exception tracking, and can instantly detect and locate running software.
Smart Images

Figure CN119292903A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of code exception tracing, and in particular to a code exception tracing method and system based on dynamic execution path. Background Art
[0002] As the scale and complexity of software systems continue to increase, exceptions in the code are becoming increasingly prominent. Traditional code exception tracking methods mainly rely on static code analysis, log review or manual debugging, which are inadequate for large-scale, highly complex software systems. Dynamic execution path tracing technology can capture the actual execution path of the program when it is running, providing rich data support for exception tracing; while deep learning technology has demonstrated powerful capabilities in pattern recognition, anomaly detection and other fields. Therefore, combining dynamic execution path tracing with deep learning technology provides new ideas and methods for code exception tracing.
[0003] Currently, there are a variety of code exception tracking tools and technologies on the market, mainly including tools based on static code analysis, systems based on log analysis, and some debuggers that integrate dynamic execution tracking functions. These tools and technologies have improved the efficiency of code exception tracking to a certain extent, but there are still the following shortcomings:
[0004] Static code analysis: It is unable to capture dynamic information when the program is running, and it is difficult to accurately identify runtime exceptions.
[0005] Log analysis: Relying on the log points pre-set by the developer, it may not record enough information for unexpected exceptions.
[0006] Dynamic execution tracing: Although it can capture the execution path, it lacks intelligent analysis methods and requires human intervention to judge anomalies.
[0007] Problems with existing technologies:
[0008] Low accuracy: Traditional methods have difficulty accurately identifying abnormal patterns in complex codes.
[0009] Low efficiency: requires a lot of manual intervention, which is time-consuming and labor-intensive.
[0010] Poor real-time performance: It is impossible to perform instant anomaly detection on software running in real time. Summary of the invention
[0011] In view of the above problems, the present invention is proposed to provide a method and system for code exception tracing based on dynamic execution paths, which overcome the above problems or at least partially solve the above problems.
[0012] According to one aspect of the present invention, a method for tracing code exceptions based on a dynamic execution path is provided, and the method for tracing code exceptions comprises:
[0013] Building a dynamic execution tracer;
[0014] Preprocessing the collected execution path data to obtain preprocessed data;
[0015] Input the preprocessed data into the deep learning model to determine whether the path is abnormal;
[0016] Anomaly detection and location are performed based on the output results of the deep learning model.
[0017] Optionally, the step of constructing a dynamic execution tracer specifically includes:
[0018] Select the insertion point;
[0019] Automatically generate instrumentation code based on the selected instrumentation point;
[0020] Carry out data collection and management.
[0021] Optionally, the selected insertion points specifically include: function entry, function exit, loop start and end, conditional judgment point, and exception handling block.
[0022] Optionally, the instrumentation code is used to replenish the execution context and record the execution context into a log or a memory buffer.
[0023] Optionally, the data collection and management specifically includes:
[0024] Data structure selection, using circular buffer, hash table plus linked list data structure;
[0025] Using data compression algorithm to compress data;
[0026] Incremental update, supports incremental collection of execution path data.
[0027] Optionally, the preprocessing of the collected execution path data specifically includes:
[0028] Clean and format the collected execution path data, and extract features useful for anomaly identification;
[0029] And use the extracted features as input to the deep learning model;
[0030] The extracted features include: statistical features, structural features and era features.
[0031] Optionally, the inputting of the preprocessed data into the deep learning model to determine whether the path is abnormal specifically includes:
[0032] Select appropriate deep learning models to process sequence data based on the characteristics of execution path data and the requirements of anomaly detection;
[0033] Train the model using known normal and abnormal execution path data;
[0034] Input the new execution path data into the trained deep learning model for analysis;
[0035] The deep learning model will output an abnormality score or probability value for each execution path to determine whether the execution path is abnormal.
[0036] Optionally, the performing anomaly detection and location according to the output result of the deep learning model specifically includes:
[0037] Anomaly detection: Set appropriate thresholds to determine whether the execution path is abnormal. When the anomaly score or probability value of an execution path exceeds the threshold, the path is considered abnormal.
[0038] Exception location: Using stack backtracing technology, we can trace back from the point where the exception occurred to the specific code location in the program, and further determine the cause and scope of the exception by combining the function call relationship and code context information.
[0039] Exception information report, generate detailed exception information report.
[0040] Optionally, the exception information report includes the exception type, occurrence location, possible cause and repair suggestions.
[0041] The present invention also provides a code exception tracking system based on a dynamic execution path, the code exception tracking system comprising:
[0042] Dynamic execution tracer building module, used to build dynamic execution tracer;
[0043] A data preprocessing module, used to preprocess the collected execution path data to obtain preprocessed data;
[0044] A deep learning model module, used to input the pre-processed data into the deep learning model and determine whether the path is abnormal or not;
[0045] The anomaly detection and localization module is used to detect and localize anomalies based on the output results of the deep learning model.
[0046] The present invention provides a method and system for tracking code anomalies based on dynamic execution paths. The method comprises: constructing a dynamic execution tracker; preprocessing the collected execution path data to obtain preprocessed data; inputting the preprocessed data into a deep learning model to determine whether the path is abnormal; and performing anomaly detection and location according to the output of the deep learning model. The execution process of the software program can be monitored in real time, key execution path information can be captured, and the deep learning model can be used to intelligently identify and locate abnormal patterns.
[0047] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0049] Figure 1 A flowchart of a code exception tracing method based on a dynamic execution path provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0051] The terms "comprises" and "having" and any variations thereof in the description embodiments, claims and drawings of the present invention are intended to cover non-exclusive inclusions, for example, including a series of steps or units.
[0052] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0053] The present invention integrates dynamic execution path tracing and deep learning technology to build an efficient and accurate code exception tracking system. It can monitor the execution process of software programs in real time, capture key execution path information, and use deep learning models to intelligently identify and locate abnormal patterns.
[0054] like Figure 1 As shown, a code exception tracking method based on a dynamic execution path includes:
[0055] 1. Dynamic Execution Tracer
[0056] 1.1 Functional Description
[0057] The dynamic execution tracker is one of the core components of the system. It is responsible for being embedded in the target software system to monitor and record the critical path information during program execution in real time.
[0058] The key path information includes function call sequence, parameter passing, return value, and exception throwing point.
[0059] 1.2 Implementation
[0060] 1.2.1 Instrumentation Technology
[0061] Selecting instrumentation points: Instrumentation points should be carefully selected to minimize performance overhead while capturing enough information. Common instrumentation points include function entry, function exit, loop start and end, conditional judgment points, and exception handling blocks.
[0062] Instrumentation code generation: Automatically generate instrumentation code based on the selected instrumentation points. The instrumentation code is responsible for capturing the execution context (such as the current function name, parameter values, return values, call stack) and recording it to the log or memory buffer.
[0063] Performance optimization: In order to reduce the impact of instrumentation on program performance, delayed recording (such as batch writing logs) and asynchronous processing (using background threads to process log data) technologies are used.
[0064] 1.2.2 Data Collection and Management
[0065] Data structure selection: In order to efficiently store and manage execution path data, data structures such as circular buffers, hash tables plus linked lists (to resolve hash conflicts) are used. The structure should support fast insertion, search, and deletion operations.
[0066] Data compression: Considering that the execution path data may be very large, the system should implement data compression algorithms (such as LZ4, Snappy) to reduce the consumption of storage space and transmission bandwidth.
[0067] Incremental update: Supports incremental collection of execution path data, that is, only recording the parts that have changed since the last check to reduce duplicate data.
[0068] 2. Data preprocessing module
[0069] 2.1 Functional Description
[0070] The data preprocessing module is responsible for cleaning and formatting the collected execution path data and extracting features useful for anomaly identification. These features will serve as input for the deep learning model.
[0071] 2.2 Implementation
[0072] 2.2.1 Data Cleaning
[0073] Denoising: Identify and remove duplicate and insignificant execution path fragments, which may be caused by instrumentation errors, code redundancy, etc.
[0074] Standardization: Unify the format and units of execution path data to ensure data consistency and comparability.
[0075] 2.2.2 Feature extraction
[0076] Statistical features: calculate the frequency of function calls, statistics of parameter changes (such as mean, variance, maximum, minimum), and frequency of exceptions thrown.
[0077] Structural features: Analyze the control flow structure (such as loops, branches, conditional judgments) in the execution path and extract its depth and complexity as features.
[0078] Time series features: For time series data (such as the timestamps of function calls), time intervals and periodic pattern features can be extracted.
[0079] 2.2.3 Data Augmentation
[0080] In order to improve the generalization ability of deep learning models, data enhancement techniques such as noise addition, random sampling, and sequence clipping are used to increase the diversity of training data.
[0081] 3. Deep Learning Model
[0082] 3.1 Functional Description
[0083] The deep learning model is the intelligent core of the system, responsible for learning the pattern differences between normal and abnormal execution paths and building an anomaly detection model. This model will be used to analyze new execution path data in real time and identify potential abnormal paths.
[0084] 3.2 Implementation
[0085] 3.2.1 Model selection
[0086] Select an appropriate deep learning model based on the characteristics of the execution path data and the needs of anomaly detection. For example, models such as recurrent neural networks (RNNs), long short-term memory networks (LSTMs), or transformers can be used to process sequence data.
[0087] 3.2.2 Model Training
[0088] The model is trained using known normal and abnormal execution path data. During the training process, the model parameters need to be optimized to improve the accuracy and efficiency of anomaly recognition.
[0089] 3.2.3 Real-time analysis
[0090] The new execution path data is input into the trained deep learning model for analysis. The model will output an abnormality score or probability value for each execution path to determine whether the path is abnormal.
[0091] 4Anomaly detection and positioning module
[0092] 4.1 Functional Description
[0093] The anomaly detection and location module is responsible for anomaly detection based on the output of the deep learning model, and locates the specific code location in combination with stack backtrace technology. At the same time, the module will also provide detailed anomaly information reports.
[0094] 4.2 Implementation
[0095] Anomaly detection: Set an appropriate threshold to determine whether the execution path is abnormal. When the anomaly score or probability value of an execution path exceeds the threshold, the path is considered abnormal.
[0096] Exception location: Using stack backtracking technology, we can trace back from the point where the exception occurred to the specific code location in the program. At the same time, we can further determine the cause and scope of the exception by combining information such as function call relationships and code context.
[0097] Abnormal information report: Generate a detailed abnormal information report, including abnormal type, location, possible cause, and repair suggestions. The report should be presented to the user in a way that is easy to understand and operate.
[0098] Beneficial effects:
[0099] Combining dynamic execution path tracing with deep learning technology, we can achieve automatic and intelligent code anomaly tracing. This cross-domain integration brings new ideas and methods to code anomaly detection.
[0100] Efficient data processing: Lightweight instrumentation technology and efficient data structures are used to collect and process execution path data, reducing data redundancy and noise interference, and improving data processing efficiency and accuracy.
[0101] Intelligent anomaly recognition: Automatically identify abnormal situations and generate anomaly reports.
[0102] Improve the accuracy of code exception tracking, and use deep learning models to intelligently analyze execution path data to identify potential abnormal patterns.
[0103] Improve the efficiency of code exception tracking, realize automatic exception detection, and reduce manual intervention.
[0104] Enhance the real-time tracking of code exceptions, and be able to instantly detect exceptions and locate problems in running software.
[0105] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A code exception tracking method based on dynamic execution path, characterized in that: The code exception tracking method comprises: Building a dynamic execution tracer; Preprocessing the collected execution path data to obtain preprocessed data; Input the preprocessed data into the deep learning model to determine whether the path is abnormal; Anomaly detection and location are performed based on the output results of the deep learning model.
2. A method for tracking code exceptions based on dynamic execution paths according to claim 1, characterized in that: The construction of the dynamic execution tracer specifically includes: Select the insertion point; Automatically generate instrumentation code based on the selected instrumentation point; Carry out data collection and management.
3. A method for tracking code exceptions based on dynamic execution paths according to claim 2, characterized in that: The selected insertion points specifically include: function entry, function exit, loop start and end, conditional judgment point, and exception handling block.
4. A method for tracking code exceptions based on dynamic execution paths according to claim 2, characterized in that: The instrumentation code is used to replenish the execution context and record the execution context to a log or a memory buffer.
5. The method for tracking code exceptions based on dynamic execution paths according to claim 2, characterized in that: The data collection and management specifically includes: Data structure selection, using circular buffer, hash table plus linked list data structure; Using data compression algorithm to compress data; Incremental update, supports incremental collection of execution path data.
6. A method for tracking code exceptions based on dynamic execution paths according to claim 1, characterized in that: The preprocessing of the collected execution path data specifically includes: Clean and format the collected execution path data, and extract features useful for anomaly identification; And use the extracted features as input to the deep learning model; The extracted features include: statistical features, structural features and era features.
7. The method for tracking code exceptions based on dynamic execution paths according to claim 1, characterized in that: The output result of inputting the preprocessed data into the deep learning model to determine whether the path is abnormal specifically includes: Select appropriate deep learning models to process sequence data based on the characteristics of execution path data and the requirements of anomaly detection; Train the model using known normal and abnormal execution path data; Input the new execution path data into the trained deep learning model for analysis; The deep learning model will output an abnormality score or probability value for each execution path to determine whether the execution path is abnormal.
8. The method for tracking code exceptions based on dynamic execution paths according to claim 1, characterized in that: The anomaly detection and location based on the output results of the deep learning model specifically includes: Anomaly detection: Set appropriate thresholds to determine whether the execution path is abnormal. When the anomaly score or probability value of an execution path exceeds the threshold, the path is considered abnormal. Exception location: Using stack backtracing technology, we can trace back from the point where the exception occurred to the specific code location in the program, and further determine the cause and scope of the exception by combining the function call relationship and code context information. Exception information report, generate detailed exception information report.
9. The method for tracking code exceptions based on dynamic execution paths according to claim 8, characterized in that: The abnormality information report includes the abnormality type, occurrence location, possible cause and repair suggestions.
10. A code exception tracking system based on dynamic execution path, characterized in that: The code exception tracking system includes: Dynamic execution tracer building module, used to build dynamic execution tracer; A data preprocessing module, used to preprocess the collected execution path data to obtain preprocessed data; A deep learning model module, used to input the pre-processed data into the deep learning model and determine whether the path is abnormal or not; The anomaly detection and localization module is used to detect and locate anomalies based on the output results of the deep learning model.
Citation Information
Cited By
Network security information processing method and system
CN119892475A