[Libreoffice-commits] .: 2 commits - framework/qa jvmfwk/plugins

Stephan Bergmann sbergmann at kemper.freedesktop.org
Sat Sep 17 01:59:32 PDT 2011


 framework/qa/complex/framework/recovery/RecoveryTest.java |    1 
 jvmfwk/plugins/sunmajor/pluginlib/makefile.mk             |    5 +
 jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx       |   39 ++++++++++----
 3 files changed, 34 insertions(+), 11 deletions(-)

New commits:
commit b03f2200610f6788f64302891a2942b8a7bb69f2
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Sat Sep 17 10:51:39 2011 +0200

    Force JVM into interpreted mode when running under Valgrind, to avoid false error reports.

diff --git a/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk b/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk
index 5b09a67..27dc8da 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk
+++ b/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk
@@ -37,6 +37,11 @@ UNOCOMPONENT1=sunjavaplugin
 .INCLUDE :  settings.mk
 DLLPRE =
 
+.IF "$(VALGRIND_CFLAGS)" != ""
+CDEFS  += -DHAVE_VALGRIND_H
+CFLAGS += $(VALGRIND_CFLAGS)
+.END
+
 # ------------------------------------------------------------------
 
 .IF "$(SOLAR_JAVA)"!=""
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index eaaaf3a..7b5b262 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -62,6 +62,12 @@
 #include "vendorlist.hxx"
 #include "diagnostics.h"
 
+#if defined HAVE_VALGRIND_H
+#include <valgrind.h>
+#else
+#define RUNNING_ON_VALGRIND 0
+#endif
+
 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
 #define SUN_MICRO "Sun Microsystems Inc."
 
@@ -629,20 +635,27 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
         return JFW_PLUGIN_E_VM_CREATION_FAILED;
     }
 
+    // Valgrind typically emits many false errors when executing JIT'ed JVM
+    // code, so force the JVM into interpreted mode:
+    bool forceInterpreted = RUNNING_ON_VALGRIND > 0;
+
     // Some testing with Java 1.4 showed that JavaVMOption.optionString has to
     // be encoded with the system encoding (i.e., osl_getThreadTextEncoding):
     JavaVMInitArgs vm_args;
 
-    boost::scoped_array<JavaVMOption> sarOptions(
-        new JavaVMOption[cOptions + 1]);
+    sal_Int32 nOptions = 1 + cOptions + (forceInterpreted ? 1 : 0);
+        //TODO: check for overflow
+    boost::scoped_array<JavaVMOption> sarOptions(new JavaVMOption[nOptions]);
     JavaVMOption * options = sarOptions.get();
 
     // We set an abort handler which is called when the VM calls _exit during
     // JNI_CreateJavaVM. This happens when the LD_LIBRARY_PATH does not contain
     // all some directories of the Java installation. This is necessary for
     // all versions below 1.5.1
-    options[0].optionString= (char *) "abort";
-    options[0].extraInfo= (void* )(sal_IntPtr)abort_handler;
+    int n = 0;
+    options[n].optionString= (char *) "abort";
+    options[n].extraInfo= (void* )(sal_IntPtr)abort_handler;
+    ++n;
     rtl::OString sClassPathProp("-Djava.class.path=");
     rtl::OString sClassPathOption;
     for (int i = 0; i < cOptions; i++)
@@ -659,21 +672,27 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
                 sClassPathOption = sClassPath + rtl::OString(sep) + sAddPath;
             else
                 sClassPathOption = sClassPath;
-            options[i+1].optionString = (char *) sClassPathOption.getStr();
-            options[i+1].extraInfo = arOptions[i].extraInfo;
+            options[n].optionString = (char *) sClassPathOption.getStr();
+            options[n].extraInfo = arOptions[i].extraInfo;
         }
         else
         {
 #endif
-            options[i+1].optionString = arOptions[i].optionString;
-            options[i+1].extraInfo = arOptions[i].extraInfo;
+            options[n].optionString = arOptions[i].optionString;
+            options[n].extraInfo = arOptions[i].extraInfo;
 #ifdef UNX
         }
 #endif
 #if OSL_DEBUG_LEVEL >= 2
-        JFW_TRACE2(OString("VM option: ") + OString(options[i+1].optionString) +
+        JFW_TRACE2(OString("VM option: ") + OString(options[n].optionString) +
                    OString("\n"));
 #endif
+        ++n;
+    }
+    if (forceInterpreted) {
+        options[n].optionString = const_cast<char *>("-Xint");
+        options[n].extraInfo = 0;
+        ++n;
     }
 
 #ifdef MACOSX
@@ -682,7 +701,7 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
     vm_args.version= JNI_VERSION_1_2;
 #endif
     vm_args.options= options;
-    vm_args.nOptions= cOptions + 1;
+    vm_args.nOptions= nOptions;
     vm_args.ignoreUnrecognized= JNI_TRUE;
 
     /* We set a global flag which is used by the abort handler in order to
commit fefbf4014c9b8ec5f1832c3c4a62911a55472658
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Sep 16 16:52:01 2011 +0200

    Removed non-ASCII commentary noise.

diff --git a/framework/qa/complex/framework/recovery/RecoveryTest.java b/framework/qa/complex/framework/recovery/RecoveryTest.java
index d2e3f04..df75f73 100755
--- a/framework/qa/complex/framework/recovery/RecoveryTest.java
+++ b/framework/qa/complex/framework/recovery/RecoveryTest.java
@@ -130,7 +130,6 @@ public class RecoveryTest extends ComplexTestCase {
      * @todo: remove recovery data before start test
      * @todo: after a second start after the crash there should no documents recovered anymore
      * @todo: enable remove of recovery files
-     * @todo: makefile anpassen auf Parameter überprüfen
      */
     public String[] getTestMethodNames() {
         return new String[]{"testCrash"};


More information about the Libreoffice-commits mailing list