lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I am using the patch you suggested for stripping symbols. It works
fine. Thanks.
But,
The scripts my application loads are sourced across a number of
different hardware and OS platforms, so using compiled code is
not really an option. When the app loads one of many Lua scripts
(which may or may not be cached), we need to load(), dump(), and
load() and then pcall().  It grates on me that I load the code twice.
The reason I am stripping the debug symbols is to save as much
memory as I can in an embedded system. In some cases nothing
is cached. There is an option to keep symbols when debugging
scripts.
So from my perspective it would nice if the code could be was loaded once
without symbols. However if this is extraordinarily difficult I guess
the dump or strip solution is better than nothing.

Do you really want to choose whether or not to strip
debug info at run time?

Absolutely.

David Burgess

Luiz Henrique de Figueiredo  wrote:
> > Does anyone else have view on my wish for:
> > lua_load(), lua_dump() to have an extra parameter that strips the
> > debug symbols?
>
> For lua_load, yes please, and in the Lua interface as well.  Is it necessary for lua_dump?  Another option might be a strip function for closures (prototypes really).

As I've mentioned earlier [1], it's much simpler to strip at dump time
than at load time. At load time, we have either to read and skip debug
info from the stream or read and save as now and then strip after loading.
The first option complicates the loader. The second option is pretty easy
to implement; luac used to do that:

 static void strip(lua_State* L, Proto* f)
 {
  int i,n=f->sizep;
  luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
  luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
  luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
  f->lineinfo=NULL; f->sizelineinfo=0;
  f->locvars=NULL;  f->sizelocvars=0;
  f->upvalues=NULL; f->sizeupvalues=0;
  f->source=luaS_newliteral(L,"=?");
  for (i=0; i<n; i++) strip(L,f->p[i]);
 }

You may call strip in ldo.c just before returning from f_parser,
or in lundump.c just before returning from LoadFunction, in which
case you may drop the "for".

Anyway, I think the main point here is that adding a flag to the API
complicates it. Do you really want to choose whether or not to strip
debug info at run time?

--lhf

[1] http://lua-users.org/lists/lua-l/2006-04/msg00623.html