An interface identification method and apparatus based on a combination of dynamic and static code analysis

By combining dynamic and static code analysis methods, constructing a real syntax tree, and collecting data using tracking points to identify interfaces, the problem of low efficiency and insufficient accuracy in existing technologies is solved, achieving high efficiency and accuracy in interface identification.

CN123114472APending Publication Date: 2026-11-17WUHAN KOTEI INFORMATICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611258980.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-19
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In existing technologies, combining static code analysis and dynamic code analysis is inefficient, the analysis results are not accurate enough, and there is a lack of effective visualization tools, which hinders a deep understanding and optimization of the interface operation mechanism.

Method used

We employ a method that combines dynamic and static code analysis. We extract function information by constructing a real syntax tree, collect runtime data using trace points, and identify interfaces by combining interface filtering rules.

Benefits of technology

It improves the accuracy of interface identification, solves the problems of redundant interfaces and misidentification, enhances analysis efficiency and applicability, provides a rich code representation foundation, and is adaptable to software projects with different architectures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114472A_ABST
    Figure CN123114472A_ABST
Patent Text Reader

Abstract

This invention relates to an interface identification method and apparatus based on a combination of static and dynamic code analysis. The method first performs static analysis, searching and reading source code files in a specified directory, constructing a real syntax tree using the Tree-Sitter tool, parsing function definitions to extract function information, and organizing it into standardized intermediate files. Then, dynamic analysis is performed, parsing the intermediate files and generating trace point configurations for function entry and exit points based on the function information. These are then imported into an integrated development environment (IDE) and the target program is run, collecting trace logs. Finally, the logs are analyzed according to preset interface filtering rules to identify and determine the target interface. This invention, by combining static and dynamic analysis, balances the accuracy of code structure with the flexibility of runtime behavior. It utilizes real syntax tree parsing to improve efficiency and leverages modular design and standardized data interfaces to achieve high scalability, effectively improving the accuracy and adaptability of interface identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of software engineering and computer science, and in particular to an interface identification method and apparatus based on a combination of dynamic and static code analysis. Background Technology

[0002] As software systems become increasingly complex, interfaces, as the core carriers for data interaction and functional collaboration between different modules and components, play a crucial role in the entire process of software development, maintenance, and iteration. They directly affect the stability, compatibility, and development efficiency of the system, and are therefore of paramount importance in software development and maintenance.

[0003] Current technologies typically employ static code analysis or dynamic code analysis methods. Static code analysis can efficiently parse code text and quickly identify the code's structure, syntax elements, and potential dependencies, but it cannot reveal the code's state and behavior during actual runtime. Dynamic code analysis, by actually running the program and collecting runtime data, can realistically capture dynamic behaviors such as function call sequences and parameter passing, but its analysis depends on the specific execution path, resulting in high runtime overhead and the potential to miss unexecuted code paths.

[0004] In attempting to combine static code analysis and dynamic code analysis, existing technologies generally suffer from low integration efficiency and insufficient accuracy of analysis results, making it difficult to balance analysis efficiency and accuracy. In addition, the industry lacks effective visualization tools to intuitively display the call relationships and sequence diagrams of interfaces, which further limits developers' in-depth understanding of the interface's operating mechanism and hinders subsequent optimization and adjustment of the interfaces. Summary of the Invention

[0005] In view of this, it is necessary to provide an interface identification method based on a combination of dynamic and static code analysis to address the aforementioned shortcomings of existing technologies.

[0006] To address the aforementioned problems, in a first aspect, embodiments of the present invention provide an interface identification method based on a combination of dynamic and static code analysis, comprising: Static analysis steps: Search for source code files in the specified directory and read them one by one; for each read source code file, construct its true syntax tree using a syntax parsing tool; traverse the true syntax tree, parse each function definition to extract function information, which includes at least the function name, return type, parameter list, and line number information corresponding to the function body; organize the function information extracted from all source code files into structured data, output and store it as an intermediate file in a standardized format; Dynamic analysis steps: Parse the intermediate file generated in the static analysis step to obtain the function information; parse the preset trace point template, generate a function entry breakpoint information block using the function information, and generate a function exit breakpoint information block using the function information and the line number information corresponding to the function body; merge the function entry breakpoint information block and the function exit breakpoint information block to obtain a trace point configuration file for tracing the function execution process; import the trace point configuration file into the integrated development environment of the target program, compile and run the target program with the trace points embedded, and collect the trace logs containing the function call sequence and call context generated during the runtime of the target program; Interface identification step: According to the preset interface filtering rules, the tracking logs collected in the dynamic analysis step are analyzed and processed, and the target interfaces that meet the interface filtering rules are identified and determined from the dynamic call information recorded in the tracking logs.

[0007] Furthermore, for each read source code file, a syntax parsing tool is used to construct its true syntax tree, including: The Tree-Sitter tool is used as a syntax parsing tool to perform syntax parsing on the read source code file and construct a real syntax tree; The query function of the Tree-Sitter tool is used to match the function definition nodes in the real syntax tree.

[0008] Furthermore, the actual syntax tree is traversed, and each function definition is parsed to extract function information, including: Traverse the actual syntax tree to obtain the function definition node corresponding to each function; For each matched function definition node, determine whether the function corresponding to the function definition node is a static function; if it is a static function, skip the function definition node; if it is not a static function, further determine whether the function is an empty function; if it is an empty function, skip the function definition node; if it is not an empty function, perform the following parsing steps: Parse the function definition node to obtain the function qualifier; Parse the function definition node to obtain the basic return type and return value qualifier; Parse the function declaration node in the function definition node to obtain the function name; Determine whether the function is an anonymous function; if it is an anonymous function, skip the function definition node; if it is not an anonymous function, parse the function definition node and obtain the return value suffix. Parse the parameter list node in the function definition node to obtain the parameter name and parameter type, wherein the parameter type is obtained by combining the parameter type qualifier, the parameter base type and the parameter type suffix; Parse the function body node in the function definition node to obtain the line number information corresponding to the function body; The function qualifier, function name, return value type, parameter name, parameter type, and line number information corresponding to the function body are integrated to form the function information; wherein, the return value type is obtained by combining the base return value type, the return value qualifier, and the return value suffix.

[0009] Furthermore, the step of organizing the function information extracted from all source code files into structured data, outputting and storing it as an intermediate file in a standardized format includes: Organize all function information corresponding to each source code file into a function information array; The filename of each source code file is associated with the corresponding function information array to form an associated dictionary with filename as key and function information array as value, which serves as structured data; The associated dictionary is converted into a standardized text file in JSON format as an intermediate file; the intermediate file is then output and stored in a specified directory.

[0010] Further, the parsing of the preset tracking point template, the generation of function entry breakpoint information blocks using the function information, and the generation of function exit breakpoint information blocks using the function information and the line number information corresponding to the function body, include: The preset tracking point templates include function breakpoint XML templates and location breakpoint XML templates; the function breakpoint XML templates are parsed, and the function information is filled into the corresponding fields of the function breakpoint XML templates to generate function entry breakpoint information blocks corresponding to the function entry points; Parse the position breakpoint XML template, fill the function information and the line number information corresponding to the function body into the corresponding fields of the position breakpoint XML template, and generate the function exit breakpoint information block corresponding to the function exit.

[0011] Furthermore, the tracepoint configuration file is imported into the integrated development environment of the target program, the target program with the tracepoints embedded is compiled and run, and trace logs containing function call sequences and call contexts generated during the runtime of the target program are collected, including: Import the tracking point configuration file into the visual integrated development tool corresponding to the target program; Within the visual integrated development tool, the target program with embedded tracking points is compiled, and the compiled target program is run. During the execution of the target program, the function name entry and exit information, actual parameter value information, call stack information, and scope information generated by the target program are collected. The collected information is organized according to a preset log format to form a trace log and then output and stored.

[0012] Furthermore, the preset interface filtering rules include at least one of the following: filtering rules based on function qualifiers, filtering rules based on function scope, and filtering rules based on component object call sequence.

[0013] Secondly, embodiments of the present invention provide an interface identification device based on a combination of dynamic and static code analysis, comprising: The static analysis module is used to search for and read source code files in a specified directory. For each source code file, a syntax parsing tool is used to construct its true syntax tree. The true syntax tree is traversed, and each function definition is parsed to extract function information, which includes at least the function name, return type, parameter list, and line number information corresponding to the function body. The function information extracted from all source code files is organized into structured data, output, and stored as an intermediate file in a standardized format. The dynamic analysis module is used to parse the intermediate files generated by the static analysis step to obtain the function information; parse the preset trace point template, generate function entry breakpoint information blocks using the function information, and generate function exit breakpoint information blocks using the function information and the line number information corresponding to the function body; merge the function entry breakpoint information blocks and the function exit breakpoint information blocks to obtain a trace point configuration file for tracing the function execution process; import the trace point configuration file into the integrated development environment of the target program, compile and run the target program with the trace points embedded, and collect the trace logs containing function call sequences and call contexts generated during the runtime of the target program; The interface identification module is used to analyze and process the tracking logs collected in the dynamic analysis step according to the preset interface filtering rules, and identify and determine the target interface that meets the interface filtering rules from the dynamic call information recorded in the tracking logs.

[0014] Thirdly, the present invention also provides an electronic device, including a memory and a processor, wherein, The memory is used to store programs; The processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps in the interface identification method based on a combination of dynamic and static code analysis as described in the first aspect embodiment of the present invention.

[0015] Fourthly, the present invention also provides a computer-readable storage medium for storing a computer-readable program or instruction, which, when executed by a processor, enables the implementation of the steps in the interface identification method based on a combination of dynamic and static code analysis as described in the first aspect embodiment of the present invention.

[0016] The interface identification method and apparatus based on a combination of dynamic and static code analysis provided by this invention have the following advantages compared with the prior art: (1) This invention adopts a combination of static and dynamic code analysis. Static analysis extracts function information by constructing a real syntax tree, while dynamic analysis collects runtime data using tracking points. This method takes into account both the accuracy of code structure and the flexibility of dynamic behavior. Compared with traditional static analysis, it can optimize interface selection by combining the real-time running status of the project, effectively solve the problems of redundant interfaces and misidentification of obsolete interfaces, and improve the accuracy of interface identification.

[0017] (2) This invention uses the Tree-Sitter tool to construct a real syntax tree (CST), which has advantages over traditional abstract syntax trees (ASTs) such as no additional dependencies, support for code snippet parsing, preservation of complete code details, and a built-in efficient pattern matching mechanism. This makes the code parsing process lighter and faster, can work without a complete project context, and provides a richer code representation foundation for subsequent possible intelligent analysis (such as LLM processing), improving the efficiency and applicability of the overall analysis process.

[0018] (3) This invention adopts a modular design. The dynamic and static analysis modules are decoupled and interconnected through JSON format intermediate files, and the interface filtering rules can be adjusted through template files. This loosely coupled architecture allows users to flexibly extend and adjust according to their needs, adapt to different software projects, and enhance the applicability and scalability of the method. Attached Figure Description

[0019] Figure 1 The flowchart of the interface identification method based on the combination of dynamic and static code analysis provided by the present invention; Figure 2 The static analysis flowchart provided for this invention; Figure 3 The dynamic analysis flowchart provided for this invention; Figure 4 The structural block diagram of the interface recognition device based on the combination of dynamic and static code analysis provided by the present invention; Figure 5 This is a structural block diagram of the electronic device provided by the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] The naming or numbering of steps in the embodiments of the present invention does not mean that the steps in the method flow must be executed in the time / logical order indicated by the naming or numbering. The execution order of the named or numbered process steps can be changed according to the technical purpose to be achieved, as long as the same or similar technical effect can be achieved.

[0022] Figure 1 This is a flowchart illustrating the interface identification method based on a combination of dynamic and static code analysis provided by the present invention. (Refer to...) Figure 1 The method includes the following steps: Step S1, Static Analysis Step: Search for source code files in the specified directory and read them one by one; for each read source code file, construct its true syntax tree using a syntax parsing tool; traverse the true syntax tree, parse each function definition to extract function information, the function information including at least the function name, return value type, parameter list, and line number information corresponding to the function body; organize the function information extracted from all source code files into structured data, output and store it as an intermediate file in a standardized format.

[0023] Existing static analysis tools mostly rely on abstract syntax trees, which suffers from numerous additional dependencies and requires complete project support. Furthermore, static analysis alone easily extracts invalid function information, failing to provide accurate structured data for subsequent dynamic analysis. Therefore, in step S1 of this invention, a real syntax tree is constructed using Tree-Sitter, functions are parsed in a fixed order, invalid functions are filtered out, and the information is organized into structured data and output as an intermediate file. This ensures the integrity of function information and provides a standardized data carrier for the connection between static and dynamic analysis.

