CN106294169B - A kind of data contention detection and playback method based on semiology analysis virtual machine - Google Patents

A kind of data contention detection and playback method based on semiology analysis virtual machine Download PDF

Info

Publication number
CN106294169B
CN106294169B CN201610679571.1A CN201610679571A CN106294169B CN 106294169 B CN106294169 B CN 106294169B CN 201610679571 A CN201610679571 A CN 201610679571A CN 106294169 B CN106294169 B CN 106294169B
Authority
CN
China
Prior art keywords
instruction
thread
sub
function
virtual machine
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.)
Expired - Fee Related
Application number
CN201610679571.1A
Other languages
Chinese (zh)
Other versions
CN106294169A (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.)
Huazhong University of Science and Technology
Original Assignee
Huazhong University of Science and Technology
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 Huazhong University of Science and Technology filed Critical Huazhong University of Science and Technology
Priority to CN201610679571.1A priority Critical patent/CN106294169B/en
Publication of CN106294169A publication Critical patent/CN106294169A/en
Application granted granted Critical
Publication of CN106294169B publication Critical patent/CN106294169B/en
Expired - Fee Related 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/362Software debugging

Abstract

The invention discloses a kind of methods concurrent program data contention detection under embedded environment and reset, in conjunction with the demand of software debugging and test, symbolization executes virtual machine approach, the dynamically operation of monitoring program, the execution information of collection procedure, and analyze data contention.And being determined property of program can also be reset by execution information so that the perform track of program can reappear.Function includes:Data contention detection based on semiology analysis virtual machine, the data contention playback based on semiology analysis virtual machine.The present invention can excavate the data contention hidden in a program, prevent multithread programs from mistake occurring at runtime.

Description

A kind of data contention detection and playback method based on semiology analysis virtual machine
Technical field
The invention belongs to software debugging technical fields, more particularly, to a kind of data based on semiology analysis virtual machine Competition detection and playback method.
Background technology
As software size is increasing, the error detection of software test and program becomes more and more important.It is existing Software test and error-detecting method can be divided into two methods of static method and dynamic approach.Static method not actual motion journey Sequence, by analyzing the calling figure in program source code, data flow diagram, controlling stream graph, executing the information such as analysis, by these information and The error model of foundation compares, to detect the error code segment that program may include.And dynamic approach is then by running journey Sequence analyzes the running orbit of program, detects mistake present in program.
The dynamic testing method of domestic and international mainstream includes the Valgrind, Yi Jiying of Nicholas Nethercot research and development at present The Pin of Te Er companies research and development, both binary system dynamic detection frame, by decompiling into executable program for intermediate generation Code, in the enterprising line program detection of intermediate code, then internal virtual machine executes source code again.
However, there are problems for existing dynamic testing method:First, Valgrind and Pin belongs to general detection block Frame, binary code compiling become intermediate code, can not actively screen thread shared data, be monitored when data contention checks More redundancy memories, to reduce the efficiency of detection;In addition, realizing " shadow value " (shadow value) inside Valgrind Technology realizes that the detection instrument of lightweight will also result in compared with large overhead under this frame;Finally, the detection under Pin frames is root It is realized according to the physical interface of offer, the function of interface is relatively fixed, and therefore, it is difficult to meet the self-defined demand of user.
Invention content
For the disadvantages described above or Improvement requirement of the prior art, the present invention provides a kind of based on semiology analysis virtual machine Data contention detects and playback method, it is intended that solving to make due to monitoring excessive redundancy memory present in existing method The technical issues of low at detection efficiency, detection process expense is big and poor expandability.
To achieve the above object, according to one aspect of the present invention, a kind of number based on semiology analysis virtual machine is provided According to competition detection and playback method, include the following steps:
(1) the program perform track operation request from host's generator terminal is received, and judges that the request is playback request, still Detection request, if it is playback request, then enters step (2), otherwise enters step (5);
(2) judge that the corresponding record file of the playback request whether there is in disk, and if so, being transferred to step (3), else process terminates;
(3) the program execution information file in record file is obtained, by obtaining the global change in semiology analysis virtual machine It measures read write command and/or multithreading function call instruction calls detection function, between load record file thread instruction Constraints, and judge whether global variable read write command and/or multithreading function call instruction can be by according to constraints It executes, if (4) can be thened follow the steps, else process terminates;
(4) it executes global variable read write command and/or multithreading function instruction, process terminates;
(5) detection being executed in semiology analysis virtual machine and asking corresponding multithread programs, it is right between multiple threads to monitor Global variable access in multithread programs, and sequencing of the multithreading to global variable access is recorded, and successively by these Order information is recorded in binary file, to generate program execution information file;
(6) command information in semiology analysis virtual machine is obtained, is detected in command information using data contention detection algorithm Global variable read-write, and using the multithreading function in multithreading function call interception funcall command information, to judge Global variable read-write whether there is data contention, if it is report the information of data contention detection mistake to client, if Program execution is not finished, then obtains next command information of the container storage for obtaining semiology analysis virtual machine, and goes to step (5) it executes.
Preferably, this method further includes multithreading extension being carried out to semiology analysis virtual machine, before step (1) with life At the semiology analysis virtual machine with multithreading function call interception and internal emulation multithreading function.
Preferably, executing the process that multithreading extends to semiology analysis virtual machine is specially:First, by function pointer and Structure builds the realization frame of multithreading emulation, and it includes at thread creation, thread waiting, thread locking and unlock to be then directed to The synchronous function of reason is written over.
Preferably, step (3) includes following sub-steps:
Memory is written in record file in program execution information file by (3-1) reading program execution information file;
(3-2) recycles the finger chosen detection and ask corresponding multithread programs according to the perform track of semiology analysis virtual machine It enables, whether decision instruction is reading instruction, write command, function call instruction, if so, step (3-3) is transferred to, otherwise according to symbol The perform track for executing virtual machine continues to execute the instruction;
Whether the memory address that (3-3) decision instruction accesses is global variable, no if yes then enter sub-step (3-4) Then enter sub-step (3-4) if the instruction is the locking and de-locking function in multithreading function call instruction, otherwise according to symbol Number execute virtual machine perform track continue to execute the instruction..
(3-4) judges that present instruction whether there is dependence, if being not present according to the file record information of write-in memory Dependence then enters sub-step (3-5), otherwise obtains next instruction in semiology analysis virtual machine, and return to sub-step (3-2) is executed;
(3-5) executes present instruction, releases the inter-instruction dependency relationship of executed instructions, to update the text of write-in memory Part records information, obtains next instruction in semiology analysis virtual machine, and sub-step (3-2) is returned when program is not finished and is executed, Until EP (end of program).
Preferably, step (5) includes following sub-steps:
The instruction performed by corresponding multithread programs is asked in (5-1) detection, and judge the instruction whether be reading instruction or Write command is then being executed if yes then enter sub-step (5-2) else if the instruction is to lock instruction or unlock instruction After locking or unlock instruction, into sub-step (5-2), this is otherwise continued to execute according to the perform track of semiology analysis virtual machine and is referred to It enables;
Whether the memory address that (5-2) decision instruction accesses is global variable address, if so, obtaining the ground of global variable The mapping relations of global variable address and number are established in location, obtain thread accesses global variable information, including thread number is with timely Between stab vector, if instruction type be write command, be transferred to sub-step (5-3), if instruction type be reading instruction if be transferred to sub-step (5-4);Otherwise the instruction is continued to execute according to the perform track of semiology analysis virtual machine;
(5-3) reads the collection of the corresponding all read access records of the global variable according to the corresponding number in global variable address It closes, traverses all read access records, each read access is recorded according to following formal layout:The thread number that read access is recorded Corresponding timestamp value timestamp value corresponding with the identical thread number that current accessed records is compared, if meet be less than etc. It in relationship, is then not processed, otherwise shows that there are priority order relations for two operations, and recorded.Finally by all read accesses The vector time stamp of record and the vector time stamp of current accessed merge;
(5-4) reads the collection of the corresponding all write access records of the global variable according to the corresponding number in global variable address It closes, each write access is recorded according to following formal layout:By the corresponding timestamp value of thread number of write access record and currently The corresponding timestamp value of identical thread number for accessing record is compared, if meeting the relationship of being less than or equal to, is not dealt with, no Then show that there are priority order relations for two operations, and is recorded.Finally by vector time stamp that all write access record with work as The vector time stamp of preceding access merges;
The set write-in record file that (5-5) records all read and write access, to complete the recording process of perform track.
Preferably, step (6) includes following sub-steps:
(6-1), which is executed, asks corresponding multithread programs, to obtain the instruction executed;
The type that (6-2) is instructed by the conditional branching structure decision in semiology analysis virtual machine, if instruction refers to for reading Load or write command store is enabled, then is transferred to sub-step (6-3);If instruction is function call instruction, it is transferred to sub-step (6-7);If instruction is other instructions, which is continued to execute according to the perform track of semiology analysis virtual machine, is then returned Return sub-step (6-1);
(6-3) judges whether the memory address that the instruction accesses is global variable, is to be transferred to sub-step (6-4), otherwise The instruction is continued to execute according to the perform track of semiology analysis virtual machine, is then back to sub-step (6-1);
(6-4) judges whether the instruction is write access, if write access, then calls and writes processing function callStore, and turn Enter sub-step (6-5), if read access, then calls reading processing function callLoad, and be transferred to sub-step (6-6);
(6-5) checks whether global variable is first time write access according to the memory address addr of global variable, if it is The thread number of the global variable then will be accessed and the timestamp of thread is stored in write record, be then back to sub-step (6- 1);Otherwise the write record information of the memory address addr of global variable, including thread number and vector time stamp etc. are taken out.It will be current The timestamp value of the current thread recorded in the vector time stamp of thread is compared with the timestamp value in write record information, if The former is less than the latter, indicates that data contention occurs, then to client, otherwise not that reports global variable writes data contention mistake It deals with, while continuing to judge to identify with the presence or absence of concurrent read access between write access twice, if there are concurrent read access, it will This time timestamp value of the current thread of write access record and the time for storing all concurrent read accesses records of write access twice The timestamp value of record current thread is compared in stamp vector, as long as meeting the relationship of being less than, is indicated that data contention occurs, is then reported The read-write data contention mistake of global variable is accused to client, empties all information stored in concurrent read access record, update Write access records, and is then back to sub-step (6-1), otherwise empties all information stored in concurrent read access record, and update is write Record is accessed, sub-step (6-1) is then back to.
(6-6) checks whether global variable is first time read access, if it is first according to the memory address of global variable The timestamp value of thread number and thread is then stored in read record by secondary read access, is then back to sub-step (6-1);If It is not first time read access, then takes out the write record information of the memory address of global variable, including thread number and vector time stamp Deng, the timestamp value of the current thread recorded in the vector time stamp of current thread is compared with the timestamp value of record, If the two meets the relationship of being less than, indicate that data contention occurs, then data reporting is competed to client, is not otherwise dealt with, simultaneously Continue to judge to identify with the presence or absence of concurrent read access between write access twice, if there are concurrent read access, 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 when Between stamp vector etc., by the timestamp value of the current thread recorded in the vector time stamp of current thread and the timestamp value of record into Row compares, if the two meets the relationship of being less than, updates concurrent read access flag, and it is addr that this read access, which is added to address, Concurrent read access record in, then update the read access that address is addr and record, and return to sub-step (6-1);
(6-7) checks whether the current calling function that function call instruction calls is multi-thread by way of string matching Eikonal number is then to enter sub-step (6-8), otherwise continues to execute the instruction according to the perform track of semiology analysis virtual machine;
(6-8) passes through string matching at the function call instruction of semiology analysis virtual machine conditional branched structure Mode identifies the title of current calling function, and obtains the parameter of function, judges current call according to the title of function and parameter Function is thread creation function or thread waits for function or locking function, or unlock function, if it is thread creation Function is then transferred to sub-step (6-9);Function is waited for if thread, then is transferred to sub-step (6-10);If locking function, then it is transferred to Sub-step (6-11);If unlock function, then sub-step (6-12) is transferred to;
(6-9) call thread creation function creation sub-line journey, sub-line journey initialize own timestamp vector, and with father's thread Vector time stamp merge, while the timestamp value of father's thread from increase 1;
(6-10) calls thread to wait for function, will wait for the vector time stamp of thread with by the timestamp of waiting thread to Amount merges;
(6-11) calls locking function, and after successfully locking, by the timestamp of the vector time stamp of thread and lock object Vector merges;
(6-12) calls unlock function, and after successfully unlocking, and the vector time stamp of thread is assigned to the time of lock object Stamp vector.
In general, through the invention it is contemplated above technical scheme is compared with the prior art, can obtain down and show Beneficial effect:
(1) detection efficiency of the invention is high:As a result of what is monitored in the method that the detection data of step (6) competes It is read and write access and the calling access information of synchronous function of global variable, and only saves last time write access record, When the read-write data contention for carrying out global variable detects and writes data contention detection, it is only necessary to the time for recording current read-write Timestamp value is compared with the timestamp value that last time write access records can judge whether data contention mistake, will detect Time complexity constant time complexity is reduced to by linear time complexity, therefore detection efficiency increases.
(2) detection overhead of the invention is small:Only judging to instruct as a result of the sub-step (5-2) in step (5) The memory address of access just establishes the mapping relations of global variable address and number when being global variable address, in detection process Only the access record of storage global variable, the access for detecting global variable whether there is data contention mistake, reduce detection and open Pin.
(3) favorable expandability of the invention:Due to the semiology analysis virtual machine used in step of the present invention (3), to its into In row multithreading expansion process, and thread creation is rewritten, thread waits for, thread locks and has unlocked processing synchronous function, it can Extension realizes that more synchronous functions are detected, and scalability is strong.
Description of the drawings
Fig. 1 is that the present invention is based on the general frame figures of the data contention of semiology analysis virtual machine detection and playback method.
Fig. 2 is that the present invention is based on the flow charts of the data contention of semiology analysis virtual machine detection and playback method.
Fig. 3 is data contention overhaul flow chart in the method for the present invention.
Fig. 4 is the flow chart of data contention record running orbit in the method for the present invention.
Fig. 5 is the flow chart of data contention playback method in the method for the present invention.
Specific implementation mode
In order to make the purpose , technical scheme and advantage of the present invention be clearer, with reference to the accompanying drawings and embodiments, right The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and It is not used in the restriction present invention.As long as in addition, technical characteristic involved in the various embodiments of the present invention described below It does not constitute a conflict with each other and can be combined with each other.
As shown in Figure 1, the present invention is based on the detection of the data contention of semiology analysis virtual machine be based on playback method it is whole Body frame is made of host's generator terminal and target generator terminal.Host's generator terminal service chart shape interface, is competed by network interface transmission data The related command of detection handles the data sended over from target machine to target generator terminal, carries out relevant processing screening, finally It is shown to user;Target machine termination receives the order that host section sends over, and executes the detection or playback of data contention, And execution information and testing result are sent to host's generator terminal by network interface.The detection knot of data contention is received from target machine termination Include in face by the testing result of data contention by the parsing and classification to information after the execution information of fruit and program On plate, the perform track of program is plotted on other one piece of panel, is checked for user.
As shown in Fig. 2, including following step the present invention is based on the detection of the data contention of semiology analysis virtual machine and playback method Suddenly:
(1) the program perform track operation request from host's generator terminal is received, and judges that the request is playback request, still Detection request, if it is playback request, then enters step (2), otherwise enters step (5);Specifically, if request in mark It is replay to know position, then the request is playback request, is otherwise detection request;
(2) judge that the corresponding record file of the playback request whether there is in disk, and if so, being transferred to step (3), else process terminates;
(3) the program execution information file in record file is obtained, 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 The constraints between record file thread instruction is recorded, and global variable read write command and/or is judged according to constraints more Whether thread function call instruction can be performed, if (4) can be thened follow the steps, else process terminates;In the present invention, make Semiology analysis virtual machine is KLEE;
It should be noted that before the process of the present invention executes, need to carry out multithreading expansion to semiology analysis virtual machine Exhibition, to generate the semiology analysis virtual machine with multithreading function call interception and internal emulation multithreading function.
Specifically, the process for executing multithreading extension to semiology analysis virtual machine is specially:First, pass through function pointer The realization frame of multithreading emulation is built with structure, being then directed to synchronous function, (thread creation, thread wait for, thread locks Handled with unlock) it is written over, wherein:
For thread creation function, every instruction is as an execution route, execution route in semiology analysis virtual machine There is independent performing environment, and all store in a reservoir, every execution route can be considered as to a thread, the mistake of thread creation Cheng Shouxian acquisition instructions information, number of parameters, function address and specific parameter information, and then executed by call sign The new thread of virtual machine internal function creation, the information such as initialization thread number, and then the vector time stamp of per thread is carried out Initialization, primary operational are that the corresponding timestamp value of this thread is set as 1, and the timestamp value of other threads is set as 0, then will Sub-line journey and the vector time stamp of father's thread merge, and obtain new vector time stamp and are assigned to sub-line journey.It will finally create Thread be stored in the container of semiology analysis virtual machine.
Function is waited for for thread, the information for waiting for thread is taken out from the container of storage thread, judges that waiting thread is It is no to be over, if be not finished, for unclosed waiting thread, the waiting set that will wait for thread that calling thread is added In, it is waken up at the end of waiting for thread, if terminated, scans sets of threads, wake up those and wait for its thread, and call Thread, which is done, relevant exits cleaning operation.
For thread locking function, this lock is first determined whether in lock is gathered, for the lock in gathering there is no lock, table Show and access the lock for the first time, create lock object, and it is busy condition that lock, which is arranged, is set as the thread of holding of lock to work as front Journey, to the lock being in idle condition, setting lock is busy condition, sets the thread of holding of lock to current thread;To busy shape The lock of state sets current thread to blocked state, and current thread is added in the waiting list of lock, after lock discharges again It obtains.
For thread UNLOCKS function, for the object of the lock in busy condition, when current thread does not hold current lock Return to mistake;To being not the waiting list of empty lock, then the thread that queue most starts is taken out, sets the thread of holding of lock to this Thread, and the wait state of the thread is reset, indicate that thread is no longer blocked state, wherein be empty lock to waiting list, It is idle state that lock, which is then arranged, and that removes lock holds thread.
(4) it executes global variable read write command and/or multithreading function instruction, process terminates;
(5) detection being executed in semiology analysis virtual machine and asking corresponding multithread programs, it is right between multiple threads to monitor Global variable access in multithread programs, and sequencing of the multithreading to global variable access is recorded, and successively by these Order information is recorded in binary file, to generate program execution information file;
(6) command information in semiology analysis virtual machine is obtained, is detected in command information using data contention detection algorithm Global variable read-write, and using the multithreading function in multithreading function call interception funcall command information, to judge Global variable read-write whether there is data contention, if it is report the information of data contention detection mistake to client, if Program execution is not finished, then obtains next command information of the container storage for obtaining semiology analysis virtual machine, and goes to step (5) it executes;
As shown in figure 3, the step of the method for the present invention (6), specifically includes following sub-steps:
(6-1), which is executed, asks corresponding multithread programs, to obtain the instruction executed;
The type that (6-2) is instructed by the conditional branching structure decision in semiology analysis virtual machine, if instruction refers to for reading Load or write command store is enabled, then is transferred to sub-step (6-3);If instruction is function call instruction, it is transferred to sub-step (6-7);If instruction is other instructions, which is continued to execute according to the perform track of semiology analysis virtual machine, is then returned Return sub-step (6-1);
(6-3) judges whether the memory address that the instruction accesses is global variable, is to be transferred to sub-step (6-4), otherwise The instruction is continued to execute according to the perform track of semiology analysis virtual machine, is then back to sub-step (6-1);
(6-4) judges whether the instruction is write access, if write access, then calls and writes processing function callStore, and turn Enter sub-step (6-5), if read access, then calls reading processing function callLoad, and be transferred to sub-step (6-6);
(6-5) checks global variable according to the memory address (for the convenience of description, assuming that address is addr) of global variable Whether it is first time write access, if it is will accesses the thread number of the global variable and the timestamp of thread is stored in and writes In record, it is then back to sub-step (6-1);Otherwise the write record information of the memory address addr of global variable, including line are taken out Journey number and vector time stamp etc..The timestamp value of the current thread recorded in the vector time stamp of current thread and write record are believed Timestamp value in breath is compared, if the former is less than the latter, indicates that data contention occurs, then that reports global variable writes number Client is given according to competition mistake, is not otherwise dealt with, while continuing to judge to whether there is concurrent read access between write access twice Mark, if there are concurrent read access, the timestamp value of the current thread that this write access is recorded and storage write access twice All concurrent read accesses records vector time stamp in the timestamp value of record current thread be compared, be less than as long as meeting Relationship indicates that data contention occurs, then reports the read-write data contention mistake of global variable to client, empty to store and concurrently read All information in record are accessed, update write access record is then back to sub-step (6-1), otherwise empties storage and concurrently reads to visit Ask that all information in record, update write access record are then back to sub-step (6-1).
(6-6) checks whether global variable is first time read access, if it is first according to the memory address of global variable The timestamp value of thread number and thread is then stored in read record by secondary read access, is then back to sub-step (6-1);If It is not first time read access, then takes out the write record information of the memory address of global variable, including thread number and vector time stamp Deng, the timestamp value of the current thread recorded in the vector time stamp of current thread is compared with the timestamp value of record, If the two meets the relationship of being less than, indicate that data contention occurs, then data reporting is competed to client, is not otherwise dealt with, simultaneously Continue to judge to identify with the presence or absence of concurrent read access between write access twice, if there are concurrent read access, 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 when Between stamp vector etc., by the timestamp value of the current thread recorded in the vector time stamp of current thread and the timestamp value of record into Row compares, if the two meets the relationship of being less than, updates concurrent read access flag, and it is addr that this read access, which is added to address, Concurrent read access record in, then update address be addr read access record, be then back to sub-step (6-1);
(6-7) checks whether the current calling function that function call instruction calls is multi-thread by way of string matching Eikonal number is then to enter sub-step (6-8), otherwise continues to execute the instruction according to the perform track of semiology analysis virtual machine;
(6-8) passes through string matching at the function call instruction of semiology analysis virtual machine conditional branched structure Mode identifies the title of current calling function, and obtains the parameter of function, judges current call according to the title of function and parameter Function is thread creation function or thread waits for function or locking function, or unlock function, if it is thread creation Function is then transferred to sub-step (6-9);Function is waited for if thread, then is transferred to sub-step (6-10);If locking function, then it is transferred to Sub-step (6-11);If unlock function, then sub-step (6-12) is transferred to;
(6-9) call thread creation function creation sub-line journey, sub-line journey initialize own timestamp vector, and with father's thread Vector time stamp merge, while the timestamp value of father's thread from increase 1;
(6-10) calls thread to wait for function, will wait for the vector time stamp of thread with by the timestamp of waiting thread to Amount merges;
(6-11) calls locking function, and after successfully locking, by the timestamp of the vector time stamp of thread and lock object Vector merges;
(6-12) calls unlock function, and after successfully unlocking, and the vector time stamp of thread is assigned to the time of lock object Stamp vector.
As shown in figure 4, the step of the method for the present invention (5) includes following sub-steps:
The instruction performed by corresponding multithread programs is asked in (5-1) detection, and judge the instruction whether be reading instruction or Write command is then being executed if yes then enter sub-step (5-2) else if the instruction is to lock instruction or unlock instruction After locking or unlock instruction, into sub-step (5-2), this is otherwise continued to execute according to the perform track of semiology analysis virtual machine and is referred to It enables;
Whether the memory address that (5-2) decision instruction accesses is global variable address, if so, obtaining the ground of global variable The mapping relations of global variable address and number are established in location, obtain thread accesses global variable information, including thread number is with timely Between stab vector, if instruction type be write command, be transferred to sub-step (5-3), if instruction type be reading instruction if be transferred to sub-step (5-4);Otherwise the instruction is continued to execute according to the perform track of semiology analysis virtual machine;
(5-3) reads the collection of the corresponding all read access records of the global variable according to the corresponding number in global variable address It closes, traverses all read access records, each read access is recorded according to following formal layout:The thread number that read access is recorded Corresponding timestamp value timestamp value corresponding with the identical thread number that current accessed records is compared, if meet be less than etc. It in relationship, is then not processed, otherwise shows that there are priority order relations for two operations, and recorded.Finally by all read accesses The vector time stamp of record and the vector time stamp of current accessed merge, and merge and are known as:According to array index from it is small to Big two arrays of order traversal, it is assumed that under when being designated as i, the higher value that i is designated as under in two arrays is assigned to current accessed Vector time stamp under be designated as the timestamp value of i.
(5-4) reads the collection of the corresponding all write access records of the global variable according to the corresponding number in global variable address It closes, each write access is recorded according to following formal layout:By the corresponding timestamp value of thread number of write access record and currently The corresponding timestamp value of identical thread number for accessing record is compared, if meeting the relationship of being less than or equal to, is not dealt with, no Then show that there are priority order relations for two operations, and is recorded.Finally by vector time stamp that all write access record with work as The vector time stamp of preceding 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 that, the higher value that i is designated as under in two arrays is assigned under the vector time stamp of current accessed and is designated as i's Timestamp value;
The set write-in record file that (5-5) records all read and write access, to complete the recording process of perform track.
As shown in figure 5, the step of the method for the present invention (3) includes following sub-steps:
Memory is written in record file in program execution information file by (3-1) reading program execution information file;
(3-2) recycles the finger chosen detection and ask corresponding multithread programs according to the perform track of semiology analysis virtual machine It enables, whether decision instruction is reading instruction, write command, function call instruction, if so, step (3-3) is transferred to, otherwise according to symbol The perform track for executing virtual machine continues to execute the instruction;
Whether the memory address that (3-3) decision instruction accesses is global variable, no if yes then enter sub-step (3-4) Then enter sub-step (3-4) if the instruction is the locking and de-locking function in multithreading function call instruction, otherwise according to symbol Number execute virtual machine perform track continue to execute the instruction..
(3-4) judges that present instruction whether there is dependence, if being not present according to the file record information of write-in memory Dependence then enters sub-step (3-5), otherwise obtains next instruction in semiology analysis virtual machine, and return to sub-step (3-2) is executed;
(3-5) executes present instruction, releases the inter-instruction dependency relationship of executed instructions, to update the text of write-in memory Part records information, obtains next instruction in semiology analysis virtual machine, and sub-step (3-2) is returned when program is not finished and is executed, Until EP (end of program).
As it will be easily appreciated by one skilled in the art that the foregoing is merely illustrative of the preferred embodiments of the present invention, not to The limitation present invention, all within the spirits and principles of the present invention made by all any modification, equivalent and improvement etc., should all include Within protection scope of the present invention.

Claims (3)

1. a kind of data contention detection and playback method based on semiology analysis virtual machine, which is characterized in that include the following steps:
(1) the program perform track operation request from host's generator terminal is received, and judges that the request is playback request, or detection Request, if it is playback request, then enters step (2), otherwise enters step (5);
(2) judge that the corresponding record file of the playback request whether there is in disk, and if so, it is transferred to step (3), it is no Then process terminates;
(3) the program execution information file in record file is obtained, is read by the global variable obtained in semiology analysis virtual machine Write command and/or multithreading function call instruction call detection function, with the constraint between load record file thread instruction Condition, and judge whether global variable read write command and/or multithreading function call instruction can be performed according to constraints, If (4) can be thened follow the steps, else process terminates;
(4) it executes global variable read write command and/or multithreading function instruction, process terminates;
(5) detection is executed in semiology analysis virtual machine and ask corresponding multithread programs, monitor between multiple threads to multi-thread Global variable access in Cheng Chengxu, and record sequencing of the multithreading to global variable access, and by these sequencings Information is recorded in binary file, to generate program execution information file, wherein executes multithreading to semiology analysis virtual machine The process of extension is specially:First, the realization frame of multithreading emulation is built by function pointer and structure, is then directed to packet Include thread creation, thread waits for, thread locks and the synchronous function of unlock processing is written over;
Step (5) includes following sub-steps:
The instruction performed by corresponding multithread programs is asked in (5-1) detection, and judges whether the instruction is reading instruction or writes finger It enables, then locking is being executed else if the instruction is to lock instruction or unlock instruction if yes then enter sub-step (5-2) Or after unlock instruction, into sub-step (5-2), the instruction is otherwise continued to execute according to the perform track of semiology analysis virtual machine;
Whether the memory address that (5-2) decision instruction accesses is global variable address, if so, the address of global variable is obtained, The mapping relations of global variable address and number are established, thread accesses global variable information, including thread number and time are obtained Stamp vector is transferred to sub-step (5-3) if instruction type is write command, and sub-step (5- is transferred to if instruction type is reading instruction 4);Otherwise the instruction is continued to execute according to the perform track of semiology analysis virtual machine;
(5-3) reads the set of the corresponding all read access records of the global variable according to the corresponding number in global variable address, All read access records are traversed, each read access is recorded according to following formal layout:The thread number pair that read access is recorded The timestamp value answered timestamp value corresponding with the identical thread number that current accessed records is compared, and is less than or equal to if meeting Relationship is then not processed, and is otherwise shown that there are priority order relations for two operations, and recorded, is finally remembered all read accesses The vector time stamp of record and the vector time stamp of current accessed merge;
(5-4) reads the set of the corresponding all write access records of the global variable according to the corresponding number in global variable address, Each write access is recorded according to following formal layout:The corresponding timestamp value of thread number and current accessed that write access is recorded The corresponding timestamp value of identical thread number of record is compared, if meeting the relationship of being less than or equal to, is not dealt with, otherwise table There are priority order relations for bright two operations, and are recorded, and the vector time stamp for finally recording all write access is visited with current The vector time stamp asked merges;
The set write-in record file that (5-5) records all read and write access, to complete the recording process of perform track;
(6) command information in semiology analysis virtual machine is obtained, is detected using data contention detection algorithm complete in command information Office's variable read-write, and using the multithreading function in multithreading function call interception funcall command information, to judge the overall situation Variable read-write whether there is data contention, if it is report the information of data contention detection mistake to client, if program Execution is not finished, then obtains next command information of the container storage for obtaining semiology analysis virtual machine, and goes to step (5) and hold Row;
Step (6) includes following sub-steps:
(6-1), which is executed, asks corresponding multithread programs, to obtain the instruction executed;
The type that (6-2) is instructed by the conditional branching structure decision in semiology analysis virtual machine, if instruction is reading instruction Load or write command store is then transferred to sub-step (6-3);If instruction is function call instruction, it is transferred to sub-step (6- 7);If instruction is not reading instruction load, write command store or function call instruction, according to semiology analysis virtual machine Perform track continues to execute the instruction, is then back to sub-step (6-1);
(6-3) judges whether the memory address that the instruction accesses is global variable, is to be transferred to sub-step (6-4), otherwise basis The perform track of semiology analysis virtual machine continues to execute the instruction, is then back to sub-step (6-1);
(6-4) judges whether the instruction is write access, if write access, then calls and writes processing function callStore, and be transferred to son Step (6-5) then calls reading processing function callLoad, and be transferred to sub-step (6-6) if read access;
(6-5) checks whether global variable is first time write access according to the memory address addr of global variable, if it is will The timestamp of the thread number and thread that access the global variable is stored in write record, is then back to sub-step (6-1);It is no The write record information of the memory address addr of global variable, including thread number and vector time stamp are then taken out, by current thread The timestamp value of the current thread recorded in vector time stamp is compared with the timestamp value in write record information, if the former is small In the latter, indicate that data contention occurs, then that reports global variable writes data contention mistake to client, does not otherwise make to locate Reason, while continuing to judge to identify with the presence or absence of concurrent read access between write access twice, if there are concurrent read accesses, by this The timestamp of the timestamp value of the current thread of write access record and all concurrent read accesses records of storage write access twice to The timestamp value that current thread is recorded in amount is compared, as long as meeting the relationship of being less than, indicates that data contention occurs, then report is complete The read-write data contention mistake of office's variable empties all information stored in concurrent read access record to client, and visit is write in update It asks record, is then back to sub-step (6-1), otherwise empty all information stored in concurrent read access record, update write access Record, is then back to sub-step (6-1);
(6-6) checks whether global variable is first time read access, is read if it is first time according to the memory address of global variable It accesses, then the timestamp value of thread number and thread is stored in read record, is then back to sub-step (6-1);If not First time read access is then taken out the write record information of the memory address of global variable, including thread number and vector time stamp, will be worked as The timestamp value of the current thread recorded in the vector time stamp of preceding thread is compared with the timestamp value of record, if the two is full Foot is less than relationship, indicates that data contention occurs, then data reporting is competed to client, is not otherwise dealt with, while continuing to judge It identifies with the presence or absence of concurrent read access between write access, if there are concurrent read access, this read access is directly added twice Into the concurrent read access record that address is addr;Otherwise it takes out read access and records information, including thread number and vector time stamp, The timestamp value of the current thread recorded in the vector time stamp of current thread is compared with the timestamp value of record, if two Person meets the relationship of being less than, then updates concurrent read access flag, this read access, which is added to the concurrently reading that address is addr, visits It asks in record, then updates the read access that address is addr and record, and return to sub-step (6-1);
(6-7) checks whether the current calling function that function call instruction calls is multi-thread eikonal by way of string matching Number is then to enter sub-step (6-8), otherwise continues to execute the instruction according to the perform track of semiology analysis virtual machine;
(6-8) at the function call instruction of semiology analysis virtual machine conditional branched structure, by way of string matching It identifies the title of current calling function, and obtains the parameter of function, current calling function is judged according to the title of function and parameter It is thread creation function or thread waiting function or locking function, or unlock function, if it is thread creation function Then it is transferred to sub-step (6-9);Function is waited for if thread, then is transferred to sub-step (6-10);If locking function, then sub-step is transferred to Suddenly (6-11);If unlock function, then sub-step (6-12) is transferred to;
(6-9) call thread creation function creation sub-line journey, sub-line journey initialize own timestamp vector, and with father's thread when Between stamp vector merge, while the timestamp value of father's thread from increase 1;
(6-10) calls thread to wait for function, will wait for the vector time stamp of thread with by the vector time stamp of waiting thread into Row merges;
(6-11) calls locking function, and after successfully locking, by the vector time stamp of the vector time stamp of thread and lock object It merges;
(6-12) calls unlock function, and after successfully unlocking, by the vector time stamp of thread assign the timestamp of lock object to Amount.
2. data contention according to claim 1 detection and playback method, which is characterized in that further include step (1) it Before, multithreading extension is carried out to semiology analysis virtual machine, has multithreading function call interception and internal emulation multi-thread to generate The semiology analysis virtual machine of Cheng Gongneng.
3. data contention detection according to claim 1 and playback method, which is characterized in that step (3) includes following sons Step:
Memory is written in record file in program execution information file by (3-1) reading program execution information file;
(3-2) recycles the instruction chosen detection and ask corresponding multithread programs according to the perform track of semiology analysis virtual machine, Whether decision instruction is that reading instruction, write command, function call instruction are otherwise held according to symbol if so, being transferred to step (3-3) The perform track of row virtual machine continues to execute the instruction;
Whether the memory address that (3-3) decision instruction accesses is global variable, if yes then enter sub-step (3-4), otherwise such as The fruit instruction is that the locking and de-locking function in multithreading function call instruction then enters sub-step (3-4), is otherwise held according to symbol The perform track of row virtual machine continues to execute the instruction;
(3-4) judges that present instruction whether there is dependence according to the file record information of write-in memory, if there is no rely on Relationship then enters sub-step (3-5), otherwise obtains next instruction in semiology analysis virtual machine, and return to sub-step (3-2) It executes;
(3-5) executes present instruction, releases the inter-instruction dependency relationship of executed instructions, to update the file note of write-in memory Information is recorded, next instruction in semiology analysis virtual machine is obtained, sub-step (3-2) is returned when program is not finished and is executed, until EP (end of program).
CN201610679571.1A 2016-08-17 2016-08-17 A kind of data contention detection and playback method based on semiology analysis virtual machine Expired - Fee Related CN106294169B (en)

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 CN106294169A (en) 2017-01-04
CN106294169B true 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)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108447330B (en) * 2018-01-30 2020-07-03 王志强 Virtual-real combined numerical control equipment cascade system and method
CN110083539B (en) * 2019-04-29 2020-11-13 广州华多网络科技有限公司 Data competition detection method and device
CN111563045B (en) * 2020-05-11 2022-11-01 西安邮电大学 Adaboost model-based concurrent program data competition statement level detection method
CN113553137B (en) * 2021-06-17 2022-11-01 中国人民解放军战略支援部队信息工程大学 DPDK-based access capability network element high-speed data processing method under NFV architecture

Citations (8)

* Cited by examiner, † Cited by third party
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

Patent Citations (8)

* Cited by examiner, † Cited by third party
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

Also Published As

Publication number Publication date
CN106294169A (en) 2017-01-04

Similar Documents

Publication Publication Date Title
CN106294169B (en) A kind of data contention detection and playback method based on semiology analysis virtual machine
US6434714B1 (en) Methods, systems, and articles of manufacture for analyzing performance of application programs
US8392930B2 (en) Resource contention log navigation with thread view and resource view pivoting via user selections
US7137105B2 (en) Dynamic software code instrumentation method and system
US9454460B2 (en) Methods, systems, and media for providing determinism in multithreaded programs
Yang et al. Efficient stateful dynamic partial order reduction
CN109643273A (en) The program tracking debugged and analyzed for time travel
US20070245312A1 (en) Precise data-race detection using locksets
CN108664380B (en) After-execution software debugging system with performance display and debugging method
JP2015528612A (en) Method and system for monitoring the execution of user requests in a distributed system
CN101645119A (en) Method and system for automatically analyzing malicious codes based on virtual hardware environment
CN111756575A (en) Performance analysis method and device of storage server and electronic equipment
CN105868626B (en) The method of monitoring software business conduct based on control stream coarseness integrality
CN103365776A (en) Parallel system weak consistency verifying method and system based on deterministic replay
US6785801B2 (en) Secondary trace build from a cache of translations in a caching dynamic translator
CN114428733A (en) Kernel data competition detection method based on static program analysis and fuzzy test
Li et al. Using anti-ant-like agents to generate test threads from the UML diagrams
CN109254883A (en) A kind of debugging apparatus and method of on-chip memory
WO2015027403A1 (en) Testing multi-threaded applications
CN109522207B (en) Atom set serialization violation detection method based on constraint solving
Feljan et al. Towards a model-based approach for allocating tasks to multicore processors
CN109542444A (en) Monitoring method, device, server and the storage medium of JAVA application
US8607204B2 (en) Method of analyzing single thread access of variable in multi-threaded program
Keane et al. A simple local-spin group mutual exclusion algorithm
CN109885489A (en) Data contention detection method and device in driver

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

Granted publication date: 20180803

Termination date: 20190817

CF01 Termination of patent right due to non-payment of annual fee