Calling link change analysis method and device, equipment and medium

By performing differential analysis of the method call relationship and source code of different versions of applications, the call link changes between versions are identified, which solves the problem that the existing technology cannot identify the call link differences, and realizes accurate positioning and software of code changes Efficiency of maintenance.

CN119473376APending Publication Date: 2025-02-18SHENZHEN YISHIHUOLALA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411452983.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The prior art cannot identify the call link differences between different versions, resulting in the inability to effectively analyze and manage code changes.

Method used

By obtaining method call relationships and method definition information for at least two versions of the application, perform a difference set operation to determine the set of addition and subtraction methods, and perform a differential comparison of the source code to determine the code change information. Based on this information, a change method collection is retrieved and changes in the latest version of the method call relationship are identified to form a call link change collection.

Benefits of technology

It realizes accurate identification and analysis of call links between different versions, helps to understand functional changes between versions, accurately determines bit code changes, improves development efficiency, and effectively maintains and upgrades the software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473376A_ABST
    Figure CN119473376A_ABST
Patent Text Reader

Abstract

The invention provides a call link change analysis method and apparatus, a device and a medium. The method comprises the steps of obtaining a method call relationship and method definition information corresponding to at least two versions of application programs; performing difference set operation on the method calling relations corresponding to different versions, and determining an increase and decrease method set; the source codes corresponding to different versions are subjected to difference comparison, code change information is determined, and the application program carries the source codes; retrieving the method definition information of the latest version based on the code change information, and determining a change method set; and determining a call link change set according to the change in the method call relationship corresponding to the latest version identified by the increase and decrease method set and the change method set. According to the method, the change of the method between the versions is marked on the basis of the provided control flow diagram, so that a developer can more systematically understand the difference between the versions of the application programs, and the software can be more effectively maintained and upgraded.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of software code processing, and in particular, relates to a call link change analysis method, device, equipment and medium. Background Art

[0002] With the rapid development of computer technology, project iterations are getting faster and faster, and computer codes must also be continuously iterated and optimized according to project requirements. For example, monitoring services in a microservice architecture through call chain analysis technology is helpful for obtaining the current operating status, locating problems, and solving the problem of service interaction tracking in a distributed network.

[0003] Especially in Android call chain analysis technology, the bytecode parsing tool Soot receives Java or Android bytecode and outputs converted bytecode, intermediate code Jimple or control flow graph (CFG), etc. However, using Soot to convert bytecode and source code into intermediate code first, and then analyze, optimize and mark, on the one hand, it is complicated and cumbersome to track the call relationship between methods; on the other hand, it is impossible to identify the changes in the method call chain between different versions of the same application. Therefore, a call chain change analysis solution is urgently needed to solve the above technical problems. Summary of the invention

[0004] In view of the shortcomings of the prior art described above, the purpose of the present application is to provide a call link change analysis method, device, equipment and medium, which are used to solve the problem that the call link differences between different versions cannot be identified during the call link change analysis in the prior art.

[0005] To achieve the above-mentioned purpose and other related purposes, the first aspect of the present application provides a call link change analysis method, including: obtaining method call relationships and method definition information corresponding to at least two versions of an application; performing a difference set operation on the method call relationships corresponding to different versions to determine a set of added and subtracted methods; performing a difference comparison on the source codes corresponding to different versions to determine code change information, wherein the application carries the source code; based on the code change information, searching the method definition information corresponding to the latest version to determine a set of changed methods, wherein the latest version number among at least two of the versions is the latest version; identifying changes in the method call relationship corresponding to the latest version according to the set of added and subtracted methods and the set of changed methods, to determine a call link change set.

[0006] In some embodiments of the first aspect, obtaining method call relationships and method definition information corresponding to at least two versions of an application program includes: obtaining an installation package file of the application program, and performing static code analysis on the installation package file to obtain method call relationships and method first instruction code line numbers of the application program; performing lexical analysis on the source code to obtain initial method definition information; correcting the initial method definition information according to the method first instruction code line number to determine final method definition information, so as to obtain method call relationships and method definition information corresponding to at least two versions.

[0007] In some embodiments of the first aspect, the method first instruction code line number includes a method name in a preset format and a first instruction code line number; the initial method definition information includes a method name in a non-preset format, a start line, and an end line; the initial method definition information is corrected according to the method first instruction code line number to determine the final method definition information, including: determining a starting line number range according to the start line and the end line in the initial method definition information; correcting the method name in a non-preset format in combination with the method name in the preset format, the first instruction code line number, and the starting line number range to determine the final method definition information.

[0008] In some embodiments of the first aspect, an installation package file of an application is obtained, and static code analysis is performed on the installation package file to obtain a method call relationship and a method first instruction code line number of the application, including: if the application is an Android application, converting the installation package file of the Android application into a compressed file in JAR format; performing static code analysis on the compressed file, extracting the call chain, obtaining the method call relationship of the application, and extracting the mapping relationship between the source code and the bytecode to obtain the method first instruction code line number of the application.

