CN108021495B - Code debugging method based on playback - Google Patents

Code debugging method based on playback Download PDF

Info

Publication number
CN108021495B
CN108021495B CN201610954150.5A CN201610954150A CN108021495B CN 108021495 B CN108021495 B CN 108021495B CN 201610954150 A CN201610954150 A CN 201610954150A CN 108021495 B CN108021495 B CN 108021495B
Authority
CN
China
Prior art keywords
program
event
playback
information
recording
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610954150.5A
Other languages
Chinese (zh)
Other versions
CN108021495A (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.)
Beijing Institute of Computer Technology and Applications
Original Assignee
Beijing Institute of Computer Technology and Applications
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 Beijing Institute of Computer Technology and Applications filed Critical Beijing Institute of Computer Technology and Applications
Priority to CN201610954150.5A priority Critical patent/CN108021495B/en
Publication of CN108021495A publication Critical patent/CN108021495A/en
Application granted granted Critical
Publication of CN108021495B publication Critical patent/CN108021495B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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
    • G06F11/3636Software debugging by tracing the execution of the program
    • 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
    • G06F11/3632Software debugging of specific synchronisation aspects

Abstract

The invention relates to a code debugging method based on playback, and belongs to the technical field of computer software. The invention eliminates the uncertainty of the parallel program in the running process caused by the parallel execution of a plurality of processes in the parallel program through the three-step code debugging strategy of the instrumentation, the tracking, the recording and the playback, positions error codes, realizes the deterministic playback of the codes, can obviously improve the efficiency and the accuracy of code debugging, improves the quality of software research and development, and provides method reference for the debugging work of the parallel program.

Description

