Force JVM into interpreted mode when running under Valgrind, to avoid false error reports.
This commit is contained in:
@@ -37,6 +37,11 @@ UNOCOMPONENT1=sunjavaplugin
|
|||||||
.INCLUDE : settings.mk
|
.INCLUDE : settings.mk
|
||||||
DLLPRE =
|
DLLPRE =
|
||||||
|
|
||||||
|
.IF "$(VALGRIND_CFLAGS)" != ""
|
||||||
|
CDEFS += -DHAVE_VALGRIND_H
|
||||||
|
CFLAGS += $(VALGRIND_CFLAGS)
|
||||||
|
.END
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
.IF "$(SOLAR_JAVA)"!=""
|
.IF "$(SOLAR_JAVA)"!=""
|
||||||
|
@@ -62,6 +62,12 @@
|
|||||||
#include "vendorlist.hxx"
|
#include "vendorlist.hxx"
|
||||||
#include "diagnostics.h"
|
#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 OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
|
||||||
#define SUN_MICRO "Sun Microsystems Inc."
|
#define SUN_MICRO "Sun Microsystems Inc."
|
||||||
|
|
||||||
@@ -629,20 +635,27 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
|
|||||||
return JFW_PLUGIN_E_VM_CREATION_FAILED;
|
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
|
// Some testing with Java 1.4 showed that JavaVMOption.optionString has to
|
||||||
// be encoded with the system encoding (i.e., osl_getThreadTextEncoding):
|
// be encoded with the system encoding (i.e., osl_getThreadTextEncoding):
|
||||||
JavaVMInitArgs vm_args;
|
JavaVMInitArgs vm_args;
|
||||||
|
|
||||||
boost::scoped_array<JavaVMOption> sarOptions(
|
sal_Int32 nOptions = 1 + cOptions + (forceInterpreted ? 1 : 0);
|
||||||
new JavaVMOption[cOptions + 1]);
|
//TODO: check for overflow
|
||||||
|
boost::scoped_array<JavaVMOption> sarOptions(new JavaVMOption[nOptions]);
|
||||||
JavaVMOption * options = sarOptions.get();
|
JavaVMOption * options = sarOptions.get();
|
||||||
|
|
||||||
// We set an abort handler which is called when the VM calls _exit during
|
// 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
|
// JNI_CreateJavaVM. This happens when the LD_LIBRARY_PATH does not contain
|
||||||
// all some directories of the Java installation. This is necessary for
|
// all some directories of the Java installation. This is necessary for
|
||||||
// all versions below 1.5.1
|
// all versions below 1.5.1
|
||||||
options[0].optionString= (char *) "abort";
|
int n = 0;
|
||||||
options[0].extraInfo= (void* )(sal_IntPtr)abort_handler;
|
options[n].optionString= (char *) "abort";
|
||||||
|
options[n].extraInfo= (void* )(sal_IntPtr)abort_handler;
|
||||||
|
++n;
|
||||||
rtl::OString sClassPathProp("-Djava.class.path=");
|
rtl::OString sClassPathProp("-Djava.class.path=");
|
||||||
rtl::OString sClassPathOption;
|
rtl::OString sClassPathOption;
|
||||||
for (int i = 0; i < cOptions; i++)
|
for (int i = 0; i < cOptions; i++)
|
||||||
@@ -659,21 +672,27 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
|
|||||||
sClassPathOption = sClassPath + rtl::OString(sep) + sAddPath;
|
sClassPathOption = sClassPath + rtl::OString(sep) + sAddPath;
|
||||||
else
|
else
|
||||||
sClassPathOption = sClassPath;
|
sClassPathOption = sClassPath;
|
||||||
options[i+1].optionString = (char *) sClassPathOption.getStr();
|
options[n].optionString = (char *) sClassPathOption.getStr();
|
||||||
options[i+1].extraInfo = arOptions[i].extraInfo;
|
options[n].extraInfo = arOptions[i].extraInfo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
options[i+1].optionString = arOptions[i].optionString;
|
options[n].optionString = arOptions[i].optionString;
|
||||||
options[i+1].extraInfo = arOptions[i].extraInfo;
|
options[n].extraInfo = arOptions[i].extraInfo;
|
||||||
#ifdef UNX
|
#ifdef UNX
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if OSL_DEBUG_LEVEL >= 2
|
#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"));
|
OString("\n"));
|
||||||
#endif
|
#endif
|
||||||
|
++n;
|
||||||
|
}
|
||||||
|
if (forceInterpreted) {
|
||||||
|
options[n].optionString = const_cast<char *>("-Xint");
|
||||||
|
options[n].extraInfo = 0;
|
||||||
|
++n;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
@@ -682,7 +701,7 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
|
|||||||
vm_args.version= JNI_VERSION_1_2;
|
vm_args.version= JNI_VERSION_1_2;
|
||||||
#endif
|
#endif
|
||||||
vm_args.options= options;
|
vm_args.options= options;
|
||||||
vm_args.nOptions= cOptions + 1;
|
vm_args.nOptions= nOptions;
|
||||||
vm_args.ignoreUnrecognized= JNI_TRUE;
|
vm_args.ignoreUnrecognized= JNI_TRUE;
|
||||||
|
|
||||||
/* We set a global flag which is used by the abort handler in order to
|
/* We set a global flag which is used by the abort handler in order to
|
||||||
|
Reference in New Issue
Block a user