[Vm-dev] RE: Linux vm

Eliot Miranda eliot.miranda at gmail.com
Sun Aug 22 02:53:30 UTC 2010


Hi Bill,

On Sat, Aug 21, 2010 at 7:39 PM, Schwab,Wilhelm K <bschwab at anest.ufl.edu>wrote:

>
> It has been a long day, and it might not have needed to be so.  Within 15
> minutes of seeing "undefined symbol: libusb_close" from dlerror(), I had the
> problem not only diagnosed but fixed; seeing the error in something related
> to USB support was enough to suggest I needed to link that library into the
> .so I was trying to load.  I was still guessing, but it was an educated
> guess based on a concrete lead.
>
> Is there a way to get such diagnostic information without hacking the vm
> source?  If not, please consider the following as a proposed patch.  I have
> tried to strike a balance between seeing enough to make sense of errant
> plugin paths and giving detailed information about failures when given an
> absolute path.  Behavior changes (I intend/think) only if something won't
> load (it says what it was trying to do) and if the library is specified by
> absolute path, in which case it gives diagnostic output on any failure to
> load.
>

What I do is manually repeat the link command using options that will cause
the linker to complain about unresolved symbols. You'll get some false
positives (dynamically-linked runtime routines) but you'll also get any
actually undefined symbols.  Use  -Wl,--warn-unresolved-symbols
-Wl,--no-allow-shlib-undefined when manually repeating the link command.

So while this is after the fact you should try remaking your plugin with the
libusb support missing, copy the link command and repeat it
adding -Wl,--warn-unresolved-symbols -Wl,--no-allow-shlib-undefined and this
tie you should see the link fail while listing libusb_close et al.

HTH
Eliot


> Bill
>
>
> ( Squeak-...-src/unix/vm/sqUnixExternalPrims.c )
> static void *tryLoadModule(char *in, char *name)
> {
>  char path[PATH_MAX], *out= path;
>  void *handle= 0;
>  int c;
>  while ((c= *in++) && ':' != c) {      /* copy next plugin path to path[]
> */
>    switch (c) {
>    case '%':
>      if ('n' == *in || 'N' == *in) {   /* replace %n with name of plugin */
>        ++in;
>        strcpy(out, name);
>        out += strlen(name);
>        continue;
>      }
>      if ('%' == *in) {
>        ++in;
>        *out++= '%';
>        continue;
>      }
>      /* fall through... */
>    default:
>      *out++= c;
>      continue;
>    }
>  }
>  sprintf(out, "/" MODULE_PREFIX "%s" MODULE_SUFFIX, name);
>  handle= dlopen(path, RTLD_NOW | RTLD_GLOBAL);
>  fdebugf((stderr, "tryLoading(%s) = %p\n", path, handle));
>
>        // 8-10 wks - no silent failures
>        if( !handle ){
>                // 8-10 - if a load fails, tell the user what we tried to
> load:
>                fprintf(stdout, "Load failed for: %s\n", path);
>
>                // 8-10 - is the given path absolute?  If so, try again with
> it
>                // as given and report diagnostic information if it fails.
>                if( (int)(name[0])==47 ) {
>                        handle=dlopen(name, RTLD_NOW | RTLD_GLOBAL);
>                        fprintf(stdout, "Load-by-name(%s) = %p\n", name,
> handle);
>                        if(!handle){
>                                fprintf(stdout,"Error loading library:
> %s\n",dlerror());
>                        }
>                }
>        }
>
>  if (!handle) {
>    struct stat buf;
>    if ((0 == stat(path, &buf)) && ! S_ISDIR(buf.st_mode))
>      fprintf(stderr, "%s\n", dlerror());
>  }
>
>  return handle;
> }
>
> ________________________________________
> From: pharo-project-bounces at lists.gforge.inria.fr [
> pharo-project-bounces at lists.gforge.inria.fr] On Behalf Of Schwab,Wilhelm K
> [bschwab at anest.ufl.edu]
> Sent: Saturday, August 21, 2010 8:19 PM
> To: Pharo-project at lists.gforge.inria.fr; vm-dev at lists.squeakfoundation.org
> Subject: [Pharo-project] Linux vm
>
> Hello all,
>
> Is there a way to get the pre-compiled linux vm to describe what the full
> path is to a library it is trying to load?    I can hack the source to do
> so, but then I start wondering what I might have disturbed in the process.
>  Out of the box, all I get is an external library with a nil handle and no
> clue what did or did not happen.
>
> At various points in my struggle today, I saw what looked like a tendency
> to load plugins from the vmpath//so.pluginName (two slashes rather than
> one).  It raises the question of whether the code is adding an extra slash
> when it is not given an explicit plugins path??  The separate concern is
> that I need information about what is happening when one of my libraries
> fails to load.
>
> One possibility is that a particular .so can't load.  How would I find out
> whether that this is case?  Is there a way to test load it or to get the vm
> to tell me the cause of a failure to load it?
>
> Bill
>
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project at lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20100821/4910f99b/attachment.htm


More information about the Vm-dev mailing list