CN110262803A - A kind of generation method and device of dependence - Google Patents

A kind of generation method and device of dependence Download PDF

Info

Publication number
CN110262803A
CN110262803A CN201910584408.0A CN201910584408A CN110262803A CN 110262803 A CN110262803 A CN 110262803A CN 201910584408 A CN201910584408 A CN 201910584408A CN 110262803 A CN110262803 A CN 110262803A
Authority
CN
China
Prior art keywords
variable
function
custom
dependence
object file
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
CN201910584408.0A
Other languages
Chinese (zh)
Other versions
CN110262803B (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.)
Weichai Power Co Ltd
Original Assignee
Weichai Power Co Ltd
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 Weichai Power Co Ltd filed Critical Weichai Power Co Ltd
Priority to CN201910584408.0A priority Critical patent/CN110262803B/en
Publication of CN110262803A publication Critical patent/CN110262803A/en
Application granted granted Critical
Publication of CN110262803B publication Critical patent/CN110262803B/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/43Checking; Contextual analysis
    • G06F8/433Dependency analysis; Data or control flow analysis

Abstract

The application provides the generation method and device of a kind of dependence, this method obtains custom variable, custom function, reference to variable and the referencing function of the object file from the symbol table of object file, and based on the custom variable and reference to variable got, generate variable dependence, based on the custom function and referencing function got, generating function dependence is finally based on variable dependence and functional dependencies, generates the dependence between file.Without matching variable and function in all code modules, and the code module of existence function dependence, variable dependence is determined according to matching result, to generating dependence, therefore the time needed for saving matching process, improve the formation efficiency of dependence.

Description

