Method and device for recovering missing software package of software project

Through program pruning and simulation building combined with software package filtering and priority enumeration strategies, the problem of inefficient build failure caused by missing software packages in C/C++ projects is solved, efficient missing software package recovery is achieved, the search space is narrowed and the search space is improved. improve construction efficiency.

CN118519670APending Publication Date: 2024-08-20XIAMEN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410678745.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-29
Publication Date
2024-08-20

AI Technical Summary

Technical Problem

When existing technology solves the problem of build failure caused by missing software packages in C/C++ projects, there are problems with inefficient iterative construction and redundant search spaces, making it difficult to automatically restore missing software packages.

Method used

Reduce build overhead and simulate missing dependency files in virtual builds through program pruning and simulated build strategies. Combined with package filtering and priority enumeration strategies, you can narrow the search space and generate installation scripts to restore missing packages.

Benefits of technology

It accelerates the extraction of missing dependency files in one build, reduces the search space, improves the efficiency of installation script synthesis, significantly reduces build time and redundant enumeration, and improves the efficiency of automatically recovering missing software packages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118519670A_ABST
    Figure CN118519670A_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for recovering a missing software package of a software project, and the method comprises the steps: promoting one-time successful construction through employing a program trimming and file simulation technology, so as to collect all missing files which reveal the root cause of an error of the missing software package; checking whether a def-use relationship exists between symbols defined in the software package and symbols used in the software project or not so as to effectively filter out irrelevant software packages; a software package set covering missing files is enumerated, a priority enumeration strategy is introduced, the number of the covered missing files is maximized during software package selection, and an installation script is synthesized. According to the method, the required software package is enumerated in the trimmed search space with extremely little redundancy, so that the efficiency of synthesizing the installation script is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software engineering, and in particular to a method and device for recovering a missing software package of a software project. Background Art

[0002] The reproducibility of software artifacts is crucial for software development and application. However, current research shows that a considerable number of C / C++ projects have irreproducible problems, mainly due to the lack of necessary software packages that lead to build failures.

[0003] The prevalence of missing package errors in C / C++ projects is largely attributed to the lack of a unified approach to managing package dependencies. Users adopt various approaches to manage package dependencies, including project documentation (e.g., readme.md), various package installation scripts (e.g., install.sh and prerequisite.sh), and some package management tools (e.g., vcpkg and conan). Due to the lack of a widely used package management standard, developers often forget to specify the required packages, which easily leads to failures when building in a new environment. When encountering missing package errors, users have to exhaustively search for the missing dependent packages based on the error message, or report the error to seek guidance from the developer, which usually requires laborious manual work when building real projects. In this work, we focus on automatically recovering missing packages for a given C / C++ project.

[0004] Solving the problem of missing package recovery is a challenging task. On the one hand, extracting the required dependencies by statically analyzing the build script is a possible solution. However, due to the complexity and diversity of the build command syntax, it is impossible to implement an all-powerful parser to accurately and completely extract dependencies from the build command, which hinders the complete retrieval of the required packages. On the other hand, dynamically capturing dependencies by monitoring the build process is another possible solution. However, when a failure caused by a missing package is encountered, the build process must be paused and can only be resumed after the necessary packages are successfully identified and installed, which is similar to a manual trial process. Therefore, this approach requires repeated and iterative builds, which is time-consuming and leads to efficiency issues. In addition, both techniques extract dependencies at the file level, so the required packages must be inferred by searching from large package repositories (e.g., there are 66,475 packages in the Ubuntu 22.04 repository).

[0005] In summary, the key to automatically recovering missing packages is to identify all the dependent packages required during the build process. Although great research progress has been made in extracting dependencies for C / C++ projects, existing methods are still insufficient in resolving build failures and recovering missing packages. Summary of the invention

[0006] In view of the technical problems mentioned above, the purpose of the embodiments of the present application is to propose a method and device for recovering missing software packages of a software project, which can hit the required software packages with very little redundant enumeration in a pruned search space, thereby improving the efficiency of installation script synthesis.

[0007] The technical solution of the present invention is as follows.

[0008] In one aspect, a method for recovering a missing software package of a software project comprises:

[0009] In the missing file detection step, the software project is pruned to obtain a pruned project; a target set in the pruned project is obtained; when each target in the target set is built, a simulation build strategy is adopted to continue the build in the absence of necessary files, and a mapping is obtained that associates the target with the missing file set;

[0010] The software package filtering step obtains the software package installation strategy, checks whether there is a def-use relationship between the symbols defined in the software package in the software package installation strategy and the symbols used in the software project based on the mapping that associates the target with the missing file set, filters out irrelevant software packages, and obtains a mapping that associates the missing files with the software package set;

[0011] The software package preferential enumeration step enumerates the software package set that covers the missing files based on the mapping that associates the missing files with the software package set, maximizes the number of missing files covered during software package selection based on the priority enumeration strategy, and synthesizes an installation script.

[0012] Preferably, the program pruning specifically includes:

[0013] Remove non-main functions from the software project and remove all statements from the body of each main function, but keep all preprocessor directives in the software project.

[0014] Preferably, the simulation construction strategy specifically includes:

[0015] When building each target t in the target set, the file IO operations are dynamically monitored and empty files are created to simulate files that need to be accessed but are missing;

[0016] Use the mockBuild function to develop a simulated build process. After the simulated build, establish a mapping that associates the target with the missing file set.

[0017] Preferably, the software package filtering step specifically includes:

[0018] When processing each missing file, all packages that provide files with the same name as the missing file are retrieved based on the mapping that associates the target with the set of missing files;

[0019] Based on the file I / O information during the simulation build, all the source code / header files accessed in the software project are collected, and the symbols used in all the accessed files are extracted through parsing-based static analysis to form a collection Suse;

[0020] For each package pkg with the same name as the missing file, extract all symbols defined in each package based on the static analysis of the parsing to form a set Sdef; when Suse and Sdef have an intersection, take the corresponding package pkg as a potential missing package;

[0021] The above steps are repeated until all potential missing software packages of the missing files are obtained, and a mapping from the missing files to the software package set is obtained. The mapping establishes a search space for a set of missing software packages.

[0022] Preferably, the software package preferably enumerates the steps, specifically including:

[0023] Based on the mapping from missing files to package sets, it is determined whether a missing file is provided by a unique package. If so, the unique package that provides the missing file is identified and installed in the installation script; otherwise, if a package can provide multiple of the remaining missing files, based on the priority enumeration strategy, the number of missing files covered is maximized during package selection, and the package is installed in the installation script.

[0024] Preferably, the priority enumeration strategy includes:

[0025] Based on the mapping from missing files to software package sets, all possible software package selections that can cover all files in the remaining missing files are generated to form a software package set Γ;

[0026] The set of packages in Γ is enumerated according to the number of missing files covered by each package in the package set, as follows:

[0027] The installation script is synthesized based on the software package installation strategy, and the software project is built to determine whether the installation script successfully solves the missing software package; if the build is successful, the installation script is returned as a feasible solution; otherwise, other software package sets in Γ are continuously checked until the build is successful.

[0028] On the other hand, a device for recovering a missing software package of a software project comprises:

[0029] A missing file detection module is used to perform program pruning on a software project to obtain a pruned project; obtain a target set in the pruned project; when building each target in the target set, a simulation build strategy is adopted to continue building in the absence of necessary files, and obtain a mapping that associates the target with the missing file set;

[0030] A software package filtering module is used to obtain a software package installation strategy, based on a mapping that associates a target with a missing file set, check whether there is a def-use relationship between symbols defined in the software package in the software package installation strategy and symbols used in the software project, filter out irrelevant software packages, and obtain a mapping that associates missing files with the software package set;

[0031] The software package preferential enumeration module is used to enumerate the software package set covering the missing files based on the mapping associated with the missing files and the software package set, maximize the number of missing files covered when selecting the software package based on the priority enumeration strategy, and synthesize an installation script.

[0032] Compared with the prior art, the present invention has the following beneficial effects:

[0033] (1) The present invention does not use an actual build involving an iterative suspension and resumption process, but instead designs a "simulated build" to accelerate the extraction of missing dependency files, which includes pruning the program in one build while retaining the original dependency relationship. On the basis of the virtual build, the missing dependency files are simulated so that the build can continue without installing the required software packages. Since the virtual build only retains preprocessing instructions but does not include other program constructs such as function bodies and global variables, the simulation file does not need to provide declarations or definitions for any symbols (including variables and functions). Therefore, the empty simulation file can ensure the successful completion of the build process.

