[antlr-interest] v3.0 debug interface
Terence Parr
parrt at cs.usfca.edu
Thu Mar 24 18:45:45 PST 2005
On Mar 24, 2005, at 6:17 PM, Tom Brandon wrote:
> I agree, though a plugin to what? How exactly is the instrumentation
> supposed to happen (Ter?)? I assume it will be through custom code
> generators extending the base ones to add debug functionality? So, will
> these be provided by Antlr or will the IDE be responsible for hooking
> in
> it's own debug generators? And then how will it divide between core
> Antlr and code-gens? Presumably some mix is needed. Code-gen needs to
> provide language-specific debug calls, but implementing entire debug
> system would be troublesome, so ideally core Antlr would be doing
> something, building on smaller units specified by code-gen (perhaps
> just
> low-level call-message stuff, perhaps higher, allowing C# to spit out
> conditional methods for debug builds might be nice). And then the IDE
> seems to need some place in the whole thing, to specify whether it
> wants
> to be doing in-process (for a target-language it can host) or net based
> otherwise for instance.
The way it works now is the following. There is a -debug command line
option that notifies the code generator to turn on the debug attribute
in the code generation templates. Then any template can reference that
boolean. For example, in the rule template you'll see this:
<if(debug)>
dbg.enterRule("<ruleName>");
dbg.location(<ruleDescriptor.tree.line>,
<ruleDescriptor.tree.column>);<\n>
<endif>
In the parser template, you'll see:
class <name> extends <if(debug)>DebugParser<else>Parser<endif> {
so some of the triggers are in the DebugParser.
These are in the Java templates. Presumably C would do something else
such as call a function or two that squirt text across the socket to
Jean's Java-based debugger.
In the debugger, the protocol will be interpreted and then
ANTLRDebugInterface methods will be triggered appropriately. So, the
debugger should not care what language is generating the events. It
will, however, have to specifically connect to a running process via a
socket to get the events. It will also be able to just invoke a parser
class if you are using Java, but that brings up other problems like
where to get input and how exactly to start up a parser etc... Those I
will work on with Jean Bovet.
Generating extra code for debugging is not that hard thanks to
StringTemplate.
Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
More information about the antlr-interest
mailing list