Program debugging method and system driven by artificial intelligence

By constructing an abstract syntax tree and utilizing an AI-driven code analysis model, the problem of relying on human experience in C/C++ program debugging is solved, enabling efficient and safe automatic generation of debugging statements and improving debugging efficiency and accuracy.

CN122019346APending Publication Date: 2026-05-12LINKEDHOPE INTELLIGENT TECH
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
LINKEDHOPE INTELLIGENT TECH
Filing Date
2026-01-04
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing C/C++ program debugging methods rely on human experience, and the generation of debugging statements is arbitrary, redundant, and prone to semantic or format errors, making it difficult to meet the debugging needs of complex programs and resulting in low debugging efficiency.

Method used

By constructing an abstract syntax tree, using an AI-driven code analysis model to perform format specifier matching and semantic feature extraction, establishing a debugging relationship between control flow and data flow, generating high-value debugging nodes and performing format security and semantic consistency verification, and automatically generating debugging statements.

Benefits of technology

It improves the accuracy and efficiency of program debugging, reduces the cost of manual intervention, and ensures the security and semantic correctness of generated debugging statements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122019346A_ABST
    Figure CN122019346A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of program debugging, and discloses an artificial intelligence driven program debugging method and system.The method comprises the steps that lexical analysis and grammatical analysis are conducted on a source code file, an abstract syntax tree is generated, and format character matching is conducted; performing semantic feature extraction on the abstract syntax tree after format character matching by using a code analysis model based on artificial intelligence; the method comprises the steps of establishing a control flow debugging relation and a data flow debugging relation between debugging information and grammar nodes, calculating to obtain debugging value weights of the grammar nodes, screening the grammar nodes with high debugging value weights, generating debugging statements by using codes based on AI driving, and performing formatting security verification and semantic consistency verification. According to the method, the syntactic structure and the semantic features of the source code are subjected to conjoint analysis, the syntactic nodes with high debugging value are intelligently screened, and the safe and semantic consistent debugging statements are generated, so that the debugging positioning precision and the debugging efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of program debugging, and more particularly to an artificial intelligence-driven program debugging method and system. Background Technology

[0002] With the rapid development of information technology and embedded systems, the C / C++ language still dominates key areas such as system software, low-level drivers, and embedded development. However, debugging C / C++ programs has long relied on two traditional methods: one is to use the GDB (GNU Debugger) tool for breakpoint debugging; the other is to insert printf() statements into the code to output key information.

[0003] While GDB offers fine-grained debugging control, its high barrier to entry requires developers to have extensive knowledge of debugging commands and necessitates enabling the `-g DEBUG` option during compilation, making it cumbersome and inefficient. While `printf` debugging is a general and direct method, its simplicity is not without its shortcomings: for debugging information involving expressions, different formatted output strings need to be manually written for different C data types; the printed information often includes more than just variable values—the variable's location in the source code is crucial for locating the problem, but this requires manual location information such as filenames and line numbers; ordinary printouts lack distinctness and are easily confused with regular program output; debugging output needs to be disabled before release, and manually added debugging code often needs to be removed, leading to omissions; warnings should be displayed during compilation to prevent the release version from printing internal information when debugging code is still present; and debugging information lacks systematic management, making it difficult to form a unified debugging framework. These problems result in complex and inefficient C / C++ program debugging, especially in large-scale projects or system-level development, where debugging time costs are high, significantly hindering product development and delivery efficiency.

[0004] In existing research, some solutions have attempted to improve debugging efficiency through automation mechanisms. For example, patent document CN115599671A discloses an application debugging method, apparatus, device, and storage medium. It responds to application debugging requests, obtains the target application identifier and debugging class identifier, further obtains the debugging code corresponding to the debugging class, redefines the target debugging class, generates a debugging agent, and then debugs the target application in conjunction with the virtual machine process identifier. This solution achieves automatic triggering and runtime agent debugging to a certain extent, reducing the degree of manual intervention. However, it mainly focuses on runtime class redefinition and debugging agent injection, with debugging granularity concentrated at the class or module level. It is difficult to deeply characterize the internal syntax structure, control flow relationships, and variable data dependencies of the source code, making it unsuitable for debugging programs in C / C++ programming languages.

[0005] To address this problem, this invention proposes an AI-driven program debugging method and system. By using AI technology, the method automatically identifies program structure and code semantic information, generates adaptive output debugging statements, and automatically marks location information, thereby improving program debugging efficiency and reliability. Summary of the Invention

[0006] This invention provides an AI-driven program debugging method and system. Addressing the technical problems of existing program debugging processes, such as debugging points relying on human experience, arbitrary generation of debugging statements, redundant debugging scope, and the potential introduction of new semantic or formatting errors, step S1 constructs an abstract syntax tree by performing lexical and syntactic analysis on the source code and automatically matches variable types with format specifiers using syntax tags. This solves the problem of inconsistent format specifiers and variable types in traditional debugging statements, which can easily lead to runtime exceptions. Step S2 introduces an AI-based code analysis model to jointly model the structural features, contextual information, and data dependencies of syntax nodes, overcoming the problem that existing debugging methods only focus on local statements and struggle to accurately identify key debugging locations. Building on this, step S3 constructs the debugging relationship between control flow and data flow and calculates debugging value weights to automatically filter high-value debugging nodes, solving the problems of blind debugging point selection and low debugging efficiency. Steps S4 and S5 utilize an AI-driven code generation model to automatically generate debugging statements consistent with the context semantics, and constrain the generated results through formatting security and semantic consistency verification mechanisms to prevent debugging statements from introducing new semantic defects or security risks.

[0007] To achieve the above objectives, the present invention provides an artificial intelligence-driven program debugging method and system, comprising the following steps: S1: Obtain the source code file of the program to be debugged, perform lexical analysis and syntax analysis on the source code file, generate an abstract syntax tree corresponding to the source code file, extract the syntax tags of the syntax nodes in the abstract syntax tree, construct a type-format specifier mapping table based on the type in the syntax tags, perform automatic format specifier matching on the syntax nodes, and obtain the abstract syntax tree after format specifier matching. S2: Based on the abstract syntax tree after matching the format specifiers and the syntax tags of the syntax nodes, the semantic features of the abstract syntax tree after matching the format specifiers are extracted using an AI-based code analysis model to obtain the semantic features of the syntax nodes. S3: Based on the semantic features of the syntax nodes, establish the control flow debugging relationship and data flow debugging relationship between the debugging information and the syntax nodes, calculate the debugging value weight of the syntax nodes, and filter out the syntax nodes with high debugging value weight. S4: Extract the context information of the syntax nodes with high debugging value weights, and use an AI-driven code generation model to generate the debugging statements corresponding to the syntax nodes with high debugging value weights. S5: Perform format security verification and semantic consistency verification on the debugging statements, insert the verification-passing debugging statements into the corresponding source code file debugging location, and compile and debug the source code file.

[0008] As a further improvement of the present invention: Further, in step S1, the source code file of the program to be debugged is obtained, and lexical and syntactic analysis are performed on the source code file to generate an abstract syntax tree corresponding to the source code file, including: S11: Perform integrity verification and standardization on the source code files to obtain standardized source code files. Mark source code files that fail integrity verification as abnormal inputs and stop the subsequent analysis process. S12: Perform lexical analysis on the standardized source code file to obtain a sequence of lexical units based on the character stream order, and record the structured attributes of the lexical units in the sequence of lexical units. The structured attributes of the lexical units include the code value, lexical type, and position of the lexical unit. The position of the lexical unit is the line number and column number of the lexical unit in the standardized source code file. S13: A bottom-up analysis model is used to perform syntactic analysis on the lexical unit sequence, extract syntactic structure units from the lexical unit sequence and create corresponding syntactic nodes, mark the hierarchical structure of the syntactic nodes, and form the abstract syntax tree corresponding to the source code file.

[0009] Further, the syntax labels of the syntax nodes in the abstract syntax tree are extracted, including: Starting from the root node of the abstract syntax tree, a depth-first traversal is used to extract semantic tags for each syntax node, thereby obtaining the syntax tags of the syntax nodes in the abstract syntax tree. The semantic tags of the syntax nodes include the type of the syntax node and the various semantic attributes corresponding to the type. The types of syntax nodes include root nodes, function nodes, variable declaration and reference nodes, control structure nodes, and expression nodes.

[0010] Furthermore, a type-format specifier mapping table is constructed to automatically match format specifiers on syntax nodes, resulting in an abstract syntax tree after format specifier matching, including: Extract the syntax nodes of the type variable declaration and reference nodes, construct a type-format specifier mapping table, use the type-format specifier mapping table to perform automatic format specifier matching on the extracted syntax nodes, obtain the format specifiers corresponding to different variable data types, and add the matched format specifiers to the semantic attributes of variable declaration and reference nodes to form an abstract syntax tree after format specifier matching.

[0011] Furthermore, in step S2, a code analysis model based on artificial intelligence is used to extract semantic features from the abstract syntax tree after the format specifier matching, including: The AI-based code analysis model includes a syntax structure encoding layer, a context and scope fusion layer, a data dependency awareness layer, and a semantic feature output layer. S21: The syntax structure encoding layer extracts the syntax tags of the syntax nodes, performs word vector encoding based on the syntax tags on the semantic attribute sequence of the syntax nodes, and obtains the encoding vector of the syntax nodes. S22: The context and scope fusion layer extracts the set of context nodes of the syntax node in the abstract syntax tree, and extracts the encoding vector of the syntax node in the set of context nodes. The encoding vector of the syntax node in the set of context nodes is weighted by attention weighting to obtain the fusion feature of the syntax node to be calculated for semantic features. S23: The data dependency awareness layer selects a set of dependent reference nodes that have a dependency reference relationship with the syntax node based on the dependency and reference relationships of the variable data in the syntax node, calculates the dependency weight coefficient between the syntax node in the dependent reference node set and the syntax node of the semantic feature to be calculated, and performs dependency weighted propagation on the encoding vector of the syntax node in the dependent reference node set to obtain the semantic propagation feature of the syntax node of the semantic feature to be calculated. S24: The semantic feature output layer weights the fusion features and semantic propagation features of the syntax node and outputs the semantic features of the syntax node.

[0012] Furthermore, the establishment of control flow debugging relationships and data flow debugging relationships between debugging information and syntax nodes in step S3 includes: S31: Based on the abstract syntax tree, extract the number of child nodes of the syntax node in the abstract syntax tree, and convert the number of child nodes into the control flow debugging relationship between debugging information and the syntax node; S32: Based on the semantic feature calculation process of the syntax node, extract the set of dependent reference nodes of the syntax node, and count the number of syntax nodes in the set of dependent reference nodes as the data flow dependency quantity of the syntax node. Convert the data flow dependency quantity into debugging information and the data flow debugging relationship between the syntax node.

[0013] Furthermore, in step S3, based on the control flow debugging relationship and data flow debugging relationship between the debugging information and the syntax nodes, the debugging value weight of the syntax nodes is calculated, and syntax nodes with high debugging value weights are selected. This step further includes: S33: Based on the semantic features of the syntax nodes, calculate the attention semantic weight between the syntax nodes in the dependent reference node set and the syntax nodes whose debugging value weights are to be calculated. S34: Based on the attention semantic weights, a graph neural network model incorporating an attention mechanism is used to calculate the node anomaly risk score of the grammar node, wherein the node anomaly risk score is used to evaluate the potential error triggering probability of the grammar node. S35: Calculate the debugging value weight of the syntax node based on the node anomaly risk score, control flow debugging relationship, and data flow debugging relationship of the syntax node. S36: Based on the debugging value weight of the syntax node, select syntax nodes with debugging value weights higher than a preset value threshold as syntax nodes with high debugging value weights.

[0014] Further, in step S4, the context information of the syntax nodes with high debugging value weights is extracted, and debugging statements corresponding to the syntax nodes with high debugging value weights are generated using an AI-driven code generation model, including: S41: Extract the context information of the syntax node with high debugging value weight. The context information includes the function name, parameter list, variable data set in the parameter list, variable data type, variable data format specifier, and variable position in the syntax node. S42: Using the format specifier of the variable data as a constraint, an AI-driven code generation model is used to receive the context information and generate semantically complete debugging statements.

