Question: how to make break point to a local proc inside module?

One of the frustrating things I am finding in using Maple debugger is that I can't set breakpoint using stopat() at some line number in some inner module, if the inner module is local module. It has to be an exported module.

Here is an example

restart;
foo:=module()
   export main_entry;
   local foo1; #inner module. But if local, Can't set breakpoint from outside

   foo1:=module()
     export main_entry;
     local foo2;

     foo2:=proc() #or breakpoint in first line here
        local s,x;
        s:=1;     #suppose I want to set break point here
        s:=s+sin(x);
     end proc;
     
     main_entry:=proc()         
        foo2();
     end proc;    
  end module;

  main_entry :=proc()
    foo1:-main_entry(); #call inner module's proc
  end proc;

end module;

Since there is inner module, local to outside module, I can't set break into the inner module procs anywhere.

stopat(foo:-foo1::foo2);
Error, module does not export `foo1`

A workaround for now is to change "local" to "export" on the inner modules declarations I want to debug, so I can setbreak points inside them, then when done, make them local again. So changed "local foo1" to "export foo1" above, and now

          stopat(foo:-foo1::foo2,2);

works.

This was also a little strange to me, since foo2() is a LOCAL proc to module foo1, yet Maple did not complain like it did when module foo1 was a LOCAL module to foo. I would have expected Maple to complain again for same reason.

So I am using the above workaround for now. But it is just a little annoying becuase I have to keep changing module from LOCAL to EXPORT in order to set breakpoints, then remember to make them local again.

Is there a better workaround?

A product suggestion: make stopat() ignore the local module setting and treat it as export for the purpose of setting a break point. This way one does not have to change the code just to set a breakpoint. Or if not to change current behavior, add a new option, as in

          stopat(........, option= ignore_local_setting)

So the default remain the same as now, but with the new option, it will set breakpoint anywhere, even in local modules.

 

Thank you

 

 

Please Wait...