CN103473177A - Method for online debugging C/C++ program - Google Patents

Method for online debugging C/C++ program Download PDF

Info

Publication number
CN103473177A
CN103473177A CN2013104448065A CN201310444806A CN103473177A CN 103473177 A CN103473177 A CN 103473177A CN 2013104448065 A CN2013104448065 A CN 2013104448065A CN 201310444806 A CN201310444806 A CN 201310444806A CN 103473177 A CN103473177 A CN 103473177A
Authority
CN
China
Prior art keywords
debugged
debugging
program
control process
control
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
Application number
CN2013104448065A
Other languages
Chinese (zh)
Other versions
CN103473177B (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.)
Peking University
Original Assignee
Peking University
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 Peking University filed Critical Peking University
Priority to CN201310444806.5A priority Critical patent/CN103473177B/en
Priority claimed from CN201310444806.5A external-priority patent/CN103473177B/en
Publication of CN103473177A publication Critical patent/CN103473177A/en
Application granted granted Critical
Publication of CN103473177B publication Critical patent/CN103473177B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method for online debugging a C/C++ program. The method comprises the steps of 1, starting debugging, starting a debugged process marked by a user name at a server side and starting a daemon thread; 2, inputting data in a console at a browser side and importing the data input by the console into an input stream of the debugged process after the data are received by a control process at the server side; meanwhile, obtaining the data output by the console of the debugged process by the control process, and pushing the data output by the console to the browser side by a server; 3, sending a series of debugging commands at the browser side, wherein the debugging commands comprise breakpoint adding, breakpoint deleting, step into, step out, current line running, continuing and variable value viewing; carrying out operations corresponding to the debugging commands on the debugged process after the debugging commands are received by the control process; 4, feeding back state information to the control process by the debugged process in real time; analyzing a state information text and pushing a corresponding state to the browser side by the control process; 5, stopping the debugged process by the control process after the debugging is finished and finishing the debugging. By adopting the method for online debugging the C/C++ program, disclosed by the invention, online debugging to a program on a browser can be realized.

Description

A kind of method of on-line debugging C/C++ program
Technical field:
The invention belongs to software technology field, be specifically related to a kind of method of on-line debugging C/C++ program.
Background technology:
Traditionally, the programmer develops and debugged program in local Integrated Development Environment.Debug client end and debugged program all operate on a machine.The programmer, by breakpoint, single step run being set, checking the operations such as variable, checks whether the run time behaviour of program conforms to expection, thus the mistake of searching, repair procedure.
Along with the rise of cloud computing, increasing programmer brings into use the Online integration development environment, development sequence in browser.The machine performance configuration of using the Online integration development environment to make the programmer not used, the restriction of operating system, development sequence whenever and wherever possible, immediately the Program Synchronization of exploitation to server.Traditional adjustment method, in the face of this new scene the time, can't be tackled following challenge:
(1) stationary problem.Under the Online integration development environment, the debugging of program action occurs in browser end, and the program of debugging operates in server end, and the debugging mode of server end is synchronizeed with browser end and had problems;
(2) multi-user management.In local development environment, once debugging only has a user, does not need to carry out multi-user's management; But for online development environment, need the many users of parallel support debugging simultaneously, dynamic assignment high in the clouds resource is given a plurality of debugging examples, and management and the resource that therefore unavoidably will relate to the multi-user are distributed.
(3) safety problem.Because user's program need to be moved at server end, if the user inputs rogue program, may make the whole system paralysis.
Therefore, traditional adjustment method based on local Integrated Development Environment is used and is had limitation in the Online integration development environment, can not meet the on-line debugging based on browser.
Summary of the invention:
For the problems referred to above, the purpose of this invention is to provide a kind of online program debugging method based on browser.The method makes the programmer can in the Online integration development environment, send debug command, Real-time Obtaining server end debugger status, carry out the control desk input and output, thereby completes the debugging work of program in browser.
Technical scheme of the present invention is as follows:
(1) programmer sends the order of " starting debugging " at browser end, and the control process of server end receives the order of " starting debugging ", the program code that security sweep will move, and scanning is by debugged process with the user name sign of rear startup.Start a daemon thread simultaneously, monitor the working time of debugged process.
(2) programmer can input data at the browser end control desk, and the control process of server end imports in the inlet flow of debugged process after receiving the control desk input.Simultaneously, control process is obtained the control desk output of debugged process.Server is pushed to browser end to control desk output, is shown to the programmer.
(3) in debug process, the programmer can send a series of debug commands at browser end, comprises that breakpoint adds, breakpoint is deleted, single step enters, single step is jumped out, run to current line, continue, check variate-value.After the control process receives debug command, debugged program is carried out to operation corresponding to debug command.
(4) debugged process in real time status information feedback to the control process.Control process parse state information text, push corresponding state to browser end.
(5) after debugging finishes, control the debugged process of procedure termination, debugging finishes.
Above-mentioned online program debugging method in affiliated step (1), when the programmer sends " starting debugging " order at browser end, attaches username information, debugged program relative address simultaneously.The control process, by the specific address of the debugged program of above-mentioned Information locating, starts debugged program.
Above-mentioned online program debugging method, in affiliated step (1), when debugged program runtime surpasses the threshold value of setting, daemon thread stops debugged process, and this debugs end.
Above-mentioned online program debugging method, in affiliated step (3) (4), after the control process of server end is obtained debugged process status information and control desk output, by server end push technology (comet), control desk output and debugged process status information pushing to browser end.
Above-mentioned online program debugging method, in affiliated step (4), after the control process of server end is obtained debugged process status information text, lexical analysis, grammatical analysis by text language, obtain running status.Running status comprises: the value that the position of the current operation of program, browser end need to be checked variable.
Above-mentioned online program debugging method, in affiliated step (5), debugged program termination has three kinds of possibilities: the natural termination of program end of run, user manually stop debugging, move overtime finger daemon termination debugging.
Technique effect of the present invention is: method of the present invention has guaranteed in the Online integration development environment, and the debugged program that the programmer can be correct at browser end has guaranteed the consistance of browser end and server end debugging mode; Multi-user's administrative mechanism is provided; Make the programmer can control the operational process of debugged process at browser end.
The accompanying drawing explanation
Fig. 1 means the flow process of debugging in the present invention.
Fig. 2 means to arrange in the present invention the example of breakpoint
Fig. 3 means the example of control desk input in the present invention
Fig. 4 means the example of single-step debug in the present invention
Fig. 5 means the example of debug command in the present invention " next line "
Fig. 6 means to check in the present invention the example of variate-value
Fig. 7 means to debug in the present invention the example of end
Embodiment:
Accompanying drawing 1 has been illustrated the debugging flow process of an example procedure.After starting application server, the control process of automatic Start-up and Adjustment.This control process is responsible for controlling all users' debugged process.
At first, the user logins online development environment, completes editor, the preservation of program.The position that need to stop in program arranges breakpoint.
Click " starting debugging " button and start debugging.Browser end sends the order of " debugging starts " to the control process of server end, the control process, according to user name and debugged program address, starts debugged process, sets maximum working time simultaneously, starts finger daemon.After controlling the debugged process of process initiation, return to the information that the browser end debugging starts, browser end demonstration debugging is carried out.
Debugged process is running into breakpoint, and operation stops.After the control process obtains the Stop message of debugged process, by debugged state of a process information, be pushed to browser end.The browser end display routine stops at the breakpoint place.
In browser end control desk input data.Client sends to the control process by the control desk input.The control process writes the control desk input on the inlet flow of debugged process.If find that the inlet flow of debugged process closes, directly return.
Browser end is clicked debug command, such as " single step enters, single step skip ", sends a command to the control process.The control process can send the related command operation to debugged process.
Browser end can be checked the local variable of current stack, or the value of a concrete variable.After control program is received and checked the variable request, send the order of checking variable to debugged process.Debugged process return state resulting text, control after process parse state resulting text the value that obtains variable, then propelling movement is worth to browser end.
When debugged process has control desk output, the control process gets control desk output, is pushed to browser end.
Program natural termination, user manually stop or the overtime termination of daemon thread after, the control process attempts killing debugged process, the message push simultaneously debugging stopped is to browser end.
Gordian technique wherein is as follows:
(1) the control process of server end debugging
The control process mainly is comprised of three modules:
Command interpreter.The control process is accepted debug command from browser end, and order is converted into debuggedly to advance
The acceptable instruction of journey.All instructions that interpreter is supported are as follows:
Operation Can accept instruction
Insert breakpoint -break-insert(line?number)
Delete breakpoint clear(line?number)
Bring into operation -exec-run
Continue operation -exec-continue
Stop operation -exec-abort
Single step enters -exec-step
Single step is exited -exec-next
Check the value of variable -data-evaluate-expression(var?name)
Check the value of the variable of all current stacks -list-locals1
The state resolver.Debugged state of a process changes, and can export corresponding status information text.These status informations are obtained by the control process with the form of text.Because state is of a great variety, the grammer of the text of status information is comparatively complicated,, if just use general string matching or matching regular expressions, be difficult to the correct status information that obtains.In the state resolver, the debugging mode text returned is carried out to grammatical analysis, lexical analysis, set up syntax tree, by the traversal syntax tree, finally obtain the status information that need to obtain.
The control desk input/output control unit.The input of the control desk brought in from browser, need the control desk input and output device to find debugged process corresponding to client by user name, after debugged process is imported to control desk input; The control desk output of debugged process, need, through the control desk input/output control unit, to find corresponding browser end, and control desk output is pushed to the objective browser end.Simultaneously, the control desk input/output control unit length that also control inputs is exported.After surpassing threshold value, the control desk input/output control unit can stop iostream, avoids system performance is caused damage.
(1) code security inspection
Traditional debugging based on local Integrated Development Environment, the programmer debugs on the machine of oneself, does not have safety problem.And, for the debugging based on online development environment, the programmer can, at any coding, comprise rogue program.Therefore, must do safety inspection to the code of program.
On specific implementation, the present invention adopts the processing mode of blacklist.Forbid and the use of operating system related function, comprise two functions of fork and system.The Fork function can be in operating system newly-built process, the shell-command that the system function can the call operation system.
(2) disposal route that debugged process endless loop, output are overflowed
Different from traditional this locality debugging, the debugging of Online integration development environment need to be in the face of multi-user's problem.A plurality of users debug simultaneously on a server, must avoid influencing each other between them.
For the unrestricted endless loop of some program, exhaust the situation of server cpu resource, the control process specifies maximum working time can to each debugged process.Once surpass this time, finger daemon will kill debugged process, stop debug process, avoid other tenants of undying influence on system operation, reduce system overhead.The setting of maximum working time is with reference to experience.For the scene the present invention relates to, the commissioning test time of a program can not surpass 5 minutes, and being made as 5 minutes is a suitable value.
For a large amount of control desk Output rusults of some program, server end is had to a large amount of transfer control platforms output data to the situation of browser end, the upper limit that the control process can setting control panel output.Once surpass the upper limit, the control process stops the obtaining of debugged process output stream, and allows debugged program ignore in the situation of control desk output and continues operation.Avoided so indivedual debugged programs to take in a large number the situation of the network bandwidth.
(2) server push technology
The order of traditional Http request protocol is: browser end sends a Http Request, after server end accepts request, returns to Http Response.This will initiate a request by the Seeking Truth browser, and browser end is responded.
For the debugging of online development environment, the debug procedures of server end can produce status data and control desk output.These outputs need server end to be pushed to browser end, and this just disagrees with traditional Http request.
In the present invention, client is by server push technology (Comet), relevant data-pushing to browser end.Particularly, a kind of method is that client removes to obtain the propelling data for the treatment of of server end every the set time.Seem like this to be exactly that server can arrive client to data-pushing, walked around the order of Http request protocol.

Claims (5)

1. the method for an on-line debugging C/C++ program is debugged the program in background server on browser, it is characterized in that, comprises the steps:
(1) programmer sends the order of " starting debugging " at browser end, and the control process of server end receives the order of " starting debugging ", the program code that security sweep will move, and scanning is by debugged process with the user name sign of rear startup.Start a daemon thread simultaneously, monitor the working time of debugged process.
(2) programmer can input data at the browser end control desk, and the control process of server end imports in the inlet flow of debugged process after receiving the control desk input.Simultaneously, control process is obtained the control desk output of debugged process.Server is pushed to browser end to control desk output, is shown to the programmer.
(3) in debug process, the programmer can send a series of debug commands at browser end, comprises that breakpoint adds, breakpoint is deleted, single step enters, single step is jumped out, run to current line, continue, check variate-value.After the control process receives debug command, debugged program is carried out to operation corresponding to debug command.
(4) debugged process in real time status information feedback to the control process.Control process parse state information text, push corresponding state to browser end.
(5) after debugging finishes, control the debugged process of procedure termination, debugging finishes.
2. the method for on-line debugging C/C++ program as claimed in claim 1, is characterized in that, in affiliated step (1), when the programmer sends " starting debugging " order at browser end, attaches username information, debugged program relative address simultaneously.The control process, by the specific address of the debugged program of above-mentioned Information locating, starts debugged program.
3. the method for on-line debugging C/C++ program as claimed in claim 1, is characterized in that, in affiliated step (1), when debugged program runtime surpasses the threshold value of setting, daemon thread stops debugged process, and this debugs end.
4. the method for on-line debugging C/C++ program as claimed in claim 1, it is characterized in that, in affiliated step (3) (4), after the control process of server end is obtained debugged process status information and control desk output, by server end push technology (comet), control desk output and debugged process status information pushing to browser end.
5. the method for on-line debugging C/C++ program as claimed in claim 1, it is characterized in that, in affiliated step (4), after the control process of server end is obtained debugged process status information text, lexical analysis, grammatical analysis parse state information text by text language, obtain running status.Running status comprises: the value that the position of the current operation of program, browser end need to be checked variable.
CN201310444806.5A 2013-09-25 A kind of method of on-line debugging C/C++ program Expired - Fee Related CN103473177B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310444806.5A CN103473177B (en) 2013-09-25 A kind of method of on-line debugging C/C++ program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310444806.5A CN103473177B (en) 2013-09-25 A kind of method of on-line debugging C/C++ program

