summaryrefslogtreecommitdiffstats
path: root/src/java/com
diff options
context:
space:
mode:
authorKenneth Russel <kbrussel@alum.mit.edu>2008-05-30 07:23:47 +0000
committerKenneth Russel <kbrussel@alum.mit.edu>2008-05-30 07:23:47 +0000
commit2ab33fc1a92fb1c6b8f0cf4b4854b657f6eab1fd (patch)
tree09f497455c2eacdd89b9f2ecfd6dc153e35bf038 /src/java/com
parent6de4ed3b34262c50a1b86f4ae69efcd0bd8f6dea (diff)
Added debugging support via -Dgluegen.debug.ProcAddressHelper and
-Dgluegen.debug.ProcAddressHelper.prefix git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@82 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/java/com')
-rw-r--r--src/java/com/sun/gluegen/runtime/ProcAddressHelper.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/java/com/sun/gluegen/runtime/ProcAddressHelper.java b/src/java/com/sun/gluegen/runtime/ProcAddressHelper.java
index 198519d..5c3c034 100644
--- a/src/java/com/sun/gluegen/runtime/ProcAddressHelper.java
+++ b/src/java/com/sun/gluegen/runtime/ProcAddressHelper.java
@@ -39,17 +39,52 @@
package com.sun.gluegen.runtime;
+import java.security.*;
+
+// Debugging only
+import java.io.*;
+
/** Helper class containing constants and methods to assist with the
manipulation of auto-generated ProcAddressTables. */
public class ProcAddressHelper {
public static final String PROCADDRESS_VAR_PREFIX = "_addressof_";
+ private static boolean DEBUG;
+ private static String DEBUG_PREFIX;
+ private static int debugNum;
+
+ static {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ DEBUG = (System.getProperty("gluegen.debug.ProcAddressHelper") != null);
+ if (DEBUG) {
+ DEBUG_PREFIX = System.getProperty("gluegen.debug.ProcAddressHelper.prefix");
+ }
+ return null;
+ }
+ });
+ }
public static void resetProcAddressTable(Object table,
DynamicLookupHelper lookup) throws RuntimeException {
Class tableClass = table.getClass();
java.lang.reflect.Field[] fields = tableClass.getFields();
+ PrintStream out = null;
+ if (DEBUG) {
+ if (DEBUG_PREFIX != null) {
+ try {
+ out = new PrintStream(new BufferedOutputStream(new FileOutputStream(DEBUG_PREFIX + File.separatorChar +
+ "procaddresshelper-" + (++debugNum) + ".txt")));
+ } catch (IOException e) {
+ e.printStackTrace();
+ out = System.err;
+ }
+ } else {
+ out = System.err;
+ }
+ out.println("ProcAddressHelper.resetProcAddressTable(" + table.getClass().getName() + ")");
+ }
for (int i = 0; i < fields.length; ++i) {
String addressFieldName = fields[i].getName();
if (!addressFieldName.startsWith(ProcAddressHelper.PROCADDRESS_VAR_PREFIX)) {
@@ -64,11 +99,20 @@ public class ProcAddressHelper {
long newProcAddress = lookup.dynamicLookupFunction(funcName);
// set the current value of the proc address variable in the table object
addressField.setLong(table, newProcAddress);
+ if (DEBUG) {
+ out.println(" " + addressField.getName() + " = 0x" + Long.toHexString(newProcAddress));
+ }
} catch (Exception e) {
throw new RuntimeException("Can not get proc address for method \"" +
funcName + "\": Couldn't set value of field \"" + addressFieldName +
"\" in class " + tableClass.getName(), e);
}
}
+ if (DEBUG) {
+ out.flush();
+ if (DEBUG_PREFIX != null) {
+ out.close();
+ }
+ }
}
}