A kind of generation method and device of dependence
Technical field
The application belongs to the generation method and device of technical field of data processing more particularly to a kind of dependence.
Background technique
When verifying code, it is thus necessary to determine that the dependence in environment in different code module between variable, function is closed System.
The existing method for obtaining variable, functional dependencies are as follows: the whole customized variables of detection and function in the environment, And customized variable and function are matched under full ambient engine, determine what customized variable or function were cited according to matching result The code module of customized variable or function is quoted in position and confirmation.
Due to needing to match customized variable and function at ambient, and with program development, generation for including under environment Code module is more and more, matches customized variable at ambient and function takes a long time, lead to the formation efficiency of dependence It is low.
Summary of the invention
In view of this, a kind of generation method and device for being designed to provide dependence of the application, existing for solving The problem for having the formation efficiency of dependence in technology low.
Technical solution is as follows:
The application provides a kind of generation method of dependence, comprising:
Each code module in environment is compiled respectively, generates object file;
For each object file, the symbol table of the object file is generated;Including at least in the symbol table should Custom variable, custom function, reference to variable and the referencing function of object file;
Obtained respectively from the symbol table custom variable of the object file, custom function, reference to variable with And referencing function, until getting custom variable, custom function, reference to variable and the reference in whole object files Function;
Based on the custom variable and reference to variable got, determination is matched customized with each reference to variable respectively Object file where variable is the dependent file of the reference to variable, generates variable dependence;
Based on the custom function and referencing function got, determination is matched customized with each referencing function respectively Object file where function is the dependent file of the referencing function, generating function dependence;
Based on variable dependence and functional dependencies, the dependence between file is generated.
Preferably, the custom variable for obtaining the object file respectively from the symbol table, custom function, Reference to variable and referencing function, until getting the custom variable in whole object files, custom function, reference change Amount and referencing function include:
Custom variable, the custom function of the object file are obtained from the symbol table, and are based on customized change Amount and the corresponding object file establish the first tables of data, are built based on custom function and the corresponding object file Vertical second tables of data;
Obtain the reference to variable and referencing function of the object file from the symbol table, and based on reference to variable, Referencing function and the corresponding object file establish third tables of data.
Preferably, described based on the custom variable and reference to variable that get, it determines and each reference to variable respectively Object file where matched custom variable is the dependent file of the reference to variable, generates variable dependence and includes:
For each reference to variable in the third tables of data, searched and the reference to variable in first tables of data Identical custom variable;
Determine the text that object file corresponding with the custom variable is relied in the first tables of data for the reference to variable Part generates variable dependence.
Preferably, described based on the custom function got and referencing function, it determines and each referencing function respectively Object file is the dependent file of the referencing function where matched custom function, and generating function dependence includes:
For each referencing function in the third tables of data, searched and the referencing function in second tables of data Identical custom function;
Determine the text that object file corresponding with the custom function is relied in the second tables of data for the referencing function Part, generating function dependence.
Present invention also provides a kind of generating means of dependence, comprising:
Compilation unit generates object file for being compiled respectively to each code module in environment;
First generation unit generates the symbol table of the object file for being directed to each object file;The symbol Custom variable, custom function, reference to variable and the referencing function of the object file are included at least in table;
First acquisition unit, for obtaining the custom variable of the object file respectively from the symbol table, making by oneself Adopted function, reference to variable and referencing function, until getting custom variable, the customized letter in whole object files Number, reference to variable and referencing function;
Second generation unit, for determining and each drawing respectively based on the custom variable and reference to variable got The object file where the custom variable of variable match is the dependent file of the reference to variable, generates variable dependence;
Third generation unit, for determining and each drawing respectively based on the custom function and referencing function got The object file where the matched custom function of function is the dependent file of the referencing function, generating function dependence;
4th generation unit generates the dependence between file for being based on variable dependence and functional dependencies Relationship.
Preferably, the first acquisition unit includes:
First obtain establish subelement, for obtained from the symbol table object file custom variable, from Defined function, and the first tables of data is established based on custom variable and the corresponding object file, it is based on custom function And the corresponding object file establishes the second tables of data;
Subelement is established in second acquisition, for obtaining the reference to variable of the object file from the symbol table and drawing Third tables of data is established with function, and based on reference to variable, referencing function and the corresponding object file.
Preferably, second generation unit includes:
Subelement is searched, each reference to variable for being directed in the third tables of data, in first tables of data Search custom variable identical with the reference to variable;
Subelement is generated, object file corresponding with the custom variable is the reference in the first tables of data for determining The file that variable is relied on generates variable dependence.
Preferably, the third generation unit includes:
Subelement is searched, each referencing function for being directed in the third tables of data, in second tables of data Search custom function identical with the referencing function;
Subelement is generated, object file corresponding with the custom function is the reference in the second tables of data for determining The file that function is relied on, generating function dependence.
Compared with prior art, above-mentioned technical proposal provided by the present application has the advantages that
From above-mentioned technical proposal it is found that obtaining making by oneself for the object file from the symbol table of object file in the application Adopted variable, custom function, reference to variable and referencing function, and based on the custom variable and reference to variable got, Variable dependence is generated, based on the custom function and referencing function got, generating function dependence is finally based on Variable dependence and functional dependencies generate the dependence between file.Without in all code modules Variable and function are matched, and determines the code module of existence function dependence, variable dependence according to matching result, from And dependence is generated, therefore the time needed for saving matching process, improve the formation efficiency of dependence.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is the present invention Some embodiments for those of ordinary skill in the art without creative efforts, can also basis These attached drawings obtain other attached drawings.
Fig. 1 is a kind of flow chart of the generation method of dependence disclosed in the present application;
Fig. 2 is the flow chart of the generation method of another dependence disclosed in the present application;
Fig. 3 is a kind of structural schematic diagram of the generating means of dependence disclosed in the present application.
Specific embodiment
To keep the purposes, technical schemes and advantages of the embodiment of the present application clearer, below in conjunction with the embodiment of the present application In attached drawing, the technical scheme in the embodiment of the application is clearly and completely described, it is clear that described embodiment is Some embodiments of the present application, instead of all the embodiments.Based on the embodiment in the application, those of ordinary skill in the art Every other embodiment obtained without making creative work, shall fall in the protection scope of this application.
The embodiment of the present application provides a kind of generation method of dependence, for determining variable in code module, function Between dependence avoid compile error in order to carry out the extension of code based on the dependence determined, verify.
By taking project development as an example, it is made of, is needing multiple code modules for the program code of the project development When a certain function of extension project or project, at least one code module can be individually developed, still, each code module is not Other code modules can be separated from and be individually present, pass through mutual reference to variable or mutual referencing function between code module Establish dependence.
It can determine that variable dependence between code module, functional dependence are closed using method provided in this embodiment System, so that it is determined that the dependence between code module out.
Specifically, as shown in Figure 1, the generation method may comprise steps of:
S101, each code module in environment is compiled respectively, generates object file.
Environment refers to exploitation environment or translation and compiling environment, and developing includes the program in machine code for forming exploration project in environment All code modules, each code module can be stored in the form of source file.
Translation and compiling environment refers to the environment being compiled using compiler to source file, generally includes to need to compile all Code module.
The source file of each code module in environment is compiled respectively, generates object file.
Object file refers to the binary file generated after compiling to source file, file suffixes .O.Source file refers to Be that the code come out with assembler language or high level language saves as the result after file.
S102, it is directed to each object file, generates the symbol table of the object file;It is included at least in the symbol table Custom variable, custom function, reference to variable and the referencing function of the object file.
It include function and variable in object file.Function includes custom function and referencing function, and variable includes Custom variable and reference to variable.
Custom function refers to the function defined in the object file, defines in each object file Function, can be cited in other object files, so that not needing to re-define function in different object files. Referencing function refers to function defined in other object files of object file reference.
For the static program code of a project, usually it is made of multiple code modules.To each code mould Block generates corresponding object file after being compiled.Then each object file is analyzed, generates object text The symbol table of part.Custom variable, custom function, reference to variable and reference letter in symbol table comprising the object file Number.
For each object file, the symbol table of the object file is obtained, to generate object text according to symbol table Dependence between part, so that it is determined that the dependence between corresponding code module out.
S103, the custom variable for obtaining the object file respectively from the symbol table, custom function, reference become Amount and referencing function, until getting the custom variable of whole object files, custom function, reference to variable and drawing Use function.
For multiple object files, oneself of the object file is successively obtained from the symbol table of each object file Defined variable, custom function, reference to variable and referencing function, until getting the customized change of whole object files Amount, custom function, reference to variable and referencing function.
By taking two object files as an example, two object files are 1.O and 2.O respectively.It is obtained from the symbol table of 1.O Get the custom variable of 1.O: data1, add1, custom function: Flash_Part1, Process1, reference to variable cie1 with And referencing function CRC32WithInitVal1.The custom variable of 2.O: data2, add2 is got from the symbol table of 2.O, Custom function: Flash_Part2, Process2, reference to variable cie2 and referencing function CRC32WithInitVal2.It is real Now get custom variable, custom function, reference to variable and the referencing function of each object file.
S104, based on the custom variable and reference to variable got, determination is matched with each reference to variable respectively Object file where custom variable is the dependent file of the reference to variable, generates variable dependence.
Still by taking two object files are 1.O and 2.O respectively as an example, it is assumed that the custom variable of 1.O includes A, and The reference to variable of 2.O includes A, then illustrates that 2.O refers to the custom variable A, 1.O of 1.O and relied on by reference to variable A in 2.O File, file dependence is established based on variables A between 1.O and 2.O.
S105, based on the custom function and referencing function got, determination is matched with each referencing function respectively Object file where custom function is the dependent file of the referencing function, generating function dependence.
Assuming that the custom function of 1.O includes a, and the referencing function of 2.O includes a, then illustrates that 2.O refers to oneself of 1.O Defined function a, 1.O establish file dependence based on function a between 1.O and 2.O by the file that referencing function a is relied in 2.O Relationship.
S106, variable dependence and functional dependencies are based on, generate the dependence between file.
For multiple object files, there may be variable dependences between object file, it is also possible to exist Functional dependencies are also possible to certainly there is no dependence, but no matter there are variable dependences between two object files Relationship or functional dependencies all determine between the two object files there are dependence, are based on this, generate file it Between dependence.
After generating the dependence between object file, it can determine between code module corresponding with object file Dependence, may thereby determine which code module refers to which code module.
Through the above technical solutions, obtaining making by oneself for the object file from the symbol table of object file in the present embodiment Adopted variable, custom function, reference to variable and referencing function, and based on the custom variable and reference to variable got, Variable dependence is generated, based on the custom function and referencing function got, generating function dependence is finally based on Variable dependence and functional dependencies generate the dependence between file.Without in all code modules Variable and function are matched, and determines the code module of existence function dependence, variable dependence according to matching result, from And dependence is generated, therefore the time needed for saving matching process, improve the formation efficiency of dependence.
For symbol table disclosed in the present embodiment, as shown in table 1,
Table 1
Type Bind Name
NOTYPE LOCAL UND
FILE LOCAL ABSCVNcalc.c
SECTION LOCAL .text_vle
SECTION LOCAL .ppc.EMB.apuinfo
SECTION LOCAL .debug_line
FUNC GLOBAL CVNcalc_GetStepNum
NOTYPE GLOBAL UND_cie
FUNC GLOBAL CVNcalc_clr
OBJECT GLOBAL CVNcalc_ctCRCStep
OBJECT GLOBAL CVNcalc_StrtAddr
OBJECT GLOBAL CVNcalc_data
FUNC GLOBAL CVNcalc_Process
NOTYPE GLOBAL UNDCRC32WithInitVal
OBJECT GLOBAL CVNcalc_data_sectionout
OBJECT GLOBAL CVNcalc_stSectionCal
FUNC GLOBAL CVNcalc_Eol_Rom_Flash_Part
OBJECT GLOBAL CVNcalc_CalOrder_Eol_Rom_Flash
OBJECT GLOBAL CVNcalc_data_init
In table 1, first is classified as type (type), and characterization variable is custom variable or reference to variable, and function is to make by oneself Adopted function or referencing function.Such as, for variable, Type value is OBJECT, then illustrates that the variable is custom variable.It is right For function, Type value is FUNC, then illustrates that the function is custom function.Either for function or variable, only Wanting Type value is NOTYPE, then illustrates that the function is referencing function or the variable is reference to variable.
Second is classified as binding (bind), and characterization variable is global variable or local variable, function be overall situation function or Local functions.Such as, for a variable, bind value is LOCAL, then illustrates that the variable is local variable, bind value is GLOBAL then illustrates that the variable is global variable.Function is identical as variable, and the bind value of function is LOCAL, then illustrates the function For local functions, bind value is GLOBAL, then illustrates that the function is overall situation function.
Third is classified as title (Name), characterizes the variable name of variable, the function name of function.
It is described below in detail based on symbol table shown in table 1, the method for generating dependence.
Shown in Figure 2, this method may comprise steps of:
S201, each code module in environment is compiled respectively, generates object file.
S202, it is directed to each object file, generates the symbol table of the object file;It is included at least in the symbol table Custom variable, custom function, reference to variable and the referencing function of the object file.
The symbol table of this step, each object file is as listed in Table 1, only the symbol table of different object files In include variable, function it is different.
S203, custom variable, the custom function that the object file is obtained from the symbol table, and be based on making by oneself Adopted variable and the corresponding object file establish the first tables of data, based on custom function and corresponding object text Part establishes the second tables of data.
Variable includes global variable and local variable, so that custom variable includes customized global variable and customized office Portion's variable only obtains the customized global variable of the object file herein from symbol table.
It is OBJECT that Bind value, which is GLOBAL and Type value, in symbol table, as the customized global change of the object file Amount, obtains the customized global variable of whole in all object files, and based on customized global variable and corresponding Object file establishes the first tables of data.
Wherein, tables of data can be Hash table, and the attribute of first row is Key in tables of data, indicate customized global variable Variable name, in table 1 third column shown in Name value it is identical, in tables of data the attribute of secondary series be values, expression The filename of object file, wherein there are corresponding relationships between filename and variable name.
By taking the corresponding object file (the entitled 1.O of the file of object file) of table 1 this symbol table as an example, acquisition is made by oneself Adopted global variable, and the first data established based on the customized global variable and corresponding object file got Table is as shown in table 2:
Table 2
Key values
CVNcalc_ctCRCStep 1.O
CVNcalc_StrtAddr 1.O
CVNcalc_data 1.O
CVNcalc_data_sectionout 1.O
CVNcalc_stSectionCal 1.O
CVNcalc_CalOrder_Eol_Rom_Flash 1.O
CVNcalc_data_init 1.O
First is classified as the customized global variable of whole in this object file of 1.O included in table 2, and second is classified as and makes by oneself The corresponding object file of adopted global variable, i.e., object file present in customized global variable.
Table 2 illustrates only the customized global change from the 1.O got in the symbol table of this object file of 1.O Amount.And so on, customized global variable is got respectively from the symbol table of each object file in full ambient engine respectively, And establish the first tables of data.
It is FUNC that Bind value, which is GLOBAL and Type value, in symbol table, as the customized global letter of the object file Number, obtains the customized overall situation function of whole in all object files, and based on customized overall situation function and corresponding Object file establishes the second tables of data.
Wherein, tables of data can be Hash table, and the attribute of first row is Key in tables of data, indicate customized overall situation function Function name, in table 1 third column shown in Name value it is identical, in tables of data the attribute of secondary series be values, expression The filename of object file, wherein there are corresponding relationships between filename and function name.
By taking the corresponding object file (the entitled 1.O of the file of object file) of table 1 this symbol table as an example, acquisition is made by oneself Adopted overall situation function, and the second data established based on the customized overall situation function and corresponding object file got Table is as shown in table 3:
Table 3
Key values
CVNcalc_GetStepNum 1.O
CVNcalc_clr 1.O
CVNcalc_Process 1.O
CVNcalc_Eol_Rom_Flash_Part 1.O
First is classified as the customized overall situation function of whole in this object file of 1.O included in table 3, and second is classified as and makes by oneself The corresponding object file of adopted overall situation function, i.e., object file present in customized overall situation function.
Table 3 illustrates only the customized global letter from the 1.O got in the symbol table of this object file of 1.O Number.And so on, customized overall situation function is got respectively from the symbol table of each object file in full ambient engine respectively, And establish the second tables of data.
S204, the reference to variable and referencing function that the object file is obtained from the symbol table, and based on reference Variable, referencing function and the corresponding object file establish third tables of data.
It is NOTYPE that Bind value, which is GLOBAL and Type value, in symbol table, as the reference to variable of the object file and is drawn Use function.Obtain the whole references to variable and referencing function in all object files.And it is based on reference to variable and correspondence Object file, referencing function and corresponding object file establish third tables of data.
Wherein, tables of data can be Hash table, and the attribute of first row is Key in tables of data, indicate the variable of reference to variable The function name of name or referencing function, identical as Name value shown in third column in table 1, the attribute of secondary series is in tables of data Values indicates the filename of object file, wherein there are corresponding relationships between filename and variable name, function name.
By taking the corresponding object file (the entitled 1.O of the file of object file) of table 1 this symbol table as an example, reference is obtained Function and reference to variable, and established based on the referencing function, reference to variable and corresponding object file got Third tables of data is as shown in table 4:
Table 4
Key values
UND_cie 1.O
UNDCRC32WithInitVal 1.O
First is classified as the whole referencing functions and reference to variable in this object file of 1.O included in table 4, and second is classified as Referencing function and the corresponding object file of reference to variable, i.e. object file present in referencing function or reference to variable.
Table 4 illustrates only referencing function and reference from the 1.O got in the symbol table of this object file of 1.O Variable.And so on, it gets referencing function respectively from the symbol table of each object file in full ambient engine respectively and draws With variable, and establish third tables of data.
It should be noted that in other embodiments, it is also based on the referencing function got and corresponding Object file is established to obtain third tables of data, and is established based on the reference to variable and corresponding object file got To the 4th tables of data.
S205, for each reference to variable in the third tables of data, search in first tables of data and draw with this With the identical custom variable of variable.
Reference to variable and custom variable are opposite, such as the custom variable A in 1.O is quoted by 2.O, this is customized Variables A is just reference to variable in 2.O, and the custom variable a in 2.O quoted by 1.O, custom variable a in 1.O just For reference to variable.Either still be used as reference to variable as custom variable, the essence of the variable be it is identical, the variable Variable name is identical.
To which the variable famous prime minister with reference to variable in third tables of data can be searched in the first tables of data according to variable name Same custom variable.
For example, in the first row of third tables of data include the two references to variable of data, cie, then, for data this Reference to variable, the sequential search data in the first row of the first tables of data.Similarly, to this reference to variable of cie, in the first data Sequential search cie in the first row of table.
S206, determine that object file corresponding with the custom variable is the reference to variable institute in first tables of data The file of dependence generates variable dependence.
Still for including the two references to variable of data, cie in the first row of third tables of data, in the first tables of data First row find data after, determine the filename of corresponding with data object file in the first tables of data, i.e., the With data with the values value of a line in the secondary series of one tables of data, such as values value is 1.O.Then determine that 1.O is third data The file that data is relied in table generates variable dependence.
Since first row includes reference to variable in third tables of data, and include in secondary series and reference to variable in first row One-to-one values value (filename of object file), thus for including data in the first row of third tables of data, The filename that object file corresponding with the data can be determined in third tables of data, i.e., in the secondary series of third tables of data With data with the values value of a line, such as values value is 2.O.Therefore after the first row of the first tables of data finds data, It can also be to rely on the customized change by object file corresponding with the reference to variable in the determination third tables of data The file of amount generates variable dependence.
Specially after the first row of the first tables of data finds data, it is determined that 2.O is to rely in the first tables of data certainly The file of defined variable data generates variable dependence.
S207, for each referencing function in the third tables of data, search in second tables of data and draw with this With the identical custom function of function.
Referencing function and custom function are opposite, such as the custom function add in 1.O is quoted by 2.O, this is made by oneself Adopted function add is just referencing function in 2.O, and the custom function clc in 2.O is quoted by 1.O, custom function clc It is just referencing function in 1.O.It is still either used as referencing function as custom function, the essence of the function is identical , the function name of the function is identical.
To which the function famous prime minister with referencing function in third tables of data can be searched in the second tables of data according to function name Same custom function.
For example, in the first row of third tables of data include the two referencing functions of clc, move, then, for clc this Referencing function, the sequential search clc in the first row of the second tables of data.Similarly, to this reference to variable of move, in the second data Sequential search move in the first row of table.
S208, determine that object file corresponding with the custom function is the referencing function institute in second tables of data The file of dependence, generating function dependence.
Still for including the two referencing functions of clc, move in the first row of third tables of data, in the second tables of data First row find clc after, determine the filename of corresponding with clc object file in the second tables of data, i.e., second With clc with the values value of a line in the secondary series of tables of data, such as values value is 1.O.Then determine that 1.O is in third tables of data The file that clc is relied on, generates functional dependencies.
Since first row includes referencing function in third tables of data, and include in secondary series and referencing function in first row One-to-one values value (filename of object file), thus for including clc in the first row of third tables of data, it can To determine the filename of corresponding with clc object file in third tables of data, i.e., in the secondary series of third tables of data and Clc with a line values value, as values value be 3.O.Therefore after the first row of the second tables of data finds clc, may be used also With by determining, object file corresponding with the referencing function is to rely on the custom function in the third tables of data File, generating function dependence.
Specially after the first row of the second tables of data finds clc, it is determined that 3.O is to rely on to make by oneself in the second tables of data The file of adopted function clc, generates functional dependencies.
S209, variable dependence and functional dependencies are based on, generate the dependence between file.
The dependence between file can be determined based on variable dependence, and, it is also true based on functional dependencies The dependence between file is made, two kinds of dependences are combined together and determine that the dependence between final file is closed System.
Such as based on the variable dependence generated in step S206, can determine based on variable data, between 1.O and 2.O There are dependences, so that it is determined that the dependence between file out.
Based on the functional dependencies generated in step S208, it can determine based on function clc, exist between 1.O and 3.O Dependence, so that it is determined that the dependence between file out.
In conjunction between 1.O and 2.O, there are dependences, and there are dependences between 1.O and 3.O, determine each text Dependence between part is that there are dependences with 2.O, 3.O respectively by 1.O.
The generation method of dependence disclosed in corresponding above-described embodiment, the present embodiment additionally provide a kind of dependence Generating means, shown in Figure 3, the generating means of the dependence include:
Compilation unit 301, the first generation unit 302, first acquisition unit 303, the second generation unit 304, third generate Unit 305 and the 4th generation unit 306.
Compilation unit 301 generates object file for being compiled respectively to each code module in environment;
First generation unit 302 generates the symbol table of the object file for being directed to each object file;It is described Custom variable, custom function, reference to variable and the referencing function of the object file are included at least in symbol table;
First acquisition unit 303, for obtained respectively from the symbol table object file custom variable, from Defined function, reference to variable and referencing function, until getting custom variable, the customized letter in whole object files Number, reference to variable and referencing function;
Second generation unit 304, for determining respectively and each based on the custom variable and reference to variable got Object file where the matched custom variable of reference to variable is the dependent file of the reference to variable, generates variable and relies on pass System;
Third generation unit 305, for determining respectively and each based on the custom function and referencing function got Object file where the matched custom function of referencing function is the dependent file of the referencing function, and generating function, which relies on, closes System;
4th generation unit 306, for be based on variable dependence and functional dependencies, generate file between according to The relationship of relying.
Through the above technical solutions, obtaining making by oneself for the object file from the symbol table of object file in the present embodiment Adopted variable, custom function, reference to variable and referencing function, and based on the custom variable and reference to variable got, Variable dependence is generated, based on the custom function and referencing function got, generating function dependence is finally based on Variable dependence and functional dependencies generate the dependence between file.Without in all code modules Variable and function are matched, and determines the code module of existence function dependence, variable dependence according to matching result, from And dependence is generated, therefore the time needed for saving matching process, improve the formation efficiency of dependence.
Optionally, first acquisition unit 303 includes: in other embodiments
Subelement is established in first acquisition and subelement is established in the second acquisition.
Subelement is established in first acquisition, for obtaining the customized change of the object file from the symbol table Amount, custom function, and the first tables of data is established based on custom variable and the corresponding object file, based on customized Function and the corresponding object file establish the second tables of data;
It is described second obtain establish subelement, for obtained from the symbol table reference to variable of the object file with And referencing function, and third tables of data is established based on reference to variable, referencing function and the corresponding object file.
Optionally, the second generation unit 304 includes:
It searches subelement and generates subelement.
The lookup subelement, each reference to variable for being directed in the third tables of data, in first data Custom variable identical with the reference to variable is searched in table;
The generation subelement, for determining, object file corresponding with the custom variable is to be somebody's turn to do in the first tables of data The file that reference to variable is relied on generates variable dependence.
Optionally, third generation unit 305 includes:
It searches subelement and generates subelement.
The lookup subelement, each referencing function for being directed in the third tables of data, in second data Custom function identical with the referencing function is searched in table;
The generation subelement, for determining, object file corresponding with the custom function is to be somebody's turn to do in the second tables of data The file that referencing function is relied on, generating function dependence.
The generation method and generating means of dependence provided by the present application can be applied to the change of project interface variable list Measure the verification of adduction relationship, the verification of Communications service list variable adduction relationship, variable, function phase between different code module The verification of mutual inclusion relation, greatly ensure that the accuracy of respective list, guarantee that exploitation input is correct.
For the various method embodiments described above, for simple description, therefore, it is stated as a series of action combinations, but Be those skilled in the art should understand that, the present invention is not limited by the sequence of acts described because according to the present invention, certain A little steps can be performed in other orders or simultaneously.Secondly, those skilled in the art should also know that, it is retouched in specification The embodiment stated belongs to preferred embodiment, and related actions and modules are not necessarily necessary for the present invention.
It should be noted that all the embodiments in this specification are described in a progressive manner, each embodiment weight Point explanation is the difference from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For device class embodiment, since it is basically similar to the method embodiment, so being described relatively simple, related place ginseng See the part explanation of embodiment of the method.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning Covering non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes that A little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article or The intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arranged Except there is also other identical elements in the process, method, article or apparatus that includes the element.
The foregoing description of the disclosed embodiments can be realized those skilled in the art or using the present invention.To this A variety of modifications of a little embodiments will be apparent for a person skilled in the art, and the general principles defined herein can Without departing from the spirit or scope of the present invention, to realize in other embodiments.Therefore, the present invention will not be limited It is formed on the embodiments shown herein, and is to fit to consistent with the principles and novel features disclosed in this article widest Range.
The above is only a preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered It is considered as protection scope of the present invention.