Code debugging method based on playback
Technical Field
The invention relates to the technical field of computer software, in particular to a code debugging method based on playback.
Background
In the software development process, code debugging is taken as a key link for ensuring the effectiveness and the correctness of a program, and high attention is paid to the code debugging, and in the general software development process, the debugging cost and the debugging time account for more than 50 percent of the whole software project. Data collected by the National Institute of Standards and Technology (NIST) show that code debugging can significantly reduce the loss caused by software failure, and about 33% of the overall loss can be compensated. Therefore, the deep research on the code debugging technology plays a crucial role in improving the software development efficiency and ensuring the software development quality.
For code debugging problems, the most common application at present is program slicing technology. The program slicing technique is a code analysis technique for decomposing a program, and plays an important role in various fields such as program understanding, program analysis, debugging, software testing, and maintenance. And can be further divided into static slices and dynamic slices according to the implementation mode. The static slice is to take all possible execution conditions of the program into consideration, acquire all executable statements in the program which may change a certain variable value, and when a certain variable value is found to be wrong in the debugging process, only the static slice related code of the variable can be checked, thereby avoiding checking the whole program. The dynamic slice-based approach considers only the execution path of a particular input program, which consists of all statements and predicates that directly or indirectly affect a variable value. The method greatly reduces the code amount in the dynamic slice compared with the static slice, reduces the search range and improves the code debugging efficiency to a certain extent. Still another scholars propose methods to replace dynamic slicing with executive slicing. The meaning of executing a slice is all statements that a certain test case executes. And analyzing all execution codes of the error cases through observation of the error cases so as to determine the execution slices of the program. The program slicing technology can reduce the error range of the code for developers and reduce the code amount to be analyzed by software developers in the debugging process.
Although the static slicing method can locate the error code, the method cannot accurately acquire the information actually executed by the program, and some codes which do not influence the variable value in actual execution may be introduced into the static slicing set, so that the static set is too large, and the code debugging efficiency is obviously reduced; for the dynamic slicing method, although the code search range is reduced to a certain extent, the method has a large calculation amount, requires a large storage space to store program execution information, and occupies a large memory; although the slicing execution method solves the problem of overlarge dynamic slice memory occupation to a certain extent, the analysis of all codes undoubtedly increases the workload of code debugging personnel.
Disclosure of Invention
Technical problem to be solved
The technical problem to be solved by the invention is as follows: the method and the device improve the code debugging efficiency and accuracy in order to meet the requirements brought by the change of the code debugging technology brought by the increase of the code scale and the parallelization of the software structure.
(II) technical scheme
In order to solve the above technical problem, the present invention provides a code debugging method based on playback, which includes the following steps:
s1, implanting a probe at the pile inserting point by identifying the pile inserting point, and inserting the pile of the source program to prepare for code playback;
s2, identifying each synchronous event of the parallel program by using the vector timestamp, and tracking and recording the synchronous events;
and S3, performing deterministic playback of the parallel program.
Preferably, step S1 specifically includes the following steps:
pile inserting by a source program: performing source program instrumentation by adopting a method of replacing standard library functions in a source program with custom functions;
capturing dynamic information: compiling and linking the source program after the pile insertion, running the program, recording dynamic information thrown out by the probe along with the gradual insertion of the probe, and writing the dynamic information into an event record library;
data processing and analysis: and by extracting and analyzing the data in the event record library, behaviors and characteristics inside the program are revealed, and preparation is made for code playback.
Preferably, step S2 specifically includes the following steps:
identification of synchronization event: identifying the events by marking a vector timestamp for each synchronous event of the parallel program, judging the time sequence relation among the events according to the vector timestamps of the events, and recording the time sequence relation;
tracking and recording of synchronization events: judging the source and destination information of the received information of each message receiving operation when the tracking program runs, recording, and maintaining a synchronous event information for each process, wherein the synchronous event information is used for tracking the synchronous event currently run by the process and a vector timestamp; and during tracking, setting a periodic check point for each process, calling a function sigsuspend () to automatically suspend at preset time intervals, calling a check point program, saving the information of the current process, and continuing to wake up the process to execute.
Preferably, in step 3, when the program encounters an error termination during the running process or the running is finished, by accessing the information in the event record library, the playback and debugging of the error state of the parallel program are performed under the mutual coordination of the playback module and the error module.
Preferably, step S3 is specifically: when the program starts to execute, the execution request of the target process is queued in the request queue; the playback module reads the event information recorded in the recording stage from the event recording library, compares the event information with an execution request submitted by a target process, determines whether to allow the parallel operation to be executed or to execute a suspended state in a process waiting queue, waits for the next response, receives a debugging instruction by the error module, controls the execution condition of the process, and reads the state of the process on the basis of single-step execution.
(III) advantageous effects
The invention eliminates the uncertainty of the parallel program in the running process caused by the parallel execution of a plurality of processes in the parallel program through the three-step code debugging strategy of the instrumentation, the tracking, the recording and the playback, positions error codes, realizes the deterministic playback of the codes, can obviously improve the efficiency and the accuracy of code debugging, improves the quality of software research and development, and provides method reference for the debugging work of the parallel program.
Drawings
FIG. 1 is a flow chart of a method of an embodiment of the present invention;
fig. 2 is a schematic diagram of a code playback step in the embodiment of the present invention.
Detailed Description
In order to make the objects, contents, and advantages of the present invention clearer, the following detailed description of the embodiments of the present invention will be made in conjunction with the accompanying drawings and examples.
Aiming at the defects and shortcomings of the existing program debugging method, the embodiment of the invention takes the parallel program as a research object and researches a code debugging method based on playback.
During the running of the parallel program, the following two uncertainties may exist: one is external uncertainty, meaning that different executions result in different operational results for the same input. This type of uncertainty is sometimes desirable and may provide developers with a variety of solutions to problems; and sometimes undesirable, the uncertainty of the result is regarded as an error in the running of the program and needs to be eliminated. The second is internal uncertainty, which means that different execution processes lead to the same operation result for the same input, but the execution paths inside the program are different. To conclude, the existence of uncertainty is caused by the parallel execution of multiple processes in a parallel program. Therefore, the elimination of uncertainty will be an important part in the code debugging process.
In the present invention, the uncertainty elimination technique is studied by the following method: recording the source and destination of each message at run-time, forming a specific identifier according to the recorded content, and forcing each message to receive the message with the specific identifier corresponding to the message. The sending and receiving operation of the defined message thread transmission is a synchronous event, and a synchronous event execution sequence is constructed for the execution of the program. Each synchronous event is executed according to a specified sequence, so that the uncertainty is eliminated, the reproduction of an original program is realized, and a good foundation is laid for code reproduction.
Based on the above thought, the code debugging method based on playback provided by the embodiment of the present invention proposes a "three-step" code debugging strategy: the method comprises the following steps of pile inserting, tracking, recording and replaying:
step 1: and (4) inserting the pile into the source program by identifying the pile inserting point and implanting a probe into the pile inserting point. The method specifically comprises the following three substeps:
(1) pile inserting by a source program: in the process of tracking and recording the synchronous events, in order to collect and arrange event information conveniently and realize accurate control of process behaviors in the process of program playback, the adopted instrumentation method is as follows: standard library functions in the source program are replaced. And replacing the concerned standard library function with a self-defined function to realize code instrumentation of the source program.
Suppose that the function to be staked is rtype func (type)1a1,type2a2,…typenan) In the formula, type1,type2,…,typenIs a root of common ginseng1,a2,…,anThe rtype is the return type of the function, and the final encapsulation function corresponding to the func is as follows:
Figure BDA0001142705720000051
in the function, c1,c2,…,cmWhich is an extra parameter that FUNC must introduce to accomplish a specific function, PRESTATEMENT and POSTSTATEMENT are instrumented codes to accomplish a specific function and cannot be simultaneously empty. Function encapsulation function FUNC (a)1,a2,…,an,c1,c2,…,cm) Simultaneously has the functions of an original function and an instrumented function, and replaces func (a) in the source code1,a2,…,an) And completing the pile inserting of the function.
(2) Capturing dynamic information: compiling and linking the source program after the pile insertion, operating the program, recording dynamic information thrown out by the probe along with the gradual insertion of the probe, and writing the dynamic information into an event record library.
(3) Data processing and analysis: by extracting and analyzing the data in the event record library, the behavior and the characteristics inside the program are revealed, and the code is prepared for playback.
Step 2: and identifying each synchronous event of the parallel program by using the vector timestamp to realize the tracking and recording of the synchronous event.
There is uncertainty because the thread scheduling of parallel programs is opaque, cannot be predicted, and the control thread switch occurs where and when. It is the uncertainty of the running of the parallel program that makes the error hard to reproduce. In order to eliminate uncertainty and realize accurate reproduction of the program, the step adopts a vector timestamp mode to identify synchronous events. The method specifically comprises the following two substeps:
(1) identification of synchronization events
The clock conditions that the logical timestamps can satisfy are:
if a → b, then C (a) < C (b)
Where "→" represents the relationship. From a → b, there is a causal relationship between events a and b, and if event a occurs before event b, then the logical timestamp c (a) of event a should be smaller than the logical timestamp c (b) of event b. The logic event stamp should satisfy the following relation when describing the event between the parallel program processes:
● if a and b are two events in a process P, and event a occurs before event b, then there is a → b;
● if a is a send event and b is a receive event, there is a → b;
● if a → b, and b → c, then a → c.
The vector timestamp is a logical timestamp that accurately represents a chronological relationship. The method comprises the steps of marking each synchronous event of the parallel program by a vector timestamp, judging the time sequence relation among the events according to the vector timestamps of the events, and recording the time sequence relation.
(2) Synchronizing tracking and recording of events
When the tracing program runs, the source and destination information of the received message of each message receiving operation is judged and recorded, so that a specific identifier can be formed for each message according to the recorded information during playback, and each message is forced to receive the message with the specific identifier, thereby avoiding internal uncertainty caused by receiving messages sent by any process. Each process maintains a synchronization event information used to track synchronization events to which the process is currently running and vector timestamps. The data structure for implementing the tracing is as follows:
recording format of structTraceRecord// trace file
{
intm _ send _ process _ id; // sending Process number
intm _ send _ event _ num; // sending a synchronization event number
intm _ receive _ process _ id; // receiving the Process number
intm _ receive _ event _ num; // receive event number
}
During tracking, a periodic check point is set for each process, for example, every n minutes, the system automatically calls a system function sigsusend () to automatically suspend, calls a check point program, stores the information of the current process, and then continues to wake up the process to execute. Thus, in the replay phase, the software developer may choose a checkpoint of interest or a suspected checkpoint to repeatedly check the execution of the process.
And step 3: deterministic playback of parallel programs
A schematic diagram of playback-based code debugging is shown in fig. 2. When the program encounters an error termination in the running process or runs and ends, the information in the event record library is accessed, and the parallel program error state is played back and debugged under the mutual coordination of the playback module and the error module. As can be seen from FIG. 2, when the program begins execution, execution requests of the target process are queued in the request queue; the playback module reads the event information recorded in the recording stage from the event recording library, compares the event information with an execution request submitted by a target process, and determines whether to allow the parallel operation to be executed or to execute a suspended state in a process waiting queue for the next response. The error module receives debugging instructions of debugging personnel, controls the execution condition of the processes, reads the states of the processes on the basis of single step execution, feeds back the state information to the debugging personnel, and realizes visualization of the communication relation among the processes.
In the process of code playback debugging, a large number of probes are introduced, so that probe effects are brought to a certain extent, but the code debugging method based on the playback enables debugging personnel to obtain a deterministic program execution situation according to recorded information, and the deterministic execution is not influenced by the existence of the probe effects. Therefore, in the code playback process, a code debugger can execute the program at any speed, and meanwhile, various debugging use cases are added in the debugging process to find out and solve errors, so that the smooth running of the parallel program is realized.
The above description is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, several modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.

Claims (1)

1. A playback-based code debugging method, comprising the steps of:
s1, implanting a probe at the pile inserting point by identifying the pile inserting point, and inserting the pile of the source program to prepare for code playback;
s2, identifying each synchronous event of the parallel program by using the vector timestamp, and tracking and recording the synchronous events;
s3, performing deterministic playback of the parallel program;
step S1 specifically includes the following steps:
pile inserting by a source program: performing source program instrumentation by adopting a method of replacing standard library functions in a source program with custom functions;
capturing dynamic information: compiling and linking the source program after the pile insertion, running the program, recording dynamic information thrown out by the probe along with the gradual insertion of the probe, and writing the dynamic information into an event record library;
data processing and analysis: by extracting and analyzing the data in the event record library, behaviors and characteristics in the program are revealed, and preparation is made for code playback;
step S2 specifically includes the following steps:
identification of synchronization event: identifying the events by marking a vector timestamp for each synchronous event of the parallel program, judging the time sequence relation among the events according to the vector timestamps of the events, and recording the time sequence relation;
tracking and recording of synchronization events: judging the source and destination information of the received information of each message receiving operation when the tracking program runs, recording, and maintaining a synchronous event information for each process, wherein the synchronous event information is used for tracking the synchronous event currently run by the process and a vector timestamp; setting a periodic check point for each process during tracking, calling a function sigsuspend () to automatically suspend at preset time intervals, calling a check point program, saving the information of the current process, and continuing to wake up the process to execute;
in step S3, when the program is terminated by an error in the running process or runs, the parallel program error state is played back and debugged under the mutual coordination of the playback module and the error module by accessing the information in the event record library;
step S3 specifically includes: when the program starts to execute, the execution request of the target process is queued in the request queue; the playback module reads the event information recorded in the recording stage from the event recording library, compares the event information with an execution request submitted by a target process, determines whether to allow the parallel operation to be executed or to execute a suspended state in a process waiting queue, waits for the next response, receives a debugging instruction by the error module, controls the execution condition of the process, and reads the state of the process on the basis of single-step execution.
CN201610954150.5A 2016-11-03 2016-11-03 Code debugging method based on playback Active CN108021495B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610954150.5A CN108021495B (en) 2016-11-03 2016-11-03 Code debugging method based on playback

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610954150.5A CN108021495B (en) 2016-11-03 2016-11-03 Code debugging method based on playback

Publications (2)

Publication Number Publication Date
CN108021495A CN108021495A (en) 2018-05-11
CN108021495B true CN108021495B (en) 2021-05-14

Family

ID=62070822

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610954150.5A Active CN108021495B (en) 2016-11-03 2016-11-03 Code debugging method based on playback

Country Status (1)

Country Link
CN (1) CN108021495B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108763596B (en) * 2018-07-11 2021-09-17 绿湾网络科技有限公司 Method and device for playing map track
CN108932201A (en) * 2018-07-16 2018-12-04 北京中科网威信息技术有限公司 The method and device of Shen prestige firewall message trajectory track
CN114327491B (en) * 2022-03-07 2022-06-21 深圳开源互联网安全技术有限公司 Source code instrumentation method, apparatus, computer device and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5794046A (en) * 1994-09-29 1998-08-11 International Business Machines Corporation Method and system for debugging parallel and distributed applications
CN1300699C (en) * 2004-09-23 2007-02-14 上海交通大学 Parallel program visuable debugging method
CN100435111C (en) * 2005-10-13 2008-11-19 同济大学 Parallel adjusting and performance analyzing method of supporting multi-language multi-platform under isomerized environment
CN104216764B (en) * 2014-07-31 2017-09-12 昆明理工大学 One kind is based on the tracking of multithreading embedded system concurrent program and back method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
面向多核/众核体系结构的确定性并行关键技术研究;周旭;《中国博士学位论文全文数据库 信息科技辑》;20160115(第01期);I138-24 *