[0009] In some embodiments of the first aspect, the source code is lexically analyzed to obtain initial method definition information, including: if the application is an Android application, obtaining a first source code in JAVA format and a second source code in Kotlin format corresponding to the Android application; creating a lexical analyzer to analyze the first source code and the second source code to determine a word set; and performing grammatical analysis and semantic analysis on the word set in turn to obtain initial method definition information.

[0010] In some embodiments of the first aspect, a difference set operation is performed on method call relationships corresponding to different versions to determine the addition or subtraction of a method set, including: taking at least one version as a historical version, and performing a difference set operation on the method call relationship corresponding to the historical version and the method call relationship corresponding to the latest version; if the difference set includes more method call relationships corresponding to the historical version than the method call relationship corresponding to the latest version, it is determined that the method call relationship corresponding to the latest version is reduced; if the difference set includes less method call relationships corresponding to the historical version than the method call relationship corresponding to the latest version, it is determined that the method call relationship corresponding to the latest version is increased; if the difference set includes a change in the method call relationship corresponding to the historical version relative to the method call relationship corresponding to the latest version, it is determined that the method call relationship corresponding to the latest version is modified; and the method set is determined to be added or subtracted based on at least one of reduction, increase or modification of the method call relationship corresponding to the latest version.

[0011] In some embodiments of the first aspect, source codes corresponding to different versions are compared and code change information is determined, including: taking at least one version as a historical version, and comparing the source code corresponding to the historical version with the source code corresponding to the latest version; if the comparison result includes that the source code corresponding to the historical version is more than the source code corresponding to the latest version, determining that the source code corresponding to the latest version is reduced; if the comparison result includes that the source code corresponding to the historical version is less than the source code corresponding to the latest version, determining that the source code corresponding to the latest version is increased; if the comparison result includes that the source code corresponding to the historical version is changed relative to the source code corresponding to the latest version, determining that the source code corresponding to the latest version is modified; and determining the code change information based on at least one of reduction, increase or modification of the source code corresponding to the latest version.

[0012] In some embodiments of the first aspect, a search is performed in the method definition information corresponding to the latest version based on the code change information to determine a set of changed methods, including: based on the code change information, determining the change line number corresponding to the source file of the code change information in the method definition information, and determining the change method to which the change line number belongs, and determining the change method set by aggregating each corresponding change method.

[0013] In some embodiments of the first aspect, a call link change set is determined based on the changes in the method call relationship corresponding to the latest version identified by the increase and decrease method set and the change method set, including: identifying the changed part of the method call relationship corresponding to the latest version through the increase and decrease method set of the method call relationship; at the same time, identifying the changed part of the method call relationship corresponding to the latest version through the change method set of the source code; and determining the call link change set by assembling the method call relationship corresponding to the identified latest version.

[0014] The second aspect of the present application provides a call link change analysis device, including: an acquisition module, used to obtain method call relationships and method definition information corresponding to at least two versions of an application; a difference set operation module, used to perform difference set operations on the method call relationships corresponding to different versions, and determine the method set to be added or subtracted; a difference comparison module, used to perform difference comparison on the source codes corresponding to different versions, and determine code change information, wherein the application carries the source code; a code change determination module, based on the code change information, searches the method definition information corresponding to the latest version, and determines the changed method set, wherein the version number of at least two versions is the latest version; a link change determination module, used to identify the changes in the method call relationship corresponding to the latest version according to the method set to be added or subtracted and the method set to be changed, and determine the call link change set.

[0015] The third aspect of the present application provides a call link change analysis device, comprising: one or more processing devices; a memory for storing one or more programs; when the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the above-mentioned call link change analysis method.

[0016] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is used to enable the computer to execute the above-mentioned call link change analysis method.

[0017] As described above, a technical solution of the call link change analysis method, device, equipment and medium described in the present application has the following beneficial effects:

[0018] The present application obtains method call relationships and method definition information corresponding to at least two versions of an application program; performs a difference set operation on the method call relationships corresponding to different versions to determine a set of added and reduced methods, and accurately identifies the added and reduced parts through the set of added and reduced methods, which helps to understand the functional changes between versions; performs a difference comparison on the source codes corresponding to different versions to determine the code change information, so that the specific change information of the code can be identified; based on the code change information, a search is performed in the method definition information corresponding to the latest version to determine the changed method set, and by accurately locating the specific method that has changed, blind searches are avoided and development efficiency is improved; changes in the method call relationship corresponding to the latest version are identified according to the set of added and reduced methods and the set of changed methods, and a call link change set is determined, so that the changes in the methods between versions are identified based on the provided control flow graph, which is conducive to developers or testers to understand the differences between application versions more systematically, thereby more effectively maintaining and upgrading the software. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 Shown is an implementation environment diagram of a call link change analysis method provided by the present application;