[0024] In some embodiments of this application, reference is made to Figure 2 The static analysis flowchart shown below details the static analysis steps: First, the system recursively searches for all source code files in the target programming language (e.g., .c files for C) in the user-specified directory, reading each file found one by one. The Tree-Sitter tool is then used to parse the read source code files, constructing a Concrete Syntax Tree (CST). The query function of the Tree-Sitter tool is then used to match function definition blocks in the CST, obtaining the function definition node for each function. The Tree-Sitter tool is a tree-structured syntax parsing tool used to parse source code to construct a syntax tree. It has a query function that can match specified nodes in the syntax tree. The Concrete Syntax Tree (CST), also known as the Abstract Syntax Tree (AST), completely preserves all syntactic details of the source code, including every lexical unit (token) such as parentheses, semicolons, and comments, providing the most original and complete representation of the code structure.

[0025] Next, we iterate through each matched function definition node and perform refined parsing and filtering in sequence: For each matched function definition node, determine whether the function corresponding to the function definition node is a static function; if it is a static function, skip the function definition node; if it is not a static function, further determine whether the function is an empty function; if it is an empty function, skip the function definition node; if it is not an empty function, perform the following parsing steps. For each matched function definition node, determine whether the function corresponding to the function definition node is a static function. If it is a static function, skip the function definition node. If it is not a static function, further determine whether the function is an empty function. If it is an empty function, skip the function definition node. If it is not an empty function, execute the following parsing steps.

[0026] Parse the function definition node to obtain the function qualifier; then parse the function definition node again to obtain the return primitive type and return type qualifier; parse the function declarator node in the function definition node to obtain the function name.

[0027] Determine if the function is anonymous. If so, skip the function definition node; otherwise, parse the function definition node to obtain the return type postfix. Combine the base return type, return type qualifier, and return type postfix to obtain the return type.

[0028] The parameter list node in the function definition node is parsed. The Tree-SitterQuery is used to match the next parameter declaration node. The node is parsed to obtain the parameter primitive type, parameter type qualifier, and parameter name. The parameter type suffix is ​​then parsed to obtain the parameter type. The three are combined to obtain the parameter type. This process is repeated until the parameter list has been traversed.

[0029] Parse the function body node in the function definition node to obtain the line number information corresponding to the function body; integrate the function qualifier, function name, return value type, parameter name, parameter type, and line number information into function information and add it to the function information array.

[0030] After all function definitions within a file have been traversed, the filename is associated with its corresponding function information array, forming an associative dictionary with filenames as keys and function information arrays as values. Once all files have been traversed, the associative dictionary is converted into a standardized JSON (JavaScript Object Notation) text file as an intermediate file, output and stored in the specified directory, completing the static analysis step. The intermediate file completely and clearly records the function skeleton information of the entire code project and is stored in the specified output directory, awaiting reading by the dynamic analysis module.

[0031] This invention uses the Tree-Sitter tool to construct a True Syntax Tree (CST), which, compared to traditional Abstract Syntax Trees (ASTs), offers advantages such as no additional dependencies, support for code snippet parsing, preservation of complete code details, and a built-in efficient pattern matching mechanism. This makes the code parsing process lighter and faster, works without requiring a complete project context, and provides a richer code representation foundation for subsequent intelligent analysis (such as LLM processing), improving the efficiency and applicability of the overall analysis process.

[0032] Step S2, Dynamic Analysis Step: Parse the intermediate file generated in the static analysis step to obtain the function information; parse the preset trace point template, generate a function entry breakpoint information block using the function information, and generate a function exit breakpoint information block using the function information and the line number information corresponding to the function body; merge the function entry breakpoint information block and the function exit breakpoint information block to obtain a trace point configuration file for tracing the function execution process; import the trace point configuration file into the integrated development environment of the target program, compile and run the target program with the trace points embedded, and collect the trace logs containing the function call sequence and call context generated during the runtime of the target program.

[0033] Existing dynamic analysis solutions rely on specific execution paths, resulting in high runtime overhead and a tendency to miss information about unexecuted code. Furthermore, the integration of dynamic and static analysis is inefficient, and the function information from static analysis cannot be reused for precise configuration of tracking points. Therefore, in step S2 of this invention, function information is obtained by parsing the intermediate files generated from static analysis, and precise entry and exit breakpoint configurations are generated using XML templates. This information is then imported into a visual development tool to run the program and collect logs. This reduces the runtime overhead of dynamic analysis and achieves efficient integration of dynamic and static analysis, providing complete dynamic call data for interface identification.

