Subject: sane-backends package not working?
To: port-mac68k@netbsd.org <port-mac68k@netbsd.org>
From: Dave Huang <khym@azeotrope.org>
List: port-mac68k
Date: 09/26/2002 20:37:46
The graphics/sane-backends package (scanner support) seems to have quit
working after the switch from a.out to ELF (I'm not positive that's what
caused the breakage, but I do know that I recompiled it after the ELF
switch and it didn't work).

The symptom is that it doesn't see my HP scanner when I tell it to list
the devices, and if I tell it my scanner's device name (i.e. scanimage
-d hp:/dev/uk0), it fails with:
scanimage: open of device hp:/dev/uk0 failed: Unknown SANE status code 135355336

Turning on SANE_DEBUG_DLL and SANE_DEBUG_HP gives:
[sanei_debug] Setting debug level of dll to 255.
[dll] sane_init: SANE dll backend version 1.0.6 from sane-backends-1.0.8
[dll] add_backend: adding backend `net'
[dll] add_backend: adding backend `abaton'
... many more backends ...
[dll] add_backend: adding backend `umax1220u'
[dll] add_backend: adding backend `v4l'
[dll] load: searching backend `hp' in `/usr/pkg/lib/sane'
[dll] load: trying to load `/usr/pkg/lib/sane/libsane-hp.so.1'
[dll] load: dlopen()ing `/usr/pkg/lib/sane/libsane-hp.so.1'
[dll] init: initializing backend `hp'
[sanei_debug] Setting debug level of hp to 255.
[hp] sane_init called
[hp] sane_init will finish with Success
scanimage: open of device hp:/dev/uk0 failed: Unknown SANE status code 35
[dll] sane_exit: exiting
[dll] sane_exit: finished

The "[hp] sane_init will finish with Success" line comes from sane_init
in hp.c (libsane-hp.so):

  DBG(3, "sane_init will finish with %s\n", sane_strstatus (status));
  return status;

And that function is called from init() in dll.c:

  DBG(3, "init: initializing backend `%s'\n", be->name);

  status = (long) (*be->op[OP_INIT]) (&version, auth_callback);

I printed the value of status, and it's not the "success" value that's
being returned from hp.c.

So what's going on here? Why is the return value being corrupted on the
way back from libsane-hp.so's sane_init? I can't get gdb to step into
libsane.so properly either--at least not at a source code level. Using
"stepi" to step at the assembly level works, although it's a pain
stepping through the dynamic linking business, and "nexti" often seems
to just run instead of doing what it's supposed to.
-- 
Name: Dave Huang         |  Mammal, mammal / their names are called /
INet: khym@azeotrope.org |  they raise a paw / the bat, the cat /
FurryMUCK: Dahan         |  dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 26 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++