[0020] Figure 2 Shown is a flow chart of a call link change analysis method provided by the present application;

[0021] Figure 3 Shown is a processing structure diagram of a call link change analysis device provided by the present application;

[0022] Figure 4 Shown is an extraction flow chart of a call link change analysis method provided by the present application;

[0023] Figure 5 Shown is a call chain generation flow chart of a call chain change analysis method provided by the present application;

[0024] Figure 6 Shown is a structural block diagram of a call link change analysis device provided by the present application;

[0025] Figure 7 Shown is a schematic diagram of the structure of an electronic device provided by the present application and suitable for implementing an embodiment of the present application. DETAILED DESCRIPTION

[0026] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.

[0027] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application, and thus the drawings only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed at will, and the component layout may also be more complicated.

[0028] The embodiment of the present application provides a call link change analysis method, which can be applied to a terminal, a server, or software running in a terminal or a server. In some embodiments, the terminal can be an electronic device such as a smart phone, a tablet computer, a vehicle terminal, a laptop computer, or a desktop computer; the server can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms; the software can be an application for call link change analysis, etc., but is not limited to the above forms.

[0029] For example, see Figure 1 Taking the call link change analysis method executed by a terminal as an example, the terminal can obtain method call relationships and method definition information corresponding to at least two versions of the application; perform a difference set operation on the method call relationships corresponding to different versions to determine the set of added and reduced methods; perform a difference comparison on the source codes corresponding to different versions to determine the code change information, wherein the application carries the source code; based on the code change information, search the method definition information corresponding to the latest version to determine the changed method set, wherein the version number of at least two versions is the latest version; identify the changes in the method call relationship corresponding to the latest version according to the set of added and reduced methods and the set of changed methods, and determine the call link change set.

[0030] The present application is described in detail below through specific embodiments. Figure 2 As shown, Figure 2 The flowchart of the call link change analysis method provided in the embodiment of the present application includes the following steps:

[0031] Step S210, obtaining method call relationships and method definition information corresponding to at least two versions of application programs;

[0032] Among them, an application refers to a computer program that is used to complete one or more specific tasks and has a visual user interface that can interact with users.

[0033] Specifically, the method calling relationship and method definition information corresponding to different versions of the same application are obtained. Different versions mainly refer to that with the upgrade of the version, the application usually introduces new functions to enhance the user experience or meet new market needs. For example, some functions are not available in the old version, but are added or improved in the new version.

[0034] For example, as an application is upgraded, there will be multiple different versions updated, such as version 1.0, version 2.0, version 3.0, etc., and in this application, it is not limited to the call link change analysis of the new and old versions of the application, but also includes the call link change analysis of two or more old versions of the application, which will not be repeated here.

[0035] In addition, as the business functions of the business system become more and more complex, the code complexity of the business system is also increasing, and there will be complex call relationships (i.e., method call relationships) in the business system, such as function calls, interface calls, etc. When the code corresponding to a function or interface changes, the functions of the upstream interface or service that directly or indirectly calls the function or interface may be affected. Therefore, after modifying the code, the developer needs to evaluate the impact of each code submission to determine the scope of the self-test and decide whether it is necessary to adjust the upstream service or interface. In this embodiment, the application includes one or more interfaces, and the implementation of each interface function can be achieved by calling one or more functions. Therefore, when the code changes, an interface call link is generated based on the call relationship between each interface and each function.

[0036] For example, method definition information refers to key elements required when defining a method in source code, including method name, return type, parameter list, modifiers, and exception list, etc. In some embodiments, if method definition information in a C language function is to be extracted, the method definition information includes functions and data types defined in the C language function; the definition information in the C language function is converted into IEC conversion information recognizable by the IEC language, and based on the correspondence between the method definition information in the C language function and the IEC conversion information, the calling relationship between the C language and the IEC language is determined; wherein the IEC conversion information includes: IEC functions and IEC data types; based on the calling relationship between the C language and the IEC language.

[0037] Optionally, obtaining method call relationships and method definition information corresponding to at least two versions of the application program includes:

[0038] Obtaining an installation package file of the application, and performing static code analysis on the installation package file to obtain a method calling relationship and a method first instruction code line number of the application;

[0039] Performing lexical analysis on the source code to obtain initial method definition information;

[0040] The initial method definition information is corrected according to the line number of the first instruction code of the method, and the final method definition information is determined to obtain the method calling relationship and method definition information corresponding to at least two versions.

[0041] For example, get the APK file of an Android application, and use decompilation tools such as apktool and jadx to parse and convert the APK file into readable source code (Java or Kotlin) and resource files. Extract the .dex (DalvikExecutable) file from the APK, which is the executable bytecode file running on the Android platform. Use tools such as smali / baksmali to view and edit these bytecodes.

[0042] Use static analysis tools (such as ASM, Soot, WALA, etc.) to perform static analysis on .dex files or decompiled source code to extract method call relationships and the first instruction line number of the method.

