[antlr-interest] Issues Remote Debugging when using C Target and ASTs

Jim Idle jimi at temporal-wave.com
Wed Aug 6 14:47:14 PDT 2008


On Wed, 2008-08-06 at 13:43 -0600, Kurt Otte wrote:

> I am new to antlr so maybe these are known issues, but I am running
> into trouble trying to get AntlrWorks to remote debug a grammar which
> is targeted at C and generates ASTs.  I have found several issues
> which I wondered if anyone had some thoughts on how to resolve.

Remote C debugging only works with the very latest 3.1beta 2. However, I
have not done any testing (yet) with the tree grammar debugging I am
afraid. This bug may well still be present. I am glad you raised this
though as it had dropped off my radar. There is always just one more
last  thing to do!

Jim

> 
> 
> #1 - It appears that code generation with the C target and ASTs
> enabled is broken if the debug option is set.
> For example, with a simple example like this (foo.g)
> 
>     grammar foo;
> 
>     options
>     {
>       output=AST;
>       language = C;
>     }
> 
>     bar : 'A'..'Z' ;
> 
> I get the following error
> 
>     java org.antlr.Tool -debug foo.g
> 
>     ANTLR Parser Generator  Version 3.1b2 (July 17, 2008)  1989-2008
> 
>     Generating fooParser.c
>     error(10):  internal error: foo.g :
> java.lang.IllegalArgumentException: Can't find template
> parserCtorBody.st; group hierarchy is [C]
>     org.antlr.stringtemplate.StringTemplateGroup.lookupTemplate(StringTemplateGroup.java:507)
>     org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:392)
>     org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:404)
>     org.antlr.stringtemplate.StringTemplateGroup.lookupTemplate(StringTemplateGroup.java:484)
>     org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:392)
>     org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:404)
>     ...
> 
> Debugging this a bit, I found that 'parserCtorBody() ::= <<   >>' is
> missing from the file C.stg.  I am not sure if this is where it is
> expected to be found it in the C code generation case, but I notice it
> was defined there for java.  If I stub out this section in the C.stg
> file with a blank section for parserCtorBody(), the error goes away
> but I don't know enough about the code to propose a proper fix.
> 
> 
> #2 – If I disable AST generation, I can get the grammar to generate
> and compile in my C app.  This app will launch and hang waiting on the
> debugger as it is supposed to.  Then when I try to connect the
> debugger, it claims the source has changed.  An easy way to replicate
> this error is to take the 'C' example in the examples-v3/C directory
> and compile it with –debug enabled.  Then try to connect ANTLRWorks to
> it.  When I do this, I get this error:  'Warning: the grammar used by
> the remote parser is not the same (C.g")'.  Is this maybe a problem
> with picking up an extra quote in the file name?  I have tried several
> examples and so far I am unable to anything to remote connect.
> 
> 
> #3 – I seems the default remote debug port in C is different than the
> ANTLRWorks default.  It took me some digging through the code to find
> it, but I guess C expects the port to be 4100
> (antlr3debugeventlistener.h:  #define DEFAULT_DEBUGGER_PORT   0xBFCC)
> and AltlrWorks expects it to be 49153
> (http://www.antlr.org/wiki/pages/viewpage.action?pageId=4554898).  I
> am not sure if makes since to line these up or update the docs, but I
> thought I would pass it along for the next guy since it took some time
> to track down.
> 
> 
> Any thoughts on how to fix or work around these issues would be much
> appreciated.
> 
> 
> Thanks,
> 
> Kurt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080806/d965ca49/attachment-0001.html 


More information about the antlr-interest mailing list