[0034] In some embodiments of this application, reference is made to Figure 3 The dynamic analysis flowchart shown below details the dynamic analysis steps: The input to the dynamic analysis step is the standardized intermediate file output by the static analysis step, specifically a JSON-formatted intermediate file. First, this JSON file is read and parsed to extract all previously stored function information, including function qualifiers, function names, return types, parameter names, parameter types, and line numbers.

[0035] Then, these function information are traversed. For each function that needs to be tracked (see...),... Figure 3 The judgment logic is "whether to track"). Perform the following operations to create a tracking point for it: The device pre-prepared a function breakpoint XML (Extensible Markup Language) template. This template defines the XML structure for setting a breakpoint triggered at a function entry point in Visual Studio. In this embodiment, Visual Studio is used as the integrated development environment to import the tracepoint configuration file and run the target program. The function breakpoint XML template is parsed, and the information of the currently traversed function is filled into the corresponding fields of the template. After filling, a small XML code block representing the function entry breakpoint is generated, called the function entry breakpoint information block.

[0036] The device pre-prepared another location breakpoint XML template, which defines how to set breakpoints at specific lines of code. The location breakpoint XML template is parsed, and the corresponding fields in the template are populated using the function name of the current function and the line number information corresponding to the function body obtained from static analysis. After population, a small XML code block representing the function's exit breakpoint is generated, called the function exit breakpoint information block.

[0037] After generating entry and exit XML blocks for each function that needs to be traced, these scattered XML blocks are merged into a complete XML file containing all breakpoint configurations, according to a format recognizable by Visual Studio. This complete XML file is the tracepoint configuration file.

[0038] Next, import the tracepoint configuration file (i.e., the complete XML file) into the Visual Studio integrated development environment. Open the corresponding source code project in Visual Studio, and the breakpoint settings in the configuration file will automatically take effect. Subsequently, the developer compiles the project in the Visual Studio environment and runs the compiled target program.

[0039] When the program runs, Visual Studio's diagnostic tools will automatically trigger once it reaches a function with a tracepoint (breakpoint) set. It will log detailed trace information at the function's entry point (at the start) and exit point (before returning). The log content includes the function name, entry and exit information, call argument values, call stack information, and scope information.

[0040] After the program finishes running, the complete trace log information is collected and output from the Visual Studio diagnostic tools. These logs form the raw data basis for the filtering and analysis in the interface identification steps.

[0041] The dynamic analysis steps in this embodiment parse the intermediate files of the static analysis and reuse function information to generate precise entry and exit breakpoint configurations, achieving efficient integration of dynamic and static analysis. Using XML templates to generate trace point configuration files reduces the configuration complexity of dynamic analysis; compiling and running with Visual Studio and collecting specified dynamic information reduces runtime overhead and ensures the relevance of logs; the collected function names, entry and exit points, call stacks, and other information provide complete dynamic data support for subsequent interface identification, improving the accuracy and flexibility of interface identification.

[0042] Step S3, Interface Identification Step: Based on the preset interface filtering rules, analyze and process the tracking logs collected in the dynamic analysis step, and identify and determine the target interfaces that meet the interface filtering rules from the dynamic call information recorded in the tracking logs.

[0043] Specifically, the first step is to parse the tracking logs collected in the dynamic analysis step and extract the recorded dynamic call information, including function name entry and exit points, call parameter values, call stack, scope, etc. The extracted dynamic call information is then categorized by function name to form a function call dataset with function name as the key and corresponding dynamic call information as the value.

[0044] Next, after reading and parsing the trace logs, each record or a series of related records in the trace logs is analyzed and judged according to preset interface filtering rules. The preset interface filtering rules include at least one of the following: filtering rules based on function qualifiers, filtering rules based on function scope, and filtering rules based on component object call sequence. Specific schemes for the above three interface filtering rules include: 1) Function Qualifier-Based Filtering Rules: This rule filters based on the static declaration attribute of a function. For example, a rule could be set as: "Exclude all function call records with the function qualifier 'static'". For each function call record in the function call dataset, trace back the function metadata extracted in the static analysis step to confirm its function qualifier; if the function qualifier is 'static', it is determined that the function does not belong to an externally public interface, and its call records are filtered out.