[0043] Perform lexical analysis on the decompiled source code, use lexical analyzer generation tools such as ANTLR to identify keywords, identifiers, symbols, etc. in the source code, and build a token stream; based on the lexical analysis results, extract the initial method definition information such as method name, return type, parameter list, modifiers, etc.

[0044] The method first instruction line number information obtained from static analysis is matched and corrected with the initial method definition information obtained from lexical analysis. If the line number information in the source code is retained during the decompilation process, the final definition information of each method, including the accurate line number, is determined through the correction process.

[0045] In this embodiment, by repeating the above-mentioned static analysis, lexical analysis, information correction, etc. for each version, the method calling relationships and method definition information differences between different versions are compared to identify which methods are added, deleted or modified, thereby identifying changes in the code.

[0046] Step S220, performing a difference operation on the method call relationships corresponding to different versions to determine the method sets to be added or subtracted;

[0047] The difference operation is the difference between the method call relationships corresponding to at least two versions, that is, the difference between two sets.

[0048] Optionally, performing a difference operation on the method call relationships corresponding to different versions to determine the method set to be added or subtracted includes:

[0049] Taking at least one version as a historical version, performing a difference operation between a method call relationship corresponding to the historical version and a method call relationship corresponding to the latest version;

[0050] If the difference set includes more method call relationships corresponding to the historical version than the method call relationships corresponding to the latest version, it is determined that the method call relationships corresponding to the latest version are reduced;

[0051] If the difference set includes fewer method call relationships corresponding to the historical version than the method call relationships corresponding to the latest version, determining that the method call relationships corresponding to the latest version are increased;

[0052] If the difference set includes a change in the method call relationship corresponding to the historical version relative to the method call relationship corresponding to the latest version, determining that the method call relationship corresponding to the latest version is modified;

[0053] Determine the method set to be added or subtracted based on at least one of reduction, addition or modification of the method call relationship corresponding to the latest version.

[0054] It should be noted that by taking the method calling relationship corresponding to the latest version as the comparison basis and comparing it with the method calling relationship corresponding to the historical version, the method calling relationship corresponding to the latest version is determined by the difference set to be at least one of reduction, increase or modification. In this way, the method set can be determined to be increased or decreased.

[0055] The reduced, added or modified method calls in the added and reduced method set are classified into different sets. For example, the method set with reduced method call relationship includes all methods that are removed or no longer called in the latest version. For another example, the method set with increased method call relationship includes all methods that are newly introduced or begin to be called in the latest version. For another example, the method set with modified method call relationship includes all methods whose parameters, return values ​​or calling order are changed in the latest version.

[0056] Through the above approach, the set of methods to be added or removed can be effectively determined, which helps to identify potential code degradation, functional deficiencies, or performance issues, and take corresponding remedial measures; and provides valuable reference information for subsequent code maintenance, optimization, and functional iteration.

[0057] Step S230, comparing the source codes corresponding to different versions to determine code change information, wherein the application carries the source code;

[0058] Optionally, source codes corresponding to different versions are compared to determine code change information, including:

[0059] Taking at least one version as a historical version, and performing a difference comparison between the source code corresponding to the historical version and the source code corresponding to the latest version;

[0060] If the comparison result includes that the source code corresponding to the historical version is more than the source code corresponding to the latest version, then determining that the source code corresponding to the latest version is reduced;

[0061] If the comparison result includes that the source code corresponding to the historical version is less than the source code corresponding to the latest version, then determining that the source code corresponding to the latest version is increased;

[0062] If the comparison result includes a change in the source code corresponding to the historical version relative to the source code corresponding to the latest version, determining the source code modification corresponding to the latest version;

[0063] The code change information is determined according to at least one of reduction, addition or modification of the source code corresponding to the latest version.