[0015] Furthermore, step S5 involves performing format security checks and semantic consistency checks on the debug statements, including: S51: Extract the format specifiers of the variable data in the debugging statement, and calculate the matching relationship between the format specifiers of the variable data in the debugging statement and the variable data in the context information, as the format security verification result; The matching relationship between the format specifier of the variable data in the debugging statement R and the variable data in the context information. The calculation formula is: ; in, This indicates the number of variable data in the debugging statement R. The format specifier for the k-th variable data in the debugging statement R. This represents the variable data in the context information corresponding to the k-th variable data in the debugging statement R. This represents variable data generated based on the type-format specifier mapping table. Variable data types and format specifiers The mismatch relationship occurs if variable data exists in the type-format specifier mapping table. Variable data types and format specifiers ,but =0, otherwise =1; S52: Construct a semantic consistency verification function to detect the consistency between the variable data, function name and the context information in the debugging statement, and obtain the semantic consistency verification result; The debugging statement Consistency between variable data, function names, and the context information The calculation formula is: ; in, Indicates debugging statements The variable data set in This represents the set of variable data in the context information. Represents a set of variable data The number of variable data in the middle, This represents calculating the intersection of sets. Indicates intersection The number of variable data in the middle, Indicates debugging statements Consistency of function names in debugging statements If the function name in the text matches the function name in the context information, then... =1, otherwise =0; S53: The format security verification result and the semantic consistency verification result are weighted to obtain a weighted verification result. If the weighted verification result is higher than the preset verification threshold, it means that the debugging statement has passed the verification; otherwise, it means that the debugging statement has failed the verification.

[0016] The present invention also proposes an artificial intelligence-driven program debugging system, which includes a compilation preprocessing module, a compile-time type safety inference module, a source code context awareness module, a debugging statement generation module, a syntax highlighting enhancement module, and a dynamic switch control module.

[0017] Compared with existing technologies, this invention proposes an artificial intelligence-driven program debugging method, which has the following beneficial effects: First, this invention constructs an AI-based code analysis model. This model achieves a unified characterization of the static structure and dynamic semantic relationships of an abstract syntax tree through multi-layered collaborative modeling that integrates syntactic structure encoding, context and scope fusion, and data dependency awareness. Specifically, the code analysis model can simultaneously perceive syntax node types, context positions, and dependency reference flow paths of variable data, effectively reducing the semantic gaps caused by relying solely on local syntactic features. Furthermore, through a dependency weighted propagation mechanism, it enhances the semantic expressive power of key variables and core syntax nodes, improving the accuracy and robustness of anomaly localization and semantic understanding of syntax nodes.

[0018] Meanwhile, this invention introduces a dual verification mechanism of format security verification and semantic consistency verification to achieve a comprehensive evaluation of the security and semantic correctness of automatically generated debugging statements. The format security verification, based on the type-format specifier mapping relationship, performs a one-to-one matching and detection of the format specifiers of variable data in the debugging statement with the types of their context variables, effectively avoiding the risk of type inconsistencies or runtime anomalies caused by incorrect format specifiers. The semantic consistency verification constrains the semantic correspondence between the debugging statement and the context information from two levels: the consistency of variable data sets and function names, preventing semantic deviations caused by misuse of variables or mismatched function identifiers. By weighted fusion of the two verification results and the introduction of a threshold determination mechanism, the invention achieves automatic screening and control of the validity of debugging statements, improving the reliability and executability of the generated debugging statements and reducing the cost of manual verification. Attached Figure Description

[0019] Figure 1 This is a flowchart illustrating an artificial intelligence-driven program debugging method according to an embodiment of the present invention. Figure 2 This is a schematic diagram of the system structure of a program debugging system provided in an embodiment of the present invention.

[0020] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0021] The realization of the objectives, functional characteristics, and advantages of this invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0022] This invention provides an AI-driven program debugging method. The execution subject of this AI-driven program debugging method includes, but is not limited to, at least one of the following electronic devices that can be configured to execute the method provided in this invention: a server, a terminal, etc. In other words, the AI-driven program debugging method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes, but is not limited to, a single server, a server cluster, a cloud server, or a cloud server cluster.

[0023] Reference Figure 1 As shown, Embodiment 1 of the present invention is as follows: S1: Obtain the source code file of the program to be debugged, perform lexical analysis and syntax analysis on the source code file, generate an abstract syntax tree corresponding to the source code file, extract the syntax tags of the syntax nodes in the abstract syntax tree, construct a type-format specifier mapping table based on the type in the syntax tags, perform automatic format specifier matching on the syntax nodes, and obtain the abstract syntax tree after format specifier matching.