[0045] 2) Scope-based filtering rules: This rule filters functions based on their runtime context. For example, a rule could be set as: "Only retain function calls whose scope belongs to the public module (PublicModule) or global." Based on the runtime scope information of each record in the trace log, it determines whether the function scope conforms to the preset allowed list; if the scope conforms to the preset allowed list, the function call record is retained; otherwise, it is treated as internal implementation details and filtered out.

[0046] 3) Filtering rules based on component object call timing: This rule filters functions based on the interaction patterns between components, representing a higher level of logical judgment. It reconstructs the timing relationships of function calls from the function call sequences and call stack information recorded in the trace logs, identifying function calls occurring between different components or objects. For example, a rule could be set as: "Filter out functions initiated by component A that call services provided by component B in the execution chain." By analyzing the call stack information and function call sequences in the trace logs, functions matching this specific interaction pattern are identified. These functions are typically key coordinators or adapters, serving as important interfaces; the analysis results of this rule can be visually presented as a timing interaction diagram.

[0047] In this embodiment, the judgment results of one or more of the above rules are comprehensively applied to filter and classify all records in the function call dataset; finally, a filtered list of target interfaces is output. Each interface in the list of target interfaces contains both its complete signature information in static code and is associated with the call evidence and context information actually observed during dynamic operation, thereby accurately identifying and determining the target interface.

[0048] This invention employs a combined approach of static and dynamic code analysis. Static analysis extracts function information by constructing a real syntax tree, while dynamic analysis collects runtime data using tracking points. This method balances the accuracy of code structure with the flexibility of dynamic behavior. Compared to traditional static analysis, it can optimize interface selection based on the real-time runtime status of the project, effectively solving the problems of redundant interfaces, misidentification of obsolete interfaces, and improving the accuracy of interface identification.

[0049] Figure 4 The structural block diagram of the interface recognition device based on the combination of dynamic and static code analysis provided by the present invention is shown below. Figure 4 The interface recognition device 400 based on a combination of dynamic and static code analysis includes: The static analysis module 401 is used to search for and read source code files in a specified directory one by one; for each source code file read, a syntax parsing tool is used to construct its true syntax tree; the true syntax tree is traversed, each function definition is parsed to extract function information, the function information including at least the function name, return value type, parameter list and line number information corresponding to the function body; the function information extracted from all source code files is organized into structured data, output and stored as an intermediate file in a standardized format; The dynamic analysis module 402 is used to parse the intermediate file generated by the static analysis step to obtain the function information; parse the preset trace point template, generate a function entry breakpoint information block using the function information, and generate a function exit breakpoint information block using the function information and the line number information corresponding to the function body; merge the function entry breakpoint information block and the function exit breakpoint information block to obtain a trace point configuration file for tracing the function execution process; import the trace point configuration file into the integrated development environment of the target program, compile and run the target program with the trace points embedded, and collect the trace logs containing the function call sequence and call context generated during the runtime of the target program; The interface identification module 403 is used to analyze and process the tracking logs collected in the dynamic analysis step according to the preset interface filtering rules, and identify and determine the target interface that meets the interface filtering rules from the dynamic call information recorded in the tracking logs.

[0050] The interface recognition device based on the combination of dynamic and static code analysis provided by the present invention is used to execute the interface recognition method based on the combination of dynamic and static code analysis provided in the foregoing embodiments. The interface recognition method based on the combination of dynamic and static code analysis has been described in detail in the above embodiments, and will not be repeated here.

[0051] This invention employs a modular design, with dynamic and static analysis modules decoupled and interconnected via a JSON-formatted intermediate file, and interface filtering rules adjustable through template files. This loosely coupled architecture allows users to flexibly extend and adjust the design according to their needs, adapting to software projects with different architectures and enhancing the method's applicability and scalability.

[0052] Figure 5 A structural block diagram of the electronic device provided by the present invention, such as Figure 5 As shown, the present invention also provides an electronic device 500, which can be a mobile terminal, desktop computer, laptop, handheld computer, server, or other computing device. The electronic device 500 includes a processor 501 and a memory 502, wherein the memory 502 stores an interface recognition program 503 based on a combination of dynamic and static code analysis.