Claims (8)

1. a kind of generation method of dependence characterized by comprising
Each code module in environment is compiled respectively, generates object file;
For each object file, the symbol table of the object file is generated;The object is included at least in the symbol table Custom variable, custom function, reference to variable and the referencing function of file;
It obtains the custom variable of the object file, custom function, reference to variable respectively from the symbol table and draws With function, until getting the custom variable in whole object files, custom function, reference to variable and reference letter Number;
Based on the custom variable and reference to variable got, determine and the matched custom variable of each reference to variable respectively Place object file is the dependent file of the reference to variable, generates variable dependence;
Based on the custom function and referencing function got, determine and the matched custom function of each referencing function respectively Place object file is the dependent file of the referencing function, generating function dependence;
Based on variable dependence and functional dependencies, the dependence between file is generated.
2. generation method according to claim 1, which is characterized in that described obtain respectively from the symbol table should Custom variable, custom function, reference to variable and the referencing function of object file, until getting whole object texts Custom variable, custom function, reference to variable and referencing function in part include:
Obtain custom variable, the custom function of the object file from the symbol table, and based on custom variable with And the corresponding object file establishes the first tables of data, establishes based on custom function and the corresponding object file Two tables of data;
The reference to variable and referencing function of the object file are obtained from the symbol table, and based on reference to variable, reference Function and the corresponding object file establish third tables of data.
3. according to the method described in claim 2, it is characterized in that, described become based on the custom variable got and reference Amount, object file where the determining matched custom variable with each reference to variable is the dependence text of the reference to variable respectively Part, generating variable dependence includes:
For each reference to variable in the third tables of data, searched in first tables of data identical as the reference to variable Custom variable;
Determine the file that object file corresponding with the custom variable is relied in the first tables of data for the reference to variable, it is raw At variable dependence.
4. according to the method described in claim 2, it is characterized in that, it is described based on the custom function got and reference letter Number, object file where the determining matched custom function with each referencing function is the dependence text of the referencing function respectively Part, generating function dependence include:
For each referencing function in the third tables of data, searched in second tables of data identical as the referencing function Custom function;
Determine the file that object file corresponding with the custom function is relied in the second tables of data for the referencing function, it is raw At functional dependencies.
5. a kind of generating means of dependence characterized by comprising
Compilation unit generates object file for being compiled respectively to each code module in environment;
First generation unit generates the symbol table of the object file for being directed to each object file;In the symbol table Including at least the custom variable of the object file, custom function, reference to variable and referencing function;
First acquisition unit, for obtaining custom variable, the customized letter of the object file respectively from the symbol table Number, reference to variable and referencing function, until getting the custom variable in whole object files, custom function, drawing With variable and referencing function;
Second generation unit, for based on the custom variable and reference to variable got, determining and each reference to become respectively Object file where flux matched custom variable is the dependent file of the reference to variable, generates variable dependence;
Third generation unit, for being determined and each reference letter respectively based on the custom function and referencing function got Object file where the matched custom function of number is the dependent file of the referencing function, generating function dependence;
4th generation unit generates the dependence between file for being based on variable dependence and functional dependencies.
6. generating means according to claim 5, which is characterized in that the first acquisition unit includes:
First obtains and establishes subelement, for obtaining the custom variable, customized of the object file from the symbol table Function, and the first tables of data is established based on custom variable and the corresponding object file, based on custom function and The corresponding object file establishes the second tables of data;
Subelement is established in second acquisition, for obtaining the reference to variable and reference letter of the object file from the symbol table Number, and third tables of data is established based on reference to variable, referencing function and the corresponding object file.
7. generating means according to claim 6, which is characterized in that second generation unit includes:
Subelement is searched, for being searched in first tables of data for each reference to variable in the third tables of data Custom variable identical with the reference to variable;
Subelement is generated, object file corresponding with the custom variable is the reference to variable in the first tables of data for determining The file relied on generates variable dependence.
8. generating means according to claim 6, which is characterized in that the third generation unit includes:
Subelement is searched, for being searched in second tables of data for each referencing function in the third tables of data Custom function identical with the referencing function;
Subelement is generated, object file corresponding with the custom function is the referencing function in the second tables of data for determining The file relied on, generating function dependence.
CN201910584408.0A 2019-06-30 2019-06-30 Method and device for generating dependency relationship Active CN110262803B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910584408.0A CN110262803B (en) 2019-06-30 2019-06-30 Method and device for generating dependency relationship

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910584408.0A CN110262803B (en) 2019-06-30 2019-06-30 Method and device for generating dependency relationship