[0064] It should be noted that the source code of the selected historical version and the latest version is extracted, including but not limited to all code files, configuration files and resource files, etc. The source code of the historical version and the latest version is compared by using a difference comparison tool (such as Git's diff command) or a third-party source code comparison tool to generate a difference comparison result, showing which files are modified, which files are added or deleted, and which lines in each file are changed.

[0065] For example, if the comparison result shows that certain files or code segments exist in the historical version but are deleted or commented out in the latest version, it is determined that the corresponding source code in the latest version is reduced. If the comparison result shows that certain files or code segments are added or uncommented in the latest version but do not exist in the historical version, it is determined that the corresponding source code in the latest version is increased. If the comparison result shows that certain files or code segments are different between the two versions (neither completely deleted nor completely added), it is determined that the corresponding source code in the latest version is modified. In this way, the code change information is determined based on at least one of the reduction, increase or modification of the source code corresponding to the latest version.

[0066] According to the above code change information, the detailed information of the code change is sorted out, including but not limited to:

[0067] A list of deleted code segments or files and their locations; a list of added code segments or files and their locations; specific changes in the modified code segments, including the changed line numbers, code content before and after modification, etc.

[0068] Through the above methods, code change information can be effectively determined and provide valuable reference for subsequent code review, testing, deployment and maintenance.

[0069] Step S240, searching the method definition information corresponding to the latest version based on the code change information to determine a set of changed methods, wherein the one with the latest version number among at least two versions is the latest version;

[0070] Optionally, searching the method definition information corresponding to the latest version based on the code change information to determine the changed method set includes:

[0071] Based on the code change information, determine the change line number corresponding to the source file of the code change information in the method definition information, and determine the change method to which the change line number belongs, and determine a change method set by aggregating each corresponding change method.

[0072] Specifically, the code change information obtained through source code difference comparison includes but is not limited to the changed file name, the type of change (addition, deletion, modification), and the specific change content (possibly including line number). In the parsed code change information, the specific line number involved in each change is found, where the line number identifies the location in the source code where the change occurred.

[0073] For example, these changed line numbers are implemented in the corresponding method definition information, and at the same time, the source code is statically analyzed to identify the start and end positions of each method definition. For example, this can also be achieved by parsing the grammatical structure in the source code (such as using an abstract syntax tree AST), where the AST can represent the grammatical structure of the source code and allow the method definition and its boundaries to be accurately located.

[0074] For example, if the change line number is mapped to the method definition information, it is determined which methods have been changed; if a method definition information contains a change line number, then the method is determined to be a changed method. All determined changed methods are aggregated into a set, namely the changed method set, which contains all methods that have been changed in the latest version relative to the historical version.

[0075] Step S250: Determine a call link change set according to the changes in the method call relationship corresponding to the latest version of the increase / decrease method set and the change method set identifier.

[0076] Optionally, determining a call link change set according to the changes in the method call relationship corresponding to the latest version of the addition and subtraction method set and the change method set identifier includes:

[0077] The changed parts in the method call relationship corresponding to the latest version are identified by the increase and decrease method set of the method call relationship; at the same time, the changed parts in the method call relationship corresponding to the latest version are identified by the change method set of the source code; and the call link change set is determined by assembling the method call relationship corresponding to the identified latest version.

[0078] It should be noted that in the method call relationship diagram, find those methods that belong to the set of added and reduced methods and mark them as changed parts, including the added new method calls, the reduced methods that are no longer called, and the modified method calls.

[0079] Similarly, in the method call relationship graph, find those methods that belong to the set of changed methods and mark them as changed parts, including methods that have been changed at the source code level, regardless of whether these changes affect the call relationship.

[0080] The identification information obtained by adding or subtracting method sets and changing method sets is integrated. For the changed part in the same method call relationship, if it is identified by two sets at the same time, this identification is retained; if it is only identified by one set, this identification is also retained.

[0081] In the method call relationship diagram that integrates the identification information, find all the method call links that contain the changed parts, which represent the path starting from the changed method, through a series of method calls, and finally reaching other methods or systems. Organize these call links into a set, namely the call link change set, which contains all the call links that have changed in the latest version relative to the historical version.

[0082] Through the above method, for each link in the call link change set, it is helpful to analyze the cause of the change, the scope of impact, and the possible problems introduced. This helps to ensure the accuracy and security of code changes and promote communication and collaboration between teams. At the same time, by calling the link change set, it can provide valuable reference for subsequent code review, testing, deployment and maintenance.

[0083] See also Figure 4 , which is an extraction flow chart of a call link change analysis method provided by the present application, including:

[0084] The call chain extraction process is as follows:

[0085] A1 uses dex2jar to convert the APK format installation file of the Android application into a jar;

[0086] A2 uses java-cg to analyze the jar to obtain the method call relationship and the first instruction line number of each method; wherein the first instruction line number of the method includes the method name and the first instruction line number in a preset format; the initial method definition information includes the method name, the start line and the end line in a non-preset format;

[0087] A3 stores method call relationships.

[0088] In some embodiments, obtaining an installation package file of an application, and performing static code analysis on the installation package file to obtain a method call relationship and a method first instruction code line number of the application includes:

[0089] If the application is an Android application, convert the installation package file of the Android application into a compressed file in JAR format;

[0090] Static code analysis is performed on the compressed file to extract the call chain to obtain the method call relationship of the application program, and the mapping relationship between the source code and the bytecode is extracted to obtain the line number of the first instruction code of the method of the application program.

[0091] It should be noted that dex2jar is an open source tool for converting DEX files into JAR files, which is beneficial for subsequent static code analysis. The dex2jar command line tool is used to convert classes.dex (or other DEX files) into JAR files. When using static analysis tools (such as ASM, Javaparser, ProGuard, etc.) to analyze JAR files, extract the calling relationship between methods. For example, if the APK file contains source code mapping information (for example, a mapping file generated by ProGuard), the method calls in the bytecode are mapped back to the method calls in the source code according to the source code mapping information. If the APK file does not contain source code mapping information, reverse engineering is used to determine the mapping relationship between the source code and the bytecode.

[0092] In addition, during the static analysis process, extracting the first instruction line number of each method also involves parsing the line number table information in the bytecode.

[0093] in, Figure 4 The extraction process of method definition information is as follows:

[0094] B1 uses ANTLR to perform lexical analysis on the Java and Kotlin source codes of Android applications to obtain method definition information;

[0095] B2 combines the method's first instruction code line number with A2's method's first instruction code line number and corrects the method definition information according to the method's starting line number interval;

[0096] B3 stores method definition information.

[0097] Among them, the FQN and non-FQN formats of the method name are distinguished. The FQN format is used as the unique signature to distinguish the method, such as,

[0098] com.xxx.baselibrary.monitor.BaseMonitor.addDataRecord(android.content.Context,java.lang.String,java.lang.String,java.util.Map)

[0099] The non-FQN is a partial name of the method:

[0100] com.xxx.baselibrary.monitor.BaseMonitor.addDataRecord

[0101] In some embodiments, the initial method definition information is corrected according to the line number of the first instruction code of the method to determine the final method definition information, including:

[0102] Determine a starting row number interval according to the starting row and the ending row in the initial method definition information;

[0103] The method name in the non-preset format is corrected in combination with the method name in the preset format, the first instruction code line number and the starting line number interval to determine the final method definition information.

[0104] Specifically, the starting line number and the ending line number of each method are extracted from the initial method definition information. Using the extracted starting line number and the ending line number, a starting line number interval is defined for each method, and the starting line number interval represents the location range of the method definition in the source code.

[0105] For example, the method name is corrected by the preset format method name and the first instruction code line number, the starting line number range in the method definition information and the non-preset format method name, and the preset format method name, source file, start line and end line in the final method definition information are determined.

[0106] In some embodiments, performing lexical analysis on the source code to obtain initial method definition information includes:

[0107] If the application is an Android application, obtaining a first source code in a JAVA format and a second source code in a Kotlin format corresponding to the Android application;

[0108] Creating a lexical analyzer to analyze the first source code and the second source code to determine a word set;

[0109] The word set is subjected to grammatical analysis and semantic analysis in sequence to obtain initial method definition information.

[0110] It should be understood that the first source code is the Java source code of the Android application, which will exist in the form of a .java file, and the second source code is the part written in Kotlin, and the source code will exist in the form of a .kt file.

[0111] Specifically, create lexical analyzers for Java and Kotlin respectively to identify keywords, identifiers, operators, separators, etc. in the two languages. Use the lexical analyzer to scan the Java and Kotlin source codes, extract all the words, and form a word set.

[0112] Create syntax analyzers for Java and Kotlin respectively, parse the syntax of the two languages, and generate corresponding syntax trees. Create semantic analyzers for Java and Kotlin respectively, process the semantic rules of the two languages, and extract method definition information from the syntax tree through semantic analysis. This includes method name, parameter type, return type, modifiers, etc., to obtain the initial method definition information.

[0113] Through the above method, the method definition information extracted from the Java and Kotlin source codes is integrated to form a unified method definition information set; at the same time, the extracted method definition information is verified and cleaned to ensure the accuracy and consistency of the initial method definition information obtained.

[0114] See Figure 3 As shown, it is a processing structure diagram of a call link change analysis device provided by the present application, including:

[0115] Soot converts bytecode and source code into intermediate code, and then performs analysis, optimization, and marking. As a general tool, Soot provides many functions. The output control flow graph can track the calling relationship between methods, but it cannot identify changes in the method call chain between different versions of the application.

[0116] For example, in Java, javac is used to compile the source code and run the java command; in Scala, scalac is used to compile and directly run the scala command. Among them, the class file is generated by compilation. The class file is a set of binary byte streams based on 8 bytes, forming a Classfile file structure.

[0117] Among them, java source (source code) is parsed and annotated using jast add parser, and combined with Classfile to obtain produce Jimple3-address IR, which is then generated into gernerate bytecode through Analyze, optimize, and tag (analysis, optimization and tag);

[0118] Specifically, Soot is used to convert Java bytecode into Jimple, and then the Jimple code is analyzed, optimized or converted, and finally the converted Jimple code is converted back to Java bytecode.

[0119] For another example, the bytecode is converted into Optimized / transformed class files+(attributes), and then output as a Java Virtual Machine.

[0120] See also Figure 5 , which is a call chain generation flow chart of a call chain change analysis method provided by the present application, wherein a change analysis is performed on version v1 and version v2 of the application, including:

[0121] Use the application of v1 to perform steps A and B to obtain the method call relationship v1 and method definition information v1;

[0122] Use the application of v2 to perform steps A and B to obtain the method call relationship v2 and method definition information v2;

[0123] Perform a difference set operation between the method call relationship v2 and the method call relationship v1 to identify the method calls that are added and reduced on the call chain v2;

[0124] Perform code-diff operation on code v1 and code v2 to obtain code change information [source file, changed line number];

[0125] Use the code change information to find the method whose call chain v2 is changed in the method definition information v2.

[0126] Through the above method, we can detect the addition, reduction and modification of methods on the call chain between different versions of code, obtain the method call relationship by analyzing the Android bytecode, and perform static analysis on the application source code to obtain method definition information. Based on the collected information, combined with the code-diff change points of the previous and next versions of the code, we can identify the call chain with changes.

[0127] In this embodiment, compared with the control flow graph (CFG) provided by general code static analysis tools, the present application identifies the changes in methods between versions based on the control flow graph provided, allowing application developers / tester personnel to analyze the method call links that have changed in application iterations, that is, identifying the changes in methods between versions based on the provided control flow graph, which is beneficial for developers or testers to understand the differences between application versions more systematically, thereby more effectively maintaining and upgrading the software.

[0128] See also Figure 6 , is a structural block diagram of a call link change analysis device 600 provided by the present application, including:

[0129] An acquisition module 601 is used to acquire method call relationships and method definition information corresponding to at least two versions of application programs;

[0130] A difference set operation module 602 is used to perform a difference set operation on the method call relationships corresponding to different versions to determine the method sets to be added or reduced;

[0131] A difference comparison module 603 is used to compare the source codes corresponding to different versions to determine code change information, wherein the application program carries the source codes;

[0132] A code change determination module 604 searches the method definition information corresponding to the latest version based on the code change information to determine a set of changed methods, wherein the version with the latest version number among at least two versions is the latest version;

[0133] The link change determination module 605 is used to determine the call link change set according to the changes in the method call relationship corresponding to the latest version of the increase and decrease method set and the change method set identifier.

[0134] It should also be noted that there is a one-to-one correspondence between the calling link change analysis method and the calling link change analysis device. Here, the technical details and technical effects involved in the calling link change analysis device are the same as the above-mentioned identification method, which will not be described one by one here. Please refer to the above-mentioned calling link change analysis method.

[0135] The present application obtains method call relationships and method definition information corresponding to at least two versions of an application program; performs a difference set operation on the method call relationships corresponding to different versions to determine a set of added and reduced methods, and accurately identifies the added and reduced parts through the set of added and reduced methods, which helps to understand the functional changes between versions; performs a difference comparison on the source codes corresponding to different versions to determine the code change information, so that the specific change information of the code can be identified; based on the code change information, a search is performed in the method definition information corresponding to the latest version to determine the changed method set, and by accurately locating the specific method that has changed, blind searches are avoided and development efficiency is improved; changes in the method call relationship corresponding to the latest version are identified according to the set of added and reduced methods and the set of changed methods, and a call link change set is determined, so that the changes in the methods between versions are identified based on the provided control flow graph, which is conducive to developers or testers to understand the differences between application versions more systematically, thereby more effectively maintaining and upgrading the software.

[0136] Reference below Figure 7 , see Figure 7 , Figure 7 It is a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present application. It should be noted that: Figure 7 The electronic device 700 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0137] like Figure 7 As shown, electronic device 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage part 708 to the random access memory (RAM) 603, such as the method in the above embodiment. In RAM 603, various programs and data required for system operation are also stored. CPU 601, ROM 602 and RAM 603 are connected to each other through bus 604. Input / output (I / O) interface 605 is also connected to bus 604.