[0053] In some embodiments, memory 502 may be an internal storage unit of a computer device, such as a hard disk or memory. In other embodiments, memory 502 may be an external storage device of a computer device, such as a plug-in hard disk, smart media card (SMc), secure digital card (SD), flash card, etc. Further, memory 502 may include both internal and external storage units of the computer device. Memory 502 is used to store application software and various types of data installed on the computer device, such as program code for installing the computer device. Memory 502 can also be used to temporarily store data that has been output or will be output. In one embodiment, when the interface identification program 503 based on a combination of dynamic and static code analysis is executed by processor 501, the following steps are implemented: Search for source code files in the specified directory and read them one by one; for each source code file read, construct its true syntax tree using a syntax parsing tool; traverse the true syntax tree, parse each function definition to extract function information, which includes at least the function name, return type, parameter list, and line number information corresponding to the function body; organize the function information extracted from all source code files into structured data, output and store it as an intermediate file in a standardized format; The intermediate file generated by the static analysis step is parsed to obtain the function information; a preset trace point template is parsed, and a function entry breakpoint information block is generated using the function information, and a function exit breakpoint information block is generated using the function information and the line number information corresponding to the function body; the function entry breakpoint information block and the function exit breakpoint information block are merged to obtain a trace point configuration file for tracing the function execution process; the trace point configuration file is imported into the integrated development environment of the target program, the target program with trace points embedded is compiled and run, and trace logs containing function call sequences and call contexts generated during the runtime of the target program are collected; According to the preset interface filtering rules, the tracking logs collected in the dynamic analysis step are analyzed and processed, and the target interfaces that meet the interface filtering rules are identified and determined from the dynamic call information recorded in the tracking logs.

[0054] In some embodiments, processor 501 may be a central processing unit (cPU), microprocessor or other data processing chip, used to run program code stored in memory 502 or process data, such as executing an interface recognition program based on a combination of dynamic and static code analysis.

[0055] This embodiment also provides a computer-readable storage medium storing an interface recognition program based on a combination of dynamic and static code analysis. When the interface recognition program based on a combination of dynamic and static code analysis is executed by a processor, it implements the steps of the interface recognition method based on a combination of dynamic and static code analysis.

[0056] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the appended claims.

[0057] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An interface identification method based on a combination of dynamic and static code analysis, characterized in that, include: Search for source code files in the specified directory and read them one by one; For each source code file read, a syntax parsing tool is used to construct its actual syntax tree; The actual syntax tree is traversed, and each function definition is parsed to extract function information, which includes at least the function name, return type, parameter list, and line number information corresponding to the function body. The function information extracted from all source code files is organized into structured data, output, and stored as an intermediate file in a standardized format. The intermediate file is parsed to obtain the function information; a preset trace point template is parsed, and a function entry breakpoint information block is generated using the function information; a function exit breakpoint information block is generated using the function information and the line number information corresponding to the function body; the function entry breakpoint information block and the function exit breakpoint information block are merged to obtain a trace point configuration file for tracing the function execution process. Import the trace point configuration file into the integrated development environment of the target program, compile and run the target program with the trace points embedded, and collect the trace logs generated by the target program during runtime, which include function call sequences and call contexts. According to the preset interface filtering rules, the tracking log is analyzed and processed to identify and determine the target interface that meets the interface filtering rules from the dynamic call information recorded in the tracking log.

2. The interface identification method based on a combination of dynamic and static code analysis according to claim 1, characterized in that, For each read source code file, a syntax parsing tool is used to construct its true syntax tree, including: The Tree-Sitter tool is used as a syntax parsing tool to perform syntax parsing on the read source code file and construct a real syntax tree; The query function of the Tree-Sitter tool is used to match the function definition nodes in the real syntax tree.

3. The interface identification method based on a combination of dynamic and static code analysis according to claim 1, characterized in that, Traverse the actual syntax tree, parse each function definition to extract function information, including: Traverse the actual syntax tree to obtain the function definition node corresponding to each function; For each matched function definition node, determine whether the function corresponding to the function definition node is a static function; if it is a static function, skip the function definition node; if it is not a static function, further determine whether the function is an empty function; if it is an empty function, skip the function definition node; if it is not an empty function, perform the following parsing steps: Parse the function definition node to obtain the function qualifier; Parse the function definition node to obtain the basic return type and return value qualifier; Parse the function declaration node in the function definition node to obtain the function name; Determine whether the function is an anonymous function; if it is an anonymous function, skip the function definition node; if it is not an anonymous function, parse the function definition node and obtain the return value suffix. Parse the parameter list node in the function definition node to obtain the parameter name and parameter type, wherein the parameter type is obtained by combining the parameter type qualifier, the parameter base type and the parameter type suffix; Parse the function body node in the function definition node to obtain the line number information corresponding to the function body; The function qualifier, function name, return value type, parameter name, parameter type, and line number information corresponding to the function body are integrated to form the function information; wherein, the return value type is obtained by combining the base return value type, the return value qualifier, and the return value suffix.

