From bd5be69aee6987754f1cbf39f61280c5c72536b3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 12 Feb 2012 06:06:59 +0100 Subject: DynamicLibraryBundle (enhancement) - Hold DEBUG, DEBUG_LOOKUP in DynamicLookupHelper - Tool complete only if named tool's GetProcAddressFunc is avail - Allow no tool/glue lib's - Use DEBUG_LOCKUP for lockup symbol trace --- src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java | 12 ++++++++++-- src/java/jogamp/common/os/UnixDynamicLinkerImpl.java | 12 ++++++++++-- src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java | 17 ++--------------- 3 files changed, 22 insertions(+), 19 deletions(-) (limited to 'src/java/jogamp/common') diff --git a/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java index c1be2c2..4eb381f 100755 --- a/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java @@ -51,11 +51,19 @@ public class MacOSXDynamicLinkerImpl implements DynamicLinker { } public long lookupSymbol(long libraryHandle, String symbolName) { - return dlsym(libraryHandle, symbolName); + final long addr = dlsym(libraryHandle, symbolName); + if(DEBUG_LOOKUP) { + System.err.println("MaxOSXDynamicLinkerImpl.lookupSymbol(0x"+Long.toHexString(libraryHandle)+", "+symbolName+") -> 0x"+Long.toHexString(addr)); + } + return addr; } public long lookupSymbolGlobal(String symbolName) { - return dlsym(RTLD_DEFAULT, symbolName); + final long addr = dlsym(RTLD_DEFAULT, symbolName); + if(DEBUG_LOOKUP) { + System.err.println("MacOSXDynamicLinkerImpl.lookupSymbolGlobal("+symbolName+") -> 0x"+Long.toHexString(addr)); + } + return addr; } public void closeLibrary(long libraryHandle) { diff --git a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java index 677df32..29998bd 100755 --- a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java @@ -50,11 +50,19 @@ public class UnixDynamicLinkerImpl implements DynamicLinker { } public long lookupSymbol(long libraryHandle, String symbolName) { - return dlsym(libraryHandle, symbolName); + final long addr = dlsym(libraryHandle, symbolName); + if(DEBUG_LOOKUP) { + System.err.println("UnixDynamicLinkerImpl.lookupSymbol(0x"+Long.toHexString(libraryHandle)+", "+symbolName+") -> 0x"+Long.toHexString(addr)); + } + return addr; } public long lookupSymbolGlobal(String symbolName) { - return dlsym(RTLD_DEFAULT, symbolName); + final long addr = dlsym(RTLD_DEFAULT, symbolName); + if(DEBUG_LOOKUP) { + System.err.println("UnixDynamicLinkerImpl.lookupSymbolGlobal("+symbolName+") -> 0x"+Long.toHexString(addr)); + } + return addr; } public void closeLibrary(long libraryHandle) { diff --git a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java index f5229f4..e7f5b52 100755 --- a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java @@ -2,23 +2,10 @@ package jogamp.common.os; -import java.security.*; - import com.jogamp.common.os.DynamicLinker; public class WindowsDynamicLinkerImpl implements DynamicLinker { - private static boolean DEBUG; - - static { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - DEBUG = (System.getProperty("jogamp.debug.NativeLibrary") != null); - return null; - } - }); - } - /** Interface to C language function:
BOOL FreeLibrary(HANDLE hLibModule); */ private static native int FreeLibrary(long hLibModule); @@ -61,14 +48,14 @@ public class WindowsDynamicLinkerImpl implements DynamicLinker { addr = GetProcAddressA(libraryHandle, _symbolName); } } - if(DEBUG) { + if(DEBUG_LOOKUP) { System.err.println("WindowsDynamicLinkerImpl.lookupSymbol(0x"+Long.toHexString(libraryHandle)+", "+symbolName+") -> "+_symbolName+", 0x"+Long.toHexString(addr)); } return addr; } public long lookupSymbolGlobal(String symbolName) { - if(DEBUG) { + if(DEBUG_LOOKUP) { System.err.println("lookupSymbolGlobal: Not supported on Windows"); } // allow DynamicLibraryBundle to continue w/ local libs -- cgit v1.2.3