[0138] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed so that a computer program read therefrom is installed into the storage section 608 as needed.

[0139] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 609, and / or installed from a removable medium 611. When the computer program is executed by a central processing unit (CPU) 601, various functions defined in the device of the present application are executed.

[0140] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above.

[0141] A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0142] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the apparatus, method and computer program product according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the above-mentioned module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based device that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0143] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not constitute limitations on the units themselves in some cases.

[0144] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor of a computer, the computer executes the call link change analysis method as described above. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.

[0145] The above embodiments are merely illustrative of the principles and effects of the present application and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.

Claims

1. A call link change analysis method, characterized in that: include: Obtain method call relationships and method definition information corresponding to at least two versions of the application program; Perform a difference operation on the method call relationships corresponding to different versions to determine the method sets to be added or reduced; Comparing the source codes corresponding to different versions to determine code change information, wherein the application carries the source codes; Based on the code change information, searching the method definition information corresponding to the latest version to determine a set of changed methods, wherein the version with the latest version number among at least two versions is the latest version; A call link change set is determined according to the changes in the method call relationship corresponding to the latest version of the addition and subtraction method set and the change method set identifier.

2. The call link change analysis method according to claim 1, characterized in that: Obtain method call relationships and method definition information corresponding to at least two versions of the application, including: Obtaining an installation package file of the application, and performing static code analysis on the installation package file to obtain a method calling relationship and a method first instruction code line number of the application; Performing lexical analysis on the source code to obtain initial method definition information; The initial method definition information is corrected according to the line number of the first instruction code of the method, and the final method definition information is determined to obtain the method calling relationship and method definition information corresponding to at least two versions.