[0024] Obtain the source code file of the program to be debugged, perform lexical and syntactic analysis on the source code file, and generate an abstract syntax tree corresponding to the source code file, including: S11: Perform integrity verification and standardization on the source code files to obtain standardized source code files. Mark source code files that fail integrity verification as abnormal inputs and stop the subsequent analysis process. Specifically, the integrity verification includes character encoding consistency verification, file structure integrity verification, and basic syntax integrity verification. Character encoding consistency verification includes detecting and unifying the file encoding (e.g., UTF-8, ASCII) to prevent illegal characters or garbled text from affecting subsequent analysis. File structure integrity verification includes checking for the presence of unclosed comment symbols (e.g., ...). ), string quotes (such as ", ') or preprocessor directive line continuation characters (\), basic syntax integrity checks include preliminary detection of the number matching relationship of curly braces, parentheses, and square brackets, used to detect obviously truncated or corrupted source code files in advance; After integrity verification, the source code file undergoes standardization processing. This standardization includes comment cleanup, macro definition expansion and normalization, whitespace character standardization, and string and character constant protection. Specifically, comment cleanup includes removing single-line and multi-line comments, retaining line number placeholders at the removed comment locations to ensure the continuity of source code location information. Macro definition expansion and normalization includes conditional parsing and expansion of #define macros to generate equivalent macro expansion results, parameter replacement and text concatenation for functional macros. Whitespace character standardization includes unifying consecutive spaces and tabs into single spaces, deleting redundant line breaks without semantic impact, and standardizing line ending format (…). The string and character constant protection includes placeholder protection for string constants and character constants during the standardization process to prevent accidental deletion of comment symbols or macro keywords, and to restore the original constant content after the standardization process is complete. S12: Perform lexical analysis on the standardized source code file to obtain a sequence of lexical units based on the character stream order, and record the structured attributes of the lexical units in the sequence of lexical units. The structured attributes of the lexical units include the code value, lexical type, and position of the lexical unit. The position of the lexical unit is the line number and column number of the lexical unit in the standardized source code file. Specifically, a lexical analyzer based on regular expression matching is used to perform lexical analysis on the standardized source code file. The lexical analyzer includes a state transition automaton, a symbol table interface, and a set of regular expression matching rules. The state transition automaton is used to scan the character stream in the source code file, the symbol table interface is used to record identifier information, and the set of regular expression matching rules is used to describe the lexical types of different lexical units and perform lexical unit matching. The lexical type set of lexical units includes: keywords: int, if, return, struct, etc.; identifiers: variable names, function names, type names; constants: integer constants, floating-point constants, character constants, string constants; operators: arithmetic operators, logical operators, bitwise operators, assignment operators; separators: parentheses, commas, semicolons, curly braces, etc.; preprocessing residual identifiers: macro expansion path markers.

[0025] S13: A bottom-up analysis model is used to perform syntactic analysis on the lexical unit sequence, extract syntactic structure units from the lexical unit sequence and create corresponding syntactic nodes, mark the hierarchical structure of the syntactic nodes, and form the abstract syntax tree corresponding to the source code file.

[0026] Specifically, the bottom-up analysis mode is a bottom-up LR parsing mode, in which the bottom-up LR parsing mode takes the lexical unit sequence obtained by lexical analysis as input, and gradually constructs the grammatical structure through a state machine process driven by "shift-reduce", and synchronously generates the grammatical nodes in the syntax tree during the reduction process.

[0027] Extracting the syntax labels of the syntax nodes in the abstract syntax tree includes: Starting from the root node of the abstract syntax tree, a depth-first traversal is used to extract semantic tags for each syntax node, thereby obtaining the syntax tags of the syntax nodes in the abstract syntax tree. The semantic tags of the syntax nodes include the type of the syntax node and the various semantic attributes corresponding to the type. The types of syntax nodes include root nodes, function nodes, variable declaration and reference nodes, control structure nodes, and expression nodes.

[0028] In one embodiment of the present invention, the semantic attributes of the root node are an empty set. The semantic attributes of the function node include the function identifier node with the function node as its parent node, the function name, the parameter list, the function return type, and the reference variable. The semantic attributes of the variable declaration and reference node include the formal parameter variable with the variable declaration and reference node as its parent node, the variable data set, the variable data type, the variable position, and the set of syntax nodes to which the variable is referenced. The semantic attributes of the control structure node include the conditional expression syntax subtree with the control structure node as its parent node, the set of logical branch paths, and the set of syntax nodes dominated by the control structure node. The semantic attributes of the expression node include the operator type (arithmetic, logical, comparison, etc.), the reference variable, and the set of operand types in the expression node.

[0029] The type-format specifier mapping table is constructed to automatically match format specifiers on syntax nodes, resulting in an abstract syntax tree after format specifier matching, including: Extract the syntax nodes of the type variable declaration and reference nodes, construct a type-format specifier mapping table (e.g., bool→"%d", double→"%f"), use the type-format specifier mapping table to perform automatic format specifier matching on the extracted syntax nodes, obtain the format specifiers corresponding to different variable data types (e.g., pointer, string), and add the matched format specifiers to the semantic attributes of variable declaration and reference nodes to form an abstract syntax tree after format specifier matching.

[0030] S2: Based on the abstract syntax tree after matching the format specifiers and the syntax labels of the syntax nodes, the semantic features of the abstract syntax tree after matching the format specifiers are extracted using an artificial intelligence-based code analysis model to obtain the semantic features of the syntax nodes.

[0031] Semantic feature extraction is performed on the abstract syntax tree after format specifier matching using an AI-based code analysis model, including: The AI-based code analysis model includes a syntax structure encoding layer, a context and scope fusion layer, a data dependency awareness layer, and a semantic feature output layer. The syntax structure encoding layer is used to vectorize and encode the type labels and semantic attributes of each syntax node in the abstract syntax tree to obtain the encoding vector of the syntax node. The context and scope fusion layer is used to fuse the context syntax features of the syntax node in the abstract syntax tree based on the encoding vector of the syntax node to obtain the fused features of the syntax node. The data dependency awareness layer performs dependency weighted propagation on the encoding vector of the syntax node based on the dependency and reference relationships of the variable data in the syntax node to form the semantic propagation features of the syntax node in a multi-dimensional propagation form. The semantic feature output layer is used to weight the fused features and the semantic propagation features to output the semantic features of the syntax node. S21: The syntax structure encoding layer extracts the syntax tags of the syntax nodes, performs word vector encoding based on the syntax tags on the semantic attribute sequence of the syntax nodes, and obtains the encoding vector of the syntax nodes. Specifically, the semantic attribute sequence is obtained by concatenating multiple semantic attributes of grammatical nodes, and the word vector encoding formula for the semantic attribute sequence is: ; in, Represents syntax nodes The encoded vector, Represents syntax nodes Sequence of semantic attributes Represents syntax nodes syntax tags, Indicates syntax tags The corresponding mapping matrix, Indicates syntax tags The corresponding mapping bias, This represents the first activation function, which is set to the ReLU function. S22: The context and scope fusion layer extracts the set of context nodes of the syntax node in the abstract syntax tree, and extracts the encoding vector of the syntax node in the set of context nodes. The encoding vector of the syntax node in the set of context nodes is weighted by attention weighting to obtain the fusion feature of the syntax node to be calculated for semantic features. As an embodiment of the present invention, the syntax node The set of context nodes in the abstract syntax tree contains syntax nodes. In the abstract syntax tree, parent nodes, child nodes, and nodes with the same scope are considered as syntax nodes. Parallel syntax nodes that belong to the same scope and have the same parent syntax node; S23: The data dependency awareness layer selects a set of dependent reference nodes that have a dependency reference relationship with the syntax node based on the dependency and reference relationships of the variable data in the syntax node, calculates the dependency weight coefficient between the syntax node in the dependent reference node set and the syntax node of the semantic feature to be calculated, and performs dependency weighted propagation on the encoding vector of the syntax node in the dependent reference node set to obtain the semantic propagation feature of the syntax node of the semantic feature to be calculated. As an embodiment of the present invention, by extracting syntax nodes The variable data in the data is obtained, and the syntax nodes for declaring, assigning, calling, and returning output of the variable data are acquired. The acquired syntax nodes are then used to construct the syntax nodes. A collection of dependency reference nodes that have dependency reference relationships; The syntax nodes of the computation dependency reference node set and the syntax nodes of the semantic features to be computed. Dependency weight coefficients between them: ; ; in, Indicates the syntax node A set of dependency reference nodes that have dependency reference relationships. , Represents a collection of dependent reference nodes. Any syntax node in the, Represents syntax nodes and Dependency weight coefficients between them Represents syntax nodes For the syntax node The total number of times variable data is declared, assigned, called, or returned in the output. Represents syntax nodes and The difference in levels between them Represents syntax nodes At the levels of the abstract syntax tree, Represents syntax nodes At the levels of the abstract syntax tree, Indicates the dependency reference adjustment factor, set It is 0.2. Set as the hierarchical control coefficient. It is 0.3. Represents an exponential function with the natural constant as its base; The syntax node The semantic propagation features are ,in Represents syntax nodes The encoded vector; S24: The semantic feature output layer weights the fusion features and semantic propagation features of the syntax node and outputs the semantic features of the syntax node.

[0032] Specifically, the syntax node The formula for calculating semantic features is: ; in, This represents the weighted matrix of fused features. Let b represent the propagation feature weighting matrix, and b represent the weighting bias. Represents the syntax node The fusion characteristics Represents the syntax node semantic features This represents the second activation function, which is set to the Sigmoid function.

[0033] It should be noted that this invention introduces a code analysis model that integrates syntactic structure encoding and semantic propagation to achieve collaborative modeling of the syntactic structure features, contextual relationships, and variable data dependencies of the abstract syntax tree. Specifically, the syntax structure encoding layer distinguishes different types of syntax nodes based on syntax labels and performs targeted vectorized mapping of semantic attributes to avoid the overlap of features of different syntax roles, thereby improving the discriminability and stability of the basic node representation. The context and scope fusion layer simultaneously introduces information from parent nodes, child nodes, and nodes in the same scope, and adaptively measures the influence of different context syntax nodes on the semantics of the target syntax node through attention weighting, effectively characterizing the structural position and local semantic environment of the syntax node in the abstract syntax tree. The data dependency awareness layer constructs semantic propagation paths based on dependency reference relationships such as variable declaration, assignment, and invocation, and calculates dependency weights by combining reference frequency and level difference, realizing the weighted propagation of semantic information of syntax nodes along the direction of real data flow, enhancing the model's ability to perceive the execution semantics of syntax nodes. The semantic feature output layer integrates the structural fusion features and semantic propagation features through weighted integration, so that the output semantic features have both structural integrity and semantic consistency, thereby significantly improving the accuracy and robustness of syntax node debugging, anomaly localization, and intelligent analysis.

[0034] Furthermore, scope refers to the range in which variable data can be effective. It is used to isolate variable data in syntax nodes and ensure that variable data with the same name will not conflict in different scopes. The scope of variable data includes global scope: variable data that can be accessed throughout the entire program; local scope: variable data that is valid within a specific function or code block; and block scope: variable data that is valid within a specific code block (such as if statement or loop).

[0035] S3: Based on the semantic features of the syntax nodes, establish the control flow debugging relationship and data flow debugging relationship between the debugging information and the syntax nodes, calculate the debugging value weight of the syntax nodes, and filter out the syntax nodes with high debugging value weights.

[0036] Establish control flow debugging relationships and data flow debugging relationships between debugging information and syntax nodes, including: S31: Based on the abstract syntax tree, extract the number of child nodes of the syntax node in the abstract syntax tree, and convert the number of child nodes into the control flow debugging relationship between debugging information and the syntax node; Specifically, the number of child nodes Convert to control flow debugging relationship The conversion formula is: ; in, This represents the maximum number of child nodes in the abstract syntax tree among all syntax nodes; S32: Based on the semantic feature calculation process of the syntax node, extract the set of dependent reference nodes of the syntax node, and count the number of syntax nodes in the set of dependent reference nodes as the data flow dependency number of the syntax node, and convert the data flow dependency number into debugging information and the data flow debugging relationship between the syntax node. Specifically, the data stream depends on the quantity Convert to data stream debugging relationship The conversion formula is: ; in, This indicates the maximum number of data flow dependencies across all syntax nodes.

[0037] It should be noted that this invention maps the number of child nodes of a syntax node in an abstract syntax tree to control flow debugging relationships and data flow debugging relationships, respectively, thereby quantifying the structural complexity and data dependency strength of the source code file. The converted relationships can objectively reflect the importance of syntax nodes in the control flow and data flow, providing a basis for the adaptive generation and priority sorting of debugging statements, thus improving the accuracy and efficiency of program debugging.

[0038] Based on the control flow debugging relationship and data flow debugging relationship between the debugging information and the syntax nodes, the debugging value weight of the syntax nodes is calculated, and syntax nodes with high debugging value weights are selected. This also includes: S33: Based on the semantic features of the syntax nodes, calculate the attention semantic weight between the syntax nodes in the dependent reference node set and the syntax nodes whose debugging value weights are to be calculated. Specifically, the syntax node With the collection of dependent reference nodes Chinese syntax nodes Attention semantic weights between The calculation formula is: ; in, Each represents a trainable attention weight matrix. The length of the semantic feature is represented by T, which represents the transpose. Represents syntax nodes With the collection of dependent reference nodes Chinese syntax nodes The scope relation factor between the syntax nodes With syntax nodes When in the same scope, =1, otherwise =0; S34: Based on the attention semantic weights, a graph neural network model incorporating an attention mechanism is used to calculate the node anomaly risk score of the grammar node, wherein the node anomaly risk score is used to evaluate the potential error triggering probability of the grammar node. Specifically, the syntax node The formula for calculating the node anomaly risk score is: ; in, Represents syntax nodes The node anomaly risk score, Represents syntax nodes and The difference in levels between them This represents a trainable anomaly risk quantification matrix. This represents the third activation function, which is set to the Softmax function. S35: Calculate the debugging value weight of the syntax node based on the node anomaly risk score, control flow debugging relationship, and data flow debugging relationship of the syntax node. As an embodiment of the present invention, the syntax node The debugging value weight is: ; in, Represents syntax nodes The debugging value weight, This represents the weighting coefficient of the node anomaly risk score, set. It is 0.6. These represent control terms based on control flow and data flow debugging relationships. Represents syntax nodes The control flow debugging relationship, Represents syntax nodes Data stream debugging relationship, This represents the set of all syntax nodes. Indicates all syntax nodes The maximum value; S36: Based on the debugging value weight of the syntax node, select syntax nodes with debugging value weights higher than a preset value threshold as syntax nodes with high debugging value weights.

[0039] It should be noted that this invention introduces a debugging value assessment method that combines a semantic feature-based attention mechanism with a graph neural network to achieve refined quantitative modeling of the anomaly risk and debugging value of syntax nodes in source code files. Specifically, this invention calculates the attention semantic weights between syntax nodes and their dependent reference nodes, thereby adaptively focusing on syntax nodes that have a greater semantic impact on the target syntax node and have key dependencies, enhancing the anomaly risk assessment's ability to perceive the relationship between real program data flow and scope. The node anomaly risk score is calculated in a graph neural network model incorporating hierarchical difference constraints, effectively suppressing the interference of irrelevant node noise on risk judgment, improving the stability and accuracy of anomaly assessment results. Furthermore, by weightedly fusing the node anomaly risk score with control flow debugging relationships and data flow debugging relationships, a unified debugging value weight evaluation index is constructed, enabling objective ranking of syntax node debugging priorities. Ultimately, it can automatically filter high-debugging-value syntax nodes, significantly reducing the scope of manual debugging, improving error location efficiency and debugging resource utilization, and is suitable for intelligent debugging and quality assurance scenarios of complex programs.

[0040] Optionally, the default value threshold is set to a debugging value weight that is higher than 70% of the syntax nodes.

[0041] As an embodiment of the present invention, multiple sets of format specifier matching abstract syntax trees are obtained, and debugging nodes that need to be debugged are manually marked in each set of format specifier matching abstract syntax trees. Each debugging node corresponds to a set of syntax nodes. The high debugging value weight syntax nodes of the multiple sets of format specifier matching abstract syntax trees are selected by using steps S2 and S3 respectively. The goal is to maximize the overlap between the selected high debugging value weight syntax nodes and the debugging nodes. The training loss function of the trainable parameters in step S2 (trainable parameters in code analysis model) and S3 is constructed. The gradient descent algorithm or Adam optimizer is used to solve the training loss function and train and optimize the trainable parameters.

[0042] S4: Extract the context information of the syntax nodes with high debugging value weights, and use an AI-driven code generation model to generate the debugging statements corresponding to the syntax nodes with high debugging value weights.

[0043] Step S4 extracts the context information of the syntax nodes with high debugging value weights, and uses an AI-driven code generation model to generate debugging statements corresponding to the syntax nodes with high debugging value weights, including: S41: Extract the context information of the syntax node with high debugging value weight. The context information includes the function name, parameter list, variable data set in the parameter list, variable data type, variable data format specifier, and variable position in the syntax node. Specifically, the parameter list includes input parameters and output parameters, and the input parameters and output parameters include adjustable variable data and non-adjustable constant data; S42: Using the format specifier of the variable data as a constraint, an AI-driven code generation model is used to receive the context information and generate semantically complete debugging statements.

[0044] Specifically, the AI-driven code generation model is an AI semantic generation model function, such as CodeBERT, Claude, etc.

[0045] S5: Perform format security verification and semantic consistency verification on the debugging statements, insert the verification-passing debugging statements into the corresponding source code file debugging location, and compile and debug the source code file.

[0046] Step S5 involves performing formatting security checks and semantic consistency checks on the debug statements, including: S51: Extract the format specifiers of the variable data in the debugging statement, and calculate the matching relationship between the format specifiers of the variable data in the debugging statement and the variable data in the context information, as the format security verification result; Specifically, the matching relationship between the format specifiers of the variable data in the debugging statement R and the variable data in the context information. The calculation formula is: ; in, This indicates the number of variable data in the debugging statement R. The format specifier for the k-th variable data in the debugging statement R. This represents the variable data in the context information corresponding to the k-th variable data in the debugging statement R. This represents variable data generated based on the type-format specifier mapping table. Variable data types and format specifiers The mismatch relationship occurs if variable data exists in the type-format specifier mapping table. Variable data types and format specifiers ,but =0, otherwise =1; S52: Construct a semantic consistency verification function to detect the consistency between the variable data, function name and the context information in the debugging statement, and obtain the semantic consistency verification result; Specifically, the debugging statement Consistency between variable data, function names, and the context information The calculation formula is: ; in, Indicates debugging statements The variable data set in This represents the set of variable data in the context information. Represents a set of variable data The number of variable data in the middle, This represents calculating the intersection of sets. Indicates intersection The number of variable data in the middle, Indicates debugging statements Consistency of function names in debugging statements If the function name in the text matches the function name in the context information, then... =1, otherwise =0; S53: The format security verification result and the semantic consistency verification result are weighted to obtain a weighted verification result. If the weighted verification result is higher than the preset verification threshold (e.g., 0.6), it means that the debugging statement passes the verification; otherwise, it means that the debugging statement fails the verification.

[0047] Optionally, the weighting weights of the formatting security check result and the semantic consistency check result are set to 0.4 and 0.6 respectively; As an embodiment of the present invention, the present invention determines the debugging location of the source code file to which the debugging statement needs to be inserted based on the syntax tag of the syntax node associated with the debugging statement. For example, for a function node, the debugging statement is inserted at the beginning of the function definition; for a conditional judgment node in a control structure node, the debugging statement is inserted after the judgment expression; for a loop node in a control structure node, the debugging statement is inserted at the beginning of the loop body, etc. After the insertion is completed, the system regenerates the complete C / C++ source file and performs compilation and debugging. Example 2:

[0048] For reference Figure 2 The diagram shows the system architecture of an AI-driven program debugging system 100, which includes a preprocessing module 101, a compile-time type safety inference module 102, a source code context awareness module 103, a debugging statement generation module 104, a syntax highlighting enhancement module 105, and a dynamic switch control module 106. The compilation preprocessing module 101 is used to obtain the source code file of the program to be debugged, perform lexical analysis and syntax analysis on the source code file, generate an abstract syntax tree corresponding to the source code file, and extract the syntax tags of the syntax nodes in the abstract syntax tree. The compile-time type safety inference module 102 constructs a type-format specifier mapping table based on the type in the syntax tag, performs automatic format specifier matching on the syntax node, obtains the abstract syntax tree after format specifier matching, and automatically selects the format specifier that matches the variable data during the generation of debugging statements; It should be noted that this invention is based on the Generic() generic mechanism of the C11 standard, constructing a type-format specifier mapping table (such as int→"%d", double→"%f"). Specifically, during the compilation phase of debugging statements, the variable types of the variable data in the debugging statement information to be debugged can be statically analyzed, and the matching format specifier can be automatically selected from the constructed mapping table, eliminating the risk of type errors caused by manual specification. The debugging information to be debugged is a block of program code, which includes expressions containing types. At the same time, the mapping table also supports the formatting strategy of extended custom types (such as structures) (i.e., defining the mapping relationship between custom types and custom format specifiers), and the compatibility handling of unknown types is achieved through the default branch.

[0049] The Source Code Context Awareness Module 103 integrates built-in C language macros (__FILE__, __LINE__, __func__) to dynamically capture the debugging location of source code files containing debugging statement information and output a standardized output template: [Source Code File Debugging Location: Line Number (Function)] Expression Literal = Expression Value (Data Type). This achieves precise mapping between debugging statement information and source code, inserting verified debugging statements into the corresponding source code file debugging location for compiling and debugging the source code file. The debugging statement generation module 104 extracts semantic features from the abstract syntax tree after format specifier matching and the syntax tags of the syntax nodes using an AI-based code analysis model to obtain the semantic features of the syntax nodes. By establishing control flow and data flow debugging relationships between debugging information and syntax nodes, it calculates the debugging value weight of the syntax nodes and filters out syntax nodes with high debugging value weights. Finally, it generates debugging statements corresponding to the syntax nodes with high debugging value weights using an AI-driven code generation model and performs formatting security checks and semantic consistency checks. The syntax highlighting enhancement module 105 and the dynamic switch control module 106 are auxiliary modules. The syntax highlighting enhancement module 105 defines multi-level visual marking rules based on the output characteristics of the terminal (such as supporting multiple display brightness, color and / or formats, such as underline, etc.). Emphasis on key fields: Expressions use a blue foreground color, and variable data types use a green foreground color to enhance the visibility of key information; Auxiliary fields are weakened: source code files and function names are halved in brightness, and line numbers are marked in red to balance information density and visual focus; Structural optimization: The code value of the expression uses peacock blue foreground color to form a color logic association with the variable data and variable data type. Structural optimization means that different output information corresponding to the output template can display different colors, brightness and / or formats.

[0050] The dynamic switch control module 106 enables / disables debug output globally through external macro definitions. When disabled, all debug macros expand to empty instructions. When the debugging phase ends, the dynamic switch control module 106 is triggered to shut down other modules and integrates the switch option into the compilation instructions (such as Makefile) of the source code file to achieve zero-code intrusion management of debugging functions. When the debug statement is disabled using external parameters, the debug statement is removed in the preprocessing stage, resulting in a source code file without debug statements. The dynamic switch control module 106 supports subdivided control strategies by module or level to avoid runtime performance loss.

[0051] By running multiple modules in the program debugging system, the system is simple to operate and easy to use; it can be used simply by including header files in the source code file. The output results are easy to read and can be highlighted (which can be turned on or off). The terminal can print source code file names, line numbers, function names, and primitive expressions. C language data types are automatically deduced, and variable values ​​and format specifier types are obtained and printed based on the input expression. Pure macro definition parsing and deduction are performed without introducing additional functions. It is compatible with C11 and later C language standards (such as GCC 4.9+, Clang 3.0+).

[0052] It should be understood that the embodiments described are for illustrative purposes only and are not limited to this structure in terms of the scope of the patent invention.

[0053] It should be noted that the sequence numbers of the above embodiments of the present invention are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, apparatus, article, or method. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.

[0054] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0055] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. An artificial intelligence-driven program debugging method, characterized in that, The method includes: S1: Obtain the source code file of the program to be debugged, perform lexical analysis and syntax analysis on the source code file, generate an abstract syntax tree corresponding to the source code file, extract the syntax tags of the syntax nodes in the abstract syntax tree, construct a type-format specifier mapping table based on the type in the syntax tags, perform automatic format specifier matching on the syntax nodes, and obtain the abstract syntax tree after format specifier matching. S2: Based on the abstract syntax tree after matching the format specifiers and the syntax tags of the syntax nodes, the semantic features of the abstract syntax tree after matching the format specifiers are extracted using an AI-based code analysis model to obtain the semantic features of the syntax nodes. S3: Based on the semantic features of the syntax nodes, establish the control flow debugging relationship and data flow debugging relationship between the debugging information and the syntax nodes, calculate the debugging value weight of the syntax nodes, and filter out the syntax nodes with high debugging value weight. S4: Extract the context information of the syntax nodes with high debugging value weights, and use an AI-driven code generation model to generate the debugging statements corresponding to the syntax nodes with high debugging value weights. S5: Perform format security verification and semantic consistency verification on the debugging statements, insert the verification-passing debugging statements into the corresponding source code file debugging location, and compile and debug the source code file.

2. The AI-driven program debugging method as described in claim 1, characterized in that, Step S1 involves obtaining the source code file of the program to be debugged, performing lexical and syntactic analysis on the source code file, and generating an abstract syntax tree corresponding to the source code file, including: S11: Perform integrity verification and standardization on the source code files to obtain standardized source code files. Mark source code files that fail integrity verification as abnormal inputs and stop the subsequent analysis process. S12: Perform lexical analysis on the standardized source code file to obtain a sequence of lexical units based on the character stream order, and record the structured attributes of the lexical units in the sequence of lexical units. The structured attributes of the lexical units include the code value, lexical type, and position of the lexical unit. The position of the lexical unit is the line number and column number of the lexical unit in the standardized source code file. S13: A bottom-up analysis model is used to perform syntactic analysis on the lexical unit sequence, extract syntactic structure units from the lexical unit sequence and create corresponding syntactic nodes, mark the hierarchical structure of the syntactic nodes, and form the abstract syntax tree corresponding to the source code file.

3. The AI-driven program debugging method as described in claim 2, characterized in that, Extracting the syntax labels of the syntax nodes in the abstract syntax tree includes: Starting from the root node of the abstract syntax tree, a depth-first traversal is used to extract semantic tags for each syntax node, thereby obtaining the syntax tags of the syntax nodes in the abstract syntax tree. The semantic tags of the syntax nodes include the type of the syntax node and the various semantic attributes corresponding to the type. The types of syntax nodes include root nodes, function nodes, variable declaration and reference nodes, control structure nodes, and expression nodes.

4. The AI-driven program debugging method as described in claim 3, characterized in that, The type-format specifier mapping table is constructed to automatically match format specifiers on syntax nodes, resulting in an abstract syntax tree after format specifier matching, including: Extract the syntax nodes of the type variable declaration and reference nodes, construct a type-format specifier mapping table, use the type-format specifier mapping table to perform automatic format specifier matching on the extracted syntax nodes, obtain the format specifiers corresponding to different variable data types, and add the matched format specifiers to the semantic attributes of variable declaration and reference nodes to form an abstract syntax tree after format specifier matching.

5. The AI-driven program debugging method as described in claim 1, characterized in that, Step S2 utilizes an AI-based code analysis model to extract semantic features from the abstract syntax tree after format specifier matching, including: The AI-based code analysis model includes a syntax structure encoding layer, a context and scope fusion layer, a data dependency awareness layer, and a semantic feature output layer. S21: The syntax structure encoding layer extracts the syntax tags of the syntax nodes, performs word vector encoding based on the syntax tags on the semantic attribute sequence of the syntax nodes, and obtains the encoding vector of the syntax nodes. S22: The context and scope fusion layer extracts the set of context nodes of the syntax node in the abstract syntax tree, and extracts the encoding vector of the syntax node in the set of context nodes. The encoding vector of the syntax node in the set of context nodes is weighted by attention weighting to obtain the fusion feature of the syntax node to be calculated for semantic features. S23: The data dependency awareness layer selects a set of dependent reference nodes that have a dependency reference relationship with the syntax node based on the dependency and reference relationships of the variable data in the syntax node, calculates the dependency weight coefficient between the syntax node in the dependent reference node set and the syntax node of the semantic feature to be calculated, and performs dependency weighted propagation on the encoding vector of the syntax node in the dependent reference node set to obtain the semantic propagation feature of the syntax node of the semantic feature to be calculated. S24: The semantic feature output layer weights the fusion features and semantic propagation features of the syntax node and outputs the semantic features of the syntax node.

6. The AI-driven program debugging method as described in claim 1, characterized in that, The S3 step establishes the control flow debugging relationship and data flow debugging relationship between debugging information and syntax nodes, including: S31: Based on the abstract syntax tree, extract the number of child nodes of the syntax node in the abstract syntax tree, and convert the number of child nodes into the control flow debugging relationship between debugging information and the syntax node; S32: Based on the semantic feature calculation process of the syntax node, extract the set of dependent reference nodes of the syntax node, and count the number of syntax nodes in the set of dependent reference nodes as the data flow dependency quantity of the syntax node. Convert the data flow dependency quantity into debugging information and the data flow debugging relationship between the syntax node.

7. The AI-driven program debugging method as described in claim 6, characterized in that, Step S3, which calculates the debugging value weight of a syntax node based on the control flow debugging relationship and data flow debugging relationship between the debugging information and the syntax node, and filters syntax nodes with high debugging value weights, further includes: S33: Based on the semantic features of the syntax nodes, calculate the attention semantic weight between the syntax nodes in the dependent reference node set and the syntax nodes whose debugging value weights are to be calculated. S34: Based on the attention semantic weights, a graph neural network model incorporating an attention mechanism is used to calculate the node anomaly risk score of the grammar node, wherein the node anomaly risk score is used to evaluate the potential error triggering probability of the grammar node. S35: Calculate the debugging value weight of the syntax node based on the node anomaly risk score, control flow debugging relationship, and data flow debugging relationship of the syntax node. S36: Based on the debugging value weight of the syntax node, select syntax nodes with debugging value weights higher than a preset value threshold as syntax nodes with high debugging value weights.

