CN109408034A - A kind of controlling stream graph building method of object-oriented program - Google Patents
A kind of controlling stream graph building method of object-oriented program Download PDFInfo
- Publication number
- CN109408034A CN109408034A CN201810221528.XA CN201810221528A CN109408034A CN 109408034 A CN109408034 A CN 109408034A CN 201810221528 A CN201810221528 A CN 201810221528A CN 109408034 A CN109408034 A CN 109408034A
- Authority
- CN
- China
- Prior art keywords
- node
- exception
- sentence
- stream
- control stream
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The present invention proposes a kind of controlling stream graph building method of object-oriented program, method includes the following steps: 1) constructing abstract syntax tree according to source code;2) Similar integral relational graph is constructed based on abstract syntax tree;3) it is the control stream subgraph of method construct coarseness according to sentence positional relationship, and then flows subgraph using node dismantling and virtual Finally nodal method to construct fine-grained control;4) the control stream of exception throws point and nested exception handling structure is analyzed using abnormal floating method;5) analytic method recalls information constructs the controlling stream graph based on sentence;6) merge the sentence set for not causing program execution order to change and form basic module, construct the controlling stream graph based on basic module.The building method of the invention is not only supported to analyze influence of the polymorphic feature to control stream, and supports the control flow analysis of the exception handling structure of multilayer nest.
Description
Technical field
The present invention relates to a kind of controlling stream graph building methods of object-oriented program, belong to Static Analysis of Programs: Techniques neck
Domain.
Background technique
Controlling stream graph is the abstraction of a process or program, and representing can traverse in a program process
All paths.To some process or program P, the controlling stream graph of P is usually indicated with four-tuple G=(N, E, Entry, Exit).Its
In, N is the set of node, and node includes basic module and two kinds of simple statement here, the former, which refers to, does not cause program execution suitable
The sentence set that sequence changes, the latter are that each simple statement is regarded as to a control stream node;E is the set on side, every
While be an ordered nodes to<ni, nj>, it indicates that from ni to nj, control that may be present shifts that (i.e. sentence ni can after having executed
Nj can be immediately performed);Entry and Exit respectively indicates the entrance and exit node of subprogram.Control flow analysis is software static state
The important component of analysis field, the even more important foundation of static analysis are widely used in program comprehension, software is analyzed, is soft
The fields such as part test.
The subject study of controlling stream graph focuses primarily upon the construction of controlling stream graph and the display to control flow analysis result.
Current main controlling stream graph building method has:
The finite automata building method that single Yongming in 1996 et al. proposes.This method is identifying and is extracting structured program
Controlling stream graph when establish an automaton model, but do not account in this model goto, break, continue,
Influence of the skip instructions such as return to controlling stream graph, and actual program control flowchart Construct Tool cannot avoid this
Problem.
The leader that Rothermel G in 2005 et al. is proposed instructs building method.This method defines leader instruction
First instruction, the target instruction target word of branch instruction and the instruction immediately following branch instruction of program entry point, process, and propose logical
Leader instruction is crossed to identify the basic module in controlling stream graph, and by program point relationship between basic module and
Branch jumps relationship to identify control stream side.But the definition of leader instruction here is adapted to structured program, towards right
It is clear that the definition that leader is instructed in the language of elephant will more be difficult to define, therefore leader instruction building method is difficult to adapt in face
To the construction of the controlling stream graph of object.
The syntax-directed translation method that 2010 Nian Sun Yongxins, Wu Jiapei, Yan great Shun et al. propose.This method proposition passes through language
Method guidance translation identifies the mode of basic module to construct controlling stream graph.This method solve the sentences such as goto in non-structural program
Control flow analysis problem, but the control flow analysis of nested exception handling structure is not furtherd investigate.
The abnormal matching construction method that Yanmei ZHANG in 2012 et al. proposes.This method proposes the abnormal type of matching to analyze
The control stream of exception handling structure, but this method is only capable of the non-nested exception control for supporting not including Finally keyword
Flow point analysis.However exception handling structure is to allow multilayer nest, and Finally keyword pair in many object oriented languages
Control the influence far part super exception catching catch of stream.
How the exception handling structure of multilayer nest is solved in the controlling stream graph building method of object-oriented program to control
The influence of stream is the emphasis of construction.Existing research achievement focuses primarily upon structuring syntactic property and simple exception handling structure
Control flow analysis, and these research achievements are difficult to move to the control of the object-oriented program comprising complicated exception handling structure
Flow graph processed constructs work.Therefore, particularly significant to the further investigation of the controlling stream graph of object-oriented program.
Summary of the invention
The present invention exactly for the technical problems in the prior art, provides one kind based on abstract syntax tree come construction face
To the controlling stream graph method of object program, comes to carry out syntax parsing to source code the present invention is based on abstract syntax tree, analyze
It is based in journey using the methods of node dismantling, abnormal matching, abnormal floating, virtual Finally, Similar integral relationship analysis to construct
The controlling stream graph of sentence is finally translated into the controlling stream graph based on basic module using basic module recognition methods.It should
Invention is not only supported to analyze influence of the polymorphic feature to control stream, and supports the control stream of the exception handling structure of multilayer nest
Analysis
The controlling stream graph building method of object-oriented program of the invention, includes the following steps:
Step 1 constructs corresponding abstract syntax tree according to source code;
Step 2 is based on abstract syntax tree and constructs Similar integral relational graph;
Step 3 according to sentence positional relationship be method construct coarseness control stream subgraph, and then using node disassemble with
And virtual Finally nodal method flows subgraph to construct fine-grained control;
Step 4 analyzes exception throws point and nested abnormality processing with abnormal floating method using abnormal matching process
The control stream of structure;
Step 5 analytic method recalls information constructs the controlling stream graph based on sentence;
Step 6 merges the sentence set for not causing program execution order to change and forms basic module, and construction is based on basic mould
The controlling stream graph of block.
Compared with prior art, the present invention mainly there is following some advantages:
(1) this method supports the control flow analysis of the nested exception handling structure comprising Finally keyword.Abnormality processing
Structure generally allows nesting, and Finally keyword is to the influence far part super exception catching catch of control stream.In the present invention
It handles influence of the Finally keyword to control stream by virtual Finally nodal method, while passing through abnormal matching and different
Normal floating method analyzes the control stream of nested exception handling structure.Compared with existing analysis method: existing structuring language
The research achievement (such as limited automechanism is made, leader instruction constructs, syntax-directed translation) of method feature is not supported to exception
The control flow analysis of processing structure;The research achievement (such as abnormal matching) of exception handling structure is still only supported not including
The control flow analysis of the non-nested exception handling structure of Finally keyword.
(2) this method is realized simple for the control flow analysis of multilayer nest compound statement, applied widely.It uses herein
Node disassembling method analyzes the control stream of nested compound statement, first by compound statement see it is integral analyze, then use
The internal structure that compound statement is analyzed with whole identical method obtains Local Subgraphs, if compound statement is multilayer nest,
Successively deeply, original compound statement node is constantly replaced with the Local Subgraphs of compound statement.Existing research achievement (if any
Limit automatic machine construction, leader instruction construction, syntax-directed translation etc.) in the key controlled in stream for analyzing nested compound statement
Step is the control flow direction of the substatement in determining compound statement, but these methods are primarily upon the compound language of simple nesting
, the control flow direction of the substatement in multilayer nest compound statement need to be made a concrete analysis of for the feature of source program, be not present
Unified analysis method.
(3) this method has versatility to the identification of basic module.Either leader in the research achievement summarized above
Building method or syntax-directed translation method are instructed, must then analyze specific language for the basic module in identification controlling stream graph
Method feature causes the building method proposed not have versatility.This method on the controlling stream graph based on sentence by merging letter
Single sentence node set forms basic module, also only needs to update the controlling stream graph based on sentence i.e. when changing language source code
Can, so that the identification of basic module has certain versatility.
(4) this method can obtain fine comprehensive controlling stream graph, carry out program comprehension, software convenient for software developer
The work such as analysis.Existing research achievement is difficult to analyze shadow of the polymorphic feature with nested exception handling structure to control stream simultaneously
It rings, it is difficult to precisely portray the control stream of object-oriented program.
Detailed description of the invention
Fig. 1 is architectural schematic of the invention, indicate the present invention involved in component and its between connection.
Fig. 2 is flow chart of the invention.
Fig. 3 is the Similar integral relational graph of embodiment;
The control stream subgraph of the considerations of Fig. 4 is embodiment exception handling structure semanteme;
Fig. 5 is the controlling stream graph based on basic module of embodiment.
Specific embodiment
In order to further enhance the appreciation and understanding of the invention, the technical solution of invention is carried out specifically with reference to the accompanying drawing
It is bright:
Fig. 1 gives the controlling stream graph tectonic system structure of object-oriented program.The tool of several major parts is given below
Body explanation.
1 abstract syntax tree resolution component
The major function of this component is that abstract syntax tree is parsed from source code.It is program source code, output that it, which is inputted,
For abstract syntax tree.
Abstract syntax tree is the structure for defining code in the form of a tree, is parsed generally from morphological analysis, syntactic analysis
Information is extracted in equal code compilation process to generate a parsing tree.All there is the abstract syntax tree of official in current most of language
Core Generator, therefore the working principle of this component is that existing abstract syntax tree is called to generate work according to the language form of source code
Tool, and encapsulate existing tool output.
2 Similar integral relationship analysis components
The major function of this component is based on abstract syntax tree come analysis classes inheritance.It is abstract syntax tree that it, which is inputted,
Output is Similar integral relational graph.
The working principle of this component are as follows: extract type declarations information first from abstract syntax tree and method claim information exists
Corresponding node is created in Similar integral relational graph, and then the interface type information or parent information that include in parsing type declarations come
The succession implementation relation between class or interface is obtained, is that side is inherited in corresponding node addition in Similar integral relational graph.
3 nodes disassemble analytic unit
The major function of this component is to be analyzed based on abstract syntax tree come the control stream to method.Its input is abstract
Syntax tree exports the method control stream subgraph to be a series of based on sentence.
The working principle of this component are as follows: construct method control stream of coarseness according to composite node positional relationship first
Figure, and then recurrence dismantling composite node is condition and substatement block, is constructed in substatement block according to statement semantics corresponding
Control stream subgraph, and forerunner's descendant node set of the composite node and the control stream side of the control stream subgraph interior joint are updated,
Recursive procedure operation finally updates corresponding section according to the semantic of skip instruction until including no longer composite node in method
The control stream side of point.
4 abnormality processing analytic units
The major function of this component is to be based on abstract syntax tree on the basis of method controls stream subgraph to nested exception
The control stream of reason structure is analyzed.It is abstract syntax tree and method control stream subgraph that it, which is inputted, is exported to have updated exception
Manage the method control stream subgraph of the control stream of structure.
The working principle of this component are as follows: abnormal throw is established according to the information of abstract syntax tree and method control stream subgraph first
The corresponding relationship of sentence and exception throws point out, and then the control stream of cycle analysis exception throws point.In analysis exception throws point
Control stream when, exception throws type is matched with the type at exception catching first in current exception handling structure,
If can match, it is throw point and capture point addition control stream side, otherwise current exception is put into nested exception handling structure
In carry out matching consideration, that is, operation of floating.If can not be matched always in operation of floating, it is considered as the exception of the throw point
Type will capture outside method, then establish throw point to the control stream side of method Egress node.
5 method call analytic units
The major function of this component be based on abstract syntax tree method control stream subgraph on the basis of to method call
Control stream is analyzed.It is abstract syntax tree, the method control stream subgraph based on sentence and Similar integral relational graph, output that it, which is inputted,
For the global controlling stream graph based on sentence.
The working principle of this component are as follows: first according to the information creation method tune of abstract syntax tree and method control stream subgraph
With the corresponding relationship of sentence and method call node, and then according to Similar integral relational graph come the corresponding time of lookup method call statement
Choosing method set and alternative approach node set is searched according to corresponding relationship, last method for building up calls node and alternative approach
The control stream side of node.
6 figure transition components
The major function of this component is to identify that basic module is based on to construct on the basis of based on the controlling stream graph of sentence
The controlling stream graph of basic module.Input is the global controlling stream graph based on sentence, is exported as the controlling stream graph based on basic module.
The working principle of this component are as follows: identify which node is simple statement node and is labeled as in figure first
Then combined is looped through, an extreme saturation is arbitrarily labeled the simple node of combined since figure,
Traversing a unmarked node for combined terminates, and the node traversed merges into a basic module node, mark
Be denoted as uncombined, the cyclic process until the node that no longer there is combined in figure, what circulation obtained when exiting
Figure is then the controlling stream graph based on basic module.
The present invention successively establishes abstract syntax tree, Similar integral relational graph, method control stream subgraph, base from source code
In intermediate results such as the global controlling stream graphs of sentence, the global controlling stream graph based on basic module is finally converted to.Specific step
Rapid following (shown in Figure 2):
Step 1 parses abstract syntax tree.According to being called existing abstract syntax tree raw according to the language form of source code
At tool, and encapsulate existing tool output.
Step 2 carries out Similar integral relationship analysis, establishes Similar integral relational graph.Specific steps are as follows:
(1) type declarations such as all classes, abstract class, anonymous class and interface information and its side are obtained from abstract syntax tree
Method claim information, creates the node in Similar integral relational graph, and node includes class name and method information defined in such.
(2) interface type information for including in type declarations or parent information are parsed further to obtain between class or interface
Succession implementation relation, be that side is inherited in the addition of corresponding node in Similar integral relational graph.
Step 3 carries out node dismantling analysis, establishes the method control stream subgraph based on sentence.Specific steps are as follows:
(1) the corresponding method claim information of method in abstract syntax tree is obtained, is constructed in the control stream subgraph of coarseness
Ingress node and Egress node.
(2) the sentence information for including in acquisition methods statement flows node for the control of each sentence builder, and according to sentence
Positional relationship addition control stream side, while control is added respectively for starting point and first statement and the last item sentence and terminal
Side is flowed, to obtain the controlling stream graph of coarseness.
(3) recurrence identification compound statement (such as conditional statement, Do statement etc.), disassemble be condition and substatement block,
Establish new control stream node for sentence in substatement block, and according to statement semantics update it is corresponding with original compound statement node before
Drive the control stream side of descendant node set.Recurrence disassembles the compound statement in substatement block, until every sentence does not have internal junction
Until structure.When recurrence disassembles abnormality processing sentence corresponding node, the part Finally, then added virtually if it does not exist
Finally node to carry out control flow analysis to the semantic of exception handling structure.
(4) the control stream side of corresponding node is updated according to the meaning of skip instruction.
Step 4 analyzes the control stream of exception handling structure on the basis of method controls stream subgraph.Specific steps are such as
Under:
(1) all sentence set comprising exception throws information, i.e. exception throws sentence collection are obtained from abstract syntax tree
It closes, and is controlled in stream subgraph from method and search corresponding node set, i.e. exception throws point set, establish exception throws point and different
Corresponding relationship between normal sentence of dishing out.
(2) the control stream of cycle analysis exception throws point checks that current exception throws point is corresponding in abstract syntax tree
Whether sentence is in exception handling structure.If being not in exception handling structure, exception throws point possesses arrival method and goes out
The control stream of mouth node;If identifying exception throws point by the information in abstract syntax tree in exception handling structure
Type carries out abnormal matching treatment.
(3) abnormal matching treatment: the Exception Type that current exception handling structure can be captured is different with exception throws point
Normal type is matched.If the Exception Type dished out is the Exception Type or subtype of capture, exception throws point and capture are established
The control stream side of exception (if exception throws point is Throw sentence, preferentially disconnects the control of exception throws point and its descendant node
System stream side);If can not match, which is subjected to abnormal floating processing.
(4) abnormal floating processing: check whether the exception handling structure where exception throws point corresponds to sentence is nested in it
In his exception handling structure.If being not in nested exception handling structure, establishes exception throws point and saved to corresponding Finally
The control stream side of point, while the last one Finally node on arrival method Egress node path is searched, it is added to method
The control stream side of Egress node;If in nested exception handling structure, by the Exception Type of exception throws point with it is nested
Exception handling structure supports that the Exception Type of capture is matched, if can match, establishes exception throws point and catchs the exception
Otherwise the exception throws point recurrence is carried out abnormal floating processing by the control stream side at place.
(5) it eliminates virtual Finally node: establishing the predecessor node set and rear-guard node of virtual Finally node
The control stream side of set, and delete virtual Finally node.
Step 5 carries out method call analysis, establishes global controlling stream graph.Specific step is as follows:
(1) the acquisition methods recalls information from abstract syntax tree obtains the affiliated class and method name letter of called method
Breath.
(2) alternative approach set is searched in Similar integral relational graph according to the affiliated class for the method for being called and method name.
(3) the corresponding sentence node of lookup method recalls information and all alternative approach collection in stream subgraph are controlled in method
Close corresponding method Ingress node and Egress node.
(4) adding method calls the control stream side of node and alternative approach entrance, Egress node.
Step 6 carries out basic module identification, establishes the controlling stream graph based on basic module.Specific step is as follows:
(1) whether had according to control stream node and only one entrance and exit marks whether the node should be closed
And if should be merged, it is labeled as combined, otherwise, is labeled as uncombined.
(2) marking all method entrance and exit nodes is uncombined.
(3) node for being is marked to begin stepping through from any, until traversing the section labeled as uncombined
Point, all combined node sets currently traversed merge into a basic module node, which is
uncombined.The node for being from next label continues traversal and merges operation, until no longer existing in figure
Labeled as the node of combined.
In short, the General Implementing process of this method are as follows: parsed by source code and obtain abstract syntax tree, in abstract syntax tree
On the basis of constructed respectively using Similar integral relationship analysis and node disassembling method Similar integral relational graph and method control stream
Figure;Then abnormal control flow analysis is carried out using abnormal matching and floating method on the basis of method controls stream subgraph;In conjunction with class
Inheritance figure is method call node checks alternative approach set, to construct global controlling stream graph;Finally by basic mould
Block identifying method converts thereof into the controlling stream graph based on basic module.
Embodiment:
For the convenience of description, suppose there is source code example simplified as follows:
1 example code of table
According to above-mentioned calculating step, successively implement:
Step 1 is according to the corresponding abstract syntax tree of the above code analysis:
It include three classes and an interface in source code in table 1, ConStrategyA class and ConStrategyB class are real
Strategy interface is showed, the discount method of Strategy interface of the calPrice method call in Context class.
Step 2 is based on abstract syntax tree and constructs Similar integral relational graph, as shown in Figure 3:
It include three type declarations nodes in the abstract syntax tree of source program, the nodename in corresponding diagram 3.Parse type
The method information that Fig. 3 interior joint is included can be obtained in the method claim information that statement includes.Further parsing type declarations include
Interface type information or parent information obtain the succession implementation relation of Fig. 3 interior joint.
Step 3 according to sentence positional relationship be method construct coarseness control stream subgraph, and then using node disassemble with
And virtual Finally nodal method flows subgraph to construct fine-grained control,
By taking calPrice method in Context as an example, the entrance and exit node of calPrice method is initially set up.
CalPrice method contains three variable declarations sentences, an abnormality processing sentence, a Return sentence.According to these
The sentence information of coarseness creates the node in controlling stream graph, and control stream side is added according to the positional relationship of sentence, obtains
To the controlling stream graph of coarseness.
Since abnormality processing sentence is compound statement, therefore further dismantling, Try, Catch in the sentence are successively established,
The control stream subgraph of Finally three parts, and the last one node of the part Finally is connected to original part Try
The last item sentence of the part Egress node S46, Try and the part Catch is connected to first node of the part Finally
S44.Due to another exception handling structure of the part Try nesting, then continue to be carried out according to the semanteme of exception handling structure into one
Step dismantling work (during dismantling, since the part Finally is not present, then correspondingly establishes virtual Finally node
VF1).The part Try of the exception handling structure of innermost layer includes this compound statement of While sentence, it is also desirable to be carried out into one
Step dismantling work.
Break skip instruction at S34 can also change control stream to a certain extent.If not considering to jump semanteme, S34
Possess the control stream side for reaching S27.Consider that S34's jumps semanteme, then S34 possesses the virtual Finally node reached outside circulation
The control stream of VF1.
Step 4 analyzes the control stream of the exception handling structure of exception throws point and nesting to update controlling stream graph, such as schemes
Shown in 4:
Above procedure includes S28 altogether, exception throws point at S30, S32 tri-.First consider exception throws point S30, it is current abnormal
The Exception Type of processing structure capture is matched, and due to being Throw sentence at S30, illustrates at runtime must at S30
Meeting throw exception, therefore the control stream side of S30 to S27 is deleted, add the control stream side of S30 to VF1.
Then consider exception throws point S32, the Exception Type of current exception handling structure capture can not be matching, carries out
Abnormal operation of floating.Foul this Exception Type exception handling structure nested with outer layer is supported to the Exception Type of capture
Strike is matched, since Foul is the subtype of Strike, successful match.It is Throw sentence at S32, when illustrating operation
S32 inherently throw exception, therefore the control stream side of S32 to S27 is deleted, the control stream side of addition S32 to VF1.
Finally consider exception throws point S28, successively undergoes abnormal matching treatment and abnormal floating processing operation, find S28
In the exception dished out can not be handled inside current method.Simultaneously because S28 is necessary before by outside exception throws method
Complete the part Finally execution, therefore add S20 to same layer nested structure Finally node VF1 control stream side, simultaneously
Searching the last one Finally node on VF1 to the path of method Egress node is S44, addition S44 to method Egress node
Control stream side.
Since VF1 is virtual Finally node, then needs to carry out elimination operation to it, add the predecessor node collection of VF1
It closes { S27, S28, S34, S39 } and arrives the control stream side of descendant node set { S44 }, while deleting VF1 node.
Step 5 analytic method calls, and side is called in addition between the Partial controll flow graph of each method:
By taking the discount method call in calPrice method as an example, the entitled discount of method belongs to Strategy
Interface.Strategy interface can be found from Similar integral relational graph possesses two realities of ConStrategyA and ConStrategyB
Existing class, and discount alternative approach is provided respectively.Therefore the discount method call S27 in calPrice method possesses arrival
The control stream of the discount method entrance and exit node of ConStrategyA and ConStrategyB class.
Step 6 merges the sentence set for not causing program execution order to change and forms basic module, and construction is based on basic mould
The global controlling stream graph of block, as shown in Figure 5:
According to whether having in controlling stream graph and whether only one entrance and exit marks the current statement structure should be by
Merge, wherein all method entrance and exit vertex ticks are uncombined, { S27, S28, S29, S31, S33, S44 } section
Point is uncombined comprising multiple entrances or exit marking, remaining node is all marked as combined.It is opened from S22 node
Begin traversal, and first set that should be merged found is { S22, S23, S24 }, merges into a basic module node, should
Basic module vertex ticks is uncombined.It next proceeds to traverse the node after the basic module node, until in figure
No longer there is the node for being labeled as combined.The controlling stream graph for completing the union operation formation of simple statement node is then by base
The controlling stream graph that control flow relation between this module is constituted.
It should be noted that above-described embodiment, is not intended to limit the scope of protection of the present invention, in above-mentioned technical proposal
On the basis of made equivalents or substitution each fall within the range that the claims in the present invention are protected.
Claims (7)
1. a kind of controlling stream graph building method of object-oriented program, which comprises the steps of:
Step 1 constructs corresponding abstract syntax tree according to source code;
Step 2 is based on abstract syntax tree and constructs Similar integral relational graph;
Step 3 is the control stream subgraph of method construct coarseness according to sentence positional relationship, and then utilizes node dismantling and void
Quasi- Finally nodal method flows subgraph to construct fine-grained control;
Step 4 analyzes exception throws point and nested exception handling structure with abnormal floating method using abnormal matching process
Control stream;
Step 5 analytic method recalls information constructs the controlling stream graph based on sentence;
Step 6 merges the sentence set for not causing program execution order to change and forms basic module, constructs based on basic module
Controlling stream graph.
2. the controlling stream graph building method of object-oriented program according to claim 1, which is characterized in that the step 1
It is middle specific as follows according to the corresponding abstract syntax tree of source code construction, it is called according to the language form of source code existing abstract
Syntax tree Core Generator, and encapsulate existing tool output.
3. the controlling stream graph building method of object-oriented program according to claim 1, which is characterized in that the step 2
In based on abstract syntax tree construct Similar integral relational graph, specific steps are as follows:
(1) type declarations such as all classes, abstract class, anonymous class and interface information and its method sound are obtained from abstract syntax tree
Bright information, creates the node in Similar integral relational graph, and node includes class name and method information defined in such;
(2) further parsing type declarations in include interface type information or parent information come obtain between class or interface after
Implementation relation is held, is that side is inherited in corresponding node addition in Similar integral relational graph.
4. the controlling stream graph building method of object-oriented program according to claim 1, which is characterized in that the step 3
The method control stream subgraph based on sentence, specific steps are established in middle progress node dismantling analysis are as follows:
(1) the corresponding method claim information of method in abstract syntax tree is obtained, the entrance in the control stream subgraph of coarseness is constructed
Node and Egress node;
(2) the sentence information for including in acquisition methods statement flows node for the control of each sentence builder, and according to the position of sentence
Relationship addition control stream side, while control stream is added respectively for starting point and first statement and the last item sentence and terminal
Side, to obtain the controlling stream graph of coarseness;
(3) recurrence identifies compound statement, and being disassembled is condition and substatement block, establishes new control for sentence in substatement block
Node is flowed, and updates the control stream side of forerunner's descendant node set corresponding with former compound statement node according to statement semantics.It passs
Return the compound statement in dismantling substatement block, until every sentence does not have internal structure.Abnormality processing language is disassembled in recurrence
When sentence corresponding node, the part Finally if it does not exist then adds virtual Finally node and carrys out language to exception handling structure
Justice carries out control flow analysis;
(4) the control stream side of corresponding node is updated according to the meaning of skip instruction.
5. the controlling stream graph building method of object-oriented program according to claim 1, which is characterized in that the step 4
In method control stream subgraph on the basis of the control stream of exception handling structure is analyzed, the specific steps are as follows:
(1) all sentence set comprising exception throws information, i.e. exception throws sentence set are obtained from abstract syntax tree, and
It is controlled in stream subgraph from method and searches corresponding node set, i.e. exception throws point set, establish exception throws point and abnormal throwing
Corresponding relationship between sentence out;
(2) the control stream of cycle analysis exception throws point checks the corresponding sentence of current exception throws point in abstract syntax tree
Whether in exception handling structure.If being not in exception handling structure, exception throws point possesses arrival method outlet section
The control stream of point;If identifying the type of exception throws point by the information in abstract syntax tree in exception handling structure,
Carry out abnormal matching treatment;
(3) abnormal matching treatment: the exception class of Exception Type and exception throws point that current exception handling structure can be captured
Type is matched, if the Exception Type dished out is the Exception Type or subtype of capture, is established exception throws point and is caught the exception
The control stream side at place;If can not match, which is subjected to abnormal floating processing;
(4) it is different abnormal floating processing: to check whether the exception handling structure where exception throws point corresponds to sentence is nested in other
In normal processing structure, if being not in nested exception handling structure, exception throws point is established to corresponding Finally node
Control stream side, while the last one Finally node on arrival method Egress node path is searched, it adds it and is exported to method
The control stream side of node;If in nested exception handling structure, by the Exception Type of exception throws point and nested exception
Processing structure supports that the Exception Type of capture is matched, if can match, establishes exception throws point and the place that catchs the exception
Otherwise the exception throws point recurrence is carried out abnormal floating processing by control stream side;
(5) it eliminates virtual Finally node: establishing the predecessor node set and rear-guard node set of virtual Finally node
Control stream side, and delete virtual Finally node.
6. the controlling stream graph building method of object-oriented program according to claim 1, which is characterized in that the step 5
Global controlling stream graph is established in middle progress method call analysis, the specific steps are as follows:
(1) the acquisition methods recalls information from abstract syntax tree obtains the affiliated class and method name information of called method;
(2) alternative approach set is searched in Similar integral relational graph according to the affiliated class for the method for being called and method name;
(3) the corresponding sentence node of lookup method recalls information and all alternative approach set pair in stream subgraph are controlled in method
The method Ingress node and Egress node answered;
(4) adding method calls the control stream side of node and alternative approach entrance, Egress node.
7. the controlling stream graph building method of object-oriented program according to claim 1, which is characterized in that the step 6
The controlling stream graph based on basic module is established in middle progress basic module identification, the specific steps are as follows:
(1) whether had according to control stream node and only one entrance and exit marks whether the node should be merged, if
It should be merged, be labeled as combined, otherwise, be labeled as uncombined;
(2) marking all method entrance and exit nodes is uncombined;
(3) node for being is marked to begin stepping through from any, until the node labeled as uncombined is traversed, when
Before all combined node sets for traversing merge into a basic module node, which is uncombined;
The node for being from next label continues traversal and merges operation, is labeled as until no longer existing in figure
The node of combined.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810221528.XA CN109408034B (en) | 2018-03-17 | 2018-03-17 | Control flow graph construction method for object-oriented program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810221528.XA CN109408034B (en) | 2018-03-17 | 2018-03-17 | Control flow graph construction method for object-oriented program |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109408034A true CN109408034A (en) | 2019-03-01 |
CN109408034B CN109408034B (en) | 2022-02-15 |
Family
ID=65464128
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810221528.XA Active CN109408034B (en) | 2018-03-17 | 2018-03-17 | Control flow graph construction method for object-oriented program |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109408034B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113449856A (en) * | 2020-03-27 | 2021-09-28 | 华为技术有限公司 | Control flow graph processing method and related equipment |
CN113672232A (en) * | 2021-07-09 | 2021-11-19 | 华为技术有限公司 | Program compiling method and device |
US20220413826A1 (en) * | 2021-06-23 | 2022-12-29 | Optum Technology, Inc. | Identifying protocol recommendations for application data objects |
CN117311678A (en) * | 2023-08-04 | 2023-12-29 | 四川大学 | Equivalent embedding method for synthesizing program module sequencing group function of AI system |
CN117311678B (en) * | 2023-08-04 | 2024-06-04 | 四川大学 | Equivalent embedding method for synthesizing program module sequencing group function of AI system |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101482847A (en) * | 2009-01-19 | 2009-07-15 | 北京邮电大学 | Detection method based on safety bug defect mode |
CN101937396A (en) * | 2010-09-30 | 2011-01-05 | 中国科学院软件研究所 | Detecting method of unsafe variable use in software program |
-
2018
- 2018-03-17 CN CN201810221528.XA patent/CN109408034B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101482847A (en) * | 2009-01-19 | 2009-07-15 | 北京邮电大学 | Detection method based on safety bug defect mode |
CN101937396A (en) * | 2010-09-30 | 2011-01-05 | 中国科学院软件研究所 | Detecting method of unsafe variable use in software program |
Non-Patent Citations (2)
Title |
---|
RAUL FECHETE: "Generating Control Flow Graphs", 《TECHNICAL REPORT 183/1-139,INSTITUTE FOR COMPUTER-AIDED AUTOMATION》 * |
宋道远等: "Java程序异常信息分析插件的研究与设计", 《计算机科学》 * |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113449856A (en) * | 2020-03-27 | 2021-09-28 | 华为技术有限公司 | Control flow graph processing method and related equipment |
US20220413826A1 (en) * | 2021-06-23 | 2022-12-29 | Optum Technology, Inc. | Identifying protocol recommendations for application data objects |
US11768673B2 (en) * | 2021-06-23 | 2023-09-26 | Optum Technology, Inc. | Identifying protocol recommendations for application data objects |
CN113672232A (en) * | 2021-07-09 | 2021-11-19 | 华为技术有限公司 | Program compiling method and device |
WO2023280078A1 (en) * | 2021-07-09 | 2023-01-12 | 华为技术有限公司 | Program compiling method and apparatus |
CN117311678A (en) * | 2023-08-04 | 2023-12-29 | 四川大学 | Equivalent embedding method for synthesizing program module sequencing group function of AI system |
CN117311678B (en) * | 2023-08-04 | 2024-06-04 | 四川大学 | Equivalent embedding method for synthesizing program module sequencing group function of AI system |
Also Published As
Publication number | Publication date |
---|---|
CN109408034B (en) | 2022-02-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104503754B (en) | A kind of design method for programming and compiling in robot graphic programming system | |
CN109408034A (en) | A kind of controlling stream graph building method of object-oriented program | |
Esparza | Decidability of model checking for infinite-state concurrent systems | |
CN113641586A (en) | Software source code defect detection method, system, electronic equipment and storage medium | |
CN103150200B (en) | A kind of C language is to the conversion method of MSVL language | |
CN110147235B (en) | Semantic comparison method and device between source code and binary code | |
CN1983295A (en) | Method and device for recognizing virus | |
CN110673854A (en) | SAS language compiling method, device, equipment and readable storage medium | |
CN110543421A (en) | Unit test automatic execution method based on test case automatic generation algorithm | |
CN106371887A (en) | System and method for MSVL compiling | |
CN109739494A (en) | A kind of API based on Tree-LSTM uses code building formula recommended method | |
CN106708739A (en) | Extended finite state machine (EFSM) model-based Web service case generation method and system | |
CN102117228A (en) | Dynamic and static combined Java program exception handling and optimization method | |
CN109190371A (en) | A kind of the Android malware detection method and technology of Behavior-based control figure | |
Höller | Translating totally ordered HTN planning problems to classical planning problems using regular approximation of context-free languages | |
Winter et al. | Integrating requirements: the Behavior Tree philosophy | |
Zhang et al. | Automated Extraction of Grammar Optimization Rule Configurations for Metamodel-Grammar Co-evolution | |
GB2366402A (en) | Syntax validation using syntax trees | |
Arora et al. | Code semantic detection | |
CN116431516A (en) | Program statement selection method and system for mutation test | |
De Lucia et al. | A two phase approach to design pattern recovery | |
Mouakher et al. | Event-based semantics of UML 2. X concurrent sequence diagrams for formal verification | |
Kaliappan et al. | On the formalization of UML activities for component-based protocol design specifications | |
Gotz et al. | Token analysis of graph-oriented process models | |
Wang et al. | Learning program representations with a tree-structured transformer |
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 |