CN110597502B - Single step debugging method for realizing PL/SQL language based on java - Google Patents

Single step debugging method for realizing PL/SQL language based on java Download PDF

Info

Publication number
CN110597502B
CN110597502B CN201910766274.4A CN201910766274A CN110597502B CN 110597502 B CN110597502 B CN 110597502B CN 201910766274 A CN201910766274 A CN 201910766274A CN 110597502 B CN110597502 B CN 110597502B
Authority
CN
China
Prior art keywords
statement
stack
sentence
execution
sub
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910766274.4A
Other languages
Chinese (zh)
Other versions
CN110597502A (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.)
Business Intelligence Of Oriental Nations Corp ltd
Original Assignee
Business Intelligence Of Oriental Nations Corp ltd
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 Business Intelligence Of Oriental Nations Corp ltd filed Critical Business Intelligence Of Oriental Nations Corp ltd
Priority to CN201910766274.4A priority Critical patent/CN110597502B/en
Publication of CN110597502A publication Critical patent/CN110597502A/en
Application granted granted Critical
Publication of CN110597502B publication Critical patent/CN110597502B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention relates to a single step debugging method for realizing PL/SQL language based on java, which comprises the following steps: s1, adding a statement call stack to record a statement execution track; s2, analyzing the source codes to generate a grammar tree; s3, adding operation logic of a statement call stack to the grammar tree; s4, circularly executing the stack top statement of the statement call stack until the statement call stack is empty. The invention can restore to the position of the breakpoint to execute again by calling the single-step execution method of the stack top statement, without executing the whole grammar tree again or realizing additional traversal logic from bottom to top.

Description

Single step debugging method for realizing PL/SQL language based on java
Technical Field
The invention relates to the programming field, in particular to a single-step debugging method for realizing a PL/SQL language based on java.
Background
An interpreter is a computer program that can interpret and run a high-level programming language line by line. The single step debugging of the interpreter can give prompts line by line when interpreting the execution programming language, thereby facilitating the debugging of the user. The current most realization methods mainly comprise the following steps:
first, the program source code is parsed into a syntax tree. The invention mainly relates to single-step debugging of source code level, and the generation method of the grammar tree is not repeated. FIG. 1 is a schematic diagram of a section of a PL/SQL script parsed into a syntax tree structure.
Wherein the execution block is a delete.
declares is a variable declaration block,
declare is a variable declaration statement,
block is a begin.
for loop is a loop statement for a loop statement,
assignment is an assignment statement.
And secondly, traversing the grammar tree to execute calculation. The traversal order of the syntax tree is typically a top-to-bottom traversal, as shown in fig. 2.
As shown in fig. 2, the sequence of for loop statement traversal in the PL/SQL script is the sequence of right sides (1) to (8), that is, the block statement (block) is called by the uppermost tree node executable block (execution block), the first assignment statement (assignment) of the for loop (for loop) is pushed down in turn, after the assignment statement calculation is completed, the first assignment statement (assignment) is returned to the for loop (for loop) by (4), the second assignment statement (assignment) is executed by the for loop, after the assignment statement execution is completed, the first assignment statement (assignment) is returned to the for loop (for loop) by (6), if its exit condition has been satisfied in the for loop, the first assignment statement (block) is returned to the block statement (block), and if there are no other block to be executed in the block statement, the first tree node executable block (execution block) is returned to the uppermost tree node executable block (execution block), thereby completing the traversal calculation of grammar statement is completed.
And thirdly, realizing single-step debugging. The single step debugging is to send out the information such as the current sentence execution state, variable condition and the like when the grammar tree traverses each sentence, and usually the information is displayed on a UI interface, so that the user interaction is convenient, then the user is waited to input a continuous execution instruction, and after receiving the continuous execution instruction, the grammar tree is continuously traversed. As shown in fig. 3, is statement single-step logic.
Multiple breakpoint debugging can be realized similarly to single-step debugging logic, and whether the sentences with breakpoints are sentences is judged before each sentence starts to execute.
With respect to the above-described prior art, it can be found that the implementation scheme records and displays only the information of the currently executed sentence, variable information, and the like, as shown in fig. 3. Although single-step debugging can be realized, the debugging is disposable and cannot be restored to the position of a certain breakpoint, and execution is continued from the secondary position. For the PL/SQL language, the execution time of the PL/SQL script is quite long, and some time reaches more than 24 hours, so that when the script is debugged, if the script is restarted from the beginning, a lot of time and resources are wasted, and the script is always required to be recovered from the position of a certain breakpoint and to be debugged continuously in a single step. If breakpoint resume execution is implemented with the current scheme, the traversal logic of the syntax tree is changed to that shown in fig. 4.
As shown in fig. 4, the breakpoint resume position is a statement pointed from a black arrow, i.e., an assignment statement node (assignment) to the left of a for loop (for loop), from which the traversal order of execution is resumed is shown. After the calculation of the assignment statement is finished, the upper layer for loop statement is called upwards by (1), the right assignment statement is called by (2), the right assignment statement is finished, the right assignment statement is returned to the for loop statement by (3), if the calculation of the for loop is finished, the block statement (block) is called upwards by (4), after the calculation of the block statement is finished, the block statement is returned to the executable block by (5), and after the calculation of the executable block is finished, the initial assignment statement is returned layer by (6) (7) (8). It can be seen from the secondary flow that, unlike the traversal order in fig. 2, even some positions are reversed, and some parts are actually bottom-up. That is, if debugging after breakpoint recovery is to be implemented, the partial bottom-up traversal logic needs to be implemented again, which wastes development effort.
For the problems in the related art, no effective solution has been proposed at present.
Disclosure of Invention
Aiming at the technical problems in the related art, the invention provides a single-step debugging method for realizing the PL/SQL language based on java, which aims to realize the single-step debugging method which is based on traversing logic from top to bottom, can recover from break points and continuously execute debugging.
In order to achieve the technical purpose, the technical scheme of the invention is realized as follows:
a java-based single-step debugging method for realizing PL/SQL language comprises the following steps:
s1, adding a statement call stack to store a statement execution state;
s2, analyzing the source codes to generate a grammar tree;
s3, adding operation logic of a statement call stack to the grammar tree;
s4, circularly executing the stack top statement of the statement call stack until the statement call stack is empty.
Further, the operation logic added in the step S3 includes a single step execution method, a statement push method, a sub-statement push method, and a statement pop method.
Furthermore, the single step execution method adds sentence call stack parameters, thereby being convenient for operating the sentence call stack.
Furthermore, the single-step execution method does not perform statement execution calculation and breakpoint judgment.
Further, the sub-sentence stacking method realizes judging whether sentence execution is finished or not, if not, the next sentence is pressed to the stack top, and index of the sentence is added by 1; if it has ended, return false, i.e. no sub-statement needs to be pushed.
Furthermore, the statement stack removing method realizes the judgment of statement stack removing.
Further, the stack removing method of the grammar tree needs to further judge the sub-statement stack removing method of the stack top statement, if the sub-statement exists, the sub-statement stack removing is carried out, and if the sub-statement does not exist, the stack removing is continued.
The invention has the beneficial effects that:
1. breakpoint recovery can be realized, namely, debugging is continued from a certain breakpoint position, and debugging time is saved.
2. The breakpoint resume calculation logic is the same as the normal single-step execution logic, and is the traversing sequence from top to bottom, so that additional traversing logic from bottom to top is not needed to be realized.
3. Breakpoint recovery can also be used as a field recovery for program exceptions.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a diagram illustrating an example of a syntax tree generation flow according to the background of the invention.
Fig. 2 is a diagram illustrating syntax tree traversal according to the background of the invention.
FIG. 3 is an exemplary diagram of statement single-step debugging logic in accordance with the background of the invention.
Fig. 4 is a diagram illustrating an example of a syntax tree traversal sequence after breakpoint recovery according to the background of the invention.
Fig. 5 is a schematic diagram of a statement call stack (CallStack) structure according to an embodiment of the present invention.
Fig. 6 is a diagram of a syntax tree class according to an embodiment of the present invention.
Fig. 7 is a schematic diagram of an example script and its syntax tree structure according to an embodiment of the present invention.
FIG. 8 is a schematic diagram of a statement call stack as a function of single step execution, according to an embodiment of the invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which are derived by a person skilled in the art based on the embodiments of the invention, fall within the scope of protection of the invention.
According to the java-based single-step debugging method for realizing the PL/SQL language, the following improvement is made on single-step debugging in the prior art:
1. a statement call stack (CallStack) is added to record the statement execution trace.
2. And adding an operation on a statement call stack (CallStack) into the grammar tree traversal logic to record the statement execution track.
3. The single step execution is modified to be driven by a stack top statement of an execution statement call stack (CallStack) to realize breakpoint recovery.
In the preferred embodiment, the specific implementation steps are as follows:
in the first step, a statement call stack (CallStack) is added, the structure of which is shown in fig. 5. Wherein, runtimeStatementPointer is a statement pointer used to identify the statement execution to index.
And secondly, analyzing the source codes to generate a grammar tree. This step is consistent with the prior art and will not be described in detail.
Thirdly, the grammar tree is added with operation logic of a sentence call stack (CallStack). The syntax tree class diagram is shown in fig. 6. Wherein:
the steppexelectue () method is a single-step execution method, and adds a parameter callStack to facilitate the operation on a statement call stack. The parameter Context is a variable up and down Wen Zhan, which is used for saving variable information, and has a small relation with single step execution debugging, and will not be described in detail.
The onenteringstate () method is a statement push method.
The next subttatment () method is a sub-sentence push method. And (3) judging whether the execution of the statement is finished or not, if not, calling to press the next statement to the stack top, adding 1 to index of the statement, and if so, returning to false, namely, no sub-statement needs to be pushed.
The onextingstate () method is a statement pop method. The method for pushing the sub-sentence of the stack top sentence (next sub-state) needs to be further judged when the sentence is pushed off, if the sub-sentence exists, the sub-sentence is pushed off, and if the sub-sentence does not exist, the stack is continuously pushed off.
And fourthly, circularly executing a stack top statement of a statement call stack (CallStack) until the statement in the stack is empty, and realizing single-step execution driven by executing the stack top statement, so that the execution traverses according to the sequence in the stack. The logic is simple to realize in this step, only one cycle is needed, and redundant description is omitted.
In order to facilitate understanding of the above technical solutions of the present invention, the following describes the above technical solutions of the present invention in detail by a specific usage manner.
In the preferred embodiment, the execution of a section of PL/SQL script is taken as an example, and the calling sequence of each method in the above steps is described, and the calculation logic of the method is also specifically described. The PL/SQL script source code and its syntax tree structure are shown in FIG. 7.
Where fun1 is a custom function that is called in an executable block (execution block).
First, a single step execution method (steppexelectue) of an executable block (execution block) is called, which calls a statement push method (oneenteringstate), adds the executable block (execution block) to the stack, and sets its index to 0, indicating the first statement. After the executable block (execution block) is pushed, the calculation logic of the statement is continuously executed, that is, a single step execution method (steppexecute) of a left declaration block (declares) is called, the declaration block (declares) is continuously pushed, the execution continues until the first leaf node, that is, the first declaration statement (declare), is reached, no operation is performed after the declaration statement is pushed for the first time, and the operation returns in sequence, so that the situation in the stack is as shown in (1) in fig. 8, that is, the stack top is the declaration statement, and the execution states of the upper-layer statements are recorded in the stack in sequence.
Then, the declaration statement at the top of the stack is fetched, and the single-step execution method (stepexsection) is called again, which executes its own calculation logic and records the information of the variable into the variable up and down Wen Zhan (Context). At this point the statement has been calculated to end, calling its pop method (onextingstate). The stack-removing method is that the stack is removed from the statement call stack (CallStack), then the statement at the top of the stack is taken out, and the statement at the top of the stack is called, namely, the sub-statement stack-removing method (nextsubstate) of the statement block (declares), and the stack-removing method of the statement block (declares) is called because only one statement exists in the current statement block. Similar to the stack-removing method of the declaration statement, the declaration block is removed, then the top statement is removed again, the execution block (execution block) is called, the sub-statement stack-removing method (next sub-state) is called, and since the right subtree exists in the execution block (execution block), the index is added with 1, and the single-step execution method (stepexsection) of the right subtree is called, and similar to the single-step execution method described above, stack removing is sequentially performed until the left assignment statement of the for loop (for loop) is removed. I.e., the case of a statement call stack, is shown in fig. 8 (2).
Finally, each time, a sentence is taken out from the stack top to carry out single-step execution, when the sentence calculation is finished, a new sentence is added to the stack top in the stack unwinding process, and the process is circulated until a sentence call stack (CallStack) is empty.
As can be seen from the above embodiment, the traversal of the syntax tree is driven by the statement at the top of the call stack (CallStack) of the execution statement, if the information of the call stack (CallStack) of the statement is saved according to the breakpoint in single-step debugging, the single-step execution method (stepexsection) of the statement at the top of the stack can be restored to the breakpoint position for re-execution without re-executing the whole syntax tree or implementing additional bottom-up traversal logic.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.