Publications (2)

Publication Number Publication Date
CN110262803A true CN110262803A (en) 2019-09-20
CN110262803B CN110262803B (en) 2023-04-18

Family

ID=67923504

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910584408.0A Active CN110262803B (en) 2019-06-30 2019-06-30 Method and device for generating dependency relationship

Country Status (1)

Country Link
CN (1) CN110262803B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112162776A (en) * 2020-09-04 2021-01-01 维沃移动通信有限公司 Dependency relationship obtaining method and device
CN113326047A (en) * 2021-06-10 2021-08-31 南京大学 C language code dependency relationship extraction method based on static analysis
CN113448553A (en) * 2021-06-23 2021-09-28 南京大学 C language project dependency information management and visualization method and system
CN117009230A (en) * 2023-07-25 2023-11-07 北京泰策科技有限公司 Accurate test method and system based on code coverage rate evaluation

Citations (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004246776A (en) * 2003-02-17 2004-09-02 Ricoh Co Ltd Automatic variable sharing compiler, automatic variable sharing linker and program development support system
KR20090104275A (en) * 2008-03-31 2009-10-06 한국항공우주산업 주식회사 Pairwise test case generation method based on module dependency and computer readable medium for recording program thereof
CN103778133A (en) * 2012-10-18 2014-05-07 阿里巴巴集团控股有限公司 Database object changing method and device
US20140150099A1 (en) * 2011-12-27 2014-05-29 Tencent Technology (Shenzhen) Company Limited Method and device for detecting malicious code on web pages
CN104866369A (en) * 2015-05-22 2015-08-26 广州华多网络科技有限公司 Data processing method and apparatus
CN104899147A (en) * 2015-06-19 2015-09-09 北京理工大学 Code static analysis method oriented to security check
CN105335137A (en) * 2014-07-23 2016-02-17 国际商业机器公司 Method and device used for processing source file
CN106294156A (en) * 2016-08-11 2017-01-04 北京邮电大学 A kind of static code fault detection analysis method and device
CN106469049A (en) * 2015-08-19 2017-03-01 腾讯科技(深圳)有限公司 A kind of method and device of file scan
CN107239458A (en) * 2016-03-28 2017-10-10 阿里巴巴集团控股有限公司 The method and device of development object relation is calculated based on big data
CN108153529A (en) * 2017-12-22 2018-06-12 杭州迪普科技股份有限公司 A kind of method and device of file compiling
CN108319858A (en) * 2018-01-29 2018-07-24 中国科学院信息工程研究所 For the data dependence graph construction method and device of uneasy total function
CN108614707A (en) * 2018-04-27 2018-10-02 深圳市腾讯网络信息技术有限公司 Static code inspection method, device, storage medium and computer equipment
CN109683957A (en) * 2018-11-28 2019-04-26 厦门中控智慧信息技术有限公司 The method and apparatus of Function Extension
CN109918078A (en) * 2019-01-23 2019-06-21 深圳壹账通智能科技有限公司 Code relies on management method, device, computer equipment and storage medium
EP3547121A1 (en) * 2017-01-11 2019-10-02 Nippon Telegraph and Telephone Corporation Combining device, combining method and combining program

Patent Citations (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004246776A (en) * 2003-02-17 2004-09-02 Ricoh Co Ltd Automatic variable sharing compiler, automatic variable sharing linker and program development support system
KR20090104275A (en) * 2008-03-31 2009-10-06 한국항공우주산업 주식회사 Pairwise test case generation method based on module dependency and computer readable medium for recording program thereof
US20140150099A1 (en) * 2011-12-27 2014-05-29 Tencent Technology (Shenzhen) Company Limited Method and device for detecting malicious code on web pages
CN103778133A (en) * 2012-10-18 2014-05-07 阿里巴巴集团控股有限公司 Database object changing method and device
CN105335137A (en) * 2014-07-23 2016-02-17 国际商业机器公司 Method and device used for processing source file
CN104866369A (en) * 2015-05-22 2015-08-26 广州华多网络科技有限公司 Data processing method and apparatus
CN104899147A (en) * 2015-06-19 2015-09-09 北京理工大学 Code static analysis method oriented to security check
CN106469049A (en) * 2015-08-19 2017-03-01 腾讯科技(深圳)有限公司 A kind of method and device of file scan
CN107239458A (en) * 2016-03-28 2017-10-10 阿里巴巴集团控股有限公司 The method and device of development object relation is calculated based on big data
CN106294156A (en) * 2016-08-11 2017-01-04 北京邮电大学 A kind of static code fault detection analysis method and device
EP3547121A1 (en) * 2017-01-11 2019-10-02 Nippon Telegraph and Telephone Corporation Combining device, combining method and combining program
CN108153529A (en) * 2017-12-22 2018-06-12 杭州迪普科技股份有限公司 A kind of method and device of file compiling
CN108319858A (en) * 2018-01-29 2018-07-24 中国科学院信息工程研究所 For the data dependence graph construction method and device of uneasy total function
CN108614707A (en) * 2018-04-27 2018-10-02 深圳市腾讯网络信息技术有限公司 Static code inspection method, device, storage medium and computer equipment
CN109683957A (en) * 2018-11-28 2019-04-26 厦门中控智慧信息技术有限公司 The method and apparatus of Function Extension
CN109918078A (en) * 2019-01-23 2019-06-21 深圳壹账通智能科技有限公司 Code relies on management method, device, computer equipment and storage medium

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112162776A (en) * 2020-09-04 2021-01-01 维沃移动通信有限公司 Dependency relationship obtaining method and device
CN112162776B (en) * 2020-09-04 2023-07-14 维沃移动通信有限公司 Dependency relationship acquisition method and device
CN113326047A (en) * 2021-06-10 2021-08-31 南京大学 C language code dependency relationship extraction method based on static analysis
CN113326047B (en) * 2021-06-10 2023-11-03 南京大学 C language code dependency relation extraction method based on static analysis
CN113448553A (en) * 2021-06-23 2021-09-28 南京大学 C language project dependency information management and visualization method and system
CN113448553B (en) * 2021-06-23 2023-11-03 南京大学 Method and system for managing and visualizing C language project dependent information
CN117009230A (en) * 2023-07-25 2023-11-07 北京泰策科技有限公司 Accurate test method and system based on code coverage rate evaluation
CN117009230B (en) * 2023-07-25 2024-04-16 北京泰策科技有限公司 Accurate test method and system based on code coverage rate evaluation

Also Published As

Publication number Publication date
CN110262803B (en) 2023-04-18

Similar Documents

Publication Publication Date Title
CN110262803A (en) A kind of generation method and device of dependence
Bogomolov et al. Authorship attribution of source code: A language-agnostic approach and applicability in software engineering
Rocha et al. DepthK: A k-Induction Verifier Based on Invariant Inference for C Programs: (Competition Contribution)
JP5527027B2 (en) Schema definition generation device, schema definition generation method, and schema definition generation program
CN110286934A (en) A kind of inspection method and device of static code
CN104992083A (en) Code obfuscation method and system for application
CN103176905B (en) A kind of Defect Correlation method and device
CN102508977B (en) Circuit optimization method for artificial circuit transplant and circuit optimization device for artificial circuit transplant
CN110096599A (en) The generation method and device of knowledge mapping
KR100650866B1 (en) Qualifying system and method for logic cell library
Raftery Contextual deduction theorems
Richa et al. Translating ATL model transformations to algebraic graph transformations
Song et al. QNNVerifier: A tool for verifying neural networks using SMT-based model checking
CN105468530A (en) Program error detection method and system based on finite-state machine
CN102012816B (en) Method and device for generating IDE engineering file and solution file
Fernández et al. Vector measure Maurey–Rosenthal-type factorizations and ℓ-sums of L1-spaces
Yu et al. Lemma learning in SMT on linear constraints
CN109325063B (en) Data management method and device
CN102663227A (en) Reliability modeling and solving method for complex voting system
Priya Topological sorting
ZHANG et al. SDG-based model validation in chemical process simulation
CN103229115B (en) Method and system for propagating the modification made to original to copy
CN105653525B (en) Method and system for importing data between account sets
Ellison et al. FortSP: a stochastic programming solver
US20240005100A1 (en) Control Unit to Map at least One Element in a Plurality of Documents and a Method therefor

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