CN106294169A - The detection of a kind of data contention based on semiology analysis virtual machine and playback method - Google Patents
The detection of a kind of data contention based on semiology analysis virtual machine and playback method Download PDFInfo
- Publication number
- CN106294169A CN106294169A CN201610679571.1A CN201610679571A CN106294169A CN 106294169 A CN106294169 A CN 106294169A CN 201610679571 A CN201610679571 A CN 201610679571A CN 106294169 A CN106294169 A CN 106294169A
- Authority
- CN
- China
- Prior art keywords
- instruction
- thread
- record
- function
- sub
- 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
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses the detection of concurrent program data contention and the method reset under a kind of embedded environment, in conjunction with the demand of software debugging Yu test, symbolization performs virtual machine approach, dynamically monitors the operation of program, the execution information of collection procedure, and analytical data competition.And by execution information, being determined property of program can also be reset so that the execution track of program can reappear.Function includes: data contention based on semiology analysis virtual machine detection, data contention playback based on semiology analysis virtual machine.The present invention can excavate the data contention hidden in a program, prevents multithread programs from operationally making a mistake.
Description
Technical field
The invention belongs to software debugging technical field, more particularly, to a kind of data based on semiology analysis virtual machine
Competition detection and playback method.
Background technology
Along with software size is increasing, the error detection of software test and program becomes more and more important.Existing
Software test and error-detecting method can be divided into static method and two kinds of methods of dynamic approach.Static method not actual motion journey
Sequence, calls the information such as figure, data flow diagram, controlling stream graph, execution analysis by analyzing in program source code, by these information and
The error model set up compares, thus the error code fragment that the program that detects may comprise.Dynamic approach is then by running journey
Sequence, analyzes the running orbit of program, mistake present in detection program.
The dynamic testing method of main flow includes the Valgrind that Nicholas Nethercot is researched and developed, Yi Jiying the most both at home and abroad
The Pin of Te Er company research and development, both binary system dynamically detects framework, by being decompiled into by executable program as middle generation
Code, detects at the enterprising line program of intermediate code, and then internal virtual machine performs source code again.
But, there are problems in existing dynamic testing method: first, Valgrind Yu Pin broadly falls into general detection block
Frame, binary code compiling becomes intermediate code, it is impossible to actively screens thread and shares data, monitored when data contention checks
Many redundancy memories, thus reduce the efficiency of detection;Additionally, Valgrind is internal realizes " shadow value " (shadow value)
Technology, the detection instrument realizing lightweight under this framework will also result in relatively large overhead;Finally, the detection under Pin framework is root
Realizing according to the physical interface provided, the function of interface is relatively fixed, therefore, it is difficult to meet the self-defined demand of user.
Summary of the invention
For disadvantages described above or the Improvement requirement of prior art, the invention provides a kind of based on semiology analysis virtual machine
Data contention detection and playback method, it is intended that solve present in existing method owing to monitoring too much redundancy memory
Cause detection efficiency expense low, detection process big and the technical problem of poor expandability.
For achieving the above object, according to one aspect of the present invention, it is provided that a kind of number based on semiology analysis virtual machine
According to competition detection and playback method, comprise the following steps:
(1) receive the program from host end and perform track operation request, and judge that this request is playback request, or
Detection request, if playback request, then enters step (2), otherwise enters step (5);
(2) judge whether log file corresponding to this playback request is present in disk, if there is then proceeding to step
(3), else process terminates;
(3) program obtained in log file performs message file, by obtaining the overall situation change in semiology analysis virtual machine
Amount read write command and/or multithreading function call instruction call detection function, to load between the instruction of log file thread
Constraints, and judge that global variable read write command and/or multithreading function call instruction whether can be by according to constraints
Perform, if can, performing step (4), else process terminates;
(4) performing global variable read write command and/or multithreading function instruction, process terminates;
(5) performing the multithread programs that detection request is corresponding in semiology analysis virtual machine, it is right to monitor between multiple thread
Global variable access in multithread programs, and record the multithreading sequencing to global variable access, and by these successively
Order information recorded in binary file, to generate program execution message file;
(6) obtain the command information in semiology analysis virtual machine, use in data contention detection algorithm detection command information
Global variable read-write, and utilize the multithreading function in multithreading function call interception funcall command information, to judge
Whether global variable read-write exists data contention, if it is reports to client by the information of data contention detection mistake, if
Program performs not terminate, then obtain and obtain next command information that the container of semiology analysis virtual machine is deposited, and forward step to
(5) perform.
Preferably, before this method is additionally included in step (1), semiology analysis virtual machine is carried out multithreading extension, with life
Become to have multithreading function call interception and the semiology analysis virtual machine of internal emulation multithreading function.
Preferably, semiology analysis virtual machine is performed the process of multithreading extension particularly as follows: first, by function pointer and
Structure build multithreading emulation realize framework, then for include thread creation, thread wait, thread lock and unblock at
The synchronous function of reason is written over.
Preferably, step (3) includes following sub-step:
(3-1) reading program performs message file, and program performs the log file write internal memory in message file;
(3-2) finger of multithread programs corresponding to detection request is chosen according to the track circulation that performs of semiology analysis virtual machine
Order, it is judged that whether instruction is reading instruction, write command, function call instruction, the most then proceed to step (3-3), otherwise according to symbol
The execution track performing virtual machine continues executing with this instruction;
(3-3) whether the memory address that decision instruction accesses is global variable, if yes then enter sub-step (3-4), no
The locking and de-locking function during then if this instruction is multithreading function call instruction, enter sub-step (3-4), otherwise according to symbol
Number perform virtual machine execution track continue executing with this instruction..
(3-4) according to the file record information of write internal memory, it is judged that whether present instruction exists dependence, if not existing
Dependence, then enter sub-step (3-5), otherwise obtains next instruction in semiology analysis virtual machine, and returns sub-step
(3-2) perform;
(3-5) present instruction is performed, the inter-instruction dependency relationship of releasing executed instructions, thus the literary composition of more newly written internal memory
Part record information, obtains next instruction in semiology analysis virtual machine, program not at the end of return sub-step (3-2) and perform,
Until EP (end of program).
Preferably, step (5) includes following sub-step:
(5-1) instruction performed by multithread programs that detection request is corresponding, and judge this instruction be whether reading instruction or
Write command, if yes then enter sub-step (5-2), this instruction is to lock instruction or unlock instruction else if, then performing
After locking or unlocking instruction, enter sub-step (5-2), otherwise continue executing with this according to the execution track of semiology analysis virtual machine and refer to
Order;
(5-2) whether the memory address that decision instruction accesses is global variable address, if it is, obtain global variable
Address, sets up the mapping relations of global variable address and numbering, obtains thread accesses global variable information, including thread number and
Vector time stamp, if instruction type is write command, then proceeds to sub-step (5-3), if instruction type is reading instruction, proceeds to sub-step
Suddenly (5-4);Otherwise continue executing with this instruction according to the execution track of semiology analysis virtual machine;
(5-3) collection of all read access records corresponding to this global variable is read according to the numbering that global variable address is corresponding
Close, travel through all of read access record, to each read access record according to following formal layout: by the thread number of read access record
Timestamp value corresponding to thread number that corresponding timestamp value is identical with current accessed record compares, and is less than if satisfied
In relation, do not process, otherwise show that two operations exist successively order relation, and carry out record.Finally by all read accesses
The vector time stamp of record merges with the vector time stamp of current accessed;
(5-4) collection of all write access records corresponding to this global variable is read according to the numbering that global variable address is corresponding
Close, to each write access record according to following formal layout: by timestamp value corresponding for the thread number of write access record with current
The timestamp value accessing the identical thread number of record corresponding compares, if meeting less than or equal to relation, does not deals with, no
Then show that two operations exist successively order relation, and carry out record.Finally by the vector time stamp of all write access records with work as
The vector time stamp of front access merges;
(5-5) set of all read and write access records is write log file, thus complete to perform the recording process of track.
Preferably, step (6) includes following sub-step:
(6-1) multithread programs that request is corresponding is performed, to obtain the instruction performed;
(6-2) by the type of the conditional branching structure decision instruction in semiology analysis virtual machine, if instruction refers to for reading
Make load or write command store, then proceed to sub-step (6-3);If instruction is function call instruction, then proceed to sub-step
(6-7);Instruct for other if instructed, then continue executing with this instruction according to the execution track of semiology analysis virtual machine, then return
Return sub-step (6-1);
(6-3) judge whether the memory address that this instruction accesses is global variable, is, proceed to sub-step (6-4), otherwise
Execution track according to semiology analysis virtual machine continues executing with this instruction, is then back to sub-step (6-1);
(6-4) judge whether this instruction is write access, if write access, then call and write process function callStore, and turn
Enter sub-step (6-5), if read access, then call reading and process function callLoad, and proceed to sub-step (6-6);
(6-5) according to the memory address addr of global variable, check whether global variable is first time write access, if
Then the timestamp of the thread number and thread that access this global variable is stored in write record, is then back to sub-step (6-
1);Otherwise take out the write record information of the memory address addr of global variable, including thread number and vector time stamp etc..Will be current
In the vector time stamp of thread, the timestamp value of the current thread of record compares with the timestamp value in write record information, if
The former is less than the latter, represents and data contention occurs, then report global variable write data contention mistake to client, the most not
Deal with, continuing to judge between twice write access, whether to there is concurrent read access mark simultaneously, if there is concurrent read access, then will
The timestamp value of the current thread of this write access record and the time of all concurrent read access record depositing twice write access
The timestamp value recording current thread in stamp vector compares, as long as meeting less than relation, representing and data contention occurs, then reporting
The read-write data contention mistake of announcement global variable, to client, empties all information deposited in concurrent read access record, updates
Write access record, is then back to sub-step (6-1), otherwise empties all information deposited in concurrent read access record, and renewal is write
Access record, be then back to sub-step (6-1).
(6-6) according to the memory address of global variable, check whether global variable is read access for the first time, if first
Secondary read access, then be stored in the timestamp value of thread number and thread in read record, is then back to sub-step (6-1);If
It not read access for the first time, then take out the write record information of the memory address of global variable, including thread number and vector time stamp
Deng, the timestamp value of current thread of record in the vector time stamp of current thread is compared with the timestamp value of record,
If both meet less than relation, represent and data contention occurs, then report data contention is to client, does not deals with, simultaneously
Continue to judge whether there is concurrent read access mark between twice write access, if there is concurrent read access, then by this read access
It is directly appended in the concurrent read access record that address is addr;Otherwise take out read access record information, including thread number and time
Between stamp vector etc., by the timestamp value of timestamp value and the record of the current thread of record in the vector time stamp of current thread
Comparing, if both meet less than relation, then update concurrent read access flag, adding this read access to address is
In the concurrent read access record of addr, then update the read access record that address is addr, and return sub-step (6-1);
(6-7) by the way of string matching, check that what function call instruction called currently calls whether function is multi-thread
Eikonal number, is to enter sub-step (6-8), otherwise continue executing with this instruction according to the execution track of semiology analysis virtual machine;
(6-8) at the function call instruction of semiology analysis virtual machine conditional branched structure, by string matching
The title of function is currently called in mode identification, and obtains the parameter of function, and title and parameter according to function judge currently to call
Function is thread creation function, or thread waits function, or locking function, or unlocks function, if thread creation
Function then proceeds to sub-step (6-9);If thread waits function, then proceed to sub-step (6-10);If locking function, then proceed to
Sub-step (6-11);If unblock function, then proceed to sub-step (6-12);
(6-9) calling thread creation function creation sub-line journey, sub-line journey initializes own timestamp vector, and with father's thread
Vector time stamp merge, simultaneously the timestamp value of father's thread from increase 1;
(6-10) call thread wait function, with by wait thread vector time stamp with by wait thread timestamp to
Amount merges;
(6-11) locking function is called, and after successfully locking, by the vector time stamp of thread and the timestamp of lock object
Vector merges;
(6-12) call unblock function, and after successfully unlocking, the vector time stamp of thread is given the time of lock object
Stamp vector.
In general, by the contemplated above technical scheme of the present invention compared with prior art, it is possible to show under acquirement
Benefit effect:
(1) detection efficiency of the present invention is high: owing to have employed monitoring in the method for the detection data contention of step (6)
It is read and write access and the access information of calling of synchronous function of global variable, and only saves last write access record,
Carry out global variable read-write data contention detect and write data contention detection time, it is only necessary to by current read-write record time
Between the timestamp value of timestamp value and last write access record compare and can judge whether data contention mistake, will
The time complexity degree of detection is reduced to constant time complexity by linear time complexity, and therefore detection efficiency has carried
High.
(2) detection overhead of the present invention is little: only judging instruction owing to have employed the sub-step (5-2) in step (5)
The memory address accessed just sets up the mapping relations of global variable address and numbering when being global variable address, during detection
Only storing the access record of global variable, whether the access of detection global variable exists data contention mistake, reduces detection and open
Pin.
(3) favorable expandability of the present invention: due to the semiology analysis virtual machine used in step of the present invention (3), it is being entered
In row multithreading expansion process, and rewrite thread creation, thread wait, thread locking and unblock process synchronous function, can
Extension realizes more synchronous function and detects, and extensibility is strong.
Accompanying drawing explanation
Fig. 1 is the general frame figure of the detection of present invention data contention based on semiology analysis virtual machine and playback method.
Fig. 2 is the flow chart of the detection of present invention data contention based on semiology analysis virtual machine and playback method.
Fig. 3 is data contention overhaul flow chart in the inventive method.
Fig. 4 is the flow chart of data contention record running orbit in the inventive method.
Fig. 5 is the flow chart of data contention playback method in the inventive method.
Detailed description of the invention
In order to make the purpose of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, right
The present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, and
It is not used in the restriction present invention.If additionally, technical characteristic involved in each embodiment of invention described below
The conflict of not constituting each other just can be mutually combined.
As it is shown in figure 1, the detection of present invention data contention based on semiology analysis virtual machine is whole with what playback method was based on
Body framework is to be made up of host end and target machine end.Host end runs graphic interface, sends data contention by network interface
The related command of detection is to target machine end, and processes the data sended over from target machine, carries out the process screening being correlated with, finally
It is shown to user;Target machine termination receives the order that host section sends over, and performs detection or the playback of data contention,
And execution information and testing result are sent to host end by network interface.The detection knot of data contention is received from target machine termination
After the execution information of fruit and program, by the parsing of information and classification, the testing result of data contention being shown in face
On plate, the execution track of program is plotted on other one piece of panel, checks for user.
As in figure 2 it is shown, the detection of present invention data contention based on semiology analysis virtual machine includes following step with playback method
Rapid:
(1) receive the program from host end and perform track operation request, and judge that this request is playback request, or
Detection request, if playback request, then enters step (2), otherwise enters step (5);Specifically, if the mark in Qing Qiu
Knowing position is replay, then this request is playback request, is otherwise detection request;
(2) judge whether log file corresponding to this playback request is present in disk, if there is then proceeding to step
(3), else process terminates;
(3) program obtained in log file performs message file, by obtaining semiology analysis virtual machine (symbolic
Virtual machine) in global variable read write command and/or multithreading function call instruction call detection function, to add
Carry the constraints between the instruction of log file thread, and judge global variable read write command and/or many according to constraints
Whether thread function call instruction can be performed, if can, performing step (4), else process terminates;In the present invention, make
Semiology analysis virtual machine be KLEE;
It should be noted that before the process of the present invention performs, need semiology analysis virtual machine is carried out multithreading expansion
Exhibition, has multithreading function call interception and the semiology analysis virtual machine of internal emulation multithreading function to generate.
Specifically, semiology analysis virtual machine is performed the process of multithreading extension particularly as follows: first, referred to by function
What pin and structure built multithreading emulation realizes framework, and then for synchronous function, (thread creation, thread wait, thread adds
Lock and unblock process) it is written over, wherein:
For thread creation function, in semiology analysis virtual machine, every instruction is as an execution route, execution route
There is independent execution environment, and all deposit in a reservoir, every execution route can be considered as a thread, the mistake of thread creation
Cheng Shouxian obtains command information, number of parameters, function address and concrete parameter information, and then is performed by call sign
The thread that virtual machine internal function creation is new, the information such as initialization thread number, and then the vector time stamp of each thread is carried out
Initializing, primary operational is that the timestamp value that this thread is corresponding is set to 1, and the timestamp value of other threads is set to 0, then will
Sub-line journey merges with the vector time stamp of father's thread, obtains new vector time stamp and is assigned to sub-line journey.Finally will create
Thread be stored in the container of semiology analysis virtual machine.
Wait function for thread, from the container of storage thread, take out the information waiting thread, it is judged that wait that thread is
No being over, if do not terminated, then for unclosed wait thread, calling the wait set of thread by waiting that thread adds
In, being waken up at the end of waiting thread, if terminated, then scanning sets of threads, wake up those threads waiting it up, and call
Thread does and relevant exits cleaning operation.
For thread locking function, first determine whether that this locks whether in lock set, for there is not the lock in lock set, table
Show and access for the first time this lock, create lock object, and lock is set for busy condition, be set to work as front by the thread of holding of lock
Journey, to being in the lock of idle condition, arranges lock for busy condition, the thread of holding of lock is set to current thread;To busy shape
The lock of state, is set to blocked state by current thread, is joined by current thread in the waiting list of lock, after lock release again
Obtain.
For thread UNLOCKS function, for being in the object of the lock of busy condition, when current thread is not held and currently locked
Return mistake;To not being the waiting list of empty lock, then take out the thread that queue starts most, the thread of holding of lock is set to this
Thread, and the waiting state of this thread is reset, represent that thread is no longer blocked state, be wherein empty lock to waiting list,
Then arranging lock is idle condition, and that removes lock holds thread.
(4) performing global variable read write command and/or multithreading function instruction, process terminates;
(5) performing the multithread programs that detection request is corresponding in semiology analysis virtual machine, it is right to monitor between multiple thread
Global variable access in multithread programs, and record the multithreading sequencing to global variable access, and by these successively
Order information recorded in the middle of binary file, to generate program execution message file;
(6) obtain the command information in semiology analysis virtual machine, use in data contention detection algorithm detection command information
Global variable read-write, and utilize the multithreading function in multithreading function call interception funcall command information, to judge
Whether global variable read-write exists data contention, if it is reports to client by the information of data contention detection mistake, if
Program performs not terminate, then obtain and obtain next command information that the container of semiology analysis virtual machine is deposited, and forward step to
(5) perform;
As it is shown on figure 3, the step of the inventive method (6) specifically includes following sub-step:
(6-1) multithread programs that request is corresponding is performed, to obtain the instruction performed;
(6-2) by the type of the conditional branching structure decision instruction in semiology analysis virtual machine, if instruction refers to for reading
Make load or write command store, then proceed to sub-step (6-3);If instruction is function call instruction, then proceed to sub-step
(6-7);Instruct for other if instructed, then continue executing with this instruction according to the execution track of semiology analysis virtual machine, then return
Return sub-step (6-1);
(6-3) judge whether the memory address that this instruction accesses is global variable, is, proceed to sub-step (6-4), otherwise
Execution track according to semiology analysis virtual machine continues executing with this instruction, is then back to sub-step (6-1);
(6-4) judge whether this instruction is write access, if write access, then call and write process function callStore, and turn
Enter sub-step (6-5), if read access, then call reading and process function callLoad, and proceed to sub-step (6-6);
(6-5) according to the memory address (describing for convenience, it is assumed that address is addr) of global variable, global variable is checked
Whether it is first time write access, if it is the timestamp of the thread number and thread that access this global variable is stored in and writes
In record, it is then back to sub-step (6-1);Otherwise take out the write record information of the memory address addr of global variable, including line
Journey number and vector time stamp etc..The timestamp value of the current thread of record in the vector time stamp of current thread is believed with write record
Timestamp value in breath compares, if the former is less than the latter, represents and data contention occurs, then report writing of global variable
Whether data contention mistake, to client, does not deals with, continue to judge to exist between twice write access concurrently to read to visit simultaneously
Asking mark, if there is concurrent read access, then the timestamp value of the current thread of this write access record being write visit with depositing twice
The timestamp value recording current thread in the vector time stamp of all concurrent read access record asked compares, as long as meeting little
In relation, represent and data contention occurs, then report that the read-write data contention mistake of global variable, to client, empties and deposits concurrently
All information in read access record, update write access record, are then back to sub-step (6-1), otherwise empty to deposit and concurrently read
Access all information in record, update write access record, be then back to sub-step (6-1).
(6-6) according to the memory address of global variable, check whether global variable is read access for the first time, if first
Secondary read access, then be stored in the timestamp value of thread number and thread in read record, is then back to sub-step (6-1);If
It not read access for the first time, then take out the write record information of the memory address of global variable, including thread number and vector time stamp
Deng, the timestamp value of current thread of record in the vector time stamp of current thread is compared with the timestamp value of record,
If both meet less than relation, represent and data contention occurs, then report data contention is to client, does not deals with, simultaneously
Continue to judge whether there is concurrent read access mark between twice write access, if there is concurrent read access, then by this read access
It is directly appended in the concurrent read access record that address is addr;Otherwise take out read access record information, including thread number and time
Between stamp vector etc., by the vector time stamp of current thread record the timestamp value of current thread enter with the timestamp value of record
Row compares, if both meet less than relation, then updates concurrent read access flag, and it is addr that this read access is added to address
Concurrent read access record in, then updating address is the read access record of addr, is then back to sub-step (6-1);
(6-7) by the way of string matching, check that what function call instruction called currently calls whether function is multi-thread
Eikonal number, is to enter sub-step (6-8), otherwise continue executing with this instruction according to the execution track of semiology analysis virtual machine;
(6-8) at the function call instruction of semiology analysis virtual machine conditional branched structure, by string matching
The title of function is currently called in mode identification, and obtains the parameter of function, and title and parameter according to function judge currently to call
Function is thread creation function, or thread waits function, or locking function, or unlocks function, if thread creation
Function then proceeds to sub-step (6-9);If thread waits function, then proceed to sub-step (6-10);If locking function, then proceed to
Sub-step (6-11);If unblock function, then proceed to sub-step (6-12);
(6-9) calling thread creation function creation sub-line journey, sub-line journey initializes own timestamp vector, and with father's thread
Vector time stamp merge, simultaneously the timestamp value of father's thread from increase 1;
(6-10) call thread wait function, with by wait thread vector time stamp with by wait thread timestamp to
Amount merges;
(6-11) locking function is called, and after successfully locking, by the vector time stamp of thread and the timestamp of lock object
Vector merges;
(6-12) call unblock function, and after successfully unlocking, the vector time stamp of thread is given the time of lock object
Stamp vector.
As shown in Figure 4, the step (5) of the inventive method includes following sub-step:
(5-1) instruction performed by multithread programs that detection request is corresponding, and judge this instruction be whether reading instruction or
Write command, if yes then enter sub-step (5-2), this instruction is to lock instruction or unlock instruction else if, then performing
After locking or unlocking instruction, enter sub-step (5-2), otherwise continue executing with this according to the execution track of semiology analysis virtual machine and refer to
Order;
(5-2) whether the memory address that decision instruction accesses is global variable address, if it is, obtain the ground of global variable
Location, sets up the mapping relations of global variable address and numbering, obtains thread accesses global variable information, including thread number with in time
Between stamp vector, if instruction type is write command, then proceeds to sub-step (5-3), if instruction type is reading instruction, proceed to sub-step
(5-4);Otherwise continue executing with this instruction according to the execution track of semiology analysis virtual machine;
(5-3) collection of all read access records corresponding to this global variable is read according to the numbering that global variable address is corresponding
Close, travel through all of read access record, to each read access record according to following formal layout: by the thread number of read access record
Timestamp value corresponding to thread number that corresponding timestamp value is identical with current accessed record compares, and is less than if satisfied
In relation, do not process, otherwise show that two operations exist successively order relation, and carry out record.Finally by all read accesses
The vector time stamp of vector time stamp and the current accessed of record merges, and merges referred to as: according to array index from little to
Two arrays of big order traversal, it is assumed that under when being designated as i, the higher value being designated as i under in two arrays is assigned to current accessed
Vector time stamp under be designated as the timestamp value of i.
(5-4) collection of all write access records corresponding to this global variable is read according to the numbering that global variable address is corresponding
Close, to each write access record according to following formal layout: by timestamp value corresponding for the thread number of write access record with current
The timestamp value accessing the identical thread number of record corresponding compares, if meeting less than or equal to relation, does not deals with, no
Then show that two operations exist successively order relation, and carry out record.Finally by the vector time stamp of all write access records with work as
The vector time stamp of front access merges, and merging process is: according to array index two arrays of order traversal from small to large,
When being designated as i under assuming, it is assigned to the higher value being designated as i under in two arrays under the vector time stamp of current accessed be designated as i's
Timestamp value;
(5-5) set of all read and write access records is write log file, thus complete to perform the recording process of track.
As it is shown in figure 5, the step of the inventive method (3) includes following sub-step:
(3-1) reading program performs message file, and program performs the log file write internal memory in message file;
(3-2) finger of multithread programs corresponding to detection request is chosen according to the track circulation that performs of semiology analysis virtual machine
Order, it is judged that whether instruction is reading instruction, write command, function call instruction, the most then proceed to step (3-3), otherwise according to symbol
The execution track performing virtual machine continues executing with this instruction;
(3-3) whether the memory address that decision instruction accesses is global variable, if yes then enter sub-step (3-4), no
The locking and de-locking function during then if this instruction is multithreading function call instruction, enter sub-step (3-4), otherwise according to symbol
Number perform virtual machine execution track continue executing with this instruction..
(3-4) according to the file record information of write internal memory, it is judged that whether present instruction exists dependence, if not existing
Dependence, then enter sub-step (3-5), otherwise obtains next instruction in semiology analysis virtual machine, and returns sub-step
(3-2) perform;
(3-5) present instruction is performed, the inter-instruction dependency relationship of releasing executed instructions, thus the literary composition of more newly written internal memory
Part record information, obtains next instruction in semiology analysis virtual machine, program not at the end of return sub-step (3-2) and perform,
Until EP (end of program).
As it will be easily appreciated by one skilled in the art that and the foregoing is only presently preferred embodiments of the present invention, not in order to
Limit the present invention, all any amendment, equivalent and improvement etc. made within the spirit and principles in the present invention, all should comprise
Within protection scope of the present invention.
Claims (6)
1. data contention based on a semiology analysis virtual machine detection and playback method, it is characterised in that comprise the following steps:
(1) receive the program from host end and perform track operation request, and judge that this request is playback request, or detection
Request, if playback request, then enters step (2), otherwise enters step (5);
(2) judge whether log file corresponding to this playback request is present in disk, if there is then proceeding to step (3), no
Then process terminates;
(3) program obtained in log file performs message file, reads by obtaining the global variable in semiology analysis virtual machine
Write command and/or multithreading function call instruction call detection function, to load the constraint between the instruction of log file thread
Condition, and judge whether global variable read write command and/or multithreading function call instruction can be performed according to constraints,
If can, performing step (4), else process terminates;
(4) performing global variable read write command and/or multithreading function instruction, process terminates;
(5) in semiology analysis virtual machine, perform the multithread programs that detection request is corresponding, monitor between multiple thread multi-thread
Global variable access in Cheng Chengxu, and record the multithreading sequencing to global variable access, and by these sequencings
Information recorded in binary file, to generate program execution message file;
(6) obtaining the command information in semiology analysis virtual machine, use in data contention detection algorithm detection command information is complete
Office's variable read-write, and utilize the multithreading function in multithreading function call interception funcall command information, to judge the overall situation
Whether variable read-write exists data contention, if it is reports to client by the information of data contention detection mistake, if program
Perform not terminate, then obtain next command information deposited of container obtaining semiology analysis virtual machine, and forward step (5) to and hold
OK.
Data contention the most according to claim 1 detection and playback method, it is characterised in that be additionally included in step (1) it
Before, semiology analysis virtual machine is carried out multithreading extension, with generation, there is multithreading function call interception and internal emulation is multi-thread
The semiology analysis virtual machine of Cheng Gongneng.
Data contention the most according to claim 2 detection and playback method, it is characterised in that semiology analysis virtual machine is held
The process of row multithreading extension particularly as follows: first, realizes framework, so by what function pointer and structure built multithreading emulation
After for include thread creation, thread wait, thread lock and unblock process synchronous function be written over.
Data contention the most according to claim 1 detection and playback method, it is characterised in that step (3) includes following son
Step:
(3-1) reading program performs message file, and program performs the log file write internal memory in message file;
(3-2) instruction of multithread programs corresponding to detection request is chosen according to the track circulation that performs of semiology analysis virtual machine,
Whether decision instruction is reading instruction, write command, function call instruction, the most then proceed to step (3-3), otherwise hold according to symbol
The execution track of row virtual machine continues executing with this instruction;
(3-3) whether the memory address that decision instruction accesses is global variable, if yes then enter sub-step (3-4), the most such as
Locking and de-locking function during really this instruction is multithreading function call instruction then enters sub-step (3-4), otherwise holds according to symbol
The execution track of row virtual machine continues executing with this instruction..
(3-4) according to the file record information of write internal memory, it is judged that whether present instruction exists dependence, if there is not dependence
Relation, then enter sub-step (3-5), otherwise obtains next instruction in semiology analysis virtual machine, and returns sub-step (3-2)
Perform;
(3-5) perform present instruction, release the inter-instruction dependency relationship of executed instructions, thus the file of more newly written internal memory is remembered
Record information, obtains next instruction in semiology analysis virtual machine, program not at the end of return sub-step (3-2) and perform, until
EP (end of program).
Data contention the most according to claim 4 detection and playback method, it is characterised in that step (5) includes following son
Step:
(5-1) instruction performed by multithread programs that detection request is corresponding, and judge whether this instruction is reading instruction or writes finger
Order, if yes then enter sub-step (5-2), this instruction is to lock instruction or unlock instruction else if, then performing locking
Or after unlocking instruction, enter sub-step (5-2), otherwise continue executing with this instruction according to the execution track of semiology analysis virtual machine;
(5-2) whether the memory address that decision instruction accesses is global variable address, if it is, obtain the address of global variable,
Set up the mapping relations of global variable address and numbering, obtain thread accesses global variable information, including thread number and time
Stamp vector, if instruction type is write command, then proceeds to sub-step (5-3), if instruction type is reading instruction, proceeds to sub-step (5-
4);Otherwise continue executing with this instruction according to the execution track of semiology analysis virtual machine;
(5-3) set of all read access records corresponding to this global variable is read according to the numbering that global variable address is corresponding,
Travel through all of read access record, to each read access record according to following formal layout: by the thread number pair of read access record
Timestamp value corresponding to thread number that the timestamp value answered is identical with current accessed record compares, and is less than or equal to if meeting
Relation, does not processes, and otherwise shows that two operations exist successively order relation, and carries out record.Finally all read accesses are remembered
The vector time stamp of record merges with the vector time stamp of current accessed;
(5-4) set of all write access records corresponding to this global variable is read according to the numbering that global variable address is corresponding,
To each write access record according to following formal layout: by timestamp value corresponding for the thread number of write access record and current accessed
The timestamp value that the identical thread number of record is corresponding compares, if meeting less than or equal to relation, does not deals with, otherwise table
There is successively order relation in bright two operations, and carries out record.Finally the vector time stamp of all write access records is visited with current
The vector time stamp asked merges;
(5-5) set of all read and write access records is write log file, thus complete to perform the recording process of track.
Data contention the most according to claim 5 detection and playback method, it is characterised in that step (6) includes following son
Step:
(6-1) multithread programs that request is corresponding is performed, to obtain the instruction performed;
(6-2) by the type of the conditional branching structure decision instruction in semiology analysis virtual machine, if instruction is reading instruction
Load or write command store, then proceed to sub-step (6-3);If instruction is function call instruction, then proceed to sub-step (6-
7);Instruct for other if instructed, then continue executing with this instruction according to the execution track of semiology analysis virtual machine, be then back to son
Step (6-1);
(6-3) judge whether the memory address that this instruction accesses is global variable, is, proceeds to sub-step (6-4), otherwise basis
The execution track of semiology analysis virtual machine continues executing with this instruction, is then back to sub-step (6-1);
(6-4) judge whether this instruction is write access, if write access, then call and write process function callStore, and proceed to son
Step (6-5), if read access, then calls reading and processes function callLoad, and proceed to sub-step (6-6);
(6-5) according to the memory address addr of global variable, check whether global variable is first time write access, if it is will
The timestamp of the thread number and thread that access this global variable is stored in write record, is then back to sub-step (6-1);No
Then take out the write record information of the memory address addr of global variable, including thread number and vector time stamp etc..By current thread
Vector time stamp in the timestamp value of current thread of record compare with the timestamp value in write record information, if the former
Less than the latter, represent and data contention occur, then report global variable write data contention mistake to client, do not make to locate
Reason, continues to judge whether there is concurrent read access mark between twice write access, if there is concurrent read access, then by this simultaneously
The timestamp value of the current thread of write access record with deposit twice write access all concurrent read access record timestamp to
The timestamp value recording current thread in amount compares, as long as meeting less than relation, representing and data contention occurs, then report is complete
The read-write data contention mistake of office's variable, to client, empties all information deposited in concurrent read access record, updates and writes visit
Ask record, be then back to sub-step (6-1), otherwise empty all information deposited in concurrent read access record, update write access
Record, is then back to sub-step (6-1).
(6-6) according to the memory address of global variable, check whether global variable is read access for the first time, if reading for the first time
Access, then the timestamp value of thread number and thread is stored in read record, is then back to sub-step (6-1);If not
Read access for the first time, then take out the write record information of the memory address of global variable, including thread number and vector time stamp etc., and will
In the vector time stamp of current thread, the timestamp value of current thread of record compares with the timestamp value of record, if both
Meet less than relation, represent and data contention occurs, then report data contention is to client, does not deals with, continues to sentence simultaneously
Whether there is concurrent read access mark between disconnected twice write access, if there is concurrent read access, then this read access directly being added
It is added in the concurrent read access record that address is addr;Otherwise take out read access record information, including thread number and timestamp to
Amounts etc., compare the timestamp value of current thread of record in the vector time stamp of current thread with the timestamp value of record
Relatively, if both meet less than relation, then update concurrent read access flag, this read access is added to address be addr also
Send out in read access record, then update the read access record that address is addr, and return sub-step (6-1);
(6-7) by the way of string matching, check that what function call instruction called currently calls whether function is multi-thread eikonal
Number, is to enter sub-step (6-8), otherwise continue executing with this instruction according to the execution track of semiology analysis virtual machine;
(6-8) at the function call instruction of semiology analysis virtual machine conditional branched structure, by the way of string matching
Identifying and currently call the title of function, and obtain the parameter of function, title and parameter according to function judge currently to call function
It is thread creation function, or thread waits function, or locking function, or unlock function, if thread creation function
Then proceed to sub-step (6-9);If thread waits function, then proceed to sub-step (6-10);If locking function, then proceed to sub-step
Suddenly (6-11);If unblock function, then proceed to sub-step (6-12);
(6-9) calling thread creation function creation sub-line journey, sub-line journey initializes own timestamp vector, and with father's thread time
Between stab vector merge, simultaneously the timestamp value of father's thread from increase 1;
(6-10) call thread and wait function, so that the vector time stamp waiting thread is entered with by the vector time stamp waiting thread
Row merges;
(6-11) locking function is called, and after successfully locking, by the vector time stamp of thread and the vector time stamp of lock object
Merge;
(6-12) call unblock function, and after successfully unlocking, the vector time stamp of thread is given the timestamp of lock object to
Amount.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610679571.1A CN106294169B (en) | 2016-08-17 | 2016-08-17 | A kind of data contention detection and playback method based on semiology analysis virtual machine |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610679571.1A CN106294169B (en) | 2016-08-17 | 2016-08-17 | A kind of data contention detection and playback method based on semiology analysis virtual machine |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106294169A true CN106294169A (en) | 2017-01-04 |
CN106294169B CN106294169B (en) | 2018-08-03 |
Family
ID=57679508
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610679571.1A Expired - Fee Related CN106294169B (en) | 2016-08-17 | 2016-08-17 | A kind of data contention detection and playback method based on semiology analysis virtual machine |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106294169B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108447330A (en) * | 2018-01-30 | 2018-08-24 | 王志强 | A kind of numerical control device cascade system and method that actual situation combines |
CN110083539A (en) * | 2019-04-29 | 2019-08-02 | 广州华多网络科技有限公司 | A kind of data contention detection method and device |
CN111563045A (en) * | 2020-05-11 | 2020-08-21 | 西安邮电大学 | Adaboost model-based concurrent program data competition statement level detection method |
CN113297069A (en) * | 2021-04-30 | 2021-08-24 | 中国科学院信息工程研究所 | Software testing method and device based on target drive |
CN113553137A (en) * | 2021-06-17 | 2021-10-26 | 中国人民解放军战略支援部队信息工程大学 | DPDK-based access capability network element high-speed data processing method under NFV architecture |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1019826A1 (en) * | 1996-10-11 | 2000-07-19 | Ericsson Australia Pty. Ltd. | A method and system for continuous software monitoring |
US7076776B2 (en) * | 2001-11-22 | 2006-07-11 | Electronics And Telecommunications Research Institute | Parallel loop transformation methods for race detection during an execution of parallel programs |
CN103365776A (en) * | 2013-06-28 | 2013-10-23 | 中国科学院计算技术研究所 | Parallel system weak consistency verifying method and system based on deterministic replay |
CN103488563A (en) * | 2013-09-05 | 2014-01-01 | 龙芯中科技术有限公司 | Data race detection method and device for parallel programs and multi-core processing system |
US8677186B2 (en) * | 2010-12-15 | 2014-03-18 | Microsoft Corporation | Debugging in data parallel computations |
CN104077144A (en) * | 2014-07-07 | 2014-10-01 | 西安交通大学 | Data race detection and evidence generation method based on multithreaded program constraint building |
CN104978272A (en) * | 2015-07-08 | 2015-10-14 | 中国科学院软件研究所 | Program scheduling method for data race detection |
CN105183655A (en) * | 2015-09-25 | 2015-12-23 | 南京大学 | Android application program data race detection based on predictability analysis |
-
2016
- 2016-08-17 CN CN201610679571.1A patent/CN106294169B/en not_active Expired - Fee Related
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1019826A1 (en) * | 1996-10-11 | 2000-07-19 | Ericsson Australia Pty. Ltd. | A method and system for continuous software monitoring |
US7076776B2 (en) * | 2001-11-22 | 2006-07-11 | Electronics And Telecommunications Research Institute | Parallel loop transformation methods for race detection during an execution of parallel programs |
US8677186B2 (en) * | 2010-12-15 | 2014-03-18 | Microsoft Corporation | Debugging in data parallel computations |
CN103365776A (en) * | 2013-06-28 | 2013-10-23 | 中国科学院计算技术研究所 | Parallel system weak consistency verifying method and system based on deterministic replay |
CN103488563A (en) * | 2013-09-05 | 2014-01-01 | 龙芯中科技术有限公司 | Data race detection method and device for parallel programs and multi-core processing system |
CN104077144A (en) * | 2014-07-07 | 2014-10-01 | 西安交通大学 | Data race detection and evidence generation method based on multithreaded program constraint building |
CN104978272A (en) * | 2015-07-08 | 2015-10-14 | 中国科学院软件研究所 | Program scheduling method for data race detection |
CN105183655A (en) * | 2015-09-25 | 2015-12-23 | 南京大学 | Android application program data race detection based on predictability analysis |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108447330A (en) * | 2018-01-30 | 2018-08-24 | 王志强 | A kind of numerical control device cascade system and method that actual situation combines |
CN108447330B (en) * | 2018-01-30 | 2020-07-03 | 王志强 | Virtual-real combined numerical control equipment cascade system and method |
CN110083539A (en) * | 2019-04-29 | 2019-08-02 | 广州华多网络科技有限公司 | A kind of data contention detection method and device |
CN110083539B (en) * | 2019-04-29 | 2020-11-13 | 广州华多网络科技有限公司 | Data competition detection method and device |
CN111563045A (en) * | 2020-05-11 | 2020-08-21 | 西安邮电大学 | Adaboost model-based concurrent program data competition statement level detection method |
CN111563045B (en) * | 2020-05-11 | 2022-11-01 | 西安邮电大学 | Adaboost model-based concurrent program data competition statement level detection method |
CN113297069A (en) * | 2021-04-30 | 2021-08-24 | 中国科学院信息工程研究所 | Software testing method and device based on target drive |
CN113553137A (en) * | 2021-06-17 | 2021-10-26 | 中国人民解放军战略支援部队信息工程大学 | DPDK-based access capability network element high-speed data processing method under NFV architecture |
CN113553137B (en) * | 2021-06-17 | 2022-11-01 | 中国人民解放军战略支援部队信息工程大学 | DPDK-based access capability network element high-speed data processing method under NFV architecture |
Also Published As
Publication number | Publication date |
---|---|
CN106294169B (en) | 2018-08-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106294169A (en) | The detection of a kind of data contention based on semiology analysis virtual machine and playback method | |
Xu et al. | Krace: Data race fuzzing for kernel file systems | |
CN107391653B (en) | Distributed NewSQL database system and picture data storage method | |
US7752605B2 (en) | Precise data-race detection using locksets | |
CN103729288B (en) | The adjustment method of application program under a kind of embedded multi-core environment | |
CN103514053B (en) | Shared-memory-based method for conducting communication among multiple processes | |
US7526750B2 (en) | Object-based systematic state space exploration of software | |
US8276124B2 (en) | Constructing petri nets from traces for diagnostics | |
US9454460B2 (en) | Methods, systems, and media for providing determinism in multithreaded programs | |
US20070288902A1 (en) | Replay debugging | |
US20120089966A1 (en) | Two pass automated application instrumentation | |
US10241894B2 (en) | Data-scoped dynamic data race detection | |
CN101446918B (en) | Method for realizing debugging of single function by user state debugger and system thereof | |
JPH10254716A (en) | Detection of concurrent error in multi-threaded program | |
US20110029819A1 (en) | System and method for providing program tracking information | |
CN101611380A (en) | Speculative throughput calculates | |
US7958149B2 (en) | Computer program and product for append mode insertion of rows into tables in database management systems | |
CN106326355B (en) | Log processing method and device in a kind of LFS system | |
Zhou et al. | Stride: Search-based deterministic replay in polynomial time via bounded linkage | |
CN114428733A (en) | Kernel data competition detection method based on static program analysis and fuzzy test | |
CN103729166B (en) | Method, device and system for determining thread relation of program | |
US20070288901A1 (en) | Viewing and modifying transactional variables | |
Li et al. | COMPI: Concolic testing for MPI applications | |
Fiedor et al. | Advances in noise‐based testing of concurrent software | |
US20120096443A1 (en) | Method of analyzing single thread access of variable in multi-threaded program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20180803 Termination date: 20190817 |