3. The call link change analysis method according to claim 2, characterized in that: The method first instruction code line number includes a method name and a first instruction code line number in a preset format; the initial method definition information includes a method name, a start line and an end line in a non-preset format; Correcting the initial method definition information according to the line number of the first instruction code of the method to determine the final method definition information includes: Determine a starting row number interval according to the starting row and the ending row in the initial method definition information; The method name in the non-preset format is corrected in combination with the method name in the preset format, the first instruction code line number and the starting line number interval to determine the final method definition information.

4. The call link change analysis method according to claim 2, characterized in that: Obtain the installation package file of the application, and perform static code analysis on the installation package file to obtain the method call relationship and the first instruction code line number of the method of the application, including: If the application is an Android application, convert the installation package file of the Android application into a compressed file in JAR format; Static code analysis is performed on the compressed file to extract the call chain to obtain the method call relationship of the application program, and the mapping relationship between the source code and the bytecode is extracted to obtain the line number of the first instruction code of the method of the application program.

5. The call link change analysis method according to claim 2, characterized in that: Perform lexical analysis on the source code to obtain initial method definition information, including: If the application is an Android application, obtaining a first source code in a JAVA format and a second source code in a Kotlin format corresponding to the Android application; Creating a lexical analyzer to analyze the first source code and the second source code to determine a word set; The word set is subjected to grammatical analysis and semantic analysis in sequence to obtain initial method definition information.

