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

Kurt Otte kurtotte at gmail.com
Wed Aug 6 15:04:24 PDT 2008


Jim,

I am using 3.1b2 with a regular (not a tree) grammar when I am seeing
these issues.

    ANTLR Parser Generator  Version 3.1b2 (July 17, 2008)  1989-2008

Is there a newer beta I should grab?  Remote debugging of a regular
grammar is supported, right?

I am have tried antlrworks-1.1.7.jar and antlrworks-1.2b5.jar.  They
both show the same issues.

Thanks,

Kurt



On Wed, Aug 6, 2008 at 3:47 PM, Jim Idle <jimi at temporal-wave.com> wrote:
> 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
>


More information about the antlr-interest mailing list