CN114647575B - C++ inter-process exception analysis system and method based on higher-order function - Google Patents

C++ inter-process exception analysis system and method based on higher-order function Download PDF

Info

Publication number
CN114647575B
CN114647575B CN202210168542.4A CN202210168542A CN114647575B CN 114647575 B CN114647575 B CN 114647575B CN 202210168542 A CN202210168542 A CN 202210168542A CN 114647575 B CN114647575 B CN 114647575B
Authority
CN
China
Prior art keywords
exception
function
analysis
parameter
statement
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210168542.4A
Other languages
Chinese (zh)
Other versions
CN114647575A (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.)
Nanjing University of Posts and Telecommunications
Original Assignee
Nanjing University of Posts and Telecommunications
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 Nanjing University of Posts and Telecommunications filed Critical Nanjing University of Posts and Telecommunications
Priority to CN202210168542.4A priority Critical patent/CN114647575B/en
Publication of CN114647575A publication Critical patent/CN114647575A/en
Application granted granted Critical
Publication of CN114647575B publication Critical patent/CN114647575B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3608Software analysis for verifying properties of programs using formal methods, e.g. model checking, abstract interpretation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Debugging And Monitoring (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a C++ inter-process anomaly analysis system and method based on a higher-order function, which belongs to the technical field of function programming and program analysis, and comprises the following steps: determining the analysis sequence of each called sub-process in the process call graph, and classifying sentences in the C++ program; collecting the set constraint of each called sub-process exception related statement and function call statement, solving the set constraint according to the set constraint rule, and storing the exception analysis results of all called sub-processes into an exception analysis function abstract through a higher-order function form after obtaining the intra-process exception analysis information; and according to the parameter transfer mode of the function and the parameter information corresponding to the shape parameters and the real parameters, correspondingly substituting the parameter set information of the high-order function type abnormal analysis function abstract at a process call point. The invention reduces the space-time overhead of the traditional method for carrying out the process analysis on the abnormality by constructing the process abnormality control flow graph and solves the problem of lower abnormality analysis efficiency.

Description

C++ inter-process exception analysis system and method based on higher-order function
Technical Field
The invention relates to a C++ inter-process anomaly analysis system and method based on a high-order function, and belongs to the technical field of functional programming and program analysis.
Background
With the increasing size of software, the requirements of people on the quality of the software are higher and higher, and in order to improve the robustness of a software system, it is becoming more and more important to quickly and effectively analyze the anomalies in the program. The main problem concerned by traditional inter-process exception analysis is how to quickly find an exception handling program matched with a thrown exception under the condition of process call, and to check out the really uncaptured exception in the program and feed back the related information (such as unique identification of the exception, exception name and propagation path of the uncaptured exception). The main current inter-process anomaly analysis method is to traverse on the basis of an inter-process anomaly control flow graph to acquire inter-process anomaly related information. Although the method can intuitively display abnormal information on the graph, the improvement of the complexity of a software system leads to great space-time overhead of constructing an abnormal control flow graph in the process.
The set constraint method achieves the purpose of analyzing the specific problem by collecting the related set constraint information of the specific problem and solving the constraint according to a certain constraint solving rule. The invention collects the constraint of the anomaly correlation set, and provides an inter-process anomaly analysis method based on the high-order function by means of the characteristic of the high-order function in function programming, namely the function can be used as a parameter and a return value, so as to solve the problem of low anomaly analysis efficiency of the traditional method.
Disclosure of Invention
The invention aims to overcome the defects in the prior art, provides a C++ inter-process anomaly analysis system and a C++ inter-process anomaly analysis method based on a higher-order function, reduces space-time overhead of the traditional method for performing inter-process anomaly analysis on anomalies by constructing an inter-process anomaly control flow graph, and solves the problem of lower anomaly analysis efficiency.
In order to achieve the above purpose, the invention is realized by adopting the following technical scheme:
In a first aspect, the present invention provides a method for analyzing c++ inter-process anomalies based on higher-order functions, including:
determining the analysis sequence of each called sub-process in the process call graph, and classifying sentences in the C++ program;
collecting the set constraint of each called sub-process exception related statement and function call statement, solving the set constraint according to the set constraint rule, and storing the exception analysis results of all called sub-processes into an exception analysis function abstract through a higher-order function form after obtaining the intra-process exception analysis information;
according to the parameter transfer mode of the function, according to the parameter information corresponding to the shape parameters and the real parameters, parameter set information of the abstract of the high-order function type exception analysis function is substituted correspondingly at a process call point, so that exception analysis information in the process is transferred to the process call point between the processes, and an exception analysis result between the processes is obtained.
Further, determining an analysis sequence of each called sub-process in the process call graph, classifying the sentences in the C++ program, including:
Constructing a procedure call graph of a C++ program;
traversing the process call graph according to the reverse topology sequencing order, and determining the analysis order of the called sub-process;
After dividing sentences in the program into related sentences, procedure call sentences and common sentences, setting a propagation path label for tracking the uncaptured exception for each sentence.
Further, collecting the set constraint of each called sub-process exception related statement and function call statement, solving the set constraint according to the set constraint rule, and storing the exception analysis results of all called sub-processes into exception analysis function digests in a high-order function mode after obtaining the intra-process exception analysis information, wherein the method comprises the following steps:
Step 2-1) sequentially selecting a sub-process to be analyzed, and initializing set constraints of the sub-process to be analyzed, wherein the set constraints comprise an exception-related set constraint of a throw statement, a try-catch processing structure and a procedure call statement;
Step 2-2) collecting exception-related set constraints for the ith throw e i statement of the sub-process to be analyzed, wherein e i is a sub-expression of the throw statement.
Step 2-3) collecting abnormal related set constraints for an ith try-catch processing structure in the sub-process to be analyzed;
step 2-4) collecting abnormal related set constraints for an ith procedure call statement in the sub-process to be analyzed;
step 2-5) judging whether collection constraint of the exception related statement and the procedure call statement is completed or not, including:
when the collection constraint of the exception related statement and the procedure call statement is not completed, iteratively updating the collection constraint of each throw statement, the try-catch processing structure and the procedure call statement collected in the sub-process to be analyzed according to the steps 2-2) to 2-4), and then executing the step 2-5) again;
When all the set constraints of the related abnormal sentences and the process call sentences are collected, solving the set constraints according to the corresponding set constraint rules to obtain a complete in-process abnormal analysis result, and storing the result in a high-order function form to generate an abnormal analysis function abstract in the high-order function form.
Further, according to the parameter transfer mode of the function, according to the parameter information corresponding to the shape parameter and the real parameter, the parameter set information of the abstract of the exception analysis function of the higher-order function is substituted correspondingly at the process call point, so that the exception analysis information in the process is transferred to the process call point between the processes, and the process exception analysis result is obtained, which comprises:
Step 3-1) collecting abnormal related set constraints of the called process exception related sentences and the process call sentences, carrying out set constraint solving according to corresponding set constraint rules, obtaining an exception analysis result of the called process, and representing the exception analysis result as a higher-order function exception analysis function abstract;
Step 3-2) according to the parameter transfer mode of the function, carrying out corresponding substitution on a function parameter binary group set in the high-order function type exception analysis function abstract according to the corresponding parameter information between the shape parameter and the real parameter at a function call point, thereby transferring the exception analysis information of the called process to the process call point and obtaining an inter-process exception analysis result of the calling process;
Step 3-3) judging whether the exception analysis results of all called sub-processes are transmitted to corresponding process call points, including:
when the exception analysis results of all called sub-processes are not all transferred to the corresponding process call points, iteratively updating the exception analysis information of all the process call points in the program according to the steps 3-1) to 3-2), and then executing the step 3-3) again;
and when the exception analysis results of all called subprocesses are completely transferred to the corresponding process call points, acquiring complete inter-process exception analysis results.
Further, the in-process exception analysis information of all called sub-processes is saved as function abstract information in the form of a higher-order function, which is:
λx.({<ExIdi,ExNamei,[labeli]>}∪{<TypeXi,NameXi>})
Wherein x represents an initial symbolizing function parameter binary group set corresponding to a process P-shaped parameter, { < ExId i, ExNamei,[labeli ] > } represents related information of an uncaptured anomaly in the process, [ label i ] represents a propagation path of the uncaptured anomaly, label i represents a label corresponding to each statement, and the set { < TypeX i,NameXi > } represents type information and names of the actual parameter corresponding to the shape parameter.
Further, the anomaly analysis information comprises a unique identification of anomalies, anomaly names and propagation paths without capturing the anomalies, and the parameter information corresponding to the shape parameters and the real parameters comprises parameter types and parameter names.
In a second aspect, the present invention provides a c++ inter-process anomaly analysis system based on a higher-order function, including:
And a classification module: the method comprises the steps of determining the analysis sequence of each called subprocess in a process call graph, and classifying sentences in a C++ program;
and the collection constraint collection and solving module is used for: the method comprises the steps of collecting set constraints of related abnormal sentences and function call sentences of each called sub-process, solving the set constraints according to set constraint rules, and storing the abnormal analysis results of all called sub-processes into an abnormal analysis function abstract through a high-order function form after acquiring in-process abnormal analysis information;
And a result acquisition module: and the parameter set information of the abstract of the high-order function type anomaly analysis function is substituted correspondingly at the process call point according to the parameter transfer mode of the function and the parameter information corresponding to the real parameters, so that the anomaly analysis information in the process is transferred to the process call point between the processes, and the anomaly analysis result between the processes is obtained.
In a third aspect, the invention provides a C++ inter-process anomaly analysis device based on a higher-order function, which comprises a processor and a storage medium;
the storage medium is used for storing instructions;
the processor is operative according to the instructions to perform the steps of the method according to any one of the preceding claims.
In a fourth aspect, the present invention provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of any of the methods described above.
Compared with the prior art, the invention has the beneficial effects that:
1. The method and the device utilize the function as the high-order function characteristic of the parameter of another function, save the abnormal analysis result of the called sub-process in the program, and transmit the abnormal analysis result of the called sub-process to the process call point in a corresponding information transmission mode between the form parameters, thereby avoiding the need of additionally constructing an inter-process control flow graph to transmit the information of abnormal analysis in the traditional method, being capable of efficiently acquiring the abnormal analysis result between the C++ processes and further being beneficial to improving the reliability and the robustness of the program;
2. Based on the set constraint method, the invention collects the abnormal related set constraint for the abnormal related statement and the procedure call statement, solves the set constraint according to the related set constraint rule, combines the higher-order function characteristic in the function programming to generate the higher-order function type abnormal analysis function abstract, conveniently completes the information substitution of the parameter binary group set at the procedure call point as required, and finally feeds back the abnormal information among the procedures, thereby improving the abnormal analysis efficiency among the C++ program procedures.
Drawings
FIG. 1 is a flowchart of a method for analyzing anomalies between C++ processes based on a high-order function according to an embodiment of the present invention.
Detailed Description
The invention is further described below with reference to the accompanying drawings. The following examples are only for more clearly illustrating the technical aspects of the present invention, and are not intended to limit the scope of the present invention.
Embodiment one:
a C++ inter-process anomaly analysis method based on a higher-order function comprises the following steps:
step 1: determining the analysis sequence of each called sub-process, and classifying sentences in the program;
Step 2: collecting the set constraint of each called sub-process exception related statement and function call statement, solving the set constraint according to the set constraint rule to obtain in-process exception analysis information, and storing the exception analysis information (unique identification of exception, exception name, propagation path without capturing exception) of all called sub-processes as function abstract information in the form of a higher-order function.
Step 3: and (3) according to the parameter transfer mode of the function, according to the parameter information (parameter type and parameter name) corresponding to the shape parameter and the real parameter, correspondingly substituting the parameter set information of the higher-order function type exception analysis function abstract in the step (2) at a process call point, and transferring the exception analysis information in the process to the process call point between the processes to obtain an exception analysis result between the processes.
The program code selected in this embodiment is shown in table 1:
Table 1 example c++ code
The step 1 specifically includes:
step 1.1: constructing a procedure call graph of a C++ program;
step 1.2: traversing the process call graph according to the reverse topology sequencing order, and determining the analysis order of the called sub-process;
Step 1.3: the expressions in the program are divided into exception related statements (throw statement, try-catch processing structure), procedure call statements, normal statements, and a tag is set for each statement to track the propagation path of the uncaptured exception.
In this embodiment, the analysis order of the called sub-process is division→function→main.
The process division contains a throw statement (statement 9), which is the first throw statement of the division sub-process, and its label is set to T dlabel,1; the process function contains a throw statement (statement 15), which is the first throw statement of the function subprocess, the tag of which is set as T flabel,1, the process function contains a process call statement (statement 17), which is the first process call statement of the function subprocess, and the tag of which is set as FC flabel,1; the process main contains a try-catch processing structure, the tag of which is C mlabel,1, the sub-expression contains a procedure call statement (statement 25), the tag of which is FC mlabel,1, the tag of which contains a throw statement (statement 29), and the tag of which is T mlabel,1.
The step 2 specifically includes:
Step 2.1: sequentially selecting a subprocess to be analyzed, marking as P, and initializing set constraint of the process P, wherein the set constraint comprises an exception-related set constraint of a throw statement, a try-catch processing structure and a process call statement;
In this embodiment, firstly, exception analysis is performed on program sub-process division, and exception-related set constraints of exception-related statements and procedure call statements in the process division are collected.
The set constraint of the throw statement is initialized to null and the set constraint of the try-catch processing structure is initialized to null.
Step 2.2: collecting anomaly related set constraints for the ith throw e i statement of process P (its tag is set to T Plabel,i, which is used to record the source point of the anomaly)Where e i is a sub-expression of the throw statement.
Firstly, setting up a sub-expression e i abnormal related set constraint according to the type of the sub-expression in a throw statement, and marking as delta i;
the set χ Pthrow,i of uncaptured exceptions for the throw statement is the set of uncaptured exceptions corresponding to the sub-expression e i And union of anomaly sets thrown in throw, { < ExId i,ExNamei > }, i.e./>Wherein the elements in the set are a binary set < ExId i, ExNamei >, which represents the related information of the exception-the unique identifier ExId and the exception name ExName corresponding to the exception;
Throwstatement set constraint Can be expressed as/>
In this embodiment, the set constraint collected by the first throw statement (statement 9) of the sub-process division can be expressed as: ; the set constraint collected for the first throw statement (statement 15) for the sub-process function is: /(I) The set constraint collected for the first throw statement (statement 29) for the sub-process main can be expressed as:
Step 2.3: collecting exception-related set constraints for the ith try-catch processing structure in P (its tag is set to C Plabel,i)
As a further refinement of the present invention, the try-catch processing structure in the source program is represented here as:
Where { e j } is the set of sub-expressions in the try block, Representing an exception handling function (x represents the parameters of the function where the catch block is located,/>Representing a set of expressions to which the handler corresponds, τ i represents the type of exception that a catch block can capture), and "|" represents a logical OR, which is used to represent multiple catch blocks.
In this embodiment, expression 23-expression 33 may be represented as a try ({ e j }) catchWherein { e j } includes expression 24 and expression 25,/>Including expression 28 and expression 29,/>For expression 32, τ 1 is a division_by_zero exception and τ 2 is a BaseError exception.
If the process in which the catch block is located (denoted as f) contains the shape parameter x, thenThe parameter x in the process f is symbolized as a function parameter binary group set TS f={<Tfparai,Nfparai>},Tfparai which corresponds to the type of the ith shape parameter in the process f, and N fparai corresponds to the name of the ith shape parameter in the process f;
collecting abnormal related set constraints of e j of each sub-expression in the try block according to the type of the sub-expression, and recording as delta j; collecting each processing expression in the catch block according to the type of the sub-expression Abnormal related set constraint/>
Each item in the exception set thrown in the throw statement { < ExId i,ExNamei > } is sequentially matched with tau i (the exception type that can be captured by the catch statement), if so, the thrown exception < ExId i,ExNamei > is captured by the catch statement, and the corresponding processing expression set is executedIf the function call links are not matched, the exception is not captured, the exception will be propagated upwards to the call function along the call chain of the function, and the related information of the uncapped exception is recorded;
Anomalies that hesitate to be trapped may again be thrown in the catch block and cannot be trapped, so the uncaptured anomaly set for each processing expression e ki of the catch block may be represented as
The set χ Ptry-catch,i of uncaptured exceptions in the try-catch processing structure, including the set of exceptions thrown in throw but not captured by catch statements, can be expressed as:
try-catch handling structure set constraints Can be expressed as/>
In this embodiment, the set constraint of the try-catch processing structure (expression 23-expression 33) in the sub-process main can be expressed as: Where τ 1 is a division_by_zero exception and τ 2 is a BaseError exception.
Step 2.4: set up set constraints on the ith procedure call statement in P (set its tag to FC Plabel,i)
Setting set constraint of corresponding sub-expressions according to the type of the sub-expressions in the called process, marking the set of the sub-expressions in the process as { e j }, and marking the set constraint corresponding to each sub-expression as delta j;
Because the same process (denoted as m (x)) can be invoked in different classes, the class invoking the process is denoted as C i (which may be multiple), and the set of uncaptured exceptions corresponding to process m (x) in class C i is denoted as Consists of union of uncaptured anomalies of the corresponding sub-expression e m within the process volume, denoted/>I.e./>
Set constraints for procedure call statementsCan be expressed as/>
In this embodiment, the exception-related set constraint of the procedure call statement (statement 13) in the sub-procedure function may be expressed as: the exception-related set constraint of the procedure call statement (statement 19) in the sub-procedure main may be expressed as: /(I)
Step 2.5: and (3) iteratively updating the aggregate constraint of each throw statement, try-catch processing structure and process call statement collected in the process P according to the steps 2.2 to 2.4 to enable the aggregate constraint to reach a stable state (namely, all the aggregate constraints of the exception-related statements and the process call statements are collected), solving the aggregate constraint according to the corresponding aggregate constraint rule to obtain a complete intra-process exception analysis result (the related information of the exception-unique identification, the exception name and the propagation path of the uncaptured exception), and storing the result by using a high-order function form to generate an exception analysis function abstract in a high-order function form.
The information of the intra-process anomalies is expressed here in the form of higher-order functions as:
λx.({<ExIdi,ExNamei,[labeli]>}∪{<TypeXi,NameXi>})
Wherein x represents an initial symbolizing function parameter binary group set (recorded as TS P and representing symbolized parameter type and parameter name information) corresponding to a process P-shaped parameter, { < ExId i,ExNamei,[labeli ] > } represents related information of non-captured anomalies in the process, [ label i ] represents a propagation path of non-captured anomalies, label i represents a label corresponding to each statement, and the set { < TypeX i,NameXi > } represents type information and name of a real parameter corresponding to the parameter, so that the subsequent anomaly analysis result of the called sub-process is conveniently transmitted to a call point at the process call point according to the parameter transmission mode of the function and the corresponding information between the shape parameters, and the inter-process anomaly analysis result of the call process is obtained.
In this embodiment, the shape parameters int a and int b of the division sub-process may be initially signed as the parameter binary group set TS d={<Tdpara1,Ndpara1>,<Tdpara2,Ndpara2 > }, the shape parameters DerivedError & d of the function sub-process may be initially signed as the parameter binary group set TS f={<Tfpara1,Nfpara1 > }, and the shape parameters of the main process are null, so TS m =null.
In this embodiment, the constraint of the anomaly correlation set collected by each statement in each sub-process is solved according to the corresponding rule, and the obtained intra-process anomaly analysis result (the anomaly analysis function abstract of the higher-order function expression) can be represented as table 2.
TABLE 2 exception analysis function summary of higher order functions
Procedure name i Abnormality analysis function abstract EAS i
division λTSd.({<Division_by_zeroId,Division_by_zeroException,[Tdlabel,1]>}∪TSd)
function λTSf.({<DerivedErrorId,DerivedError,[Tflabel,1]>}∪TSf)
main λTSm.({<Division_by_zeroId,Division_by_zeroException,[Tmlabel,1]>}∪TSm)
The step 3 specifically includes:
Step 3.1: collecting abnormal related sentences of a called process (marked as Q) and abnormal related set constraints of the process call sentences according to the method in the step 2, carrying out set constraint solving according to corresponding set constraint rules to obtain an abnormal analysis result of the process Q, and representing the abnormal analysis result as a higher-order function type abnormal analysis function abstract;
Step 3.2: according to the parameter transfer mode of the function, corresponding substitution is carried out on the function parameter binary group set in the high-order function type exception analysis function abstract generated in the step 2.5 according to the corresponding parameter information (parameter type and parameter name) between the shape parameter and the real parameter at the function call point, so that exception analysis information of the process Q is transferred to the process call point, and an inter-process exception analysis result of the call process is obtained;
The transfer mode of the function parameters can be divided into value-based transfer and address-based (reference-based) transfer, if the parameters of the function are value-based, the exception analysis result at the calling site can be directly obtained through the higher-order function exception analysis function abstract, if the parameters of the function are address-based (reference-based) transfer, the exception analysis result of the called sub-process can be transferred to the calling process through the corresponding relation between the shape parameters and the real parameters, the instantiation of the higher-order function exception analysis function abstract is completed, and therefore the transfer of exception analysis information between the processes is realized, and the inter-process exception analysis result is obtained.
Step 3.3: and (3) iteratively updating the exception analysis information of all the procedure call points in the program according to the steps 3.1 and 3.2 to enable the exception analysis information to reach a stable state (exception analysis results of all called subprocesses are transmitted to corresponding procedure call points) and obtaining complete inter-procedure exception analysis results.
In this embodiment, as can be seen from the abstract of the high-order functional anomaly analysis function, the anomaly analysis result in the function process is: { < DerivedErrorId, derivedError, [ T flabel,1 ] > }, the exception analysis result of the called procedure division at the procedure call site (statement 17) (labeled FC flabel,1) is: lambda y. ({ < Division_by_ zeroId, division_by_ zeroException, [ T dlabel,1 ] > } > U.S. { < TypeY, nameY > }) according to the correspondence between the shape parameters and the real parameters, the variable y can be substituted by the function parameter binary set of the shape parameters of the corresponding Division process, wherein the function parameter binary set of the shape parameters is TS d, the exception analysis result of the Division process can be transferred to the call point through the corresponding parameter information of the shape real parameters, so the exception analysis result among the function processes is that :{<Division_by_zeroId,Division_by_zeroExceptio n,[Tdlabel,1,FCflabel,1]>,<DerivedErrorId,DerivedError,[Tflabel,1]>}.
Similarly, the exception analysis result in the main process is as follows: { < division_by_ zeroId, division_by_ zeroException, [ T mlabel,1 ] > }, the exception analysis result of the called procedure function at the procedure call site (statement 25) (labeled FC mlabel,1) is: lambda z. ({ < DerivedErrorId, derivedError, [ T flabel,1 ] > } > U.S. { < TypeZ, nameZ > }), the variable z can be substituted by the function parameter binary set of the corresponding function process form parameter through the corresponding relation between the form parameter and the real parameter, wherein the function parameter binary set of the form parameter is TS f, and the exception analysis result of the function process can be transmitted to the process call point in the main process through the corresponding parameter information of the form real parameter, so the exception analysis result among the main processes is that {<DerivedErrorId,DerivedError, [Tflabel,1]>,<Division_by_zeroId,Division_by_zeroException,[Tmlabel,1]>}.
The invention provides a C++ inter-process anomaly analysis method based on a higher-order function, which aims at the problem of large space-time overhead of the traditional inter-process anomaly analysis method, namely, constructing a huge inter-process anomaly control flow graph to transfer anomaly information in a process.
Embodiment two:
A C++ inter-process abnormality analysis system based on a higher-order function can realize the C++ inter-process abnormality analysis method based on the higher-order function according to the first embodiment, comprising:
And a classification module: the method comprises the steps of determining the analysis sequence of each called subprocess in a process call graph, and classifying sentences in a C++ program;
and the collection constraint collection and solving module is used for: the method comprises the steps of collecting set constraints of related abnormal sentences and function call sentences of each called sub-process, solving the set constraints according to set constraint rules, and storing the abnormal analysis results of all called sub-processes into an abnormal analysis function abstract through a high-order function form after acquiring in-process abnormal analysis information;
And a result acquisition module: and the parameter set information of the abstract of the high-order function type anomaly analysis function is substituted correspondingly at the process call point according to the parameter transfer mode of the function and the parameter information corresponding to the real parameters, so that the anomaly analysis information in the process is transferred to the process call point between the processes, and the anomaly analysis result between the processes is obtained.
Embodiment III:
the embodiment of the invention also provides a C++ inter-process abnormality analysis device based on a higher-order function, which can realize the C++ inter-process abnormality analysis method based on the higher-order function of the first embodiment, and comprises a processor and a storage medium;
the storage medium is used for storing instructions;
The processor is configured to operate according to the instructions to perform the steps of the method of:
determining the analysis sequence of each called sub-process in the process call graph, and classifying sentences in the C++ program;
collecting the set constraint of each called sub-process exception related statement and function call statement, solving the set constraint according to the set constraint rule, and storing the exception analysis results of all called sub-processes into an exception analysis function abstract through a higher-order function form after obtaining the intra-process exception analysis information;
according to the parameter transfer mode of the function, according to the parameter information corresponding to the shape parameters and the real parameters, parameter set information of the abstract of the high-order function type exception analysis function is substituted correspondingly at a process call point, so that exception analysis information in the process is transferred to the process call point between the processes, and an exception analysis result between the processes is obtained.
Embodiment four:
The embodiment of the present invention also provides a computer readable storage medium, which can implement the c++ inter-process anomaly analysis method based on the higher-order function according to the first embodiment, wherein a computer program is stored on the computer readable storage medium, and the program when executed by a processor implements the steps of the method:
determining the analysis sequence of each called sub-process in the process call graph, and classifying sentences in the C++ program;
collecting the set constraint of each called sub-process exception related statement and function call statement, solving the set constraint according to the set constraint rule, and storing the exception analysis results of all called sub-processes into an exception analysis function abstract through a higher-order function form after obtaining the intra-process exception analysis information;
according to the parameter transfer mode of the function, according to the parameter information corresponding to the shape parameters and the real parameters, parameter set information of the abstract of the high-order function type exception analysis function is substituted correspondingly at a process call point, so that exception analysis information in the process is transferred to the process call point between the processes, and an exception analysis result between the processes is obtained.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and variations could be made by those skilled in the art without departing from the technical principles of the present invention, and such modifications and variations should also be regarded as being within the scope of the invention.

Claims (7)

1. A C++ inter-process anomaly analysis method based on a higher-order function is characterized by comprising the following steps:
determining the analysis sequence of each called sub-process in the process call graph, and classifying sentences in the C++ program;
collecting the set constraint of each called sub-process exception related statement and function call statement, solving the set constraint according to the set constraint rule, and storing the exception analysis results of all called sub-processes into an exception analysis function abstract through a higher-order function form after obtaining the intra-process exception analysis information;
According to the parameter transfer mode of the function, according to the parameter information corresponding to the shape parameter and the real parameter, correspondingly substituting parameter set information of the abstract of the high-order function type abnormal analysis function at a process call point, and transferring the abnormal analysis information in the process to the process call point to obtain an abnormal analysis result between the processes;
Collecting the set constraint of each called sub-process exception related statement and function call statement, solving the set constraint according to a set constraint rule, and storing exception analysis results of all called sub-processes into exception analysis function abstracts through a high-order function after obtaining in-process exception analysis information, wherein the method comprises the following steps:
Step 2-1) sequentially selecting a sub-process to be analyzed, and initializing set constraints of the sub-process to be analyzed, wherein the set constraints comprise an exception-related set constraint of a throw statement, a try-catch processing structure and a procedure call statement;
step 2-2) collecting exception-related set constraints for an ith throw e i statement of the sub-process to be analyzed, wherein e i is a sub-expression of the throw statement;
step 2-3) collecting abnormal related set constraints for an ith try-catch processing structure in the sub-process to be analyzed;
step 2-4) collecting abnormal related set constraints for an ith procedure call statement in the sub-process to be analyzed;
step 2-5) judging whether collection constraint of the exception related statement and the procedure call statement is completed or not, including:
when the collection constraint of the exception related statement and the procedure call statement is not completed, iteratively updating the collection constraint of each throw statement, the try-catch processing structure and the procedure call statement collected in the sub-process to be analyzed according to the steps 2-2) to 2-4), and then executing the step 2-5) again;
When collection of all the set constraints of the related abnormal sentences and the process call sentences is completed, solving the set constraints according to corresponding set constraint rules to obtain a complete in-process abnormal analysis result, and storing the result in a high-order function form to generate an abnormal analysis function abstract in the high-order function form;
According to the parameter transfer mode of the function, according to the parameter information corresponding to the shape parameter and the real parameter, the parameter set information of the abstract of the exception analysis function of the higher-order function is substituted correspondingly at the process call point, so that the exception analysis information in the process is transferred to the process call point between the processes, and an inter-process exception analysis result is obtained, and the method comprises the following steps:
Step 3-1) collecting abnormal related set constraints of the called process exception related sentences and the process call sentences, carrying out set constraint solving according to corresponding set constraint rules, obtaining an exception analysis result of the called process, and representing the exception analysis result as a higher-order function exception analysis function abstract;
Step 3-2) according to the parameter transfer mode of the function, carrying out corresponding substitution on a function parameter binary group set in the high-order function type exception analysis function abstract according to the corresponding parameter information between the shape parameter and the real parameter at a function call point, thereby transferring the exception analysis information of the called process to the process call point and obtaining an inter-process exception analysis result of the calling process;
Step 3-3) judging whether the exception analysis results of all called sub-processes are transmitted to corresponding process call points, including:
when the exception analysis results of all called sub-processes are not all transferred to the corresponding process call points, iteratively updating the exception analysis information of all the process call points in the program according to the steps 3-1) to 3-2), and then executing the step 3-3) again;
and when the exception analysis results of all called subprocesses are completely transferred to the corresponding process call points, acquiring complete inter-process exception analysis results.
2. The c++ inter-process exception analysis method based on high-order functions according to claim 1, wherein determining the analysis order of each called sub-process in the process call graph classifies sentences in the c++ program, comprising:
Constructing a procedure call graph of a C++ program;
traversing the process call graph according to the reverse topology sequencing order, and determining the analysis order of the called sub-process;
After dividing sentences in the program into related sentences, procedure call sentences and common sentences, setting a propagation path label for tracking the uncaptured exception for each sentence.
3. The c++ inter-process exception analysis method based on the high-order function according to claim 1, wherein the in-process exception analysis information of all called sub-processes is saved as function digest information in the form of the high-order function:
λx.({<E xI di,E x Na m ei,[l a be li]>}∪{<TypeXi,NameXi>})
Wherein x represents an initial symbolization function parameter binary group set corresponding to the process P-shaped parameter,
{ < ExId i,ExNamei,[labeli > } indicates related information of an abnormality not captured in the process, [ label i ] indicates a propagation path of the abnormality not captured, label i indicates a tag corresponding to each sentence, and the set { < TypeX i,NameXi > } indicates type information and names of real parameters corresponding to the shape parameters.
4. The c++ inter-process anomaly analysis method based on a high-order function according to claim 1, wherein the anomaly analysis information includes unique identification of anomalies, anomaly names and propagation paths of the anomalies that are not captured, and the parameter information corresponding to the shape parameters and real parameters includes parameter types and parameter names.
5. A C++ inter-process anomaly analysis system based on a higher-order function is characterized by comprising:
And a classification module: the method comprises the steps of determining the analysis sequence of each called subprocess in a process call graph, and classifying sentences in a C++ program;
and the collection constraint collection and solving module is used for: the method is used for collecting the set constraint of each called sub-process exception related statement and function call statement, solving the set constraint according to the set constraint rule, and storing the exception analysis results of all called sub-processes into exception analysis function abstracts through a higher-order function form after obtaining the intra-process exception analysis information, and comprises the following steps:
Step 2-1) sequentially selecting a sub-process to be analyzed, and initializing set constraints of the sub-process to be analyzed, wherein the set constraints comprise an exception-related set constraint of a throw statement, a try-catch processing structure and a procedure call statement;
step 2-2) collecting exception-related set constraints for an ith throw e i statement of the sub-process to be analyzed, wherein e i is a sub-expression of the throw statement;
step 2-3) collecting abnormal related set constraints for an ith try-catch processing structure in the sub-process to be analyzed;
step 2-4) collecting abnormal related set constraints for an ith procedure call statement in the sub-process to be analyzed;
step 2-5) judging whether collection constraint of the exception related statement and the procedure call statement is completed or not, including:
when the collection constraint of the exception related statement and the procedure call statement is not completed, iteratively updating the collection constraint of each throw statement, the try-catch processing structure and the procedure call statement collected in the sub-process to be analyzed according to the steps 2-2) to 2-4), and then executing the step 2-5) again;
When collection of all the set constraints of the related abnormal sentences and the process call sentences is completed, solving the set constraints according to corresponding set constraint rules to obtain a complete in-process abnormal analysis result, and storing the result in a high-order function form to generate an abnormal analysis function abstract in the high-order function form;
And a result acquisition module: the method is used for correspondingly substituting parameter set information of the abstract of the high-order function type exception analysis function at a process call point according to parameter transfer modes of the function and corresponding parameter information of the real parameter, so that exception analysis information in a process is transferred to the process call point between the processes, and an inter-process exception analysis result is obtained, and comprises the following steps:
Step 3-1) collecting abnormal related set constraints of the called process exception related sentences and the process call sentences, carrying out set constraint solving according to corresponding set constraint rules, obtaining an exception analysis result of the called process, and representing the exception analysis result as a higher-order function exception analysis function abstract;
Step 3-2) according to the parameter transfer mode of the function, carrying out corresponding substitution on a function parameter binary group set in the high-order function type exception analysis function abstract according to the corresponding parameter information between the shape parameter and the real parameter at a function call point, thereby transferring the exception analysis information of the called process to the process call point and obtaining an inter-process exception analysis result of the calling process;
Step 3-3) judging whether the exception analysis results of all called sub-processes are transmitted to corresponding process call points, including:
when the exception analysis results of all called sub-processes are not all transferred to the corresponding process call points, iteratively updating the exception analysis information of all the process call points in the program according to the steps 3-1) to 3-2), and then executing the step 3-3) again;
and when the exception analysis results of all called subprocesses are completely transferred to the corresponding process call points, acquiring complete inter-process exception analysis results.
6. The C++ inter-process abnormality analysis device based on the higher-order function is characterized by comprising a processor and a storage medium;
the storage medium is used for storing instructions;
The processor being operative according to the instructions to perform the steps of the method according to any one of claims 1 to 4.
7. A computer readable storage medium having stored thereon a computer program, characterized in that the program when executed by a processor realizes the steps of the method according to any of claims 1-4.
CN202210168542.4A 2022-02-23 2022-02-23 C++ inter-process exception analysis system and method based on higher-order function Active CN114647575B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210168542.4A CN114647575B (en) 2022-02-23 2022-02-23 C++ inter-process exception analysis system and method based on higher-order function

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210168542.4A CN114647575B (en) 2022-02-23 2022-02-23 C++ inter-process exception analysis system and method based on higher-order function

Publications (2)

Publication Number Publication Date
CN114647575A CN114647575A (en) 2022-06-21
CN114647575B true CN114647575B (en) 2024-05-10

Family

ID=81994078

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210168542.4A Active CN114647575B (en) 2022-02-23 2022-02-23 C++ inter-process exception analysis system and method based on higher-order function

Country Status (1)

Country Link
CN (1) CN114647575B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115794592B (en) * 2023-02-10 2023-07-04 南京邮电大学 Data competition detection method based on higher-order function

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102117228A (en) * 2011-02-28 2011-07-06 复旦大学 Dynamic and static combined Java program exception handling and optimization method
CN103279421A (en) * 2013-06-14 2013-09-04 武汉大学 Program exception propagation model construction method based on data provenance technology
CN105912459A (en) * 2016-04-01 2016-08-31 北京理工大学 Detection method for array bound based on symbolic execution

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8719802B2 (en) * 2010-09-30 2014-05-06 Nec Laboratories America, Inc. Interprocedural exception method
US8631395B2 (en) * 2011-09-02 2014-01-14 Microsoft Corporation Inter-procedural dead catch handler optimizations

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102117228A (en) * 2011-02-28 2011-07-06 复旦大学 Dynamic and static combined Java program exception handling and optimization method
CN103279421A (en) * 2013-06-14 2013-09-04 武汉大学 Program exception propagation model construction method based on data provenance technology
CN105912459A (en) * 2016-04-01 2016-08-31 北京理工大学 Detection method for array bound based on symbolic execution

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种静态分析C~(++)异常处理的方法;姜淑娟;徐宝文;史亮;肖洋;;计算机科学;20060425(04);全文 *

Also Published As

Publication number Publication date
CN114647575A (en) 2022-06-21

Similar Documents

Publication Publication Date Title
CN111277578A (en) Encrypted flow analysis feature extraction method, system, storage medium and security device
US20080155335A1 (en) Graphical analysis to detect process object anomalies
CN111401418A (en) Employee dressing specification detection method based on improved Faster r-cnn
CN114726654B (en) Data analysis method and server for coping with cloud computing network attack
CN114647575B (en) C++ inter-process exception analysis system and method based on higher-order function
US11704186B2 (en) Analysis of deep-level cause of fault of storage management
CN115118482B (en) Industrial control system intrusion detection clue analysis and tracing method, system and terminal
CN115657890A (en) PRA robot customizable method
CN113138906A (en) Call chain data acquisition method, device, equipment and storage medium
CN113094269A (en) Application program test exception analysis method and device
CN117333038A (en) Economic trend analysis system based on big data
CN102193859B (en) Code analysis method and system
CN115829925A (en) Appearance defect detection method and device, computer equipment and storage medium
CN115687161A (en) Method for automatically generating interface test case based on scanning maven warehouse
Foidl et al. Data pipeline quality: Influencing factors, root causes of data-related issues, and processing problem areas for developers
Asaduzzaman Visualization and analysis of software clones
CN116700583A (en) Implementation method and device for process automation and storage medium
Hou et al. Collaborative workflow for analyzing large-scale data for antimicrobial resistance: An experience report
CN113570333B (en) Process design method suitable for integration
Varghese et al. Understanding Data Pre-processing with a Hybrid Diagram Integrating ER and Data Flow Notation
CN116886582B (en) Network security assessment recording method and system based on BP neural network
CN116680098B (en) Industrial robot safety monitoring method and device and electronic equipment
CN116869449B (en) Method and system for detecting faults of vaginal dilation device
CN115470925B (en) Quantum computer
CN117421611B (en) Method and system for filtering waste gas components of cement manufacturing plant

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