CN112698832B - 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
CN112698832B
CN112698832B CN202011606125.0A CN202011606125A CN112698832B CN 112698832 B CN112698832 B CN 112698832B CN 202011606125 A CN202011606125 A CN 202011606125A CN 112698832 B CN112698832 B CN 112698832B
Authority
CN
China
Prior art keywords
file
source code
compiling
memory address
function
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.)
Active
Application number
CN202011606125.0A
Other languages
Chinese (zh)
Other versions
CN112698832A (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

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

Abstract

The embodiment of the application discloses a method, a device and equipment for identifying a code change influence range, which are used for calling an editing engineering file to compile a source code file before change to generate a first compiling result 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 objective function from the first editing result file. And modifying the modified source code file to change the memory address range occupied by the target function in 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. And finally, calling a compiling engineering file compiling target 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 compiling result file and the second compiling result file, so that the code change influence range can be conveniently confirmed later, 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 disclosure 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 requirement of software development. After the code is changed, other code parts can be influenced, and developers need to test the influence range of the code change so as to ensure the correctness of the code.
At present, the influence range of code change cannot be accurately determined, and a developer needs to test and confirm the whole code of the modified software code. This results in longer times to test the software code and less efficient software development. If the developer performs test checking based on the inaccurate code change influence range, problems can also occur in the software code. Therefore, how to determine a more accurate code change influence range is a problem to be solved.
Disclosure of Invention
In view of this, the embodiments of the present application provide a method, apparatus, and device for identifying a code change influence range, which can accurately determine the code change influence range, so as to clearly determine the range of code testing, and improve the efficiency of software development and the quality of codes.
In order to solve the above problems, the technical solution provided in the embodiments of the present application is as follows:
A method of identifying a range of influence of a code change, the method comprising:
invoking a compiling engineering file to compile a source code file before modification to generate a first compiling result file, wherein the first compiling result file comprises a memory address range and an idle memory address range occupied by each function in the source code file before modification;
acquiring a source code file after modification, determining a target function with code modification in the source code file after modification, and acquiring a first memory address range occupied by the target function when compiling the source code file before modification from the first compiling result file;
changing the memory address range occupied by the target function in compiling by modifying the source code file after modification, and adding a null function at the corresponding position of the target function of the source code file after modification to generate a target source code file, so that the target function occupies a second memory address range in the idle memory address range when compiling the target source code file, and the null function occupies the first memory address range;
invoking 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 the 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 objective function is the initial address of the first memory address range or not in a third compiling result file generated when the compiling engineering file is called to compile the changed source code file;
if yes, the source code file after the change is determined to be restored normally.
In one possible implementation manner, the generating the target source code file by modifying the modified source code file to change the memory address range occupied by the target function at the time of compiling and adding a null function at the corresponding position of the target function of the modified source code file includes:
adding a sector offset instruction to the target function in the source code file after the change, wherein the sector offset instruction to the target function is used for indicating that the target function occupies a second memory address range in the idle memory address range when compiling;
And determining the size of a null function according to the first memory address range, adding the null function before or after the target function of the source code file after the change, and generating the target source code file.
In one possible implementation manner, 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 one possible implementation manner, the comparing the first compiling result file and the second compiling result file to determine the code change influence scope includes:
comparing the first compiling result file and the second compiling result file, and determining the part with the difference in the first compiling result file and the second compiling result file as a code change influence range.
In one possible implementation, the method further includes:
highlighting the code change influence range.
An apparatus to identify a range of influence of a code change, the apparatus comprising:
the first compiling unit is used for calling a compiling engineering file to compile the source code file before changing to generate a first compiling result file, and the first compiling result file comprises a memory address range and an idle memory address range occupied by each function in the source code file before changing;
The first determining unit is used for obtaining a source code file after modification, determining an objective function with code modification in the source code file after modification, and obtaining a first memory address range occupied by the objective function when the source code file before modification is compiled from the first compiling result file;
the modifying unit is used for modifying the memory address range occupied by the target function in compiling by modifying the source code file after modification, adding a null function at the corresponding position of the target function of the source code file after modification, and generating a target source code file so that the target function occupies a second memory address range in the free memory address range when compiling the target source code file, 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 and generating a second compiling result file;
and the comparison unit is used for comparing the first compiling result file and the second compiling result file and determining a code change influence range.
An apparatus for identifying a range of influence of a code change, comprising: the computer program comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the method for changing the influence range of the identification code is realized when the processor executes the computer program.
A computer readable storage medium having instructions stored therein which, when executed on a terminal device, cause the terminal device to perform the above-described method of identifying code altering an impact range.
From this, 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 firstly called to compile the source code file before change, a first compiling result file is generated, and the memory address range and the idle memory address range occupied by each function in the source code file before change can be determined through the first compiling result file. And acquiring a source code file after the change, determining an objective function with code change in the source code file after the change, and acquiring a first memory address range occupied by the objective function from a first editing result file. The first memory address range is the memory address range occupied by the objective function before the code change. And modifying the modified source code file to change the memory address range occupied by the target function in 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. Therefore, the first memory address range occupied by the target function before the code change is occupied by the null function, and the memory address range occupied by the function after the target function in the source code file after the change is not influenced by the change of the target function. The target function occupies a second memory address range within the free memory address range when the target source code file is compiled. The target function after the memory address range is adjusted occupies the idle memory address range, the memory address range occupied by the function in the subsequent code during compiling is not influenced, and the influence range 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 compiling according to the second compiling result file. Comparing the first compiling result file and the second compiling result file, the code change influence range after the objective function is changed can be determined. Therefore, the identification of the code change influence scope can be accurately realized, the subsequent confirmation of the code change influence scope is facilitated, the efficiency of software development is improved, and the quality of the developed software is ensured.
Drawings
FIG. 1 is a schematic diagram of a source code according to an embodiment of the present application occupying a memory address range during compiling;
FIG. 2 is a flowchart of a method for identifying a code change impact range according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a CHK file according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of an object source code file occupying a memory address range in a compiling process according to an embodiment of the present application;
FIG. 5 is a schematic diagram illustrating another source code according to an embodiment of the present application occupying a memory address range during compiling;
FIG. 6 is a flowchart of another method for identifying code change impact ranges provided by embodiments of the present application;
FIG. 7 is a schematic diagram of a modified source code file after modification according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an apparatus for identifying an influence range of code modification according to an embodiment of the present application.
Detailed Description
In order to make the above objects, features and advantages of the present application more comprehensible, embodiments accompanied with figures and detailed description are described in further detail below.
In order to facilitate understanding and explanation of the technical solutions provided by the embodiments of the present application, the background art of the present application will be described first.
The inventor discovers that instructions and data generated by the existing software code during compiling occupy memory addresses according to the compiling sequence after researching traditional code changes. When a part of functions in the software code are changed, the memory address range occupied by the changed functions at the time of compiling can be changed, and meanwhile, the memory address range occupied by all subsequent functions at the time of compiling can be influenced. After the code is changed, a developer can confirm the influence range of the code change by checking the memory address range occupied by compiling so as to ensure the quality of the code. And because the changed functions can cause the change of the memory address range occupied by all subsequent functions in compiling, a developer cannot accurately determine the real code change influence range.
Because the influence scope of code change cannot be accurately determined at present, a developer needs to confirm a larger influence scope, so that the test time is prolonged, and the efficiency of software development is reduced. If the developer confirms the influence scope of the code change based on the inaccuracy, part of the influence scope of the code change may be missed, so that the unaltered code is problematic, and the quality of the software code is affected.
Based on this, the embodiment of the application provides a method for identifying a code change influence range, firstly, an editing engineering file is called to compile a source code file before change, a first compiling result file is generated, 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 compiling result file. And acquiring a source code file after the change, determining an objective function with code change in the source code file after the change, and acquiring a first memory address range occupied by the objective function from a first editing result file. The first memory address range is the memory address range occupied by the objective function before the code change. And modifying the modified source code file to change the memory address range occupied by the target function in 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. Therefore, the first memory address range occupied by the target function before the code change is occupied by the null function, and the memory address range occupied by the function after the target function is ensured not to be influenced by the target function change. The target function occupies a second memory address range within the free memory address range when the target source code file is compiled. The target function after the memory address range is adjusted occupies the idle memory address range, the memory address range occupied by the function in the subsequent code cannot be influenced, and the influence range 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 compiling according to the second compiling result file. Comparing the first compiling result file and the second compiling result file, the code change influence range after the objective function is changed can be determined. Therefore, the identification of the code change influence range can be accurately realized, the accurate change code influence range can be conveniently confirmed later, and the accuracy of the software code and the efficiency of software development are improved.
In order to facilitate understanding of the method for identifying the influence range of code modification provided in the embodiment of the present application, the following description is made in connection with the scenario example shown in fig. 1. Referring to fig. 1, a schematic diagram of a source code according to an embodiment of the present application occupying a memory address range in a compiling process is shown.
In practical application, the source code occupies a certain memory address range in the compiling process. The memory address range occupied by each function in the source code is sequentially determined 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 when 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 objective function in compiling can be adjusted to the free area. In order to avoid the influence of the target function on the memory address range occupied by other functions after the change, the memory address range occupied by the target function is adjusted to be in the second memory address range of the idle area. And the first memory address range occupied by the objective function before the change is determined, the first memory address range is occupied by the null function, so that the first memory address range of the objective function after the modification also has a corresponding function, and the memory address range occupied by the follow-up function during compiling is not influenced. And adjusting the memory address range occupied by the target function in compiling 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. The code change influence range caused by changing the objective function can be determined by comparing a first compiling result file generated by compiling the source code file before changing by the compiling engineering file and a second compiling result file generated by compiling the objective source code file by the compiling engineering file.
Those skilled in the art will appreciate that the schematic diagram shown in fig. 1 is but one example in which embodiments of the present application may be implemented. The scope of applicability of the embodiments of the application is not limited in any way by the framework.
In order to facilitate understanding of the present application, a method for implementing auxiliary lane change according to an embodiment 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 an influence range of code modification 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 the change to generate a first compiling result file, wherein the first compiling result file comprises a memory address range and an idle memory address range occupied by each function in the source code file before the change.
The source code file before the change refers to the source code file before the current 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 compiling the source code file before changing by calling the compiling engineering file. The compiled instruction and data are stored in the memory, and occupy a certain memory address. In the embodiment of the present application, the Memory address may be an address in ROM (Read-Only Memory) or RAM (Random Access Memory ).
It should be noted that, the memory address range occupied by compiling the source code file is in a predetermined memory area. The memory address also has a free area, which is an unused memory area.
In the compiling process, a corresponding first compiling result file is generated, wherein the first compiling result file comprises instructions and data obtained by compiling each function in the source code file before changing, and a memory address range occupied by the instructions and the data. In one possible implementation, the first compilation effort file may be a CHK format file or a MAP format file. Referring to fig. 3, a schematic diagram of a CHK file according to an embodiment of the present application is shown. Wherein, the data in the solid line box represents the memory address, and the data in the dotted line box is the instruction and the data obtained after the code is compiled. According to the first compiling result file obtained by compiling, the memory address range and the idle memory address range occupied by each function in the source code file before changing during compiling can be determined.
S202: and acquiring a source code file after the change, determining an objective function with code change in the source code file after the change, and acquiring a first memory address range occupied by the objective function when compiling the source code file before the change from a first compiling result file.
And acquiring a source code file after the change, and determining an objective function changed by the code change according to the source code file after the change, wherein the number of the objective functions can be one or more. The method for determining the objective function is not limited in the embodiments of the present application, and in one possible implementation, the source code file before the modification and the source code file after the modification may be compared to determine the objective function in which the code modification occurs.
And determining a first memory address range occupied by compiling the objective function before the change occurs according to the first compiling result file.
It can be understood that, when the objective function is changed, the instruction and data generated by compiling the objective function will change, and the corresponding occupied memory address range will change compared with the first memory address range, so as to affect the memory address range occupied by the function compiled later.
In the embodiment of the present application, the mode of changing the objective function is not limited, and the objective function may be modified, deleted or added, and when the objective function is a function newly added in the current code change, the first memory address range of the objective function obtained from the first compilation result file is empty.
S203: and changing the memory address range occupied by the target function in compiling by modifying the source code file after the modification, and adding a null function at the corresponding position of the target function of the source code file after the modification to generate the target source code file, so that the target function occupies a second memory address range in the idle memory address range when the target source code file is compiled, and the null function occupies the first memory address range.
Referring to fig. 4, a schematic diagram of a target source code file occupying a memory address range in a compiling process according to an embodiment of the present application is shown. In order to avoid that the target function influences the memory address range occupied by the subsequently compiled function after the change, the memory address range occupied by the target function of the source code file after the change during the compiling can be modified. And adjusting the memory address range occupied by the changed target function in compiling to a second memory address range in the idle memory address range.
In one possible implementation, it is also necessary to determine that free memory addresses are sufficient to use before modifying the memory address range occupied by the source code file change objective function at compile time after the change.
It should be noted that, when the deleting and changing operation is performed on the objective function, the corresponding second memory address range may be empty.
After the memory address range occupied by the target function at the time of compiling is adjusted, the memory address range originally occupied by the target function at the time of compiling, namely the first memory address range, is free, and the memory address range occupied by the function subsequently compiled at the time of compiling is affected. Therefore, it is also necessary to add a null function to the location corresponding to the target function of the source code file after the modification to generate the target source code file. Referring to fig. 5, a schematic diagram of another source code according to an embodiment of the present application occupying a memory address range in a compiling process is shown. The null function may be a function that does not affect the compiling result of the object source code file, and implements memory occupation of the first memory address range at compile time. The null function may specifically be a Dummy function.
By adding the null function at the corresponding position of the target function of the source code file after the change, 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 is avoided when the other functions are compiled, and the code change influence range which is accurate is convenient to identify later.
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 at compile time is different from the memory address range occupied by the source code file before change at compile time. 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 is provided with 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 compiling result file with the second compiling result file to determine a code change influence range includes:
comparing the first compiling result file and the second compiling result file, and determining the part with the difference in the first compiling result file and the second compiling result file as a code change influence range.
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 part with the difference in the first compiling result file and the second compiling result file can be specifically an instruction and data with the difference and a memory address range with the difference.
It will be appreciated that 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 compiling is different from the instruction and data obtained by the target function before the change at the time of compiling, and when comparing the first compiling result file with the second compiling result file, the data difference stored in the first memory address range can be obtained. In addition, the second memory address range has instructions and data obtained by compiling the target function, and the difference of the data stored in the second memory address range can be obtained unlike the data storage in the idle memory address range obtained by compiling the source code file before the change.
In one possible implementation, the modification of the target data may be deletion, and the second memory address range is empty. Correspondingly, the part with the difference in the first compiling result file and the second compiling result file can be the instruction and the data in the first memory address range. In another possible implementation, the modification of the target data may be an increase, and the first memory address range is empty. Correspondingly, the part with the difference in the first compiling result file and the second compiling result file can be the instruction and the data in the second memory address range.
In one possible implementation, the method further includes:
highlighting the code change influence range.
To facilitate 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 a different color.
Based on the above-mentioned related content of S201-S205, it is known that by modifying the source code file after modification to change the memory address range occupied by the objective function at compile time, and adding a null function at the corresponding position of the objective function of the source code file after modification, the memory address range occupied by the objective function in the source code file before modification can be occupied by the null function, and the memory address range occupied by the objective function at compile time in the source code file after modification can be adjusted to the free memory address range. Therefore, the influence on the memory address range occupied by compiling other functions is avoided, the code change influence range is reduced, and the accurate code change influence range is obtained through identification by comparing the first compiling result file and 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 unchanged codes is saved, and the development efficiency of the software codes and the quality of the software codes are improved.
The target source code file is a source code file obtained by modifying the modified source code file to change the memory address range occupied by the target function during compiling and adding a null function at the corresponding position of the target function of the modified source code file. The compiling result of the target source code file is influenced by the space function and the memory address range adjustment occupied by the target function during compiling, the use efficiency of the memory address range is low, and the execution efficiency of the source code file is low.
Based on this, the embodiment of the application further provides a method for identifying the influence range of code change, referring to fig. 6, which is a flowchart of another method for identifying the influence range of code change provided in the embodiment of the 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 changed source code file is the reverse of the method of modifying the changed source code file to the target source code file.
The target source code file is obtained after modifying the memory address range occupied by the target function in compiling and adding the null function. 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 recovery of the source code file after modification is realized.
In one possible implementation, before restoring the target source code file to the changed source code file, it is also necessary to determine that the memory address occupied by compiling the source code file that can be used in the memory address is sufficient. It is determined 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 compilation of the source code file.
The embodiment of the application provides a specific implementation mode of generating a target source code file by modifying a memory address range occupied by a target function when compiling through modifying a source code file after modification and adding a null function at a position corresponding to the target function of the source code file after modification. And correspondingly provides a specific embodiment for restoring the target source code file into the changed source code file, which is specifically described below.
S207: and calling a compiling engineering file to compile the changed source code file.
Compiling the changed source code file to obtain a compiling result of the changed source code file, and redefining the compiling result of the source code file written in the memory address range.
Based on the related content of S206-S207, it is known that the compiling efficiency of the restored modified source code file is higher than that of the target source code file. And the addresses used in compiling have consistency and continuity, so that the use efficiency of the memory address and the instruction execution efficiency are improved, and the subsequent software development by using the source code file after the change is facilitated.
In one possible implementation, the memory address range occupied by the target function of the source code file after modification at compile time may be modified by setting a sector offset instruction of the target function. The method comprises the steps of changing the memory address range occupied by the target function in compiling by modifying the source code file after modification, and adding a null function at the corresponding position of the target function of the source code file after modification to generate the target source code file, and specifically comprises the following steps:
adding a sector offset instruction for the target function in the source code file after the change, wherein the sector offset instruction for the target function is used for indicating a second memory address range of the target function in an idle memory address range when the target function is compiled;
and determining the size of the null function according to the first memory address range, and adding the null function before or after changing the target function of the source code file to generate the target source code file.
The sector offset instruction is used to indicate the memory address range occupied after the function is compiled. And adding a sector offset instruction aiming at the target function in the source code file after the change, and migrating the memory address range occupied by the target function after the compiling to a second memory address range, so that the memory address range occupied by the target function after the change does not influence the memory address range occupied by other functions after the subsequent compiling during the compiling.
After the memory address range occupied by the compiled objective function is adjusted, the memory address range occupied by the compiled objective function is left vacant. In order to prevent the occupation of the subsequently compiled function, the memory address range occupied by the subsequently compiled function is changed, the size of the null function is determined according to the first memory address range, and the null function is added before or after the target function of the source code file is changed, so that the null function is compiled before or after the target function is compiled, and the first memory address range is occupied.
Referring to fig. 7, a schematic diagram of a modified source code file after modification according to an embodiment of the present application is shown. Wherein FIG. 7 (a) is a schematic diagram of an object source code file with null function added before the object function. When compiling the target source code file, firstly compiling a null function in front of the target function, and occupying a first memory address range when compiling the null function. After compiling the null function, compiling the target function, and occupying a second memory address range when compiling the target function. Then compiling the functions according to the original compiling sequence, and occupying the memory address range behind the first memory address range according to the sequence when compiling the subsequent functions. FIG. 7 (b) is a schematic diagram of an object source code file with null function added after an object function. When compiling the target source code file, compiling the target function first, and occupying a second memory address range when compiling the target function. The null function is compiled after the target function is compiled, and a first memory address range is occupied when the null function is compiled. Then compiling the function according to the original compiling sequence, and occupying the memory address range behind the first memory address range according to the compiling sequence when compiling the subsequent function. Therefore, the influence of the target function on the memory address range occupied by other functions after the change can be avoided.
And generating a target source code file by using the changed source code file with the sector offset instruction and the null function.
In the embodiment of the application, the memory address range occupied by the target function in compiling is adjusted through the sector offset instruction, and the first memory address range is occupied by the null function, 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 objective function can be accurately determined according to the generated objective source code.
Further, corresponding to the method for generating the target source code file, the embodiment of the application provides a specific implementation manner of restoring the target source code file to the changed source code file, 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 modified source code file 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 subsequent software development by using the modified source code file is facilitated.
After the changed source code file is restored by utilizing the target source code file, the changed source code file can be verified, and the restoration of the changed source code file is ensured to be normal.
In addition to the above S206-S207, 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 or not in a third compiling result file generated when the compiling engineering file is called to compile the changed source code file;
if yes, the source code file is determined to be restored normally after the change.
When the objective function is changed, the functions other than the objective function are not changed. When the objective function is one, the memory address range occupied by other functions before the objective function compiling sequence is unchanged. Therefore, the starting address of the memory address range occupied by the changed objective function is the same as the starting address of the first memory address range. When the target functions are multiple, the memory address range occupied by other functions before the first compiled target function is unchanged. Therefore, the starting address of the memory address range occupied by the first objective function is the same as the starting address of the corresponding first memory address range.
It should be noted that, if the objective function is a newly added function and the first memory address corresponding to the objective function is empty, the restored source code file after the restoration is not able to be determined to be normal by comparing the starting address of the occupied memory address range obtained by the objective function in the third compiling result file with the starting address of the first memory address range.
After the changed source code file obtained through 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 source code file after the change from the third compiling result file.
And acquiring the initial address of the memory address range occupied by the first objective function from the third compiling result file. When the objective function is one, the first objective function is the objective function; when there are a plurality of objective functions, the first objective function is the first objective function determined in the compiling order.
And comparing the acquired starting address of the memory address range occupied by the first target function with the starting address of the first memory address range. If the initial address of the memory address range occupied by the first objective function is the initial address of the first memory address range, the source code file can be determined to be restored to be normal after the change.
Based on the above, it can be known that by comparing the starting address of the memory address range occupied by the first objective function with the starting address of the first memory address range, whether the restored source code file is restored or not can be accurately determined. Therefore, the memory address range occupied by the objective function can be ensured to be restored, and the development by using the source code file after the change is facilitated.
Based on the method for identifying the influence range of code change provided in 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, a schematic structural diagram of an apparatus for identifying an influence range of code modification according to an embodiment of the present application is shown. As shown in fig. 8, the apparatus for changing the influence range of the identification code includes:
a first compiling unit 801, configured to invoke a compiling engineering file to compile a source code file before modification, and generate a first compiling result file, where the first compiling result file includes a memory address range and an idle memory address range occupied by each function in the source code file before modification;
A first determining unit 802, configured to obtain a source code file after modification, determine that a code-modified target function 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 compiling the source code file before modification;
a modifying unit 803, configured to modify a memory address range occupied by the objective function at the time of compiling by modifying the modified source code file, and add a null function to a location corresponding to the objective function of the modified source code file, so as to generate an objective source code file, so that the objective function occupies a second memory address range within the free memory address range when compiling the objective source code file, and the null function occupies the first memory address range;
the second compiling unit 804 is configured to invoke the compiling engineering file to compile the target source code file, and generate a second compiling result file;
and a comparing unit 805 configured to compare the first compiling result file and the second compiling result file and determine a code change influence range.
In one possible implementation, after determining the code change scope of influence, 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:
the judging unit is used for determining whether the initial address of the memory address range occupied by the first objective function is the initial address of the first memory address range or not in a third compiling result file generated when the compiling engineering file is called to compile the changed source code file;
and the second determining unit is used for determining that the source code file after the change is restored to be normal if the source code file is changed to be normal.
In a possible implementation manner, the modifying unit 803 is specifically configured to add a sector offset instruction to the objective function in the source code file after the modification, where the sector offset instruction to the objective function is used to indicate that the objective function occupies a second memory address range in the free memory address range when compiled;
and determining the size of a null function according to the first memory address range, adding the null function before or after the target function of the source code file after the change, and generating the target source code file.
In one possible implementation manner, the restoring unit is specifically configured to delete a sector offset instruction of the objective function and the null function in the objective source code file, and restore the modified source code file.
In one 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 portion of the first compilation result file and the second compilation result file, where the portion of the first compilation result file and the second compilation result file have a difference, 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, the embodiment of the application also provides equipment for identifying the influence range of code change, which comprises the following steps: the method for changing the influence range of the identification code according to the embodiment is realized by the memory, the processor and the computer program stored in the memory and capable of being run on the processor when the processor executes the computer program.
In addition, the embodiment of the application further provides a computer readable storage medium, wherein instructions are stored in the computer readable storage medium, and when the instructions run on a terminal device, the terminal device is caused to execute the method for changing the influence range of the identification code according to the embodiment.
According to the device and equipment for identifying the code change influence range, the editing engineering file is called to compile the source code file before change, the first compiling result file is generated, and the memory address range and the idle memory address range occupied by each function in the source code file before change can be determined through the first compiling result file. And acquiring a source code file after the change, determining an objective function with code change in the source code file after the change, and acquiring a first memory address range occupied by the objective function from a first editing result file. The first memory address range is the memory address range occupied by the objective function before the code change. And modifying the modified source code file to change the memory address range occupied by the target function in 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. Therefore, the first memory address range occupied by the target function before the code change is occupied by the null function, and the memory address range occupied by the function after the target function in the source code file after the change is not influenced by the change of the target function. The target function occupies a second memory address range within the free memory address range when the target source code file is compiled. The target function after the memory address range is adjusted occupies the idle memory address range, the memory address range occupied by the function in the subsequent code during compiling is not influenced, and the influence range 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 compiling according to the second compiling result file. Comparing the first compiling result file and the second compiling result file, the code change influence range after the objective function is changed can be determined. Therefore, the identification of the code change influence scope can be accurately realized, the subsequent confirmation of the code change influence scope is facilitated, the efficiency of software development is improved, and the quality of the developed software is ensured.
It should be noted that, in the present description, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different manner from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other. For the system or device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the relevant points refer to the description of the method section.
It should be understood that in this application, "at least one" means one or more, and "a plurality" means two or more. "and/or" for describing the association relationship of the association object, the representation may have three relationships, for example, "a and/or B" may represent: only a, only B and both a and B are present, wherein a, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship. "at least one of" or the like means any combination of these items, including any combination of single item(s) or plural items(s). 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 relational terms such as first and second, and the like are 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. Moreover, 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 one … …" does not exclude the presence of other like 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. The software modules may be disposed 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 range of influence of a code change, the method comprising:
invoking a compiling engineering file to compile a source code file before modification to generate a first compiling result file, wherein the first compiling result file comprises a memory address range and an idle memory address range occupied by each function in the source code file before modification;
acquiring a source code file after modification, determining a target function with code modification in the source code file after modification, and acquiring a first memory address range occupied by the target function when compiling the source code file before modification from the first compiling result file;
Changing the memory address range occupied by the target function in compiling by modifying the source code file after modification, and adding a null function at the corresponding position of the target function of the source code file after modification to generate a target source code file, so that the target function occupies a second memory address range in the idle memory address range when compiling the target source code file, and the null function occupies the first memory address range;
invoking 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 the code change.
2. The method of claim 1, wherein after determining the code change impact range, 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 according to claim 2, wherein the method further comprises:
determining whether the initial address of the memory address range occupied by the first objective function is the initial address of the first memory address range or not in a third compiling result file generated when the compiling engineering file is called to compile the changed source code file;
If yes, the source code file after the change is determined to be restored normally.
4. The method according to claim 2, wherein the generating the object source code file by modifying the modified source code file to change the memory address range occupied by the object function at the time of compiling and adding a null function at the corresponding position of the object function of the modified source code file includes:
adding a sector offset instruction to the target function in the source code file after the change, wherein the sector offset instruction to the target function is used for indicating that the target function occupies a second memory address range in the idle memory address range when compiling;
and determining the size of a null function according to the first memory address range, adding the null function before or after the target function of the source code file after the change, and generating the 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 the comparing the first compilation effort file and the second compilation effort file to determine a code change scope of influence comprises:
comparing the first compiling result file and the second compiling result file, and determining the part with the difference in the first compiling result file and the second compiling result file as a code change influence range.
7. The method according to claim 1 or 6, characterized in that the method further comprises:
highlighting the code change influence range.
8. An apparatus for identifying a range of influence of a code change, the apparatus comprising:
the first compiling unit is used for calling a compiling engineering file to compile the source code file before changing to generate a first compiling result file, and the first compiling result file comprises a memory address range and an idle memory address range occupied by each function in the source code file before changing;
the first determining unit is used for obtaining a source code file after modification, determining an objective function with code modification in the source code file after modification, and obtaining a first memory address range occupied by the objective function when the source code file before modification is compiled from the first compiling result file;
The modifying unit is used for modifying the memory address range occupied by the target function in compiling by modifying the source code file after modification, adding a null function at the corresponding position of the target function of the source code file after modification, and generating a target source code file so that the target function occupies a second memory address range in the free memory address range when compiling the target source code file, 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 and generating a second compiling result file;
and the comparison unit is used for comparing the first compiling result file and the second compiling result file and determining a code change influence range.
9. An apparatus for identifying a range of influence of a code change, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the method of identifying code change impact ranges of any of claims 1-7 when the computer program is executed.
10. A computer readable storage medium having instructions stored therein which, when run on a terminal device, cause the terminal device to perform the method of identifying code change impact ranges of any 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 CN112698832A (en) 2021-04-23
CN112698832B true 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
一种监测函数语义信息访存地址序列的方法;陈荔城;崔泽汉;包云岗;陈明宇;沈林峰;梁祺;;计算机研究与发展;20130515(05);全文 *
基于增量链接的PE文件信息隐藏技术研究;田祖伟;杨恒伏;罗阳旭;;计算机科学;20121215(12);全文 *

Also Published As

Publication number Publication date
CN112698832A (en) 2021-04-23

Similar Documents

Publication Publication Date Title
US7962832B2 (en) Method for detecting memory error
CN108459954B (en) Application program vulnerability detection method and device
CN108664394B (en) Memory leakage process tracing method and device
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
CN110209520B (en) Method and device for improving SSD (solid State disk) testing efficiency, computer equipment and storage medium
CN112905441A (en) Test case generation method, test method, device and equipment
CN112698832B (en) Method, device and equipment for identifying code change influence range
CN108196975B (en) Data verification method and device based on multiple checksums and storage medium
CN111240987A (en) Migration program detection method and device, electronic equipment and computer readable storage medium
CN109032612B (en) Interface calling method and device of hybrid application and computer readable storage medium
CN115456628A (en) Intelligent contract viewing method and device based on block chain, storage medium and equipment
CN114817047A (en) Compiler test method, case generation method and device and instruction storage structure
CN114610516A (en) Application program repairing method and device, computer equipment and storage medium
JP7050587B2 (en) Violation dependency detector and violation dependency detector
CN113704114A (en) Automatic testing method, device, equipment and medium for functional interface
CN112925561A (en) Software development method and device, computer equipment and storage medium
US11397662B2 (en) Method for debugging computer program, device employing method, and storage medium
CN112486497A (en) Compiling configuration file generation method and device, electronic equipment and storage medium
CN111338956A (en) Automatic pressure measurement method, device, equipment and storage medium
CN112527657B (en) Method and equipment for automatic pile insertion in unit test
CN111078549A (en) Code coverage rate processing method and device and computer equipment
CN115794651B (en) Conflict-free pile inserting method and system supporting multiple binaries
CN116627391B (en) UI component detection method, device, equipment and storage medium
CN115185844A (en) Method and device for testing application program

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