CN104503793A - Method for running and graphically analyzing codes in code practicing software - Google Patents
Method for running and graphically analyzing codes in code practicing software Download PDFInfo
- Publication number
- CN104503793A CN104503793A CN201410812693.4A CN201410812693A CN104503793A CN 104503793 A CN104503793 A CN 104503793A CN 201410812693 A CN201410812693 A CN 201410812693A CN 104503793 A CN104503793 A CN 104503793A
- Authority
- CN
- China
- Prior art keywords
- code
- information
- file
- program
- variable
- 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.)
- Pending
Links
Landscapes
- Stored Programmes (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a method for running and graphically analyzing codes in code practicing software. The method includes the steps: 1), compiling a code submitted by a user through a compiler, and returning the code after passing confirmation; 2), generating two results in the process of compiling, wherein the results include a machine language with binary codes and action scope and digital display format information recording variable in the code; 3), starting to simulate each step when the codes run, and extracting state information of each step; 4), encapsulating the state information to be an engine, and providing a jsvascript file including program execution behaviors to a front-end program; 5), decomposing the information for preparation for dsiplay after the front-end program receives the Javascriptjs file; 6), displaying a graphical result through rendering by a browser. By the method, cost for the user to learn the codes is lowered, and principles and steps therein can be sensed while the user uses a high-level language for programming, so that learning effect of the user is improved.
Description
Technical field
The present invention relates to computer programming learning method, especially relate in computer programming process, by the operation of code and patterned parsing are combined, allow user see the change procedure of each step in code operational process and correlated variables, make user better understand principle and the process of programming.。
Background technology
In current computer programming study, by traditional code exercise software learning computer programming method.Above-mentioned code exercise software can only in the programmed environment of this locality, and the upper use of such as VS, eclipse, more novel product can be accomplished to programme on webpage.This situation causes the cost of user learning code very high, and user is after use higher level lanquage is programmed, and also needing computing machine code to be changed into machine language could run.This process is that " " operation, user can not perception principle wherein and step, affects the effect of user learning for black box.
Summary of the invention
The operation and the patterned parsing that the object of the invention is code to practise code in software combine, and allow user see each step in code operational process and the change procedure of correlated variables.User student is allowed better to understand principle and the process of programming.
In order to realize object of the present invention, following technical scheme is proposed:
Code practises the operation of code in software and a patterned analytic method, and described method uses compiler, program behavior information generator and browser, comprises step:
1) first user submit to code compile through compiler, confirm errorless after return;
2) two parts of results are generated in above-mentioned compilation process: one is the machine language of binary code, and portion is the action scope, the digital display format information that record variable in code;
3) start simulation in code each step operating, propose the status information of each step;
4) described status information is packaged into engine, the jsvascript file comprising program act of execution is supplied to Front End;
5) front end receives Jsvascriptjs file, then by information decomposition, ready for showing;
6) eventually pass playing up of browser, demonstrate patterned result.
In step 1, described compilation process comprises the code compilation process based on clang, comprises concrete steps:
1.1) code is submitted to: visitor submits to C code to run debugger to graphical code by front-end edit device automatically;
1.2) Clang lexical analysis and grammatical analysis: call Clang compiler, does morphology and all analyses of plumage to the code submitted to, and generate abstract syntax tree to code generator, generation variable output format and variable enliven block information in file;
1.3) code generator: read in abstract syntax tree from Clang, obtains assembly code, and then generating object file.Comprise variable name and register corresponding relation in assembly code, assembly instruction and code line number corresponding relation etc. meet the Debugging message of DWARF standard;
1.4) linker: read in the file destination that code generator generates, then generate last executable file with existing dynamic link library link.This executable file contains the convenient built-in function following the trail of code implementation of Debugging message and customization.
In step 3, also comprise:
3.1) executable file comprising procedure sign table information is loaded in LLDB process;
3.2) by breakpoint setup in main function position, guarantee that trace information is collected from the first row statement of main function;
3.3) use single step fill order, perform the collection of laggard line program running status in each single step;
3.4) collect the status information that present procedure runs, described status information comprises all values of the variable in action scope, the ruuning situation of call stack, the situation of local variable in the situation of object, the situation of global variable and current function in heap;
3.5) status information of step 3.4 being collected, adopts structurized mode, utilizes the dict dictionary structure in Python to store; If program not yet performs end, repeat the step that single step performs;
3.6) utilize json-dump storehouse, the program state information above-mentioned dictionary structure stored, is saved in text with json form;
3.7) by the json structured data that Json-dump generates, play up code generator through JS, generate the Javascript program code having comprised running state of programs record.
In step 6, comprise further:
6.1) running state of programs recorded information is loaded: by the Javascript load of file of generation in the phase of playing up, be saved in renderer inside in the mode of array;
6.2) one-step program running status is extracted: the single step counting run according to present procedure, extracts corresponding state from array, and gives renderer and play up;
6.3 program states are played up: according to the array content extracted, play up respectively to stack frame, heap space, global variable, pointer adduction relationship.Obtain final display effect.
The cost of user learning code reduces by the present invention, makes user can perception principle wherein and step while using higher level lanquage to carry out programming, and improves the effect of user learning.
Accompanying drawing explanation
Fig. 1 reflects the operation of code of the present invention and patterned analyzing step entire block diagram;
Fig. 2 is the code compilation process based on clang in background program behavioural analysis stage;
Fig. 3 is the Program extraction process in background program behavioural analysis stage;
Fig. 4 reflects the block diagram in foreground browser renders stage.
Embodiment
For making the object, technical solutions and advantages of the present invention clearly understand, below in conjunction with the drawings and specific embodiments, the present invention is described in more detail.
1, program is run
Fig. 1 reflects the operation of code of the present invention and patterned analyzing step entire block diagram, as shown in the figure:
First the compiling system that the code that user submits to runs debugger through graphical code compiles, confirm errorless after return;
Two parts of results are generated: one is the machine language of binary code, and portion is the information such as action scope, digital display format recording variable in code in compilation process;
System starts simulation in code each step operating, proposes the status information of each step;
These Information encapsulations become engine, are supplied to Front End;
Front end receives js file, then by information decomposition, ready for showing;
Eventually pass playing up of browser, demonstrate patterned result.
The architecture principle of 2, decomposing
1) Fig. 2 is the code compilation process of background program behavioural analysis stage based on clang, comprising:
Submit code to: visitor clicks
Button, front-end edit device submits to C code to run debugger to graphical code automatically;
Clang lexical analysis and grammatical analysis: graphical code runs debugger and calls Clang compiler, morphology and all analyses of plumage are done to the code submitted to, generate abstract syntax tree to code generator, generation variable output format and variable enliven block information in file;
Code generator: read in abstract syntax tree from Clang, obtains assembly code, and then generating object file.Comprise variable name and register corresponding relation in assembly code, assembly instruction and code line number corresponding relation etc. meet the Debugging message of DWARF standard;
Linker: read in the file destination that code generator generates, then run with graphical code the executable file that in debugger, existing dynamic link library link generation is last.This executable file contains Debugging message, and graphical code runs the convenient built-in function following the trail of code implementation of debugger customization.
2) Fig. 3 is the Program extraction process in background program behavioural analysis stage, comprising:
Trace object based on LLDB-Python-Binging: be loaded into by executable file in LLDB process, comprises procedure sign table information;
Breakpoint is set: by breakpoint setup in main function position, guarantees that the trace information of CTtutor is collected from the first row statement of main function;
Single step executive routine: use single step fill order, perform the collection of laggard line program running status in each single step;
Logging program running state information: collect the status information that present procedure runs, comprise all values of the variable in action scope, the ruuning situation of call stack, the situation of local variable in the situation of the situation of object, global variable, current function in heap;
Dictionary structure is stored in status information table: by the status information of collecting above, adopts structurized mode, utilizes the dict dictionary structure in Python to store.If program not yet performs end, repeat the step that single step performs;
Json-dump: utilize json-dump storehouse, the program state information above-mentioned dictionary structure stored, is saved in text with json form;
Play up code building: the json structured data that Json-dump generates, play up code generator through JS, generate the Javascript program code having comprised running state of programs record.
3) Fig. 4 is the foreground browser renders stage, comprising:
Running state of programs recorded information is loaded: the Javascript load of file graphical code being run the generation of debugger backstage, in the phase of playing up, is saved in renderer inside in the mode of array;
One-step program running status is extracted: the single step counting run according to present procedure, extracts corresponding state from array, and gives renderer and play up;
Program state is played up: according to the array content extracted, play up respectively to stack frame, heap space, global variable, pointer adduction relationship.Obtain final display effect.
Above-described specific embodiment; further detailed description has been carried out to object of the present invention, technical scheme and beneficial effect; be understood that; the foregoing is only specific embodiments of the invention; be not limited to the present invention; within the spirit and principles in the present invention all, any amendment made, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.
Claims (4)
1. code practises the operation of code in software and a patterned analytic method, and described method uses compiler, program behavior information generator and browser, it is characterized in that comprising step:
1) first user submit to code compile through compiler, confirm errorless after return;
2) two parts of results are generated in above-mentioned compilation process: one is the machine language of binary code, and portion is the action scope, the digital display format information that record variable in code;
3) start simulation in code each step operating, propose the status information of each step;
4) described status information is packaged into engine, the jsvascript file comprising program act of execution is supplied to Front End;
5) front end receives Jsvascriptjs file, then by information decomposition, ready for showing;
6) eventually pass playing up of browser, demonstrate patterned result.
2. analytic method according to claim 1, is characterized in that, in step 1, described compilation process comprises the code compilation process based on clang, comprises concrete steps:
1.1) code is submitted to: visitor submits to C code to run debugger to graphical code by front-end edit device automatically;
1.2) Clang lexical analysis and grammatical analysis: call Clang compiler, does morphology and all analyses of plumage to the code submitted to, and generate abstract syntax tree to code generator, generation variable output format and variable enliven block information in file;
1.3) code generator: read in abstract syntax tree from Clang, obtains assembly code, and then generating object file;
comprise variable name and register corresponding relation in assembly code, assembly instruction and code line number corresponding relation etc. meet the Debugging message of DWARF standard;
1.4) linker: read in the file destination that code generator generates, then generate last executable file with existing dynamic link library link;
this executable file contains the convenient built-in function following the trail of code implementation of Debugging message and customization.
3. analytic method according to claim 1, is characterized in that, in step 3, comprising:
3.1) executable file comprising procedure sign table information is loaded in LLDB process;
3.2) by breakpoint setup in main function position, guarantee that trace information is collected from the first row statement of main function;
3.3) use single step fill order, perform the collection of laggard line program running status in each single step;
3.4) collect the status information that present procedure runs, described status information comprises all values of the variable in action scope, the ruuning situation of call stack, the situation of local variable in the situation of object, the situation of global variable and current function in heap;
3.5) status information of step 3.4 being collected, adopts structurized mode, utilizes the dict dictionary structure in Python to store; If program not yet performs end, repeat the step that single step performs;
3.6) utilize json-dump storehouse, the program state information above-mentioned dictionary structure stored, is saved in text with json form;
3.7) by the json structured data that Json-dump generates, play up code generator through JS, generate the Javascript program code having comprised running state of programs record.
4., according to the analytic method of claim 1-3 described in one of them, it is characterized in that, in step 6, comprise further:
6.1) running state of programs recorded information is loaded: by the Javascript load of file of generation in the phase of playing up, be saved in renderer inside in the mode of array;
6.2) one-step program running status is extracted: the single step counting run according to present procedure, extracts corresponding state from array, and gives renderer and play up;
6.3 program states are played up: according to the array content extracted, play up respectively to stack frame, heap space, global variable, pointer adduction relationship; Obtain final display effect.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410812693.4A CN104503793A (en) | 2014-12-24 | 2014-12-24 | Method for running and graphically analyzing codes in code practicing software |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410812693.4A CN104503793A (en) | 2014-12-24 | 2014-12-24 | Method for running and graphically analyzing codes in code practicing software |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104503793A true CN104503793A (en) | 2015-04-08 |
Family
ID=52945194
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410812693.4A Pending CN104503793A (en) | 2014-12-24 | 2014-12-24 | Method for running and graphically analyzing codes in code practicing software |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104503793A (en) |
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105183552A (en) * | 2015-09-25 | 2015-12-23 | 东华大学 | System for positioning potential interruption safety hazard in operation system and application of system |
CN107895115A (en) * | 2017-12-04 | 2018-04-10 | 北京元心科技有限公司 | Method and device for preventing stack overflow and terminal equipment |
CN109471622A (en) * | 2018-11-02 | 2019-03-15 | 成都娄外科技有限公司 | A kind of program editing method and device |
CN110007922A (en) * | 2019-03-21 | 2019-07-12 | 深圳点猫科技有限公司 | Compilation Method, device and the equipment of graphical source code based on artificial intelligence |
CN110096281A (en) * | 2019-04-24 | 2019-08-06 | 深圳市码上趣学科技有限公司 | Code analysis method, resolution server, storage medium and device |
CN111381813A (en) * | 2018-12-28 | 2020-07-07 | 北京字节跳动网络技术有限公司 | Front-end page debugging method and device, computer equipment and storage medium |
CN111651155A (en) * | 2020-06-03 | 2020-09-11 | 北京智趣工场教育科技有限公司 | Programming learning operating system and external interactive system |
CN111708572A (en) * | 2020-05-20 | 2020-09-25 | 西安理工大学 | Automatic control flow chart generation method based on Clang program structure |
CN111767116A (en) * | 2020-06-03 | 2020-10-13 | 江苏中科重德智能科技有限公司 | Virtual machine for mechanical arm program development programming language and operation method for assembly file |
CN112133146A (en) * | 2020-10-14 | 2020-12-25 | 天津之以科技有限公司 | Algorithm practice code execution visualization system |
CN112598969A (en) * | 2020-12-28 | 2021-04-02 | 慧科教育科技集团有限公司 | Interactive programming teaching method |
CN113110845A (en) * | 2021-04-25 | 2021-07-13 | 达而观数据(成都)有限公司 | Plug-in system based on dynamic template compiling technology and implementation method thereof |
CN116501378A (en) * | 2023-06-27 | 2023-07-28 | 武汉大数据产业发展有限公司 | Implementation method and device for reverse engineering reduction source code and electronic equipment |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101650651A (en) * | 2009-09-17 | 2010-02-17 | 浙江大学 | Visualizing method of source code level program structure |
CN102915242A (en) * | 2012-09-26 | 2013-02-06 | 北京广利核系统工程有限公司 | Method for implementing code programming by graphical operations |
CN103197929A (en) * | 2013-03-25 | 2013-07-10 | 中国科学院软件研究所 | System and method for graphical programming facing children |
-
2014
- 2014-12-24 CN CN201410812693.4A patent/CN104503793A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101650651A (en) * | 2009-09-17 | 2010-02-17 | 浙江大学 | Visualizing method of source code level program structure |
CN102915242A (en) * | 2012-09-26 | 2013-02-06 | 北京广利核系统工程有限公司 | Method for implementing code programming by graphical operations |
CN103197929A (en) * | 2013-03-25 | 2013-07-10 | 中国科学院软件研究所 | System and method for graphical programming facing children |
Cited By (21)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105183552A (en) * | 2015-09-25 | 2015-12-23 | 东华大学 | System for positioning potential interruption safety hazard in operation system and application of system |
CN107895115A (en) * | 2017-12-04 | 2018-04-10 | 北京元心科技有限公司 | Method and device for preventing stack overflow and terminal equipment |
CN107895115B (en) * | 2017-12-04 | 2021-01-29 | 北京元心科技有限公司 | Method and device for preventing stack overflow and terminal equipment |
CN109471622A (en) * | 2018-11-02 | 2019-03-15 | 成都娄外科技有限公司 | A kind of program editing method and device |
CN111381813A (en) * | 2018-12-28 | 2020-07-07 | 北京字节跳动网络技术有限公司 | Front-end page debugging method and device, computer equipment and storage medium |
CN110007922B (en) * | 2019-03-21 | 2022-10-21 | 深圳点猫科技有限公司 | Artificial intelligence-based graphical source code compiling method, device and equipment |
CN110007922A (en) * | 2019-03-21 | 2019-07-12 | 深圳点猫科技有限公司 | Compilation Method, device and the equipment of graphical source code based on artificial intelligence |
CN110096281A (en) * | 2019-04-24 | 2019-08-06 | 深圳市码上趣学科技有限公司 | Code analysis method, resolution server, storage medium and device |
CN110096281B (en) * | 2019-04-24 | 2023-06-30 | 北京码上趣学科技有限公司 | Code analysis method, analysis server, storage medium and device |
CN111708572A (en) * | 2020-05-20 | 2020-09-25 | 西安理工大学 | Automatic control flow chart generation method based on Clang program structure |
CN111708572B (en) * | 2020-05-20 | 2022-11-25 | 西安理工大学 | Automatic control flow chart generation method based on Clang program structure |
CN111651155B (en) * | 2020-06-03 | 2020-12-11 | 北京智趣工场教育科技有限公司 | Programming learning operating system and external interactive system |
CN111651155A (en) * | 2020-06-03 | 2020-09-11 | 北京智趣工场教育科技有限公司 | Programming learning operating system and external interactive system |
CN111767116A (en) * | 2020-06-03 | 2020-10-13 | 江苏中科重德智能科技有限公司 | Virtual machine for mechanical arm program development programming language and operation method for assembly file |
CN111767116B (en) * | 2020-06-03 | 2023-09-05 | 江苏中科重德智能科技有限公司 | Virtual machine for developing programming language for mechanical arm program and running method for assembly file |
CN112133146A (en) * | 2020-10-14 | 2020-12-25 | 天津之以科技有限公司 | Algorithm practice code execution visualization system |
CN112598969A (en) * | 2020-12-28 | 2021-04-02 | 慧科教育科技集团有限公司 | Interactive programming teaching method |
CN113110845A (en) * | 2021-04-25 | 2021-07-13 | 达而观数据(成都)有限公司 | Plug-in system based on dynamic template compiling technology and implementation method thereof |
CN113110845B (en) * | 2021-04-25 | 2021-10-26 | 达而观数据(成都)有限公司 | Plug-in system based on dynamic template compiling technology and implementation method thereof |
CN116501378A (en) * | 2023-06-27 | 2023-07-28 | 武汉大数据产业发展有限公司 | Implementation method and device for reverse engineering reduction source code and electronic equipment |
CN116501378B (en) * | 2023-06-27 | 2023-09-12 | 武汉大数据产业发展有限公司 | Implementation method and device for reverse engineering reduction source code and electronic equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104503793A (en) | Method for running and graphically analyzing codes in code practicing software | |
US20180107585A1 (en) | Using edit and continue to dynamically set and unset optimizations in source code while debugging | |
Garzón et al. | Umple: A framework for model driven development of object-oriented systems | |
CN103942086A (en) | AADL-based method for establishing, analyzing and simulating hybrid system model | |
CN106484403A (en) | A kind of cross-platform graphical developing system of robot | |
CN101976187A (en) | Stack tracing method and device in decompilation process and decompiler | |
Klemens | 21st century C: C tips from the new school | |
CN108595334B (en) | Method and device for calculating dynamic slices of Java program and readable storage medium | |
CN104915199B (en) | A kind of method and apparatus that Flash projects are converted to Html5 projects | |
Leroy | Mechanized semantics for compiler verification | |
CN104317580A (en) | Integrated development environment for virtual test application (APP) | |
CN110187886A (en) | A kind of documentation website generation method and terminal | |
CN110442520B (en) | Cross debugging system and method based on PLC programming language | |
Tapia et al. | A PDDL-based simulation system | |
US11714609B2 (en) | Automatic generation of source code implementing a regular expression | |
CN103455307A (en) | Method and device for processing information output by command line | |
CN114281709A (en) | Unit testing method, system, electronic equipment and storage medium | |
CN111736834B (en) | DSL-based user interface generation method, device and storage medium | |
JP2011186806A (en) | Debugging device and debugging method | |
Aranega et al. | Using trace to situate errors in model transformations | |
US20090112568A1 (en) | Method for Generating a Simulation Program Which Can Be Executed On a Host Computer | |
Blunk et al. | Efficient Development of Domain-Specific Simulation Modelling Languages and Tools | |
Garzón et al. | Exploring how to develop transformations and tools for automated umplification | |
CN117520191B (en) | Test completeness checking method, device and storage medium based on program path | |
Lee et al. | Using LLDB |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20150408 |