Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support maps in the debugger #213

Merged
merged 1 commit into from Feb 7, 2014
Merged

Support maps in the debugger #213

merged 1 commit into from Feb 7, 2014

Conversation

nox
Copy link
Contributor

@nox nox commented Feb 1, 2014

No description provided.

@psyeugenic
Copy link
Contributor

Debugger support, very nice. =)

Somehow I feel that dbg_ieval should use the erl_eval code alot more, it's tedious copy paste work.

@nox
Copy link
Contributor Author

nox commented Feb 1, 2014

@psyeugenic The biggest WTF is the erl_eval_SUITE test suite in the debugger application. I thought it was an interpreted version of erl_eval_SUITE from stdlib, but not even.

@ghost ghost assigned psyeugenic Feb 1, 2014
@OTP-Maintainer
Copy link

Patch has passed first testings and has been assigned to be reviewed

@psyeugenic
Copy link
Contributor

I think this needs some work.

Create the following:

-module(t).
-compile([export_all]).

go() ->
    M = #{ v => 1 },
    loop(M, [1,2,3,4,5,6,7,8,9,10,11,12]).

loop(M, []) -> M;
loop(#{ v := U } = M, [V|Vs]) ->
    loop(M#{ v := U + V }, Vs).

Compile with 'debug_info'.

Start the debugger:

Eshell V6.0  (abort with ^G)
1> debugger:start().
{ok,<0.35.0>}

And Interpret with: Module -> Interpret -> "t.erl"

** {{badmatch,
        {function_clause,
            [{dbg_iload,pattern,
                 [{map,19,[{map_field_exact,19,{atom,19,v},{var,19,'U'}}]}],
                 [{file,"dbg_iload.erl"},{line,181}]},
             {dbg_iload,pattern,1,[{file,"dbg_iload.erl"},{line,185}]},
             {dbg_iload,patterns,1,[{file,"dbg_iload.erl"},{line,175}]},
             {dbg_iload,clause,2,[{file,"dbg_iload.erl"},{line,164}]},
             {dbg_iload,clauses,1,[{file,"dbg_iload.erl"},{line,159}]},
             {dbg_iload,store_forms,4,[{file,"dbg_iload.erl"},{line,117}]},
             {dbg_iload,store_module,4,[{file,"dbg_iload.erl"},{line,81}]},
             {dbg_iload,load_mod1,4,[{file,"dbg_iload.erl"},{line,55}]}]}},
...

Do you wanna take a look at it or do you defer to me? =)

@nox
Copy link
Contributor Author

nox commented Feb 3, 2014

Will look at it tonight, completely forgot about patterns, ah ah.

Sounds like GitHub doesn't highlight maps correctly, btw.

@psyeugenic
Copy link
Contributor

Great!
Perhaps I should poke someone about the highlighter.. =o

Btw, an easier way to test:

#!/usr/bin/env escript

main(_) ->
    io:format("~p~n",[go()]),
    ok.

go() ->
    M = #{ v => 1 },
    loop(M, [1,2,3,4,5,6,7,8,9,10,11,12]).

loop(M, []) -> M;
loop(#{ v := U } = M, [V|Vs]) ->
    loop(M#{ v := U + V }, Vs).

And in bash shell:

$OTP_PATH/bin/escript -d t.erl

@nox
Copy link
Contributor Author

nox commented Feb 3, 2014

Oh really nice, didn't know about -d.

@nox
Copy link
Contributor Author

nox commented Feb 3, 2014

@psyeugenic Amended. Where should I put a test?

@psyeugenic
Copy link
Contributor

Add a map_SUITE in debugger/test. Look at the other suites there.

dbg_iload traverses guard expressions, check the following also:

foo(M) ->
    if 
        is_map(M) -> yep;
        true -> nope
    end.

Apparently I have to fix wx on my mac ..

@nox
Copy link
Contributor Author

nox commented Feb 3, 2014

Will do.

@OTP-Maintainer
Copy link

Patch has passed first testings and has been assigned to be reviewed

@nox
Copy link
Contributor Author

nox commented Feb 4, 2014

@psyeugenic It doesn't really traverse BIF calls so no problem with guards, but I will put one in the test anyway.

A test is commented-out in map_SUITE:t_update_exact/1, waiting for a fixed
maps:update/3 function with correct integer/float semantics.
@nox
Copy link
Contributor Author

nox commented Feb 4, 2014

@psyeugenic Added a bunch of tests, there is one commented-out with regard to integer/float semantics in map keys.

@psyeugenic
Copy link
Contributor

Goody! I'll add it to nightly builds.

Yeah I know about the integer/float thingy. I'm working on it.

@OTP-Maintainer
Copy link

Patch has passed first testings and has been assigned to be reviewed

@psyeugenic
Copy link
Contributor

OTP-11673

@proxyles proxyles merged commit 286c090 into erlang:master Feb 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants