Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
White space agnostics prevents debugging from working?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
André van der Merwe  
View profile  
 More options Nov 5, 6:32 am
From: André van der Merwe <Andre...@pyrogenesis.co.za>
Date: Thu, 5 Nov 2009 13:32:55 +0200
Local: Thurs, Nov 5 2009 6:32 am
Subject: White space agnostics prevents debugging from working?

When I try debug a boo script with white space agnostic mode on I am then unable to debug. This seems impossible but I can very easily reproduce the problem.

Am I perhaps setting up white space agnostic mode incorrectly? I've always done this
booc.Parameters.Pipeline.RemoveAt(0);
booc.Parameters.Pipeline.Insert(0, new WSABooParsingStep());

Does anyone have any idea how I can fix this?

Thanks in advance

Here is the code that will not debug.
---------------------------------------------------------------------
string code = @"class Tester:
    public def TestMethod():
        print 1
        System.Diagnostics.Debugger.Break()
        print 2
        print 3
    end  //** remove to fix
end  //** remove to fix

print 2";

var codeReader = new StringReader(code);

var booc = new BooCompiler();
booc.Parameters.GenerateInMemory = true;
booc.Parameters.Input.Add(new ReaderInput("test.boo", codeReader));
booc.Parameters.OutputType = CompilerOutputType.ConsoleApplication;
booc.Parameters.Debug = true;
booc.Parameters.WhiteSpaceAgnostic = true;  //** remove to fix
booc.Parameters.Pipeline = new CompileToMemory();

booc.Parameters.Pipeline.RemoveAt(0);  //** remove to fix
booc.Parameters.Pipeline.Insert(0, new WSABooParsingStep());  //** remove to fix

CompilerContext context = booc.Run();

if (context.Errors.Count == 0)
{
                 var asm = context.GeneratedAssembly;
                 var type = asm.GetType("Tester");
                 var o = Activator.CreateInstance(type);
                 var method = type.GetMethod("TestMethod");
                 method.Invoke(o, new object[] { });

}

---------------------------------------------------------------------

If you remove the "//** remove to fix" lines it will debug happily.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
André van der Merwe  
View profile  
 More options Nov 5, 1:41 pm
From: André van der Merwe <Andre...@pyrogenesis.co.za>
Date: Thu, 5 Nov 2009 20:41:20 +0200
Local: Thurs, Nov 5 2009 1:41 pm
Subject: RE: White space agnostics prevents debugging from working?
After a bit more investigation it looks like the WSA pipeline is not emitting the IL ".line" instructions which is why the debugging is not working. (Both compiles create PDBs with the exact same size)

E.g. compare these two sections from the same boo script

Any ideas on how I can fix this?

Compiled with white space agnostic mode
-------------------------------------------
    // Method begins at RVA 0x2050
    // Code size       24 (0x18)
    .maxstack  1
    IL_0000:  /* 17   |                  */ ldc.i4.1
    IL_0001:  /* 28   | (0A)000001       */ call       void [mscorlib/*23000001*/]System.Console/*01000002*/::WriteLine(int32) /* 0A000001 */
    IL_0006:  /* 28   | (0A)000002       */ call       void [mscorlib/*23000001*/]System.Diagnostics.Debugger/*01000003*/::Break() /* 0A000002 */
-------------------------------------------

Compiled with the standard pipeline (notice the .line directives)
-------------------------------------------
    // Method begins at RVA 0x2050
    // Code size       24 (0x18)
    .maxstack  1
    .language '{00000000-0000-0000-0000-000000000000}', '{00000000-0000-0000-0000-000000000000}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}'
// Source File 'C:\...\wss\test.boo'
    .line 3,4 : 0,0 'C:\\...\\wss\\test.boo'
//000003:         print 1
    IL_0000:  /* 17   |                  */ ldc.i4.1
    IL_0001:  /* 28   | (0A)000001       */ call       void [mscorlib/*23000001*/]System.Console/*01000002*/::WriteLine(int32) /* 0A000001 */
    .line 4,5 : 0,0 ''
//000004:         System.Diagnostics.Debugger.Break()
    IL_0006:  /* 28   | (0A)000002       */ call       void [mscorlib/*23000001*/]System.Diagnostics.Debugger/*01000003*/::Break() /* 0A000002 */
-------------------------------------------

------------
From: boolang@googlegroups.com [mailto:boolang@googlegroups.com] On Behalf Of André van der Merwe
Subject: White space agnostics prevents debugging from working?

