CN112698832A - Method, device and equipment for identifying code change influence range - Google Patents

Method, device and equipment for identifying code change influence range Download PDF

Info

Publication number
CN112698832A
CN112698832A CN202011606125.0A CN202011606125A CN112698832A CN 112698832 A CN112698832 A CN 112698832A CN 202011606125 A CN202011606125 A CN 202011606125A CN 112698832 A CN112698832 A CN 112698832A
Authority
CN
China
Prior art keywords
file
source code
memory address
compiling
change
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011606125.0A
Other languages
Chinese (zh)
Other versions
CN112698832B (en
Inventor
李志鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Neusoft Corp
Original Assignee
Neusoft Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Neusoft Corp filed Critical Neusoft Corp
Priority to CN202011606125.0A priority Critical patent/CN112698832B/en
Publication of CN112698832A publication Critical patent/CN112698832A/en
Application granted granted Critical
Publication of CN112698832B publication Critical patent/CN112698832B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/49Partial evaluation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/48Incremental compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses a method, a device and equipment for identifying a code change influence range, wherein a first compilation result file is generated by calling a source code file before compiling and changing an editing engineering file. And acquiring the source code file after the change to determine the target function with the code change. And acquiring a first memory address range occupied by the target function from the first editing result file. And modifying the memory address range occupied by the changed target function of the changed source code file during compiling, and adding a null function at the corresponding position of the target function of the changed source code file to generate a target source code file. And finally, calling the compiling engineering file to compile the target source code file to generate a second compiling result file. The code change influence range after the target function is changed can be accurately determined by comparing the first compilation result file with the second compilation result file, the change code influence range is convenient to confirm subsequently, the software development efficiency is improved, and the quality of developed software is ensured.

Description

Method, device and equipment for identifying code change influence range
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, and a device for identifying a code change influence range.
Background
In the process of software development, a developer needs to modify software codes according to the software development requirements. Part of the code may affect other code parts after being changed, and developers need to test the influence range of the code change to ensure the correctness of the code.
At present, the influence range of code change cannot be determined more accurately, and developers need to perform test validation on the whole code of the modified software code. This results in longer test time for software code and less efficient software development. If the developer performs test checking based on the inaccurate code change influence range, problems may also occur in the software code. Therefore, how to determine the more accurate code change influence range is an urgent problem to be solved.
Disclosure of Invention
In view of this, embodiments of the present application provide a method, an apparatus, and a device for identifying a code change influence range, which can accurately determine the code change influence range, so as to define a code test range, and improve software development efficiency and code quality.
In order to solve the above problem, the technical solution provided by the embodiment of the present application is as follows:
a method of identifying a code change scope of influence, the method comprising:
calling a compiling engineering file to compile a source code file before change to generate a first compiling result file, wherein the first compiling result file comprises a memory address range occupied by each function in the source code file before change and a free memory address range;
acquiring a source code file after change, determining that a target function with code change exists in the source code file after change, and acquiring a first memory address range occupied by the target function when the source code file before change is compiled from the first compilation result file;
modifying the changed source code file to change the memory address range occupied by the target function during compiling, and adding a null function at a position corresponding to the target function of the changed source code file to generate a target source code file, so that the target function occupies a second memory address range in the free memory address range when the target source code file is compiled, and the null function occupies the first memory address range;
calling the compiling engineering file to compile the target source code file to generate a second compiling result file;
and comparing the first compiling result file with the second compiling result file to determine the influence range of code change.
In one possible implementation, after determining the code change scope of influence, the method further includes:
restoring the target source code file into the changed source code file;
and calling the compiling engineering file to compile the changed source code file.
In one possible implementation, the method further includes:
determining whether the initial address of the memory address range occupied by the first target function is the initial address of the first memory address range in a third compilation result file generated when the compilation engineering file is called to compile the changed source code file;
if so, determining that the source code file is restored to be normal after the change.
In a possible implementation manner, the generating the target source code file by modifying the changed source code file to change the memory address range occupied by the target function during compiling and adding a null function to a position corresponding to the target function of the changed source code file includes:
adding a sector offset instruction for the target function in the changed source code file, wherein the sector offset instruction for the target function is used for indicating that the target function occupies a second memory address range in the free memory address range during compiling;
and determining the size of a null function according to the first memory address range, and adding the null function before or after the target function of the changed source code file to generate a target source code file.
In one possible implementation, the restoring the target source code file to the changed source code file includes:
and deleting the sector offset instruction of the target function and the null function in the target source code file, and restoring the changed source code file.
In a possible implementation manner, the comparing the first compilation result file and the second compilation result file to determine a code change influence scope includes:
and comparing the first compiling result file with the second compiling result file, and determining a part of the first compiling result file, which is different from the second compiling result file, as a code change influence range.
In one possible implementation, the method further includes:
and highlighting the code change influence range.
An apparatus for identifying a code change influence range, the apparatus comprising:
the system comprises a first compiling unit, a second compiling unit and a third compiling unit, wherein the first compiling unit is used for calling a compiling engineering file to compile a source code file before change to generate a first compiling result file, and the first compiling result file comprises a memory address range occupied by each function in the source code file before change and an idle memory address range;
a first determining unit, configured to obtain a source code file after change, determine that an object function with a code change exists in the source code file after change, and obtain, from the first compilation result file, a first memory address range occupied by the object function when the source code file before change is compiled;
a modifying unit, configured to modify the changed source code file to change a memory address range occupied by the target function during compilation, and add a null function to a position corresponding to the target function of the changed source code file, so as to generate a target source code file, where the target function occupies a second memory address range within the null memory address range when the target source code file is compiled, and the null function occupies the first memory address range;
the second compiling unit is used for calling the compiling engineering file to compile the target source code file to generate a second compiling result file;
and the comparison unit is used for comparing the first compilation result file with the second compilation result file and determining the influence range of code change.
An apparatus for identifying a code change influence range, comprising: the system comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein when the processor executes the computer program, the method for identifying the influence range of code change is realized.
A computer-readable storage medium having stored therein instructions which, when run on a terminal device, cause the terminal device to execute the above-described method of identifying a code change impact range.
Therefore, the embodiment of the application has the following beneficial effects:
according to the method, the device and the equipment for identifying the code change influence range, the editing engineering file is called to compile the source code file before change to generate the first compilation result file, and the memory address range occupied by each function in the source code file before change and the free memory address range can be determined through the first compilation result file. And then acquiring a source code file after the change, determining that a target function with code change exists in the source code file after the change, and acquiring a first memory address range occupied by the target function from the first editing result file. The first memory address range is the memory address range occupied by the target function prior to the code change. And modifying the memory address range occupied by the changed target function of the changed source code file during compiling, and adding a null function at the corresponding position of the target function of the changed source code file to generate a target source code file. Therefore, the empty function is used for occupying the first memory address range occupied by the target function before code change, and the memory address range occupied by the function after the target function in the source code file after change is not influenced by the change of the target function. And when the target source code file is compiled, the target function occupies a second memory address range in the free memory address range. The target function occupying the free memory address range after the memory address range is occupied is adjusted, the memory address range occupied by the function in the subsequent code during compiling is not influenced, and the range of influence on the code is reduced. And finally, calling the compiling engineering file to compile the target source code file to generate a second compiling result file. And determining the memory address range occupied by the target function after adjusting the memory address range occupied by the target function during compiling according to the second compiling result file. And comparing the first compiling result file with the second compiling result file to determine the code change influence range after the target function is changed. Therefore, the code change influence range can be accurately identified, the change code influence range is convenient to confirm subsequently, the software development efficiency is improved, and the quality of the developed software is ensured.
Drawings
Fig. 1 is a schematic diagram illustrating a memory address range occupied by a source code in a compiling process according to an embodiment of the present application;
FIG. 2 is a flowchart of a method for identifying a code change influence scope according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a CHK file provided by an embodiment of the present application;
fig. 4 is a schematic diagram illustrating a memory address range occupied by a target source code file in a compiling process according to an embodiment of the present application;
fig. 5 is a schematic diagram illustrating another source code occupying a memory address range in a compiling process according to an embodiment of the present application;
FIG. 6 is a flowchart of another method for identifying code change influence ranges according to an embodiment of the present application;
FIG. 7 is a diagram illustrating a modified source code file according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an apparatus for identifying a code change influence range according to an embodiment of the present application.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, embodiments accompanying the drawings are described in detail below.
In order to facilitate understanding and explaining the technical solutions provided by the embodiments of the present application, the following description will first describe the background art of the present application.
After studying on traditional code change, the inventor finds that instructions and data generated during compiling of the existing software code occupy memory addresses according to a compiling sequence. When part of functions in the software code are changed, the memory address range occupied by the changed functions during compiling changes, and the memory address range occupied by all subsequent functions during compiling is influenced. After the code is changed, a developer can confirm the influence range of the code change by checking the memory address range occupied during compiling so as to ensure the quality of the code. Since the changed functions cause the change of the memory address range occupied by all the subsequent functions during compiling, developers cannot accurately determine the real code change influence range.
Because the influence range of code change cannot be accurately determined at present, developers need to confirm a larger influence range, so that the test time is prolonged, and the software development efficiency is reduced. If the developer confirms based on the inaccurate code change influence range, part of the code change influence range may be omitted, so that the unchanged code has problems and the quality of the software code is affected.
Based on this, an embodiment of the present application provides a method for identifying a code change influence range, where an editing engineering file is called first to compile a source code file before change, so as to generate a first compilation result file, and a memory address range and a free memory address range occupied by each function in the source code file before change can be determined through the first compilation result file. And then acquiring a source code file after the change, determining that a target function with code change exists in the source code file after the change, and acquiring a first memory address range occupied by the target function from the first editing result file. The first memory address range is the memory address range occupied by the target function prior to the code change. And modifying the memory address range occupied by the changed target function of the changed source code file during compiling, and adding a null function at the corresponding position of the target function of the changed source code file to generate a target source code file. Therefore, the empty function is used for occupying the first memory address range occupied by the target function before code change, and the memory address range occupied by the function after the target function is not influenced by the change of the target function. And when the target source code file is compiled, the target function occupies a second memory address range in the free memory address range. The target function occupying the free memory address range after the memory address range is occupied is adjusted, the memory address range occupied by the function in the subsequent code is not influenced, and the range of influence on the code is reduced. And finally, calling the compiling engineering file to compile the target source code file to generate a second compiling result file. And determining the memory address range occupied by the target function after adjusting the memory address range occupied by the target function during compiling according to the second compiling result file. And comparing the first compiling result file with the second compiling result file to determine the code change influence range after the target function is changed. Therefore, the code change influence range can be accurately identified, the accurate change code influence range is convenient to confirm subsequently, and the accuracy of the software code and the software development efficiency are improved.
In order to facilitate understanding of the method for identifying the influence range of code change provided in the embodiment of the present application, the following description is made with reference to a scenario example shown in fig. 1. Referring to fig. 1, a schematic diagram of a source code occupying a memory address range in a compiling process according to an embodiment of the present application is shown.
In practical applications, the source code occupies a certain memory address range during the compiling process. The memory address range occupied by each function in the source code is determined in sequence according to the compiling sequence of each function in the source code compiling process. For example, as shown in the CODE area in fig. 1, the CODE area is a memory address area occupied by the source CODE during compiling. In addition, the memory address range also has a free area, and the free area is irrelevant to the CODE area, so that the memory address range occupied by the changed target function during compiling can be adjusted to the free area. In order to avoid that the target function influences the memory address range occupied by other functions after the change, the memory address range occupied by the target function is adjusted to the second memory address range of the idle area. And determining a first memory address range occupied by the target function before the change, and occupying the first memory address range by using the null function, so that the first memory address range of the target function after the modification also has a corresponding function, and the memory address range occupied by the subsequent function during compiling can not be influenced. And adjusting the memory address range occupied by the target function during compiling on the changed source code, and adding a null function at the corresponding position of the target function of the changed source code file to obtain the target source code file. By comparing a first compilation result file generated by compiling the source code file before the change by the compilation engineering file with a second compilation result file generated by compiling the target source code file by the compilation engineering file, the influence range of the code change caused by changing the target function can be determined.
Those skilled in the art will appreciate that the schematic diagram shown in fig. 1 is only one example in which embodiments of the present application may be implemented. The scope of applicability of the embodiments of the present application is not limited in any way by this framework.
In order to facilitate understanding of the present application, a method for implementing auxiliary lane change provided by the embodiments of the present application is described below with reference to the accompanying drawings.
Referring to fig. 2, which is a flowchart of a method for identifying a code change influence range according to an embodiment of the present application, as shown in fig. 2, the method may include S201 to S205:
s201: and calling a compiling engineering file to compile the source code file before change to generate a first compiling result file, wherein the first compiling result file comprises a memory address range occupied by each function in the source code file before change and a free memory address range.
The source code file before the change refers to a source code file before the present code change. The source code file can be compiled through the compiling engineering file, and corresponding instructions and data are generated in the process of calling the compiling engineering file to compile the source code file before change. The compiled instructions and data are stored in the memory and occupy certain memory addresses. In the embodiment of the present application, the Memory address may be an address in a ROM (Read-Only Memory) or a RAM (Random Access Memory).
It should be noted that the memory address range occupied when compiling the source code file is in the predetermined memory area. The memory address also has a free area, which is an unused memory area.
And in the compiling process, generating a corresponding first compiling result file, wherein the first compiling result file comprises instructions and data compiled by each function in the source code file before the change and a memory address range occupied by the instructions and the data. In one possible implementation, the first compilation result file may be a CHK format file or a MAP format file. Referring to fig. 3, the figure is a schematic diagram of a CHK file provided in an embodiment of the present application. The data in the solid line block represents a memory address, and the data in the dotted line block is instructions and data obtained after the code is compiled. And determining a memory address range and a free memory address range occupied by each function in the source code file before change during compiling according to the compiled first compilation result file.
S202: the method comprises the steps of obtaining a source code file after change, determining that an object function with code change exists in the source code file after change, and obtaining a first memory address range occupied by the object function when the source code file before change is compiled from a first compilation result file.
And acquiring a source code file after change, and determining a target function changed by the code change according to the source code file after change, wherein the target function can be one or more. The method for determining the objective function is not limited in the embodiments of the present application, and in a possible implementation manner, the source code file before the change and the source code file after the change may be compared to determine the objective function in which the code change occurs.
And determining a first memory address range occupied by compiling the target function before the target function is changed according to the first compiling result file.
It can be understood that, when the target function is changed, the instructions and data compiled and generated by the target function will change, and the corresponding occupied memory address range will change compared with the first memory address range, thereby affecting the memory address range occupied by the subsequently compiled function.
In the embodiment of the present application, a manner of changing the target function is not limited, and the target function may be modified, deleted, or added, and when the target function is a function newly added at the time of the code change of this time, a first memory address range of the target function obtained from the first compilation result file is empty.
S203: and modifying the memory address range occupied by the modified target function of the modified source code file during compiling, and adding a null function at the corresponding position of the target function of the modified source code file to generate the target source code file, so that the target function occupies a second memory address range in the free memory address range during compiling the target source code file, and the null function occupies a first memory address range.
Referring to fig. 4, this figure is a schematic diagram illustrating that a target source code file occupies a memory address range in a compiling process according to an embodiment of the present application. In order to avoid that the target function influences the memory address range occupied by the function compiled subsequently after being changed, the memory address range occupied by the target function of the source code file during compiling after being changed can be modified. And adjusting the memory address range occupied by the changed target function during compiling to a second memory address range in the free memory address range.
In a possible implementation manner, before modifying the memory address range occupied by the changed target function of the changed source code file during compiling, it is further required to determine that the free memory address is enough to be used.
It should be noted that, when the delete change operation is performed on the target function, the corresponding second memory address range may be empty.
After the memory address range occupied by the target function during compiling is adjusted, the memory address range originally occupied by the target function during compiling, namely the first memory address range, is vacant, and the memory address range occupied by the function subjected to subsequent compiling during compiling is influenced. Therefore, it is also necessary to add a null function to the target function corresponding position of the source code file after the change to generate the target source code file. Referring to fig. 5, a schematic diagram of another source code occupying a memory address range in a compiling process according to an embodiment of the present application is shown. The null function may be a function that does not affect the compilation result of the target source code file and that occupies the memory of the first memory address range when compiling. The null function may specifically be a Dummy function.
By adding the null function at the position corresponding to the target function of the changed source code file, the null function can be compiled when the target function is compiled, and the first memory address range is occupied. Therefore, the influence on the memory address range occupied by compiling other functions when compiling other functions is avoided, and the more accurate code change influence range can be conveniently obtained by subsequent identification.
S204: and calling the compiling engineering file to compile the target source code file to generate a second compiling result file.
The memory address range occupied by the target source code file during compiling is different from the memory address range occupied by the source code file before change during compiling. And calling the compiling engineering file to compile the target source code file to generate a corresponding second compiling result file. The second compiling result file has instructions and data generated by the target source code file during compiling and an occupied memory address range.
S205: and comparing the first compiling result file with the second compiling result file to determine the influence range of the code change.
And comparing the first compiling result file with the second compiling result file to obtain the code change influence range.
Specifically, comparing the first compilation result file with the second compilation result file to determine the influence range of the code change includes:
and comparing the first compiling result file with the second compiling result file, and determining the part of the first compiling result file, which is different from the second compiling result file, as the influence range of the code change.
The compiling result file comprises instructions and data generated by compiling the source code file and a memory address range occupied by the instructions and the data. The parts of the first compilation result file and the second compilation result file that have differences may be instructions and data that have differences and memory address ranges that have differences.
It will be appreciated that the occupation of the first memory address range is achieved by adding a null function at the location of the target function. However, the data obtained by the null function at the time of compilation is different from the instructions and data obtained by the target function before the change at the time of compilation, and when the first compilation result file is compared with the second compilation result file, the data difference stored in the first memory address range can be obtained. In addition, the instructions and data obtained by compiling the target function in the second memory address range are different from the non-data storage in the free memory address range obtained by compiling the source code file before the change, and the difference of the data stored in the second memory address range can be obtained.
In one possible implementation, the target data may be modified by deleting the target data, and the second memory address range is empty. Correspondingly, the part of the first compilation result file that is different from the part of the second compilation result file may be instructions and data in the first memory address range. In another possible implementation manner, the target data may be changed in an increasing manner, and the first memory address range is empty. Correspondingly, the part of the first compilation result file that is different from the part of the second compilation result file may be instructions and data in the second memory address range.
In one possible implementation, the method further includes:
the code change impact range is highlighted.
To facilitate the determination of the code change impact range, the code change impact range may be highlighted. For example, the code change influence range is displayed in different colors.
Based on the relevant contents of S201 to S205, it can be known that the memory address range occupied by the target function in the source code file before the change during compilation can be occupied by the empty function by modifying the memory address range occupied by the changed target function in the source code file after the change during compilation, and adding the empty function to the corresponding position of the target function in the source code file after the change, and the memory address range occupied by the target function in the source code file after the change during compilation can be adjusted to the free memory address range. Therefore, the influence on the memory address range occupied by compiling other functions is avoided, and the code change influence range is reduced, so that the accurate code change influence range is identified and obtained by comparing the first compiling result file with the second compiling result file. Therefore, the code test can be carried out only aiming at the accurate code change influence range, the test process of the code which is not changed is saved, and the software code development efficiency and the software code quality are improved.
The target source code file is a source code file obtained by modifying a memory address range occupied by a changed target function of the changed source code file during compiling and adding a null function at a position corresponding to the target function of the changed source code file. The compiling result of the target source code file is influenced by the adjustment of the memory address range occupied by the null function and the target function during compiling, the use efficiency of the memory address range is not high, and the execution efficiency of the source code file is also low.
Based on this, the embodiment of the present application further provides a method for identifying a code change influence range, and refer to fig. 6, which is a flowchart of another method for identifying a code change influence range provided in the embodiment of the present application. In addition to the above S201-S205, after S205, the method further comprises the following two steps:
s206: and restoring the target source code file into a changed source code file.
It will be appreciated that the method of restoring the target source code file to the altered source code file is the reverse process of the method of modifying the altered source code file to the target source code file.
The target-based source code file is obtained by modifying a memory address range occupied by a target function during compiling and adding a null function to the changed source code file. The empty function can be correspondingly deleted from the target source code file, and the memory address range occupied by the target function during compiling is modified into the original memory address range, so that the source code file after being changed is restored.
In a possible implementation manner, before the target source code file is restored to the changed source code file, it is further required to determine that sufficient memory addresses occupied by compiling the source code file that can be used in the memory addresses are sufficient. And determining that the memory address occupied by the compiled object function can be adjusted to the memory address range of the code segment occupied by the compiled source code file.
The embodiment of the application provides a specific implementation mode for generating a target source code file by modifying a memory address range occupied by a modified target function of a modified source code file during compiling and adding a null function at a position corresponding to the target function of the modified source code file. And correspondingly, a specific implementation for restoring the target source code file into the changed source code file is provided, which is specifically referred to as the following.
S207: and calling a compiling engineering file to compile the changed source code file.
Compiling the changed source code file to obtain the compiling result of the changed source code file, and re-determining the compiling result of the source code file written in the memory address range.
Based on the relevant contents of S206-S207, the compilation efficiency of the modified source code file obtained by restoring is higher compared with that of the target source code file. And the addresses used during compiling have consistency and continuity, so that the use efficiency of the memory address and the instruction execution efficiency are improved, and the software development by utilizing the changed source code file is facilitated subsequently.
In a possible implementation manner, the memory address range occupied by the target function of the source code file after being changed during compiling can be modified by setting a sector offset instruction of the target function. The method for generating the target source code file comprises the following steps of modifying a memory address range occupied by a modified target function of the modified source code file during compiling, and adding a null function at a position corresponding to the target function of the modified source code file, wherein the method specifically comprises the following steps:
adding a sector offset instruction for the target function in the changed source code file, wherein the sector offset instruction for the target function is used for indicating that the target function occupies a second memory address range in the idle memory address range during compiling;
and determining the size of the empty function according to the first memory address range, and adding the empty function before or after the target function of the source code file after the change to generate the target source code file.
The sector offset instruction is used to indicate the memory address range occupied by the function after compilation. Adding a sector offset instruction aiming at the target function in the changed source code file, and migrating the memory address range occupied by the compiled target function to a second memory address range, so that the memory address range occupied by the changed target function does not influence the memory address range occupied by other functions compiled subsequently during compiling.
After the memory address range occupied by the compiled target function is adjusted, the memory address range occupied by the compiled target function originally is vacant. In order to prevent the occupied function of the subsequent compilation from changing the memory address range occupied by the function of the subsequent compilation, the size of the empty function is determined according to the first memory address range, and the empty function is added before or after the target function of the changed source code file, so that the empty function is compiled before or after the target function is compiled to occupy the first memory address range.
Referring to fig. 7, this is a schematic diagram of a modified changed source code file according to an embodiment of the present application. Fig. 7(a) is a schematic diagram of an object source code file to which a null function is added before an object function. When compiling the target source code file, compiling a null function before the target function, and occupying a first memory address range when compiling the null function. The target function is compiled after the null function is compiled, and the second memory address range is occupied when the target function is compiled. And compiling the subsequent functions according to the original compiling sequence, wherein the subsequent functions occupy the memory address range after the first memory address range according to the sequence during compiling. FIG. 7(b) is a schematic diagram of the target source code file with null functions added after the target function. When the target source code file is compiled, the target function is compiled first, and a second memory address range is occupied when the target function is compiled. A null function is compiled after the target function is compiled, and the null function occupies a first memory address range when the null function is compiled. And compiling the subsequent functions according to the original compiling sequence, wherein the subsequent functions occupy the memory address range after the first memory address range according to the compiling sequence during compiling. Therefore, the influence of the target function on the memory address range occupied by other functions after the target function is changed can be avoided.
And generating a target source code file by using the changed source code file with the added sector offset instruction and the null function.
In the embodiment of the application, the memory address range occupied by the target function during compiling is adjusted through the sector offset instruction, and the empty function is used for occupying the first memory address range, so that the memory address range occupied by compiling of other functions is not influenced when the target function is changed. Therefore, the code change influence range caused by changing the target function can be accurately determined according to the generated target source code.
Further, corresponding to the method for generating a target source code file, an embodiment of the present application provides a specific implementation manner for restoring a target source code file into a source code file after modification, which specifically includes:
and deleting the sector offset instruction and the null function of the target function in the target source code file, and restoring the changed source code file.
And deleting the sector offset instruction and the null function of the target function from the target source code file, and restoring to obtain the modified source code file which is not adjusted.
Based on the above, the obtained source code file after change occupies a continuous memory address range during compiling, so that the use efficiency of the memory address and the instruction execution efficiency are improved, and the source code file after change is conveniently used for software development.
After the changed source code file is restored by using the target source code file, the changed source code file can be verified, and the changed source code file is ensured to be restored normally.
In addition to S206-S207 above, the method may further include:
determining whether the initial address of the memory address range occupied by the first target function is the initial address of the first memory address range in a third compiling result file generated when the compiling engineering file is called to compile the changed source code file;
if so, determining that the source code file is restored to be normal after the change.
When the objective function is changed, the other functions than the objective function are not changed. When the target function is one, the memory address range occupied by other functions before the compiling sequence of the target function is unchanged. Therefore, the initial address of the memory address range occupied by the changed target function is the same as the initial address of the first memory address range. When the target function is multiple, the memory address range occupied by other functions before the first compiled target function is unchanged. Therefore, the start address of the memory address range occupied by the first target function is the same as the start address of the corresponding first memory address range.
It should be noted that, if the target function is a newly added function and the first memory address corresponding to the target function is empty, it cannot be determined that the restored changed source code file is restored normally by comparing the start address of the occupied memory address range acquired by the target function in the third compilation result file with the start address of the first memory address range.
After the changed source code file obtained by restoring the target source code file is obtained, the compiling engineering file can be called to compile the changed source code file, and a third compiling result file is obtained. And obtaining the memory address range occupied by each function in the changed source code file from the third compiling result file.
And acquiring the initial address of the memory address range occupied by the first target function from the third compiling result file. When the target function is one, the first target function is the target function; when the target function is plural, the first target function is the first target function determined in the compiling order.
And comparing the initial address of the memory address range occupied by the acquired first target function with the initial address of the first memory address range. If the initial address of the memory address range occupied by the first target function is the initial address of the first memory address range, it can be determined that the source code file is restored normally after the change.
Based on the above, by comparing the start address of the memory address range occupied by the first target function with the start address of the first memory address range, it can be determined whether the changed source code file after the target source code file is restored is accurately restored. Therefore, the memory address range occupied by the target function can be restored, and the development by utilizing the changed source code file is facilitated subsequently.
Based on the method for identifying the influence range of code change provided by the above method embodiment, the embodiment of the present application further provides a device for identifying the influence range of code change, and the device for identifying the influence range of code change will be described below with reference to the accompanying drawings.
Referring to fig. 8, this figure is a schematic structural diagram of an apparatus for identifying a code change influence range according to an embodiment of the present application. As shown in fig. 8, the apparatus for recognizing the influence range of code change includes:
a first compiling unit 801, configured to invoke a compiling engineering file to compile a source code file before change, and generate a first compiling result file, where the first compiling result file includes a memory address range occupied by each function in the source code file before change and an idle memory address range;
a first determining unit 802, configured to obtain a source code file after modification, determine that a target function of code modification exists in the source code file after modification, and obtain, from the first compilation result file, a first memory address range occupied by the target function when the source code file before modification is compiled;
a modifying unit 803, configured to modify the changed source code file to change a memory address range occupied by the target function during compilation, and add an empty function to a position corresponding to the target function of the changed source code file, so as to generate a target source code file, where the target function occupies a second memory address range within the empty memory address range when the target source code file is compiled, and the empty function occupies the first memory address range;
the second compiling unit 804 is configured to call the compiling engineering file to compile the target source code file, and generate a second compiling result file;
a comparing unit 805, configured to compare the first compilation result file and the second compilation result file, and determine a code change influence range.
In one possible implementation, after determining the code change influence range, the apparatus further includes:
the restoring unit is used for restoring the target source code file into the changed source code file;
and the third compiling unit is used for calling the compiling engineering file to compile the changed source code file.
In one possible implementation, the apparatus further includes:
a determining unit, configured to determine whether a start address of a memory address range occupied by a first target function is a start address of a first memory address range in a third compilation result file generated when the compilation engineering file is called to compile the modified source code file;
and the second determining unit is used for determining that the source code file is restored to be normal after the change if the source code file is restored to be normal after the change.
In a possible implementation manner, the modifying unit 803 is specifically configured to add a sector offset instruction for the target function in the modified source code file, where the sector offset instruction for the target function is used to indicate that the target function occupies a second memory address range in the free memory address range during compiling;
and determining the size of a null function according to the first memory address range, and adding the null function before or after the target function of the changed source code file to generate a target source code file.
In a possible implementation manner, the restoring unit is specifically configured to delete the sector offset instruction of the target function and the null function in the target source code file, and restore the changed source code file.
In a possible implementation manner, the comparing unit 805 is specifically configured to compare the first compilation result file and the second compilation result file, and determine a part of the first compilation result file that is different from the second compilation result file as a code change influence range.
In one possible implementation, the apparatus further includes:
a display unit for highlighting the code change influence range
In addition, an embodiment of the present application further provides an apparatus for identifying a code change influence range, including: the system comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the method for identifying the influence range of code change according to the embodiment.
In addition, an embodiment of the present application further provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are executed on a terminal device, the instructions cause the terminal device to perform the method for changing the influence range of the identification code according to the embodiment.
According to the device and the equipment for identifying the code change influence range, the editing engineering file is called to compile the source code file before change to generate the first compilation result file, and the memory address range and the free memory address range occupied by each function in the source code file before change can be determined through the first compilation result file. And then acquiring a source code file after the change, determining that a target function with code change exists in the source code file after the change, and acquiring a first memory address range occupied by the target function from the first editing result file. The first memory address range is the memory address range occupied by the target function prior to the code change. And modifying the memory address range occupied by the changed target function of the changed source code file during compiling, and adding a null function at the corresponding position of the target function of the changed source code file to generate a target source code file. Therefore, the empty function is used for occupying the first memory address range occupied by the target function before code change, and the memory address range occupied by the function after the target function in the source code file after change is not influenced by the change of the target function. And when the target source code file is compiled, the target function occupies a second memory address range in the free memory address range. The target function occupying the free memory address range after the memory address range is occupied is adjusted, the memory address range occupied by the function in the subsequent code during compiling is not influenced, and the range of influence on the code is reduced. And finally, calling the compiling engineering file to compile the target source code file to generate a second compiling result file. And determining the memory address range occupied by the target function after adjusting the memory address range occupied by the target function during compiling according to the second compiling result file. And comparing the first compiling result file with the second compiling result file to determine the code change influence range after the target function is changed. Therefore, the code change influence range can be accurately identified, the change code influence range is convenient to confirm subsequently, the software development efficiency is improved, and the quality of the developed software is ensured.
It should be noted that, in the present specification, the embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the system or the device disclosed by the embodiment, the description is simple because the system or the device corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method of identifying a scope of influence of a code change, the method comprising:
calling a compiling engineering file to compile a source code file before change to generate a first compiling result file, wherein the first compiling result file comprises a memory address range occupied by each function in the source code file before change and a free memory address range;
acquiring a source code file after change, determining that a target function with code change exists in the source code file after change, and acquiring a first memory address range occupied by the target function when the source code file before change is compiled from the first compilation result file;
modifying the changed source code file to change the memory address range occupied by the target function during compiling, and adding a null function at a position corresponding to the target function of the changed source code file to generate a target source code file, so that the target function occupies a second memory address range in the free memory address range when the target source code file is compiled, and the null function occupies the first memory address range;
calling the compiling engineering file to compile the target source code file to generate a second compiling result file;
and comparing the first compiling result file with the second compiling result file to determine the influence range of code change.
2. The method of claim 1, wherein after determining a code change scope of influence, the method further comprises:
restoring the target source code file into the changed source code file;
and calling the compiling engineering file to compile the changed source code file.
3. The method of claim 2, further comprising:
determining whether the initial address of the memory address range occupied by the first target function is the initial address of the first memory address range in a third compilation result file generated when the compilation engineering file is called to compile the changed source code file;
if so, determining that the source code file is restored to be normal after the change.
4. The method according to claim 2, wherein the generating the target source code file by modifying the changed source code file to change a memory address range occupied by the target function during compiling and adding a null function to a corresponding position of the target function of the changed source code file comprises:
adding a sector offset instruction for the target function in the changed source code file, wherein the sector offset instruction for the target function is used for indicating that the target function occupies a second memory address range in the free memory address range during compiling;
and determining the size of a null function according to the first memory address range, and adding the null function before or after the target function of the changed source code file to generate a target source code file.
5. The method of claim 4, wherein the restoring the target source code file to the altered source code file comprises:
and deleting the sector offset instruction of the target function and the null function in the target source code file, and restoring the changed source code file.
6. The method of claim 1, wherein comparing the first compilation product file to the second compilation product file to determine a scope of influence of code changes comprises:
and comparing the first compiling result file with the second compiling result file, and determining a part of the first compiling result file, which is different from the second compiling result file, as a code change influence range.
7. The method of claim 1 or 6, further comprising:
and highlighting the code change influence range.
8. An apparatus for identifying a code change influence range, the apparatus comprising:
the system comprises a first compiling unit, a second compiling unit and a third compiling unit, wherein the first compiling unit is used for calling a compiling engineering file to compile a source code file before change to generate a first compiling result file, and the first compiling result file comprises a memory address range occupied by each function in the source code file before change and an idle memory address range;
a first determining unit, configured to obtain a source code file after change, determine that an object function with a code change exists in the source code file after change, and obtain, from the first compilation result file, a first memory address range occupied by the object function when the source code file before change is compiled;
a modifying unit, configured to modify the changed source code file to change a memory address range occupied by the target function during compilation, and add a null function to a position corresponding to the target function of the changed source code file, so as to generate a target source code file, where the target function occupies a second memory address range within the null memory address range when the target source code file is compiled, and the null function occupies the first memory address range;
the second compiling unit is used for calling the compiling engineering file to compile the target source code file to generate a second compiling result file;
and the comparison unit is used for comparing the first compilation result file with the second compilation result file and determining the influence range of code change.
9. An apparatus for identifying a range of influence of a code change, comprising: memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the method of identifying a scope of influence of a code change according to any of claims 1-7 when executing the computer program.
10. A computer-readable storage medium, having stored therein instructions which, when run on a terminal device, cause the terminal device to execute the method of identifying a code alteration impact scope according to any one of claims 1-7.
CN202011606125.0A 2020-12-28 2020-12-28 Method, device and equipment for identifying code change influence range Active CN112698832B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011606125.0A CN112698832B (en) 2020-12-28 2020-12-28 Method, device and equipment for identifying code change influence range

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011606125.0A CN112698832B (en) 2020-12-28 2020-12-28 Method, device and equipment for identifying code change influence range

Publications (2)

Publication Number Publication Date
CN112698832A true CN112698832A (en) 2021-04-23
CN112698832B CN112698832B (en) 2024-02-13

Family

ID=75512391

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011606125.0A Active CN112698832B (en) 2020-12-28 2020-12-28 Method, device and equipment for identifying code change influence range

Country Status (1)

Country Link
CN (1) CN112698832B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102289375A (en) * 2011-09-02 2011-12-21 中兴通讯股份有限公司 Code generation method and system
US8607208B1 (en) * 2008-10-01 2013-12-10 Oracle International Corporation System and methods for object code hot updates
WO2015200235A1 (en) * 2014-06-25 2015-12-30 Microsoft Technology Licensing, Llc Techniques for edit-and-continue and enhanced optimized debugging on optimized code
CN105446723A (en) * 2014-09-02 2016-03-30 国际商业机器公司 Method and device for identifying semantic difference between source code versions
CN108874438A (en) * 2018-06-25 2018-11-23 南京中感微电子有限公司 Patch generation method, device, electronic equipment and computer program product
CN111666206A (en) * 2020-04-30 2020-09-15 北京百度网讯科技有限公司 Method, device, equipment and storage medium for acquiring influence range of change code

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8607208B1 (en) * 2008-10-01 2013-12-10 Oracle International Corporation System and methods for object code hot updates
CN102289375A (en) * 2011-09-02 2011-12-21 中兴通讯股份有限公司 Code generation method and system
WO2015200235A1 (en) * 2014-06-25 2015-12-30 Microsoft Technology Licensing, Llc Techniques for edit-and-continue and enhanced optimized debugging on optimized code
CN105446723A (en) * 2014-09-02 2016-03-30 国际商业机器公司 Method and device for identifying semantic difference between source code versions
CN108874438A (en) * 2018-06-25 2018-11-23 南京中感微电子有限公司 Patch generation method, device, electronic equipment and computer program product
CN111666206A (en) * 2020-04-30 2020-09-15 北京百度网讯科技有限公司 Method, device, equipment and storage medium for acquiring influence range of change code

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
田祖伟;杨恒伏;罗阳旭;: "基于增量链接的PE文件信息隐藏技术研究", 计算机科学, no. 12, 15 December 2012 (2012-12-15) *
陈荔城;崔泽汉;包云岗;陈明宇;沈林峰;梁祺;: "一种监测函数语义信息访存地址序列的方法", 计算机研究与发展, no. 05, 15 May 2013 (2013-05-15) *

Also Published As

Publication number Publication date
CN112698832B (en) 2024-02-13

Similar Documents

Publication Publication Date Title
CN108427731B (en) Page code processing method and device, terminal equipment and medium
CN108170465B (en) Version information management method, electronic equipment and readable storage medium
CN111124921B (en) Method, device, equipment and storage medium for detecting memory boundary crossing
CN108664394B (en) Memory leakage process tracing method and device
CN107643893B (en) Program detection method and device
CN110955409B (en) Method and device for creating resources on cloud platform
CN111679852A (en) Detection method and device for conflict dependency library
US20130152049A1 (en) Warning of register and storage area assignment errors
CN110688320A (en) Global variable detection method and device and terminal equipment
CN112698832B (en) Method, device and equipment for identifying code change influence range
CN111240987A (en) Migration program detection method and device, electronic equipment and computer readable storage medium
CN110688198A (en) System calling method and device and electronic equipment
CN114706586A (en) Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium
CN114817047A (en) Compiler test method, case generation method and device and instruction storage structure
CN114625663A (en) Test method, test device, computer equipment and storage medium
CN113609478A (en) IOS platform application program tampering detection method and device
CN112527660B (en) Static detection method and device for codes
US11397662B2 (en) Method for debugging computer program, device employing method, and storage medium
CN106897588B (en) Processing method and device of label function
CN110765008A (en) Data processing method and device
JP2019215607A (en) Violation dependence detection device and violation dependence detection program
EP4209896A1 (en) Code processing method and apparatus, and device
CN112527657B (en) Method and equipment for automatic pile insertion in unit test
CN111694730B (en) Method and device for eliminating error reference control resource
CN115454492A (en) Method for updating configuration parameters of application program and related product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant