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

Ulf Wiger (TN/EAB) ulf.wiger@REDACTED
Fri Jun 15 19:07:35 CEST 2007


I've been thinking that this should be quite doable 
as long as the abstract code is available.
(Note also that the debug_info can be encrypted to 
protect it from outsiders).

I wrote a small module that fetches the abstract 
code and evaluates functions in it.

It's short, so I've attached it.

1> lfun:eval(lists,sublist_2,[[1,2,3,4,5],3]).
[1,2,3]
2> erlang:function_exported(lists,sublist_2,2).
false 

BR,
Ulf W


> -----Original Message-----
> From: erlang-questions-bounces@REDACTED 
> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of 
> Scott Lystig Fritchie
> Sent: den 15 juni 2007 18:50
> To: erlang-questions@REDACTED
> Subject: Re: [erlang-questions] I need to call unexported 
> functions from theerlang shell
> 
> >>>>> "kw" == =?ISO-8859-1?Q?Claes Wikstr=F6m?= <ISO-8859-1> writes:
> 
> kw> I sympathize with Luke here. Debugging live systems, 
> being able to 
> kw> call non exported functions from the shell is often ... well 
> kw> necessary.
> 
> Now that I've had an Erlang app running in someone else's 
> data center, I have also run into that situation, and have 
> really wished I could call non-exported functions.
> 
> Would it be any less icky to create a new BIF to work around 
> the problem?
> 
>     erlang:apply(Function::atom(), Args::list(term()))
> 
> ... where Function must be in the caller's module and thus 
> can act like any function in a module calling any other 
> function in that module?  Then each source module would have 
> added (via -include() or
> whatever) one more exported function:
> 
>     trap_door(Function, Args) ->
>         erlang:apply(Function, Args).
> 
> I see that Luke keeps mumbling something about the R9C-0 release.
> Adding such a BIF to VMs in the field could be, er, an 
> interesting trick.  :-)
> 
> -Scott
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lfun.erl
Type: application/octet-stream
Size: 3676 bytes
Desc: lfun.erl
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070615/7ee68c6f/attachment.obj>


More information about the erlang-questions mailing list