4. The interface identification method based on a combination of dynamic and static code analysis according to claim 1, characterized in that, The step of organizing the function information extracted from all source code files into structured data, outputting and storing it as an intermediate file in a standardized format, includes: Organize all function information corresponding to each source code file into a function information array; The filename of each source code file is associated with the corresponding function information array to form an associated dictionary with filename as key and function information array as value, which serves as structured data; The associated dictionary is converted into a standardized text file in JSON format as an intermediate file; the intermediate file is then output and stored in a specified directory.

5. The interface identification method based on a combination of dynamic and static code analysis according to claim 1, characterized in that, The parsing of the preset tracking point template, the generation of function entry breakpoint information blocks using the function information, and the generation of function exit breakpoint information blocks using the function information and the line number information corresponding to the function body, include: The preset tracking point templates include function breakpoint XML templates and location breakpoint XML templates; the function breakpoint XML templates are parsed, and the function information is filled into the corresponding fields of the function breakpoint XML templates to generate function entry breakpoint information blocks corresponding to the function entry points; Parse the position breakpoint XML template, fill the function information and the line number information corresponding to the function body into the corresponding fields of the position breakpoint XML template, and generate the function exit breakpoint information block corresponding to the function exit.

6. The interface identification method based on a combination of dynamic and static code analysis according to claim 1, characterized in that, Import the tracepoint configuration file into the integrated development environment of the target program, compile and run the target program with the tracepoints embedded, and collect the trace logs generated by the target program during runtime, which include function call sequences and call contexts, including: Import the tracking point configuration file into the visual integrated development tool corresponding to the target program; Within the visual integrated development tool, the target program with embedded tracking points is compiled, and the compiled target program is run. During the execution of the target program, the function name entry and exit information, actual parameter value information, call stack information, and scope information generated by the target program are collected. The collected information is organized according to a preset log format to form a trace log and then output and stored.

7. The interface identification method based on a combination of dynamic and static code analysis according to claim 1, characterized in that, The preset interface filtering rules include at least one of the following: filtering rules based on function qualifiers, filtering rules based on function scope, and filtering rules based on component object call sequence.

8. An interface recognition device based on a combination of dynamic and static code analysis, the device being used to execute the interface recognition method based on a combination of dynamic and static code analysis as described in any one of claims 1-7, characterized in that, The device includes: The static analysis module is used to search for and read source code files in a specified directory. For each source code file, a syntax parsing tool is used to construct its true syntax tree. The true syntax tree is traversed, and each function definition is parsed to extract function information, which includes at least the function name, return type, parameter list, and line number information corresponding to the function body. The function information extracted from all source code files is organized into structured data, output, and stored as an intermediate file in a standardized format. The dynamic analysis module is used to parse the intermediate files generated by the static analysis step to obtain the function information; parse the preset trace point template, generate function entry breakpoint information blocks using the function information, and generate function exit breakpoint information blocks using the function information and the line number information corresponding to the function body; merge the function entry breakpoint information blocks and the function exit breakpoint information blocks to obtain a trace point configuration file for tracing the function execution process; import the trace point configuration file into the integrated development environment of the target program, compile and run the target program with the trace points embedded, and collect the trace logs containing function call sequences and call contexts generated during the runtime of the target program; The interface identification module is used to analyze and process the tracking logs collected in the dynamic analysis step according to the preset interface filtering rules, and identify and determine the target interface that meets the interface filtering rules from the dynamic call information recorded in the tracking logs.

9. An electronic device, Its features are, Including memory and processor, among which, The memory is used to store programs; The processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps in the interface identification method based on a combination of dynamic and static code analysis as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps in the interface identification method based on a combination of dynamic and static code analysis as described in any one of claims 1 to 7.