[0034] (2) In order to reduce the search space for inferring required software packages from files, the present invention proposes a two-stage analysis, including software package filtering and priority determination, to simplify the inference process of required software packages. Since the required software packages should contain missing dependent files and symbols, in the software package filtering stage, the missing files identified in the simulation build process are used to determine a set of candidate software packages containing these files. At the same time, the symbols used in the project code are compared with the symbols defined in the missing files provided by the candidate software packages to filter out irrelevant software packages. In the software package priority determination stage, higher priorities are assigned to software packages that cover more missing files, and a set of software packages containing all missing files is selected based on these priorities, and a greedy strategy is used to find a set of software packages to solve the missing software package error with minimal redundant enumeration. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0036] Figure 1 A schematic diagram of a formal description of the program syntax of an embodiment of the present invention;

[0037] Figure 2 This is a motivation example diagram of restoring a missing software package according to an embodiment of the present invention;

[0038] Figure 3 A brief flowchart of a method for recovering a software project missing software package according to an embodiment of the present invention;

[0039] Figure 4 A detailed flow chart of a method for recovering a software project missing software package according to an embodiment of the present invention;

[0040] Figure 5 This is a diagram of a missing file detection algorithm according to an embodiment of the present invention;

[0041] Figure 6 It is a filtering software package algorithm diagram of an embodiment of the present invention;

[0042] Figure 7 This is an example diagram of software package filtering according to an embodiment of the present invention;

[0043] Figure 8 An algorithm diagram of synthesizing installation scripts by software package priority enumeration according to an embodiment of the present invention;

[0044] Fig. 9 This is an example diagram of synthesizing installation scripts by prioritizing enumeration of software packages according to an embodiment of the present invention;

[0045] Fig.10 Schematic diagram of experimental results of PackHunter and baseline of an embodiment of the present invention;

[0046] Fig.11 The present invention is a structural block diagram of a device for recovering a software package with missing software items according to an embodiment of the present invention. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] Taking a C / C++ software project as an example, the problem is first formally described, including a formal description of program syntax, a formal statement of missing software package errors and software package recovery problems; then a method for recovering missing software packages in a software project of the present invention is described in detail.

[0049] Specifically, Figure 1 The grammar shown in the formal description of C / C++ projects. A project consists of header files, source files, and build scripts. Specifically, both header files and source files may contain various preprocessing directives, including those involving specific header file inclusions and macro definitions. Function signatures and definitions appear in header files and source files, respectively. It is worth noting that the function body can be empty or consist of multiple statements, such as assignments and function calls. Without loss of generality, it is assumed that each function defined in a source file is declared in the corresponding header file. Finally, a build script is a set of build target dependencies, each dependency is associated with a set of instructions (recipes).

[0050] Formally, the missing package error is stated as follows.

[0051] Definition 1. (Missing Package Error) Let P be a C / C++ project. In P, a missing package error is the absence of a specific package that is required for a specific target t to be successfully built in P.

[0052] Basically, missing package errors manifest as missing preprocessor directives, functions, and files that should be provided by the missing package. When the build process generates missing package errors, its error message can indicate the root cause and guide the developer to locate the missing package for repair.

[0053] See also Figure 2 As shown in the example, an error is encountered when building the target guetzli, indicating that the file png.h is not found. Therefore, source files that include png.h as a header file, such as guetzli.cc, cannot use the symbols defined in this file. For example, the call to the function png_jmpbuf on line 61 of the source file guetzli.cc becomes invalid. The absence of the package that provides png.h results in a missing package error.

[0054] Figure 2In , the root cause of missing package errors is the missing of specific files. Specifically, symbols defined in the missing files, such as preprocessor directives and functions, are inaccessible to the current C / C++ project. Existing studies have shown that missing package errors are prevalent in real C / C++ projects. Specifically, more than 50% of C / C++ project build failures are caused by missing packages. The difficulty in identifying and installing missing packages is a significant obstacle for programmers who want to create executable artifacts of their own systems.