Claims (1)

1. A single-step debugging method for realizing PL/SQL language based on java is characterized by comprising the following steps:
s1, adding a statement call stack to store a statement execution state;
s2, analyzing the source codes to generate a grammar tree;
s3, adding operation logic of a statement call stack to the grammar tree; the added operation logic in the step S3 comprises a single step execution method, a statement push method, a sub-statement push method and a statement push method; the single step execution method adds sentence call stack parameters, thereby being convenient for operating the sentence call stack; the single step execution method does not carry out statement execution calculation and breakpoint judgment; the sub-sentence stacking method realizes judging whether the sentence execution is finished or not, if not, the next sentence is pressed to the stack top, and the index of the sentence is added by 1; if so, returning to false, namely, no sub-statement needs to be pushed; the statement stack removing method realizes the judgment of statement stack removing; the stack pulling method of the sub-sentence of the sentence at the top of the stack needs to be further judged when the grammar tree is pulled down, if the sub-sentence exists, the sub-sentence is pulled down, and if the sub-sentence does not exist, the stack pulling down is continued;
s4, circularly executing the stack top statement of the statement call stack until the statement call stack is empty.
CN201910766274.4A 2019-08-20 2019-08-20 Single step debugging method for realizing PL/SQL language based on java Active CN110597502B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910766274.4A CN110597502B (en) 2019-08-20 2019-08-20 Single step debugging method for realizing PL/SQL language based on java

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910766274.4A CN110597502B (en) 2019-08-20 2019-08-20 Single step debugging method for realizing PL/SQL language based on java

Publications (2)

Publication Number Publication Date
CN110597502A CN110597502A (en) 2019-12-20
CN110597502B true CN110597502B (en) 2023-05-23

Family

ID=68854700

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910766274.4A Active CN110597502B (en) 2019-08-20 2019-08-20 Single step debugging method for realizing PL/SQL language based on java

Country Status (1)

Country Link
CN (1) CN110597502B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113721896A (en) * 2021-06-25 2021-11-30 中债金科信息技术有限公司 Optimization processing method and device for financial fraud modeling language
CN117076314A (en) * 2023-08-22 2023-11-17 深圳计算科学研究院 Lightweight PL/SQL language debugger implementation method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102202242A (en) * 2011-05-19 2011-09-28 广东星海数字家庭产业技术研究院有限公司 Realization method of JavaScript interpreter based on set-top box browser
CN102981957A (en) * 2012-11-30 2013-03-20 福建天晴数码有限公司 Virtual breakpoint script debugging method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8087002B2 (en) * 2006-04-04 2011-12-27 Tibco Software Inc. Method and system for providing a visual debugger for an interpreted statistical language
US10127138B2 (en) * 2013-06-06 2018-11-13 Microsoft Technology Licensing, Llc. Debugging native code by transitioning from execution in native mode to execution in interpreted mode
US9507691B2 (en) * 2014-01-10 2016-11-29 International Business Machines Corporation Conditional component breakpoint setting system and method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102202242A (en) * 2011-05-19 2011-09-28 广东星海数字家庭产业技术研究院有限公司 Realization method of JavaScript interpreter based on set-top box browser
CN102981957A (en) * 2012-11-30 2013-03-20 福建天晴数码有限公司 Virtual breakpoint script debugging method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
一种C语言级单步调试系统的功能实现方案;林广栋等;《单片机与嵌入式系统应用》;20150201(第02期);第48-51页 *
一种组合式基于调用栈的程序切片方法;戚晓芳等;《东南大学学报(自然科学版)》;20111120;第41卷(第06期);第1171-1176页 *

Also Published As

Publication number Publication date
CN110597502A (en) 2019-12-20

Similar Documents

Publication Publication Date Title
US10671355B2 (en) Code completion with machine learning
Miltner et al. On the fly synthesis of edit suggestions
US9110682B2 (en) State machine control of a debugger
US8533669B2 (en) Analysis of dynamic elements in bounded time
CN110149800B (en) Apparatus for processing abstract syntax tree associated with source code of source program
US8201140B2 (en) System and method for creating and using graphical object instances in a statechart environment
CN110597502B (en) Single step debugging method for realizing PL/SQL language based on java
US10540262B2 (en) Using edit and continue to dynamically set and unset optimizations in source code while debugging
US11579856B2 (en) Multi-chip compatible compiling method and device
CN103077111A (en) Method and system for locating continuous integration failed case
CN108595334B (en) Method and device for calculating dynamic slices of Java program and readable storage medium
CN110362312A (en) A kind of syntax conversion compiling system and method suitable for a variety of frames
CN113312268A (en) Intelligent contract code similarity detection method
CN111857681B (en) Software-defined key function positioning and extracting method of C + + system
Iannone et al. Refactoring android-specific energy smells: A plugin for android studio
CN111158665B (en) Code generation method and device, electronic equipment and storage medium
CN111222141B (en) Automobile electronic control unit code vulnerability analysis method and system
CN117289938A (en) Intelligent auxiliary system for software development
Haque et al. Generic code cloning method for detection of clone code in software development
US20150026523A1 (en) Debugging method and computer program product
Mota et al. Model checking CML: tool development and industrial applications
Zhang et al. Identifying use cases in source code
CN112596737A (en) Method, system, equipment and storage medium for scanning function call relation
EP3942404A1 (en) Code completion for overloaded methods
CN109947420A (en) A kind of the shortcut key mechanism implementation method and electronic equipment of code editor

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