8. The AI-driven program debugging method as described in claim 1, characterized in that, Step S4 extracts the context information of the syntax nodes with high debugging value weights, and uses an AI-driven code generation model to generate debugging statements corresponding to the syntax nodes with high debugging value weights, including: S41: Extract the context information of the syntax node with high debugging value weight. The context information includes the function name, parameter list, variable data set in the parameter list, variable data type, variable data format specifier, and variable position in the syntax node. S42: Using the format specifier of the variable data as a constraint, an AI-driven code generation model is used to receive the context information and generate semantically complete debugging statements.

9. The AI-driven program debugging method as described in claim 1, characterized in that, Step S5 involves performing formatting security checks and semantic consistency checks on the debug statements, including: S51: Extract the format specifiers of the variable data in the debugging statement, and calculate the matching relationship between the format specifiers of the variable data in the debugging statement and the variable data in the context information, as the format security verification result; The matching relationship between the format specifier of the variable data in the debugging statement R and the variable data in the context information. The calculation formula is: ; in, This indicates the number of variable data in the debugging statement R. The format specifier for the k-th variable data in the debugging statement R. This represents the variable data in the context information corresponding to the k-th variable data in the debugging statement R. This represents variable data generated based on the type-format specifier mapping table. Variable data types and format specifiers The mismatch relationship occurs if variable data exists in the type-format specifier mapping table. Variable data types and format specifiers ,but =0, otherwise =1; S52: Construct a semantic consistency verification function to detect the consistency between the variable data, function name and the context information in the debugging statement, and obtain the semantic consistency verification result; The debugging statement Consistency between variable data, function names, and the context information The calculation formula is: ; in, Indicates debugging statements The variable data set in This represents the set of variable data in the context information. Represents a set of variable data The number of variable data in the middle, This represents calculating the intersection of sets. Indicates intersection The number of variable data in the middle, Indicates debugging statements Consistency of function names in debugging statements If the function name in the text matches the function name in the context information, then... =1, otherwise =0; S53: The format security verification result and the semantic consistency verification result are weighted to obtain a weighted verification result. If the weighted verification result is higher than the preset verification threshold, it means that the debugging statement has passed the verification; otherwise, it means that the debugging statement has failed the verification.

10. An artificial intelligence-driven program debugging system, characterized in that, The program debugging system includes a compilation preprocessing module, a compile-time type safety inference module, a source code context awareness module, a debugging statement generation module, a syntax highlighting enhancement module, and a dynamic switch control module, to implement an artificial intelligence-driven program debugging method as described in any one of claims 1-9.