[0055] In order to reduce the burden of programmers when building C / C++ projects, the present invention studies the problem of automatically restoring missing software packages. First, two important preliminary knowledge, namely, software package installation strategy and installation script, are introduced as follows.

[0056] Definition 2. (Package Installation Policy) A package installation policy I is a function that maps packages to their installation commands. In particular, dom(I) is called a package base, which represents a finite set of packages that may be used.

[0057] The package installation strategy I defined in Definition 2 is responsible for taking a limited set of packages as the package base (i.e., dom(I)) and providing guidance for their installation. For example, one can focus on packages maintained by the Linux package manager because the installation commands for these packages are easily accessible. With the guidance of the package installation strategy, the programmer can locate the missing packages and install them by executing the corresponding installation commands. Fundamentally, the programmer needs to specify an installation script, as defined below, to restore the missing packages.

[0058] Definition 3. (Installation script) For a C / C++ project P, an installation script fps is a series of commands to install the software package. After executing fps, P can be successfully built.

[0059] consider Figure 2 The installation script should contain the installation command for the package libpng-dev. After running the installation script, the missing package, libpng-dev, can provide the missing file png.h, thus resolving the missing package error in the project.

[0060] As mentioned earlier, manually specifying installation scripts can be a time-consuming and laborious task, especially when dealing with a large package repository and multiple missing packages. Solving the missing package recovery problem is not a simple task. The challenges mainly come from two aspects. First, extracting dependency files by monitoring the repeated and iterative build process, that is, pausing the build when the build fails and resuming the build after trying to install the package, is a time-consuming task that raises efficiency concerns. Second, inferring missing packages from dependency files requires searching from a huge package repository, and the large space of candidate packages will exacerbate efficiency issues.

[0061] In order to solve the above problems, the present invention formalizes the missing software package recovery problem and proposes an effective and efficient solution, which will greatly reduce the burden of developers engaged in C / C++ projects when facing missing software packages.

[0062] See also Figure 3 and Figure 4 As shown, the present invention provides a method for recovering a missing software package of a software project, comprising:

[0063] S301, missing file detection step, performs program pruning on the software project to obtain a pruned project; obtains a target set in the pruned project; when building each target in the target set, adopts a simulation build strategy, continues to build in the absence of necessary files, and obtains a mapping that associates the target with the missing file set.

[0064] Specifically, detecting missing files requires dynamically monitoring the build project so that file I / O information can be collected. However, a single build process can result in considerable overhead, especially considering the need to repeatedly try different software packages and rebuild the project. In order to achieve efficient missing file detection, the present invention proposes two effective strategies, namely program pruning and simulation build, which aim to minimize the overhead associated with a single build and reduce the number of build iterations, respectively. These strategies are formally presented in Figure 5 In Algorithm 1.

[0065] Program pruning is explained as follows. Program pruning is performed to speed up a single build, which is presented in the form of the reduceProgram function in line 2 of Algorithm 1. It should be noted that the successful build of a target depends only on the existence of its main function, so non-main functions are removed from the project and all statements are removed from the body of each main function. In particular, all preprocessing directives are retained in the project. This program pruning does not change the file IO information during the build, while significantly reducing the build time. In this way, the detection of missing files can be accelerated by reducing the overhead of a single build.

[0066] The mock build is explained as follows. In order to avoid multiple iterations of the project build, a mock strategy is adopted to allow the build process to continue in the absence of necessary files. Specifically, when building each target t, the file IO operations are dynamically monitored, and empty files are created to simulate the files that need to be accessed but are missing. The mock build process is formulated by the mockBuild function in line 6 of Algorithm 1. After the mock build, a mapping from the build target to a set of missing files can be established, which is used to discover missing packages in subsequent stages.

[0067] It should be noted that a simulated build only needs to build the project once. Any build errors due to missing files will be skipped, avoiding the additional overhead caused by unnecessary project rebuilds. It is important to note that simply creating an empty file for the missing file is sufficient to ensure a successful build. By leveraging program pruning, all symbols imported from the package are effectively removed, resulting in the decoupling of the target project from the files in its dependent packages. Therefore, program pruning not only reduces the overhead associated with a single build, but also enables monitoring of file I / O information with just one round of simulated build.

