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

It is not possible to debug modules using the maybe expression #7410

Closed
lucavallerini opened this issue Jun 17, 2023 · 0 comments · Fixed by #7599
Closed

It is not possible to debug modules using the maybe expression #7410

lucavallerini opened this issue Jun 17, 2023 · 0 comments · Fixed by #7599
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@lucavallerini
Copy link

lucavallerini commented Jun 17, 2023

Describe the bug
It is not possible to debug a module using the maybe expression.

To Reproduce
Create a minimal project with a test module using the maybe_expr, then try to "interpret" it by calling int:i/1 on said module: the function will crash due to a function_clause error on the dbg_iload:expr/3 function. Looking into the source code, it does not seem to handle the 'maybe' and maybe_match expressions.

** exception exit: {{{badmatch,{function_clause,[{dbg_iload,expr,
                                                            [{'maybe',{9,3},
                                                                      [{maybe_match,{10,10},
                                                                                    {atom,{10,5},true},
                                                                                    {call,{10,13},
                                                                                          {remote,{10,19},
                                                                                                  {atom,{10,13},erlang},
                                                                                                  {atom,{10,...},is_integer}},
                                                                                          [{var,{10,31},'I'}]}},
                                                                       {op,{11,7},'+',{var,{11,5},'I'},{integer,{11,9},10}}],
                                                                      {'else',{12,3},
                                                                              [{clause,{13,5},
                                                                                       [{var,{13,5},'_'}],
                                                                                       [],
                                                                                       [{bin,{13,10},[{...}]}]}]}},
                                                             true,
                                                             #{ctype =>
                                                                   #{{module_info,0} => local,
                                                                     {module_info,1} => local,
                                                                     {test,1} => local},
                                                               exp => [{module_info,0},{module_info,1},{test,1}]}],
                                                            [{file,"dbg_iload.erl"},{line,458}]},
                                                 {dbg_iload,exprs,3,[{file,"dbg_iload.erl"},{line,452}]},
                                                 {dbg_iload,clause,3,[{file,"dbg_iload.erl"},{line,213}]},
                                                 {dbg_iload,clauses,2,[{file,"dbg_iload.erl"},{line,206}]},
                                                 {dbg_iload,store_forms,4,
                                                            [{file,"dbg_iload.erl"},{line,142}]},
                                                 {dbg_iload,store_module,4,
                                                            [{file,"dbg_iload.erl"},{line,86}]},
                                                 {dbg_iload,'-load_mod1/4-fun-0-',4,
                                                            [{file,"dbg_iload.erl"},{line,58}]}]}},
                     [{dbg_iserver,handle_call,3,
                                   [{file,"dbg_iserver.erl"},{line,228}]},
                      {gen_server,try_handle_call,4,
                                  [{file,"gen_server.erl"},{line,1149}]},
                      {gen_server,handle_msg,6,
                                  [{file,"gen_server.erl"},{line,1178}]},
                      {proc_lib,init_p_do_apply,3,
                                [{file,"proc_lib.erl"},{line,240}]}]},
                    {gen_server,call,
                                [dbg_iserver,
                                 {load,test,
                                       "/home/luca/Progetti/dev/erlang/maybedbg/_build/default/lib/maybedbg/src/test.erl",
                                       <<131,104,5,100,0,18,105,110,116,101,114,112,114,101,116,
                                         101,114,95,...>>},
                                 infinity]}}
     in function  gen_server:call/3 (gen_server.erl, line 385)
     in call from int:load/2 (int.erl, line 539)

Expected behavior
It should be possible to debug/interpret modules using the maybe expression.

Affected versions
OTP 25+ but I cannot test on 26+ but I am assuming that they are affected too by looking into the source code.

Additional context
I created a minimal project here: https://github.com/lucavallerini/erlmaybedbg. The test module is the affected one.

@lucavallerini lucavallerini added the bug Issue is reported as a bug label Jun 17, 2023
@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Jun 19, 2023
bjorng added a commit to bjorng/otp that referenced this issue Aug 29, 2023
@bjorng bjorng linked a pull request Aug 29, 2023 that will close this issue
bjorng added a commit that referenced this issue Aug 31, 2023
/OTP-18740

Teach the debugger to handle the maybe expression
@bjorng bjorng closed this as completed in 39f160f Aug 31, 2023
ilya-klyuchnikov pushed a commit to ilya-klyuchnikov/otp that referenced this issue Sep 1, 2023
rickard-green pushed a commit that referenced this issue Sep 7, 2023
…nt-25

* bjorn/debugger/handle-maybe/GH-7410/OTP-18740:
  Teach the debugger to handle the maybe expression
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants