How to pause a custom built interpreter while debugging?
I am developing a new custom programming language to perform some computations on numbers and display the results in a particular format.
For this purpose, I am using Antlr4 for Lexical Analysis and Parsing, and am developing this in Java. I have been able to "execute" the program by overriding the visitor methods generated by Antlr4.
I am now trying to add debugging functionality, and am trying to pause the execution upon hitting a breakpoint and then resume. Apart from this, I also need to support Step Through, Step In, Step Out, and Resume.
Could someone please throw some light on how to accomplish this?
java debugging antlr antlr4 interpreter
add a comment |
I am developing a new custom programming language to perform some computations on numbers and display the results in a particular format.
For this purpose, I am using Antlr4 for Lexical Analysis and Parsing, and am developing this in Java. I have been able to "execute" the program by overriding the visitor methods generated by Antlr4.
I am now trying to add debugging functionality, and am trying to pause the execution upon hitting a breakpoint and then resume. Apart from this, I also need to support Step Through, Step In, Step Out, and Resume.
Could someone please throw some light on how to accomplish this?
java debugging antlr antlr4 interpreter
Usually I would recommend JITing the code and inserting interrupt code 3, then catch with a debugger, but that doesn’t really work here. Instead of what you’re currently doing I would recommend compiling the code into a virtual language which you would then run over sequentially, then you can add code to create breakpoints. Once a breakpoint is triggered in your virtual code the simplest (and most hacky) solution would be to call a dummy function which you place a breakpoint into in your IDE.
– van dench
Jan 1 at 4:35
add a comment |
I am developing a new custom programming language to perform some computations on numbers and display the results in a particular format.
For this purpose, I am using Antlr4 for Lexical Analysis and Parsing, and am developing this in Java. I have been able to "execute" the program by overriding the visitor methods generated by Antlr4.
I am now trying to add debugging functionality, and am trying to pause the execution upon hitting a breakpoint and then resume. Apart from this, I also need to support Step Through, Step In, Step Out, and Resume.
Could someone please throw some light on how to accomplish this?
java debugging antlr antlr4 interpreter
I am developing a new custom programming language to perform some computations on numbers and display the results in a particular format.
For this purpose, I am using Antlr4 for Lexical Analysis and Parsing, and am developing this in Java. I have been able to "execute" the program by overriding the visitor methods generated by Antlr4.
I am now trying to add debugging functionality, and am trying to pause the execution upon hitting a breakpoint and then resume. Apart from this, I also need to support Step Through, Step In, Step Out, and Resume.
Could someone please throw some light on how to accomplish this?
java debugging antlr antlr4 interpreter
java debugging antlr antlr4 interpreter
asked Jan 1 at 4:19
user2970477user2970477
337
337
Usually I would recommend JITing the code and inserting interrupt code 3, then catch with a debugger, but that doesn’t really work here. Instead of what you’re currently doing I would recommend compiling the code into a virtual language which you would then run over sequentially, then you can add code to create breakpoints. Once a breakpoint is triggered in your virtual code the simplest (and most hacky) solution would be to call a dummy function which you place a breakpoint into in your IDE.
– van dench
Jan 1 at 4:35
add a comment |
Usually I would recommend JITing the code and inserting interrupt code 3, then catch with a debugger, but that doesn’t really work here. Instead of what you’re currently doing I would recommend compiling the code into a virtual language which you would then run over sequentially, then you can add code to create breakpoints. Once a breakpoint is triggered in your virtual code the simplest (and most hacky) solution would be to call a dummy function which you place a breakpoint into in your IDE.
– van dench
Jan 1 at 4:35
Usually I would recommend JITing the code and inserting interrupt code 3, then catch with a debugger, but that doesn’t really work here. Instead of what you’re currently doing I would recommend compiling the code into a virtual language which you would then run over sequentially, then you can add code to create breakpoints. Once a breakpoint is triggered in your virtual code the simplest (and most hacky) solution would be to call a dummy function which you place a breakpoint into in your IDE.
– van dench
Jan 1 at 4:35
Usually I would recommend JITing the code and inserting interrupt code 3, then catch with a debugger, but that doesn’t really work here. Instead of what you’re currently doing I would recommend compiling the code into a virtual language which you would then run over sequentially, then you can add code to create breakpoints. Once a breakpoint is triggered in your virtual code the simplest (and most hacky) solution would be to call a dummy function which you place a breakpoint into in your IDE.
– van dench
Jan 1 at 4:35
add a comment |
1 Answer
1
active
oldest
votes
ANTLR4 generated parsers cannot be stopped and resumed in the middle of a parse run. For that use the interpreters that come with the ANTLR4 runtime. They implement a simple ATN walk, which can be stopped at any point and the current ATN state be saved for later resume of the debugger.
I implemented this approach in my vscode-antlr4 extension, which allows to debug arbitrary ANTLR4 grammars. See also the vscode marketplace for more details.
Thank you for sharing this. I will try this approach.
– user2970477
Jan 3 at 10:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53992981%2fhow-to-pause-a-custom-built-interpreter-while-debugging%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
ANTLR4 generated parsers cannot be stopped and resumed in the middle of a parse run. For that use the interpreters that come with the ANTLR4 runtime. They implement a simple ATN walk, which can be stopped at any point and the current ATN state be saved for later resume of the debugger.
I implemented this approach in my vscode-antlr4 extension, which allows to debug arbitrary ANTLR4 grammars. See also the vscode marketplace for more details.
Thank you for sharing this. I will try this approach.
– user2970477
Jan 3 at 10:51
add a comment |
ANTLR4 generated parsers cannot be stopped and resumed in the middle of a parse run. For that use the interpreters that come with the ANTLR4 runtime. They implement a simple ATN walk, which can be stopped at any point and the current ATN state be saved for later resume of the debugger.
I implemented this approach in my vscode-antlr4 extension, which allows to debug arbitrary ANTLR4 grammars. See also the vscode marketplace for more details.
Thank you for sharing this. I will try this approach.
– user2970477
Jan 3 at 10:51
add a comment |
ANTLR4 generated parsers cannot be stopped and resumed in the middle of a parse run. For that use the interpreters that come with the ANTLR4 runtime. They implement a simple ATN walk, which can be stopped at any point and the current ATN state be saved for later resume of the debugger.
I implemented this approach in my vscode-antlr4 extension, which allows to debug arbitrary ANTLR4 grammars. See also the vscode marketplace for more details.
ANTLR4 generated parsers cannot be stopped and resumed in the middle of a parse run. For that use the interpreters that come with the ANTLR4 runtime. They implement a simple ATN walk, which can be stopped at any point and the current ATN state be saved for later resume of the debugger.
I implemented this approach in my vscode-antlr4 extension, which allows to debug arbitrary ANTLR4 grammars. See also the vscode marketplace for more details.
answered Jan 1 at 11:45
Mike LischkeMike Lischke
21.5k352105
21.5k352105
Thank you for sharing this. I will try this approach.
– user2970477
Jan 3 at 10:51
add a comment |
Thank you for sharing this. I will try this approach.
– user2970477
Jan 3 at 10:51
Thank you for sharing this. I will try this approach.
– user2970477
Jan 3 at 10:51
Thank you for sharing this. I will try this approach.
– user2970477
Jan 3 at 10:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53992981%2fhow-to-pause-a-custom-built-interpreter-while-debugging%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Usually I would recommend JITing the code and inserting interrupt code 3, then catch with a debugger, but that doesn’t really work here. Instead of what you’re currently doing I would recommend compiling the code into a virtual language which you would then run over sequentially, then you can add code to create breakpoints. Once a breakpoint is triggered in your virtual code the simplest (and most hacky) solution would be to call a dummy function which you place a breakpoint into in your IDE.
– van dench
Jan 1 at 4:35