Also Published As

Publication number Publication date
CN108021495A (en) 2018-05-11

Similar Documents

Publication Publication Date Title
US8522176B2 (en) Method of recording and replaying call frames for the testbench
Dean et al. Perfcompass: Online performance anomaly fault localization and inference in infrastructure-as-a-service clouds
US8726225B2 (en) Testing of a software system using instrumentation at a logging module
US9483383B2 (en) Injecting faults at select execution points of distributed applications
US20210064512A1 (en) Selective memory tracing of program execution
US10095611B1 (en) Methodology for unit test and regression framework
US10725889B2 (en) Testing multi-threaded applications
US10698805B1 (en) Method and system for profiling performance of a system on chip
JP6363152B2 (en) Apparatus, method, computer program, and storage medium for data flow analysis
CN108021495B (en) Code debugging method based on playback
US20180300229A1 (en) Root cause analysis of non-deterministic tests
CN115357515B (en) Debugging method and device of multi-core system, computer equipment and storage medium
CN110059014B (en) Concurrent program data competition instruction level positioning method
CN106529304B (en) A kind of Android applies concurrent leakage location
Pacheco Postmortem debugging in dynamic environments
CN110688245A (en) Information acquisition method, device, storage medium and equipment
CN112612697A (en) Software defect testing and positioning method and system based on byte code technology
CN102279797A (en) Method and system for detecting memory leakage
Quinn et al. Sledgehammer:{Cluster-Fueled} Debugging
CN110633199A (en) Testing apparatus, method, and medium for block chain supporting intelligent contract
Kasikci et al. Failure sketches: A better way to debug
CN112084108A (en) Test script generation method and device and related components
US10061604B2 (en) Program execution recording and playback
Sundmark et al. Monitored software components-a novel software engineering approach
CN115454792A (en) Method and system for analyzing performance bottleneck on embedded operating system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant