AC_DEFINE_UNQUOTED([CACAO_PREFIX], "${CACAO_PREFIX}", [installation prefix])
AC_SUBST(CACAO_PREFIX)
+dnl define libdir prefix
+if test "x$libdir" = "xNONE"; then
+ CACAO_LIBDIR=$ac_default_libdir
+else
+ CACAO_LIBDIR=$libdir
+fi
+dnl expand CACAO_LIBDIR to something that is usable in C code
+AS_AC_EXPAND([CACAO_LIBDIR], ${CACAO_LIBDIR})
+AC_DEFINE_UNQUOTED([CACAO_LIBDIR], "${CACAO_LIBDIR}", [library installation prefix])
+AC_SUBST(CACAO_LIBDIR)
+
dnl Features
Changes: Edwin Steiner
Samuel Vinson
-
+ Christan Thalinger
- $Id: jvmti.c 5141 2006-07-16 15:58:21Z twisti $
+ $Id: jvmti.c 5147 2006-07-17 15:11:15Z twisti $
*/
+
+#include "config.h"
+
#include <assert.h>
+#include <string.h>
+#include <linux/unistd.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <ltdl.h>
+#include <unistd.h>
+#include <sched.h>
#include "native/jni.h"
#include "native/native.h"
#include "vm/suck.h"
#include "boehm-gc/include/gc.h"
-#include <string.h>
-#include <linux/unistd.h>
-#include <sys/time.h>
-#include "toolbox/logging.h"
-#include <stdlib.h>
-#include <sys/types.h>
-#include <ltdl.h>
-#include <unistd.h>
-#include <sched.h>
-
#if defined(ENABLE_THREADS)
#include "threads/native/threads.h"
#include <sched.h>
static jvmtiError
GetLoadedClasses (jvmtiEnv * env, jint * class_count_ptr, jclass ** classes_ptr)
{
- int i,j=0;
- classcache_name_entry *nameentry;
- classcache_class_entry *classentry;
-
CHECK_PHASE_START
CHECK_PHASE(JVMTI_PHASE_LIVE)
CHECK_PHASE_END;
- if (class_count_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
- if (classes_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
-
- CLASSCACHE_LOCK();
- *classes_ptr =
- heap_allocate(sizeof(jclass)*(hashtable_classcache.entries),true,NULL);
-
- /* look in every slot of the hashtable */
- for (i=0; i<hashtable_classcache.size; i++) {
- nameentry = hashtable_classcache.ptr[i];
- while (nameentry != NULL) { /* iterate over hashlink */
-
- /* filter pseudo classes $NEW$,$NULL$,$ARRAYSTUB$ out */
- if (nameentry->name->text[0] == '$')
- {
- *class_count_ptr -= 1;
- break;
- }
+ if (class_count_ptr == NULL)
+ return JVMTI_ERROR_NULL_POINTER;
- classentry = nameentry->classes;
- while (classentry != NULL){ /* iterate over classes with same name */
- if (classentry->classobj != NULL) { /*get only loaded classes */
- assert(j<hashtable_classcache.entries);
- (*classes_ptr)[j]=classentry->classobj;
- j++;
- }
- classentry = classentry->next;
- }
- nameentry = nameentry->hashlink;
- }
- }
-
- CLASSCACHE_UNLOCK();
+ if (classes_ptr == NULL)
+ return JVMTI_ERROR_NULL_POINTER;
- *class_count_ptr = j;
+ classcache_jvmti_GetLoadedClasses(class_count_ptr, classes_ptr);
return JVMTI_ERROR_NONE;
}
len = strlen(opt_arg);
- /* separate argumtents */
- while ((opt_arg[i] != '=') && (i<len)) i++;
- if (i<len)
- arg = &opt_arg[i+1];
+ /* separate arguments */
+
+ while ((opt_arg[i] != '=') && (i < len))
+ i++;
+
+ opt_arg[i] = '\0';
+
+ if (i < len)
+ arg = &opt_arg[i + 1];
else
arg = "";
if (agentbypath) {
/* -agentpath */
- *libname=heap_allocate(sizeof(char)*i,true,NULL);
- strncpy(*libname,opt_arg,i);
- (*libname)[i]='\0';
- } else {
+
+ *libname = GCMNEW(char, i);
+
+ strcpy(*libname, opt_arg);
+ }
+ else {
/* -agentlib */
- *libname=heap_allocate(sizeof(char)*(i+7),true,NULL);
- strncpy(*libname,"lib",3);
- strncpy(&(*libname)[3],opt_arg,i);
- strncpy(&(*libname)[i+3],".so",3);
+
+ len = strlen("lib") + i + strlen(".so") + strlen("0");
+
+ *libname = GCMNEW(char, len);
+
+ strcpy(*libname, "lib");
+ strcat(*libname, opt_arg);
+ strcat(*libname, ".so");
}
/* try to open the library */
Changes: Christian Thalinger
- $Id: classcache.c 5123 2006-07-12 21:45:34Z twisti $
+ $Id: classcache.c 5147 2006-07-17 15:11:15Z twisti $
*/
hashtable hashtable_classcache;
#if defined(ENABLE_THREADS)
-#if defined(ENABLE_JVMTI)
-java_objectheader *lock_hashtable_classcache;
-#else
static java_objectheader *lock_hashtable_classcache;
#endif
-#endif
/*============================================================================*/
}
#endif /* defined(ENABLE_VERIFIER) */
+
+/* classcache_jvmti_GetLoadedClasses *******************************************
+
+
+*******************************************************************************/
+
+#if defined(ENABLE_JVMTI)
+void classcache_jvmti_GetLoadedClasses(jint *class_count_ptr,
+ jclass **classes_ptr)
+{
+ classcache_name_entry *en;
+ classcache_class_entry *clsen;
+ s4 i;
+ s4 j;
+
+ CLASSCACHE_LOCK();
+
+ *classes_ptr = GCMNEW(jclass, hashtable_classcache.entries);
+
+ /* look in every slot of the hashtable */
+
+ for (i = 0, j = 0; i < hashtable_classcache.size; i++) {
+ /* iterate over hashlink */
+
+ for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) {
+ /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */
+
+ if (en->name->text[0] == '$') {
+ *class_count_ptr -= 1;
+ break;
+ }
+
+ /* iterate over classes with same name */
+
+ for (clsen = en->classes; clsen != NULL; clsen = clsen->next) {
+ /* get only loaded classes */
+
+ if (clsen->classobj != NULL) {
+ assert(j < hashtable_classcache.entries);
+ (*classes_ptr)[j] = clsen->classobj;
+ j++;
+ }
+ }
+ }
+ }
+
+ CLASSCACHE_UNLOCK();
+
+ *class_count_ptr = j;
+}
+#endif /* defined(ENABLE_JVMTI) */
+
+
/*============================================================================*/
/* DEBUG DUMPS */
/*============================================================================*/
Authors: Edwin Steiner
- Changes:
+ Changes: Christian Thalinger
- $Id: classcache.h 4957 2006-05-26 11:48:10Z edwin $
+ $Id: classcache.h 5147 2006-07-17 15:11:15Z twisti $
*/
#include <stdio.h> /* for FILE */
+#if defined(ENABLE_JVMTI)
+# include "native/jni.h"
+#endif
+
#include "vm/hashtable.h"
#include "vm/references.h"
extern hashtable hashtable_classcache;
-#if defined(ENABLE_JVMTI)
-#if defined(ENABLE_THREADS)
-# define CLASSCACHE_LOCK() builtin_monitorenter(lock_hashtable_classcache)
-# define CLASSCACHE_UNLOCK() builtin_monitorexit(lock_hashtable_classcache)
-#else
-# define CLASSCACHE_LOCK()
-# define CLASSCACHE_UNLOCK()
-#endif
-
-extern java_objectheader *lock_hashtable_classcache;
-#endif
/* structs ********************************************************************/
methodinfo *m);
#endif
+#if defined(ENABLE_JVMTI)
+void classcache_jvmti_GetLoadedClasses(jint *class_count_ptr,
+ jclass **classes_ptr);
+#endif
+
#ifndef NDEBUG
void classcache_debug_dump(FILE *file,utf *only);
#endif
bool vm_create(JavaVMInitArgs *vm_args)
{
char *cp;
- s4 cplen;
+ s4 len;
s4 opt;
s4 i, j, k;
bool opt_version;
strcpy(bootclasspath, cp);
} else {
- cplen = strlen(CACAO_VM_ZIP) +
+ len = strlen(CACAO_VM_ZIP) +
strlen(":") +
strlen(CLASSPATH_GLIBJ_ZIP) +
strlen("0");
- bootclasspath = MNEW(char, cplen);
+ bootclasspath = MNEW(char, len);
strcat(bootclasspath, CACAO_VM_ZIP);
strcat(bootclasspath, ":");
strcat(bootclasspath, CLASSPATH_GLIBJ_ZIP);
case OPT_BOOTCLASSPATH_A:
/* append to end of bootclasspath */
- cplen = strlen(bootclasspath);
+ len = strlen(bootclasspath);
bootclasspath = MREALLOC(bootclasspath,
char,
- cplen,
- cplen + strlen(":") +
+ len,
+ len + strlen(":") +
strlen(opt_arg) + strlen("0"));
strcat(bootclasspath, ":");
/* prepend in front of bootclasspath */
cp = bootclasspath;
- cplen = strlen(cp);
+ len = strlen(cp);
bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
- cplen + strlen("0"));
+ len + strlen("0"));
strcpy(bootclasspath, opt_arg);
strcat(bootclasspath, ":");
strcat(bootclasspath, cp);
- MFREE(cp, char, cplen);
+ MFREE(cp, char, len);
break;
case OPT_GLIBJ:
MFREE(bootclasspath, char, strlen(bootclasspath));
- cplen = strlen(CACAO_VM_ZIP) +
+ len = strlen(CACAO_VM_ZIP) +
strlen(":") +
strlen(opt_arg) +
strlen("0");
- bootclasspath = MNEW(char, cplen);
+ bootclasspath = MNEW(char, len);
strcpy(bootclasspath, CACAO_VM_ZIP);
strcat(bootclasspath, ":");
case OPT_DEBUG:
/* this option exists only for compatibility reasons */
break;
+
case OPT_NOAGENT:
/* I don't know yet what Xnoagent should do. This is only for
compatiblity with eclipse - motse */
break;
+
case OPT_XRUNJDWP:
- agentbypath=jvmti=jdwp=true;
- i = strlen(opt_arg)+33;
- agentarg = MNEW(char,i);
- /* XXX how can I get the <prefix>/lib directory ? */
- snprintf(agentarg,i,"/usr/local/cacao/lib/libjdwp.so=%s",&opt_arg[1]);
+ agentbypath = true;
+ jvmti = true;
+ jdwp = true;
+
+ len =
+ strlen(CACAO_LIBDIR) +
+ strlen("/libjdwp.so=") +
+ strlen(opt_arg) +
+ strlen("0");
+
+ agentarg = MNEW(char, len);
+
+ strcpy(agentarg, CACAO_LIBDIR);
+ strcat(agentarg, "/libjdwp.so=");
+ strcat(agentarg, &opt_arg[1]);
break;
+
case OPT_AGENTPATH:
agentbypath = true;
+
case OPT_AGENTLIB:
- jvmti=true;
+ jvmti = true;
agentarg = opt_arg;
break;
#endif
if (jvmti) {
jvmti_set_phase(JVMTI_PHASE_ONLOAD);
jvmti_agentload(agentarg, agentbypath, &handle, &libname);
- if (jdwp) MFREE(agentarg,char,strlen(agentarg));
+
+ if (jdwp)
+ MFREE(agentarg, char, strlen(agentarg));
+
jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
}