When I try debug a boo script with white space agnostic mode on I am then unable to debug. This seems impossible but I can very easily reproduce the problem.

Am I perhaps setting up white space agnostic mode incorrectly? I've always done this
       booc.Parameters.Pipeline.RemoveAt(0);
       booc.Parameters.Pipeline.Insert(0, new WSABooParsingStep());

Does anyone have any idea how I can fix this?  

Thanks in advance

Here is the code that will not debug.
---------------------------------------------------------------------
string code = @"class Tester:
    public def TestMethod():
        print 1
        System.Diagnostics.Debugger.Break()
        print 2
        print 3
    end  //** remove to fix
end  //** remove to fix

print 2";

var codeReader = new StringReader(code);

var booc = new BooCompiler();
booc.Parameters.GenerateInMemory = true;
booc.Parameters.Input.Add(new ReaderInput("test.boo", codeReader));
booc.Parameters.OutputType = CompilerOutputType.ConsoleApplication;
booc.Parameters.Debug = true;
booc.Parameters.WhiteSpaceAgnostic = true;  //** remove to fix
booc.Parameters.Pipeline = new CompileToMemory();

booc.Parameters.Pipeline.RemoveAt(0);  //** remove to fix
booc.Parameters.Pipeline.Insert(0, new WSABooParsingStep());  //** remove to fix

CompilerContext context = booc.Run();

if (context.Errors.Count == 0)
{
                 var asm = context.GeneratedAssembly;
                 var type = asm.GetType("Tester");
                 var o = Activator.CreateInstance(type);
                 var method = type.GetMethod("TestMethod");
                 method.Invoke(o, new object[] { });

}

---------------------------------------------------------------------

If you remove the "//** remove to fix" lines it will debug happily.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrigo B. de Oliveira  
View profile  
 More options Nov 5, 1:45 pm
From: "Rodrigo B. de Oliveira" <rodrigobam...@gmail.com>
Date: Thu, 5 Nov 2009 16:45:07 -0200
Local: Thurs, Nov 5 2009 1:45 pm
Subject: Re: White space agnostics prevents debugging from working?
2009/11/5 André van der Merwe <Andre...@pyrogenesis.co.za>:

> After a bit more investigation it looks like the WSA pipeline is not emitting the IL ".line" instructions which is why the debugging is not working. (Both compiles create PDBs with the exact same size)

> E.g. compare these two sections from the same boo script

> Any ideas on how I can fix this?

I think the parser might not be counting lines properly but I didn't
have time to confirm this.

Try to just parse something (other than compile it) and see if the
node's LexicalInfo is pointing to the correct place...


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
André van der Merwe  
View profile  
 More options Nov 5, 2:00 pm
From: André van der Merwe <Andre...@pyrogenesis.co.za>
Date: Thu, 5 Nov 2009 21:00:11 +0200
Local: Thurs, Nov 5 2009 2:00 pm
Subject: RE: White space agnostics prevents debugging from working?

>I think the parser might not be counting lines properly but I didn't
>have time to confirm this.

>Try to just parse something (other than compile it) and see if the
>node's LexicalInfo is pointing to the correct place...

Hi,

I added a compiler step that calls a visitor to check the node's LexicalInfo.Line property in EnterMemberReferenceExpression and for both the WSA and non-WSA the line numbers look correct. (Hope this is what you were suggesting...)

Thanks for the help.

Full test code
--------------------------

class Program
{
    static void Main(string[] args)
    {
        string code = @"
class Tester:
    public def TestMethod():
        print 1
        System.Diagnostics.Debugger.Break()
        print 2
        print 3
    end
end

System.Diagnostics.Debugger.Break()
print 2";

        var codeReader = new StringReader(code);
        File.WriteAllText("test.boo", code);

        var booc = new BooCompiler();
        booc.Parameters.GenerateInMemory = true;
        booc.Parameters.Input.Add(new ReaderInput("test.boo", codeReader));
        booc.Parameters.OutputType = CompilerOutputType.ConsoleApplication;
        booc.Parameters.Debug = true;
        booc.Parameters.WhiteSpaceAgnostic = true;
        //booc.Parameters.Pipeline = new CompileToMemory();
        booc.Parameters.Pipeline = new CompileToFile();
        booc.Parameters.OutputAssembly = "test.exe";

        //booc.Parameters.Pipeline.RemoveAt(0);
        //booc.Parameters.Pipeline.Insert(0, new WSABooParsingStep());
        booc.Parameters.Pipeline[0] = new WSABooParsingStep();

        booc.Parameters.Pipeline.Add(new RunVisitorCompilerStep(new TestVisitor()));

        CompilerContext context = booc.Run();

        if (context.Errors.Count == 0)
        {
            var asm = context.GeneratedAssembly;
            var type = asm.GetType("Tester");
            var o = Activator.CreateInstance(type);
            var method = type.GetMethod("TestMethod");
            method.Invoke(o, new object[] { });
        }
    }

}

class TestVisitor : DepthFirstVisitor
{
    public override bool EnterMemberReferenceExpression(MemberReferenceExpression node)
    {
        Console.WriteLine("{0} {1}", node.LexicalInfo.Line, node.ToString());
        return base.EnterMemberReferenceExpression(node);
    }

}

public class RunVisitorCompilerStep : AbstractCompilerStep
{
    private readonly DepthFirstVisitor m_visitor;

    public RunVisitorCompilerStep(DepthFirstVisitor visitor)
    {
        m_visitor = visitor;
    }

    public override void Run()
    {
        m_visitor.Visit(CompileUnit);
    }

}

--------------------------

Both output this

3 System.Console.WriteLine
3 System.Console
4 System.Diagnostics.Debugger.Break
4 System.Diagnostics.Debugger
4 System.Diagnostics
5 System.Console.WriteLine
5 System.Console
6 System.Console.WriteLine
6 System.Console
10 System.Diagnostics.Debugger.Break
10 System.Diagnostics.Debugger
10 System.Diagnostics
11 System.Console.WriteLine
11 System.Console


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
André van der Merwe  
View profile  
 More options Nov 5, 2:05 pm
From: André van der Merwe <Andre...@pyrogenesis.co.za>
Date: Thu, 5 Nov 2009 21:05:40 +0200
Local: Thurs, Nov 5 2009 2:05 pm
Subject: RE: White space agnostics prevents debugging from working?
Ah! So the line number is correct however for the WSA compile the LexicalInfo's FileName and FullPath properties are empty. So I assume this is causing the problem.

I'll look at the source and see if I can spot where this is happening. Any pointers will be welcome :)

Thanks again

-----Original Message-----
From: boolang@googlegroups.com [mailto:boolang@googlegroups.com] On Behalf Of André van der Merwe
Sent: 05 November 2009 21:00
To: boolang@googlegroups.com
Subject: RE: White space agnostics prevents debugging from working?

>I think the parser might not be counting lines properly but I didn't
>have time to confirm this.

>Try to just parse something (other than compile it) and see if the
>node's LexicalInfo is pointing to the correct place...

Hi,

I added a compiler step that calls a visitor to check the node's LexicalInfo.Line property in EnterMemberReferenceExpression and for both the WSA and non-WSA the line numbers look correct. (Hope this is what you were suggesting...)

Thanks for the help.

Full test code
--------------------------

class Program
{
    static void Main(string[] args)
    {
        string code = @"
class Tester:
    public def TestMethod():
        print 1
        System.Diagnostics.Debugger.Break()
        print 2
        print 3
    end
end

System.Diagnostics.Debugger.Break()
print 2";

        var codeReader = new StringReader(code);
        File.WriteAllText("test.boo", code);

        var booc = new BooCompiler();
        booc.Parameters.GenerateInMemory = true;
        booc.Parameters.Input.Add(new ReaderInput("test.boo", codeReader));
        booc.Parameters.OutputType = CompilerOutputType.ConsoleApplication;
        booc.Parameters.Debug = true;
        booc.Parameters.WhiteSpaceAgnostic = true;
        //booc.Parameters.Pipeline = new CompileToMemory();
        booc.Parameters.Pipeline = new CompileToFile();
        booc.Parameters.OutputAssembly = "test.exe";

        //booc.Parameters.Pipeline.RemoveAt(0);
        //booc.Parameters.Pipeline.Insert(0, new WSABooParsingStep());
        booc.Parameters.Pipeline[0] = new WSABooParsingStep();

        booc.Parameters.Pipeline.Add(new RunVisitorCompilerStep(new TestVisitor()));

        CompilerContext context = booc.Run();

        if (context.Errors.Count == 0)
        {
            var asm = context.GeneratedAssembly;
            var type = asm.GetType("Tester");
            var o = Activator.CreateInstance(type);
            var method = type.GetMethod("TestMethod");
            method.Invoke(o, new object[] { });
        }
    }

}

