digitalmars.D - generative programming and debugging
- Gor Gyolchanyan (3/3) Oct 19 2011 Do anybody know a good way to (statically) debug a generated code?
- Timon Gehr (21/24) Oct 19 2011 pragma(msg, foo()); // debug
- Gor Gyolchanyan (9/34) Oct 19 2011 good point. I'll need to generate comments for that code, that contain
- Don (8/50) Oct 19 2011 I've made a couple of improvements to the CTFE engine for the next
- Jacob Carlborg (6/9) Oct 19 2011 The Eclipse plugin Descent has support for compile time debugging. It
- Gor Gyolchanyan (2/12) Oct 19 2011
- Jacob Carlborg (5/20) Oct 19 2011 Well, it might be worth to just start up eclipse once in a while for
- Ary Manzana (3/10) Oct 19 2011 Does it still work?
- Jacob Carlborg (4/15) Oct 19 2011 Descent is quite slow and often freezes, otherwise it's working quite we...
Do anybody know a good way to (statically) debug a generated code? Currently it takes lots of effort to determine the place, where the code is being incorrectly generated.
Oct 19 2011
On 10/19/2011 11:07 AM, Gor Gyolchanyan wrote:Do anybody know a good way to (statically) debug a generated code? Currently it takes lots of effort to determine the place, where the code is being incorrectly generated.pragma(msg, foo()); // debug mixin(foo()); You can additionally use something in the lines of the following if it is not immediately obvious which function generated the incorrect code. import std.stdio, std.conv; string X(string file=__FILE__, int line=__LINE__){ return "// "~file~"("~to!string(line)~")\n"; } string foo(){ string r; foreach(i;0..3) r~=q{writeln("hello world");}~X(); foreach(i;0..3) r~=q{writekn("hello world");}~X(); // whoops return r; } void main(){ pragma(msg, foo()); mixin(foo()); } It would be kinda nice if the compiler pointed directly to the source location that generated the incorrect code.
Oct 19 2011
good point. I'll need to generate comments for that code, that contain information about the place, where the code was generated. There are 2 things I'd really like to have: 1. Be able to obtain the name (possibly an alias) of a function on the call stack on the given depth. 2. Be able to obtain file and line of a function on the call stack on the given depth. This would be awesome for generating very convenient debug info. On Wed, Oct 19, 2011 at 2:32 PM, Timon Gehr <timon.gehr gmx.ch> wrote:On 10/19/2011 11:07 AM, Gor Gyolchanyan wrote:Do anybody know a good way to (statically) debug a generated code? Currently it takes lots of effort to determine the place, where the code is being incorrectly generated.pragma(msg, foo()); // debug mixin(foo()); You can additionally use something in the lines of the following if it is not immediately obvious which function generated the incorrect code. import std.stdio, std.conv; string X(string file=3D__FILE__, int line=3D__LINE__){ =A0 =A0 return "// "~file~"("~to!string(line)~")\n"; } string foo(){ =A0 =A0string r; =A0 =A0foreach(i;0..3) r~=3Dq{writeln("hello world");}~X(); =A0 =A0foreach(i;0..3) r~=3Dq{writekn("hello world");}~X(); // whoops =A0 =A0return r; } void main(){ =A0 =A0pragma(msg, foo()); =A0 =A0mixin(foo()); } It would be kinda nice if the compiler pointed directly to the source location that generated the incorrect code.
Oct 19 2011
On 19.10.2011 12:50, Gor Gyolchanyan wrote:good point. I'll need to generate comments for that code, that contain information about the place, where the code was generated. There are 2 things I'd really like to have: 1. Be able to obtain the name (possibly an alias) of a function on the call stack on the given depth. 2. Be able to obtain file and line of a function on the call stack on the given depth. This would be awesome for generating very convenient debug info.I've made a couple of improvements to the CTFE engine for the next release, which gives a substantially better call stack trace when an error occurs. Please suggest further improvements.On Wed, Oct 19, 2011 at 2:32 PM, Timon Gehr<timon.gehr gmx.ch> wrote:I don't know how it could really do that. I mean, what if at the end of foo, you looped over 'r' and changed every 'k' to 'l', and every 'l' to 'k'? Then the first line would be the one with the error!On 10/19/2011 11:07 AM, Gor Gyolchanyan wrote:Do anybody know a good way to (statically) debug a generated code? Currently it takes lots of effort to determine the place, where the code is being incorrectly generated.pragma(msg, foo()); // debug mixin(foo()); You can additionally use something in the lines of the following if it is not immediately obvious which function generated the incorrect code. import std.stdio, std.conv; string X(string file=__FILE__, int line=__LINE__){ return "// "~file~"("~to!string(line)~")\n"; } string foo(){ string r; foreach(i;0..3) r~=q{writeln("hello world");}~X(); foreach(i;0..3) r~=q{writekn("hello world");}~X(); // whoops return r; } void main(){ pragma(msg, foo()); mixin(foo()); } It would be kinda nice if the compiler pointed directly to the source location that generated the incorrect code.
Oct 19 2011
On 2011-10-19 11:07, Gor Gyolchanyan wrote:Do anybody know a good way to (statically) debug a generated code? Currently it takes lots of effort to determine the place, where the code is being incorrectly generated.The Eclipse plugin Descent has support for compile time debugging. It also have a compile time view which shows the result of string mixins and template mixins. -- /Jacob Carlborg
Oct 19 2011
This is cool. Unfortunately, descent is a big pain to use for everything else. On Wed, Oct 19, 2011 at 3:12 PM, Jacob Carlborg <doob me.com> wrote:On 2011-10-19 11:07, Gor Gyolchanyan wrote:Do anybody know a good way to (statically) debug a generated code? Currently it takes lots of effort to determine the place, where the code is being incorrectly generated.The Eclipse plugin Descent has support for compile time debugging. It also have a compile time view which shows the result of string mixins and template mixins. -- /Jacob Carlborg
Oct 19 2011
On 2011-10-19 13:21, Gor Gyolchanyan wrote:This is cool. Unfortunately, descent is a big pain to use for everything else.Well, it might be worth to just start up eclipse once in a while for cases like these.On Wed, Oct 19, 2011 at 3:12 PM, Jacob Carlborg<doob me.com> wrote:-- /Jacob CarlborgOn 2011-10-19 11:07, Gor Gyolchanyan wrote:Do anybody know a good way to (statically) debug a generated code? Currently it takes lots of effort to determine the place, where the code is being incorrectly generated.The Eclipse plugin Descent has support for compile time debugging. It also have a compile time view which shows the result of string mixins and template mixins. -- /Jacob Carlborg
Oct 19 2011
On 10/19/11 8:12 AM, Jacob Carlborg wrote:On 2011-10-19 11:07, Gor Gyolchanyan wrote:Does it still work? I have the idea that once I abandon a project it somehow stops working. :-PDo anybody know a good way to (statically) debug a generated code? Currently it takes lots of effort to determine the place, where the code is being incorrectly generated.The Eclipse plugin Descent has support for compile time debugging. It also have a compile time view which shows the result of string mixins and template mixins.
Oct 19 2011
On 2011-10-19 17:42, Ary Manzana wrote:On 10/19/11 8:12 AM, Jacob Carlborg wrote:Descent is quite slow and often freezes, otherwise it's working quite well. -- /Jacob CarlborgOn 2011-10-19 11:07, Gor Gyolchanyan wrote:Does it still work? I have the idea that once I abandon a project it somehow stops working. :-PDo anybody know a good way to (statically) debug a generated code? Currently it takes lots of effort to determine the place, where the code is being incorrectly generated.The Eclipse plugin Descent has support for compile time debugging. It also have a compile time view which shows the result of string mixins and template mixins.
Oct 19 2011