[erlang-questions] I need to call unexported functions from the erlang shell

Olivier Sambourg <>
Fri Jun 15 11:52:03 CEST 2007


Hi,

Can someone explain to me why the following "procedure" isn't sufficient?

- compile your erlang sources normally, place the resulting .beam files in
your code path (application-vsn/ebin)
- compile the same erlang sources with the +export_all flag, place the
resulting .beam files outside of your code path (application-vsn/ebin-debug)
- run your application using the production beam files until the need arises
to use unexported functions in the shell
- in the shell, change your code path to application-vsn/ebin-debug
(code:replace_path/2)
- load the module(s) you want to use (l(module)). The loaded beam is now the
one from ebin-debug/
- do whatever you need to do
- change the code path back to application-vsn/ebin
- load the production version of the modules you had to debug
- back to normal again

I admit I haven't fully tested this, but I fail to see why it would not work
(as long as your application supports code loading...)
Please enlighten me :)

Regards,

Olivier

On 6/15/07, Thomas Lindgren <> wrote:
>
>
> --- Claes Wikström <> wrote:
>
> > Kenneth Lundin wrote:
> > > Hi,
> > >
> > > I don't really understand why there is a big need
> > for Luke to call
> > > local functions
> > > from the shell during debugging of a live system?
> > >
> >
> > I sympathize with Luke here. Debugging live systems,
> > being able
> > to call non exported functions from the shell is
> > often ... well
> > necessary.
>
> Fully agreed on the practicalities, and adding a
> '%preserved' or generating a module_info-like function
> for the same functionality is straightforward, but
> does it in practice fix anything substantial beyond
> adding +export_all in the makefiles?
>
> As far as I can tell, it _does_ fix one minor thing,
> apply can't directly call unexported functions, and it
> also makes the module interface look tidier. I'm not
> sure that's enough for me to become enthusiastic; I'd
> like more bang per buck. Am I missing something?
>
> Best,
> Thomas
>
>
>
>
>
>
> ____________________________________________________________________________________
> Be a better Heartthrob. Get better relationship answers from someone who
> knows. Yahoo! Answers - Check it out.
> http://answers.yahoo.com/dir/?link=list&sid=396545433
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070615/0f466bed/attachment.html>


More information about the erlang-questions mailing list