Publications (2)

Publication Number Publication Date
CN103473177A true CN103473177A (en) 2013-12-25
CN103473177B CN103473177B (en) 2016-11-30

Family

ID=

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106406973A (en) * 2016-11-17 2017-02-15 杭州华恩教育科技有限公司 System and method for dynamically compiling and running external code
CN111464333A (en) * 2020-03-06 2020-07-28 浙江大华技术股份有限公司 Remote debugging method, computer equipment, storage device and remote debugging system
CN111984537A (en) * 2020-08-24 2020-11-24 上海睿成软件有限公司 WebIDE-based software testing method, storage medium and device
WO2021047585A1 (en) * 2019-09-12 2021-03-18 安徽寒武纪信息科技有限公司 Program debugging method, apparatus, debugging tool and computer device
CN114968751A (en) * 2021-02-24 2022-08-30 中国联合网络通信集团有限公司 Program debugging method and program debugging device of code-free development platform

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102270125A (en) * 2010-06-04 2011-12-07 中兴通讯股份有限公司 Device and method for developing Web application
US20120246610A1 (en) * 2011-03-23 2012-09-27 Infosys Technologies Ltd. Online integrated development environment with code assist

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102270125A (en) * 2010-06-04 2011-12-07 中兴通讯股份有限公司 Device and method for developing Web application
US20120246610A1 (en) * 2011-03-23 2012-09-27 Infosys Technologies Ltd. Online integrated development environment with code assist

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
PKUMASS团队: "云时代的集成开发环境", 《中国教育网络》 *
吴凌等: "CEclipse:一个基于服务组合的在线集成开发环境", 《计算机研究与发展》 *
朱松盛: "可在线编程的多功能单片机实验板", 《南京师范大学学报(工程技术版)》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106406973A (en) * 2016-11-17 2017-02-15 杭州华恩教育科技有限公司 System and method for dynamically compiling and running external code
WO2021047585A1 (en) * 2019-09-12 2021-03-18 安徽寒武纪信息科技有限公司 Program debugging method, apparatus, debugging tool and computer device
CN111464333A (en) * 2020-03-06 2020-07-28 浙江大华技术股份有限公司 Remote debugging method, computer equipment, storage device and remote debugging system
CN111984537A (en) * 2020-08-24 2020-11-24 上海睿成软件有限公司 WebIDE-based software testing method, storage medium and device
CN111984537B (en) * 2020-08-24 2021-12-07 上海睿成软件有限公司 WebIDE-based software testing method, storage medium and device
CN114968751A (en) * 2021-02-24 2022-08-30 中国联合网络通信集团有限公司 Program debugging method and program debugging device of code-free development platform

Similar Documents

Publication Publication Date Title
CN102789413B (en) A kind of debug system of concurrent program and method
CA2915620C (en) Method and apparatus for code virtualization and remote process call generation
CN112187585B (en) Network protocol testing method and device
US10185644B2 (en) Service implementation based debugger for service oriented architecture projects
US9720753B2 (en) CloudSeer: using logs to detect errors in the cloud infrastructure
CA2915619A1 (en) Method and apparatus for customized software development kit (sdk) generation
CN112988599B (en) Page debugging method and device, electronic equipment and storage medium
CN104281520A (en) Tracking and debugging method, device and system
CN102087577A (en) Location independent execution of user interface operations
CN101727316A (en) Parallel program integrated development system suitable for clustering system as well as application implementation method thereof
CN103729292A (en) Cross-host cross-platform remote command invoking method and system
CN102609472A (en) Method and system for implementing performance test of distributed database system
CN111949272A (en) Compilation optimization method and device for hosted application, electronic device and readable storage medium
CN113051514A (en) Element positioning method and device, electronic equipment and storage medium
CN103324567B (en) A kind of adjustment method of application engine and debug system
CN105955838A (en) System halt reason check method and device
CN102750143A (en) Digital signal processing (DSP) developing method based on matrix laboratory (MATLAB) component object model (COM) component calling
CN114253798A (en) Index data acquisition method and device, electronic equipment and storage medium
CN105630665A (en) Application program debugging method based on Android system, and terminal equipment
CN112667795A (en) Dialog tree construction method and device, dialog tree operation method, device and system
CN103473177A (en) Method for online debugging C/C++ program
CN103473177B (en) A kind of method of on-line debugging C/C++ program
CN108228448B (en) Code tracking method and device
CN103164776B (en) A kind of medicine traceability system and medicine retroactive method thereof and flow monitoring method
CN106649118B (en) A kind of generation method of the Java code SSA single path based on AST

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
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: 20161130

Termination date: 20170925