class TestVisitor : DepthFirstVisitor
{
    public override bool EnterMemberReferenceExpression(MemberReferenceExpression node)
    {
        Console.WriteLine("{0} {1}", node.LexicalInfo.Line, node.ToString());
        return base.EnterMemberReferenceExpression(node);
    }

}

public class RunVisitorCompilerStep : AbstractCompilerStep
{
    private readonly DepthFirstVisitor m_visitor;

    public RunVisitorCompilerStep(DepthFirstVisitor visitor)
    {
        m_visitor = visitor;
    }

    public override void Run()
    {
        m_visitor.Visit(CompileUnit);
    }

}

--------------------------

Both output this

3 System.Console.WriteLine
3 System.Console
4 System.Diagnostics.Debugger.Break
4 System.Diagnostics.Debugger
4 System.Diagnostics
5 System.Console.WriteLine
5 System.Console
6 System.Console.WriteLine
6 System.Console
10 System.Diagnostics.Debugger.Break
10 System.Diagnostics.Debugger
10 System.Diagnostics
11 System.Console.WriteLine
11 System.Console


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrigo B. de Oliveira  
View profile  
 More options Nov 5, 2:22 pm
From: "Rodrigo B. de Oliveira" <rodrigobam...@gmail.com>
Date: Thu, 5 Nov 2009 17:22:52 -0200
Local: Thurs, Nov 5 2009 2:22 pm
Subject: Re: White space agnostics prevents debugging from working?
2009/11/5 André van der Merwe <Andre...@pyrogenesis.co.za>:

> Ah! So the line number is correct however for the WSA compile the LexicalInfo's FileName and FullPath properties are empty. So I assume this is causing the problem.

Hmm... I think there's a special token factory that's required for
file names to be preserved during antlr parsing. Maybe it's not being
configured for the wsa parser....

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
André van der Merwe  
View profile  
 More options Nov 5, 3:11 pm
From: André van der Merwe <Andre...@pyrogenesis.co.za>
Date: Thu, 5 Nov 2009 22:11:25 +0200
Local: Thurs, Nov 5 2009 3:11 pm
Subject: RE: White space agnostics prevents debugging from working?

>Hmm... I think there's a special token factory that's required for
>file names to be preserved during antlr parsing. Maybe it's not being
>configured for the wsa parser....

Found it.

In Boo.Lang.Parser.WSABooParser: in the CreateBooLexer method (line 77 boo 0.9.2.3383)

Change: lexer.Initialize(selector, tabSize, BooToken.Creator);
To: lexer.Initialize(selector, tabSize, BooToken.TokenCreator);

If I change that my script debugs perfectly.

Thanks for the help.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
André van der Merwe  
View profile  
 More options Nov 5, 3:35 pm
From: André van der Merwe <Andre...@pyrogenesis.co.za>
Date: Thu, 5 Nov 2009 22:35:17 +0200
Local: Thurs, Nov 5 2009 3:35 pm
Subject: RE: White space agnostics prevents debugging from working?
I've raised an issue and submitted a patch
        http://jira.codehaus.org/browse/BOO-1262

Thanks again

-----Original Message-----
From: boolang@googlegroups.com [mailto:boolang@googlegroups.com] On Behalf Of André van der Merwe
Sent: 05 November 2009 22:11
To: boolang@googlegroups.com
Subject: RE: White space agnostics prevents debugging from working?

>Hmm... I think there's a special token factory that's required for
>file names to be preserved during antlr parsing. Maybe it's not being
>configured for the wsa parser....

Found it.

In Boo.Lang.Parser.WSABooParser: in the CreateBooLexer method (line 77 boo 0.9.2.3383)

Change: lexer.Initialize(selector, tabSize, BooToken.Creator);
To: lexer.Initialize(selector, tabSize, BooToken.TokenCreator);

If I change that my script debugs perfectly.

Thanks for the help.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrigo B. de Oliveira  
View profile  
 More options Nov 5, 3:47 pm
From: "Rodrigo B. de Oliveira" <rodrigobam...@gmail.com>
Date: Thu, 5 Nov 2009 18:47:27 -0200
Local: Thurs, Nov 5 2009 3:47 pm
Subject: Re: White space agnostics prevents debugging from working?
Great! I'll be applying it shortly...

2009/11/5 André van der Merwe <Andre...@pyrogenesis.co.za>:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google