Static checking method and device for source code pairing

A static inspection and source code technology, applied in the computer field, can solve the problems of concealment and delay, difficulty in program debugging, busy waiting, etc., so as to improve the efficiency of pairing inspection, reduce the workload of programmers, and achieve high pairing inspection. The effect of efficiency

Active Publication Date: 2012-11-28
TSINGHUA UNIV
View PDF3 Cites 20 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

The source code pairing error is difficult to be directly discovered by the compiler, but it can bring hidden and delayed adverse consequences
For example, only applying for memory but not releasing it will lead to memory leaks, and unpaired locks and semaphores may cause deadlock and busy waiting
These pairing errors bring additional difficulties to program debugging
[0003] Usually, the source code matching work relies on developers to perform static manual inspection of the source code, relying on manual line-by-line scanning inspection of the code, which is less efficient and less accurate

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Static checking method and device for source code pairing
  • Static checking method and device for source code pairing
  • Static checking method and device for source code pairing

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0047] Embodiment 1, when unpaired elements to be paired appear in the main function, the pairing is added at the end of the main function.

[0048] Example 1.1 Add pairing at the end of the main function when unpaired memory elements appear in the main function.

[0049]

[0050] As shown in the above example, the pointer "a" of integer type applies for a memory space with a size of 50 words through malloc, and when the operation is completed, free(a) releases the memory space. If one of the operations is missing, it is incorrect. This method can check out the exception and prompt the program developer.

[0051] Example 1.2 When an unpaired lock element appears in the main function, add pairing at the end of the main function.

[0052]

[0053] As shown in the above example, the spin_lock lock test_lock locks the data through splin_lock, and other threads will be busy waiting if they perform the same operation. If one of the operations is missing, it is incorrect. Thi...

Embodiment 2

[0057] In the second embodiment, when unpaired elements to be paired appear in the sub-function, the pairing is added at the end of the sub-function.

[0058] Example 2.1 When an unpaired memory element appears in a sub-function, add a pair at the end of the sub-function.

[0059]

[0060] When an unpaired lock element and entropy element appear in a subfunction, the case of adding a pair at the end of the subfunction is similar to this example.

Embodiment 3

[0061] In the third embodiment, when unpaired elements to be paired appear in the branch structure, a pair is added at the end of each branch of the branch structure.

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention provides a static checking method and a static checking device for source code pairing. The method comprises the following steps of: performing lexical analysis on source codes, filtering annotation in the source codes, and splitting the source codes into a plurality of mark flows; performing syntactic analysis on the mark flows to construct a syntactic tree; performing semantic analysis on the syntactic tree, searching elements required to be paired, and marking an action region of the elements required to be paired; judging whether the elements required to be paired are paired in the action region or not; if the non-paired elements required to be paired are discovered, judging whether correction is allowed or not; if the correction is allowed, adding pairs at the end of the action region; and if the correction is not allowed, giving an alarm and a prompt. By the method, the pairing detecting efficiency can be effectively improved, stability of a system is improved, certain boundary errors are effectively avoided, user programs can be automatically corrected according to setting of a user, and the workload of a programmer is greatly reduced.

Description

technical field [0001] The invention relates to the field of computer technology, in particular to a static checking method and device for source code pairing. Background technique [0002] In the software development process, source code pairing is one of the important debugging and testing tasks. The source code pairing error is difficult to be directly discovered by the compiler, but it can bring hidden and delayed adverse consequences. For example, only applying for memory but not releasing it will lead to memory leaks, and unpaired locks and semaphores may cause deadlock and busy waiting. These pairing errors bring additional difficulties to program debugging. [0003] Usually, the source code matching work relies on developers to perform static manual inspection of the source code, relying on manual line-by-line scanning inspection of the code, which is low in efficiency and low in accuracy. Contents of the invention [0004] The present invention aims at solving ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F11/36
Inventor 胡事民刘虎球
Owner TSINGHUA UNIV
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products