6. The call link change analysis method according to claim 1, characterized in that: Perform a difference operation on the method call relationships corresponding to different versions to determine the method sets to be added or subtracted, including: Taking at least one version as a historical version, performing a difference operation between a method call relationship corresponding to the historical version and a method call relationship corresponding to the latest version; If the difference set includes more method call relationships corresponding to the historical version than the method call relationships corresponding to the latest version, it is determined that the method call relationships corresponding to the latest version are reduced; If the difference set includes fewer method call relationships corresponding to the historical version than the method call relationships corresponding to the latest version, determining that the method call relationships corresponding to the latest version are increased; If the difference set includes a change in the method call relationship corresponding to the historical version relative to the method call relationship corresponding to the latest version, determining that the method call relationship corresponding to the latest version is modified; Determine the method set to be added or subtracted based on at least one of reduction, addition or modification of the method call relationship corresponding to the latest version.

7. The call link change analysis method according to claim 1, characterized in that: Compare the source codes of different versions to determine the code change information, including: Taking at least one version as a historical version, and performing a difference comparison between the source code corresponding to the historical version and the source code corresponding to the latest version; If the comparison result includes that the source code corresponding to the historical version is more than the source code corresponding to the latest version, then determining that the source code corresponding to the latest version is reduced; If the comparison result includes that the source code corresponding to the historical version is less than the source code corresponding to the latest version, then determining that the source code corresponding to the latest version is increased; If the comparison result includes a change in the source code corresponding to the historical version relative to the source code corresponding to the latest version, determining the source code modification corresponding to the latest version; The code change information is determined according to at least one of reduction, addition or modification of the source code corresponding to the latest version.

8. The call link change analysis method according to claim 1, characterized in that: Retrieving the method definition information corresponding to the latest version based on the code change information to determine a set of changed methods includes: Based on the code change information, determine the change line number corresponding to the source file of the code change information in the method definition information, and determine the change method to which the change line number belongs, and determine a change method set by aggregating each corresponding change method.

9. The call link change analysis method according to claim 1, characterized in that: Determining a call link change set according to the changes in the method call relationship corresponding to the latest version of the increase / decrease method set and the change method set identifier includes: The changed parts in the method call relationship corresponding to the latest version are identified by the increase and decrease method set of the method call relationship; at the same time, the changed parts in the method call relationship corresponding to the latest version are identified by the change method set of the source code; and the call link change set is determined by assembling the method call relationship corresponding to the identified latest version.

10. A call link change analysis device, characterized in that: include: An acquisition module, used to acquire method call relations and method definition information corresponding to at least two versions of application programs; The difference set operation module is used to perform difference set operations on the method call relationships corresponding to different versions to determine the method sets to be added or subtracted; A difference comparison module, used to compare the source codes corresponding to different versions and determine code change information, wherein the application carries the source code; A code change determination module, which searches the method definition information corresponding to the latest version based on the code change information to determine a set of changed methods, wherein the version with the latest version number among at least two of the versions is the latest version; The link change determination module is used to determine the call link change set according to the changes in the method call relationship corresponding to the latest version of the increase and decrease method set and the change method set identifier.

11. An electronic device, characterized in that: include: one or more processing devices; A memory for storing one or more programs; When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the call link change analysis method described in any one of claims 1 to 9.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program is used to enable a computer to execute the call link change analysis method described in any one of claims 1 to 9.