[0068] exist Figure 1 In the simulation, the file png.h is missing in the build target guetzli. Based on the simulation build, we can monitor the access operations of the missing files and create corresponding empty files for png.h. In program pruning, the statements of non-main functions and main functions are removed, such as the statements in the file guetzli.cc. With the help of program pruning, the simulation build only needs to be performed once to successfully collect all missing files, such as the file png.h.

[0069] S302, software package filtering step, obtains the software package installation policy, based on the mapping that associates the target with the missing file set, checks whether there is a def-use relationship between the symbols defined in the software package in the software package installation policy and the symbols used in the software project, filters out irrelevant software packages, and obtains a mapping that associates the missing files with the software package set.

[0070] Although missing file detection can effectively identify all missing files in a project, it still needs to address the problem that a single missing file may be provided by multiple different packages. When synthesizing installation scripts, this phenomenon may significantly increase the search space. In order to filter out irrelevant packages, we rely on an important insight that symbol def-use relationships enable filtering out infeasible packages in a lightweight manner. Specifically, if a package pkg provides a missing file, but the file does not define any symbols that are used in the source / header files of the target C / C++ project, then the file provided by pkg can be decoupled from the project, indicating that pkg cannot support necessary components required by the build process.

[0071] Specifically, the present invention proposes a method for filtering irrelevant software packages, see Figure 6 As shown in Algorithm 2. Initially, it accepts three inputs: a C / C++ project P, a package installation strategy I, and a mapping M obtained from Algorithm 1 that associates targets with missing file sets. f . When processing each missing file f′, the getPotentialPkg function in line 4 retrieves all packages that provide files with the same name as f′. Based on the file I / O information during the simulated build, all accessed source code / header files in project P are collected in line 5, and the symbols used in all accessed files are extracted through parsing-based static analysis to form a set Suse (line 8). At the same time, we consider each package pkg that provides file f′ and collect all symbols defined in the corresponding file in a similar manner to form a set Sdef (line 11). The package pkg can only be considered for use in the C / C++ project if Suse and Sdef are not disjoint (lines 13–14). Finally, a mapping M from missing files to package sets is obtained p ,This mapping defines the search space for the installation script synthesis.,Due to the design of package filtering, infeasible packages can be safely,discarded, effectively reducing the search space for the synthesis,process.

[0072] Note that in line 5 of Algorithm 2, no additional simulation build is performed to obtain the source code / header files being accessed.

[0073] See also Figure 7 As shown in the figure, the missing file png.h in the project can be provided by multiple packages. By analyzing the contents of the provided png.h file and the accessed files in the C / C++ project, the png.h file in libpng-dev defines the symbols used in the project, such as the function png_jmpbuf. Therefore, the package libpng-dev is a potential missing package. The other packages do not provide any symbols used by the project. Therefore, the list of missing packages can be narrowed down for subsequent installation script synthesis.

[0074] S303, a software package preferential enumeration step, enumerates the software package set that covers the missing files based on the mapping that associates the missing files with the software package set, maximizes the number of missing files covered when selecting the software package based on the priority enumeration strategy, and synthesizes an installation script.

[0075] Based on the missing file detection step and the package filtering step, a search space of a set of missing packages can be established for the target C / C++ project. Essentially, a set of packages needs to be selected from the search space that can cover all the missing files identified during the simulation build process. In order to further accelerate the enumeration of missing packages, package prioritization during the enumeration process is proposed. First, if a missing file f′ is provided by a unique package pkg, we must install pkg in the installation script. Otherwise, the file f′ will still be missing after executing the installation script. Second, if a package can provide multiple missing files, it is likely required by the C / C++ project. Therefore, a priority enumeration is performed to verify whether the enumerated packages contribute to a successful build.

[0076] Figure 8 The algorithm for synthesizing installation scripts through package-first enumeration is formalized in Algorithm 3 shown. First, identify the software package that can uniquely provide a specific missing file (lines 2-6). The remaining missing files, represented by the set Sf in line 6, can be covered by multiple software packages. Therefore, the getCoverPkgSet function is used to generate all possible software package selections that can cover all files in Sf and form a set Γ (line 8). Then, the software package sets in Γ are enumerated according to the number of missing files covered by the software packages in each software package set (lines 9-14). Specifically, the installation script fps is synthesized based on the software package installation strategy I (line 12), and the target C / C++ project P is built to determine whether the installation script fps successfully solves the missing software package. If the build is successful, fps is directly returned as a feasible solution to the problem. Otherwise, continue to check other software package sets in Γ until the build is successful. To ensure the integrity of subsequent iterations, if the installation script fails to support a successful build, the newly installed software package will be uninstalled.

[0077] It should be noted that the build in line 13 represents the actual build, not the simulated build. In the simulated build mentioned in the missing file detection step, the project is simplified to only contain an empty main function body, and the available symbols that should be provided by the package cannot be verified. Considering the time overhead of performing an actual build, the package-prioritized enumeration in the package filtering step and in Algorithm 3 can significantly reduce the time cost of the synthetic installation script, because the required packages are more likely to be selected early in the enumeration process, and almost no redundant actual build is required.

[0078] See also Fig. 9As shown, the straight arrows represent the mapping from missing files to potential missing packages obtained in Algorithm 2. The missing file libfreetype.so is only provided by the package libfreetype-dev. Therefore, the installation script should contain the installation command for the package libfreetype-dev. At the same time, the missing files qtransform.h and qtwidgetsconfig.h can be provided by the package qtbase5-dev, so the priority of enumerating qtbase5-dev is higher than qt3d5-dev and qt6-base-dev. Therefore, two packages libfreetype-dev and qtbase5-dev are selected at the beginning of the priority enumeration. After verification by the actual build, an installation script was successfully synthesized, which installed libfreetype-dev and qtbase5-dev.

[0079] The performance of the PackHunter method of the present invention is compared with the existing CCScanner and TryInstall algorithms as follows. Fig.10 As shown in the PackHunter column, PackHunter successfully synthesized installation scripts for all C / C++ projects to restore missing packages. The time cost ranged from 3.79 seconds to 1,692.25 seconds, with an average time cost of 141.69 seconds. The ratio of the average time cost of PackHunter to the time cost of the actual build of the corresponding C / C++ project was only 6.78, indicating the low overhead of the method in helping the build process in actual situations. In particular, project mane has about 10MLoC, and its actual build cost is quite high, consuming a total of 767.50 seconds. To make matters worse, the number of missing packages in project mane reaches 15, which makes it very challenging to manually fix missing package errors. It is worth noting that, except for project mane, all projects can be processed within 13 minutes. The high efficiency proves the practical value of PackHunter in analyzing actual C / C++ projects, especially large-scale projects.

[0080] exist Fig.10The PackHunter subcolumn shows the time cost of each stage of PackHunter. First, the average time cost of missing file detection is 42.60 seconds, but the overhead may vary greatly between different projects. When a project contains more lines and build targets, missing file detection will take more time to process each file and build the target accordingly. However, the average value of the ratio of the time cost of missing file detection to the time cost of actual construction is only 0.57, indicating that the program pruning and virtual construction of the present invention can significantly reduce the overhead of missing file detection. Secondly, the average cost of software package filtering is only 3.43 seconds. The number of missing files in the project, the number of software packages that provide missing files, and the header files / source files accessed can affect the overhead of this stage because these files determine the scope of static analysis based on parsing. It is worth noting that for most projects, PackHunter can complete software package filtering in a few seconds. Third, the software package filtering and software package priority enumeration design of the present invention enable PackHunter to quickly find missing software packages.

[0081] See also Fig.11 As shown, the present invention also discloses a device for recovering a software project missing software package, comprising:

[0082] The missing file detection module 1101 is used to perform program pruning on the software project to obtain a pruned project; obtain a target set in the pruned project; when building each target in the target set, adopt a simulation build strategy to continue building in the absence of necessary files, and obtain a mapping that associates the target with the missing file set;

[0083] The software package filtering module 1102 is used to obtain the software package installation policy, and based on the mapping that associates the target with the missing file set, check whether there is a def-use relationship between the symbols defined in the software package in the software package installation policy and the symbols used in the software project, filter out irrelevant software packages, and obtain a mapping that associates the missing files with the software package set;

[0084] The software package preferred enumeration module 1103 is used to enumerate the software package set that covers the missing files based on the mapping between the missing files and the software package set, maximize the number of missing files covered when selecting the software package based on the priority enumeration strategy, and synthesize an installation script.

[0085] The specific implementation of a device for recovering a software project with missing software packages and a method for recovering a software project with missing software packages will not be described repeatedly in this embodiment.

[0086] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above invention concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.

Claims

1. A method for recovering a missing software package of a software project, characterized in that: include: In the missing file detection step, the software project is pruned to obtain a pruned project; a target set in the pruned project is obtained; when each target in the target set is built, a simulation build strategy is adopted to continue the build in the absence of necessary files, and a mapping is obtained that associates the target with the missing file set; The software package filtering step obtains the software package installation strategy, checks whether there is a def-use relationship between the symbols defined in the software package in the software package installation strategy and the symbols used in the software project based on the mapping that associates the target with the missing file set, filters out irrelevant software packages, and obtains a mapping that associates the missing files with the software package set; The software package preferential enumeration step enumerates the software package set that covers the missing files based on the mapping that associates the missing files with the software package set, maximizes the number of missing files covered during software package selection based on the priority enumeration strategy, and synthesizes an installation script.

2. The method for recovering a missing software package of a software project according to claim 1, characterized in that: The program pruning specifically includes: Remove non-main functions from the software project and remove all statements from the body of each main function, but keep all preprocessor directives in the software project.

3. The method for recovering a missing software package of a software project according to claim 1, characterized in that: The simulation construction strategy specifically includes: When building each target t in the target set, the file IO operations are dynamically monitored and empty files are created to simulate files that need to be accessed but are missing; Use the mockBuild function to develop a simulated build process. After the simulated build, establish a mapping that associates the target with the missing file set.

4. The method for recovering a missing software package of a software project according to claim 1, characterized in that: The software package filtering step specifically includes: When processing each missing file, all packages that provide files with the same name as the missing file are retrieved based on the mapping that associates the target with the set of missing files; Based on the file I / O information during the simulation build, all the accessed source code / header files in the software project are collected, and the symbols used in all the accessed files are extracted through parsing-based static analysis to form a set Suse; for each package pkg with the same name as the missing file, all the symbols defined in each package are extracted through parsing-based static analysis to form a set Sdef; when Suse and Sdef have an intersection, the corresponding package pkg is regarded as a potential missing package; The above steps are repeated until all potential missing software packages of the missing files are obtained, and a mapping from the missing files to the software package set is obtained. The mapping establishes a search space for a set of missing software packages.

5. The method for recovering a missing software package of a software project according to claim 1, characterized in that: The software package preferably enumerates steps, specifically including: Based on the mapping from missing files to package sets, it is determined whether a missing file is provided by a unique package. If so, the unique package that provides the missing file is identified and installed in the installation script; otherwise, if a package can provide multiple of the remaining missing files, based on the priority enumeration strategy, the number of missing files covered is maximized during package selection, and the package is installed in the installation script.

6. The method for recovering a missing software package of a software project according to claim 1, characterized in that: The priority enumeration strategy includes: Based on the mapping from missing files to software package sets, all possible software package selections that can cover all files in the remaining missing files are generated to form a software package set Γ; The set of packages in Γ is enumerated according to the number of missing files covered by each package in the package set, as follows: The installation script is synthesized based on the software package installation strategy, and the software project is built to determine whether the installation script successfully solves the missing software package; if the build is successful, the installation script is returned as a feasible solution; otherwise, other software package sets in Γ are continuously checked until the build is successful.

7. A device for recovering a missing software package of a software project, characterized in that: include: A missing file detection module is used to perform program pruning on a software project to obtain a pruned project; obtain a target set in the pruned project; when building each target in the target set, a simulation build strategy is adopted to continue building in the absence of necessary files, and obtain a mapping that associates the target with the missing file set; A software package filtering module is used to obtain a software package installation strategy, based on a mapping that associates a target with a missing file set, check whether there is a def-use relationship between symbols defined in the software package in the software package installation strategy and symbols used in the software project, filter out irrelevant software packages, and obtain a mapping that associates missing files with the software package set; The software package preferential enumeration module is used to enumerate the software package set covering the missing files based on the mapping associated with the missing files and the software package set, maximize the number of missing files covered when selecting the software package based on the priority enumeration strategy, and synthesize an installation script.