Christmas request! VD closure debugging

Michelle Long HappyDance321 at gmail.com
Tue Dec 18 20:09:20 UTC 2018


On Saturday, 15 December 2018 at 07:33:30 UTC, Rainer Schuetze 
wrote:
>
>
> On 15/12/2018 01:45, Michelle Long wrote:
>> On Friday, 14 December 2018 at 18:40:47 UTC, Rainer Schuetze 
>> wrote:
>>>
>>>
>>> On 14/12/2018 04:21, Michelle Long wrote:
>>>> [...]
>>>
>>> Have you tried the latest release with dmd master/nightly? I 
>>> have added appropriate debug information to be generated by 
>>> dmd and added support for these in mago. It should show 
>>> variables captured from an outer function as local variables.
>> 
>> 
>> Cool, I tried but the link was down:
>> 
>> https://downloads.dlang.org/nightlies/dmd-master/dmd.master.windows.7z
>
> Not sure why this doesn't work, but the release archive still 
> works: 
> http://downloads.dlang.org/nightlies/dmd-master-2018-12-15/
>
>> 
>> I assume I'll have to download the VD nightly too?
>
> No, version 0.48 already has that.
>
>> Is there a link to that?
>>
> Development mostly happens on my fork and is tested by 
> https://ci.appveyor.com/project/rainers/visuald. The resulting 
> installers are slightly different than actual releases due to 
> limitations of the images provided by Appveyor (i.e. not all 
> versions of VS installed in the same image).
>
>> https://github.com/dlang/visuald/releases
>> 
>> It would be nice if there were similar links on the D download 
>> page for Visual D or on the github page for the nightly, if it 
>> exists.
>> 
>> Thanks for the work you have done! I appreciate it!

Ok, I installed the latest dmd,rebuilt some libraries and the 
source for it then tried some code I had and the parent variables 
did not show up:

The code was effectively

auto foo()
{
     int x = 0;
     auto bar()
     {
        int y = 0;
        x++;
     }
}

I put a BP on the `int y = 0;` line and the variable x is not 
being displayed.

x is not showing up in the locals but I did add it as a watch and 
it seemed to show it just fine. This might just be a simple 
display bug for locals. It is also showing up for autos! So this 
is actually good and seems to be working. I was mistakenly 
thinking they should be locals.

I tend to use only locals rather than auto's and watches because 
of the screen real estate required.

Not sure if there is any feasible solution.

Would it be possible to have, say, a variable in the locals 
called "globals"(or some better name) that contained all the 
globals to the scope or just list the globals inline(like autos 
does) when there are just a few or when they are just one level 
above(which would get most needed cases)? Possibly prefix the 
variable with something like @ or # to signify it is a global in 
this case.

Again, the main idea is to save screen space and time by not 
having to juggle windows. Locals tend to cover most cases 
fine(biggest problem I have with it is that I tend to have 
trouble finding a specific variable by name since the list is in 
some order that makes no sense to me... definitely not 
alphabetical and VS doesn't allow sorting... I'd actually 
preferred them sorted, or at least have it as an option since 
then I can locate the variables much quicker).


Possible solutions:

1. + Globals
        x
        ...
    y
[Just list all global variables to the current scope in a globals 
tree]

2. y
    + Globals
         x
         Globals
         ...
[Show the globals in a tree if that info is available]

3. x
    y
[If there are just a few globals or parent variables then inline 
them]

4. 1 at x
    y
[using prefix, 1 is the ancestor level of the variable and @ is 
just stating it is global]




Optional's:
1. Allow different sorting of variable names in the locals, 
autos, watches, etc. Not sure why VS doesn't have this built in, 
maybe a switch is required or something must be setup? Most 
programs that display any type of information in a column will 
allow it to be sorted. I think that VS does do this in C# but I 
can't recall.

2. case scopes seem to capture(show in locals) all the variables 
outside it. That is, a case doesn't seem to create it's own local 
scope.

case 1:
    int x;
case 2:
    int y;

x is shown while debugging in y... x is not needed to be seen 
though.

3. List types from derived to base instead of base to 
derived(already discussed before).


You can do all this stuff when ever you feel like it of course... 
Just pointing out some improvements. I haven't tested the globals 
fix yet but if it works well then I will just switch to autos or 
use a watch when I need to.







More information about the Digitalmars-d-ide mailing list