* src/vm/vm.c (vm_create): Changed vmlog init interface.
* src/cacaoh/dummy.c (vmlog_cacao_set_prefix, vmlog_cacao_set_stringprefix,
vmlog_cacao_set_ignoreprefix): Dummies added.
* contrib/vmlog/vmlog.h, contrib/vmlog/vmlog.c, contrib/vmlog/vmlog_cacao.h,
contrib/vmlog/vmlog_cacao.c: Changed vmlog init interface.
--HG--
branch : edwin-replacement
extra : transplant_source : %F0%0C%E3%E5%7C%FB%E4%19%97J%E3%7D%EFNt%E6IP%16%9E
/*** option parsing **************************************************/
+vmlog_options *vmlog_opt_new(void)
+{
+ vmlog_options *opts;
+
+ VMLOG_XZNEW(opts,vmlog_options);
+
+ return opts;
+}
+
int vmlog_opt_parse_seq(const char *arg,int len,vmlog_seq_t *seq)
{
char *buf;
return 1;
}
+void vmlog_opt_set_prefix(vmlog_options *opts, const char *arg)
+{
+ opts->prefix = vmlog_strdup(arg,strlen(arg));
+}
+
+void vmlog_opt_set_stringprefix(vmlog_options *opts, const char *arg)
+{
+ opts->stringprefix = vmlog_strdup(arg,strlen(arg));
+}
+
+void vmlog_opt_set_ignoreprefix(vmlog_options *opts, const char *arg)
+{
+ opts->ignoreprefix = vmlog_strdup(arg,strlen(arg));
+}
+
static int vmlog_opt_parse_one_option(vmlog_options *opts, const char *arg, const char *nextarg)
{
int eat;
if (strcmp(arg,"-vmlog:prefix") == 0) {
if (!nextarg)
vmlog_die("expected a prefix after -vmlog:prefix");
- opts->prefix = vmlog_strdup(nextarg,strlen(nextarg));
+ vmlog_opt_set_prefix(opts,nextarg);
eat++;
}
else if (strcmp(arg,"-vmlog:strings") == 0) {
if (!nextarg)
vmlog_die("expected a prefix after -vmlog:strings");
- opts->stringprefix = vmlog_strdup(nextarg,strlen(nextarg));
+ vmlog_opt_set_stringprefix(opts,nextarg);
eat++;
}
else if (strcmp(arg,"-vmlog:ignore") == 0) {
if (!nextarg)
vmlog_die("expected a prefix after -vmlog:ignore");
- opts->ignoreprefix = vmlog_strdup(nextarg,strlen(nextarg));
+ vmlog_opt_set_ignoreprefix(opts,nextarg);
eat++;
}
else {
assert(pargc);
- VMLOG_XZNEW(opts,vmlog_options);
+ opts = vmlog_opt_new();
if (*pargc && argv[0])
opts->progname = vmlog_strdup(argv[0],strlen(argv[0]));
assert(vmargs);
- VMLOG_XZNEW(opts,vmlog_options);
+ opts = vmlog_opt_new();
i = 0;
while (i < vmargs->nOptions) {
vmlog_log_entry * vmlog_ringbuf_prev(vmlog_ringbuf *ring,int prefetch);
/* option parsing */
+vmlog_options *vmlog_opt_new(void);
+void vmlog_opt_set_prefix(vmlog_options *opts, const char *arg);
+void vmlog_opt_set_stringprefix(vmlog_options *opts, const char *arg);
+void vmlog_opt_set_ignoreprefix(vmlog_options *opts, const char *arg);
int vmlog_opt_parse_seq(const char *arg,int len,vmlog_seq_t *seq);
int vmlog_opt_parse_range(const char *arg,vmlog_seq_t *start,vmlog_seq_t *end);
vmlog_options *vmlog_opt_parse_cmd_line(int *pargc,char **argv);
static vmlog_log *vmlog_global_log = NULL;
static java_object_t *vmlog_global_lock = NULL;
+static vmlog_options *vmlog_cacao_options = NULL;
/*** locking *********************************************************/
/*** internal functions **********************************************/
-void vmlog_cacao_init(JavaVMInitArgs *vmargs)
+void vmlog_cacao_init()
{
- vmlog_options *opts;
-
- opts = vmlog_opt_parse_vmargs(vmargs);
-
- if (!opts->prefix)
+ if (!vmlog_cacao_options->prefix)
return;
- vmlog_global_log = vmlog_log_new(opts->prefix,1);
+ vmlog_global_log = vmlog_log_new(vmlog_cacao_options->prefix,1);
- if (opts->ignoreprefix) {
+ if (vmlog_cacao_options->ignoreprefix) {
vmlog_log_load_ignorelist(vmlog_global_log,
- opts->ignoreprefix);
+ vmlog_cacao_options->ignoreprefix);
}
- if (opts->stringprefix) {
+ if (vmlog_cacao_options->stringprefix) {
vmlog_load_stringhash(vmlog_global_log,
- opts->stringprefix);
+ vmlog_cacao_options->stringprefix);
}
- vmlog_opt_free(opts);
+ vmlog_opt_free(vmlog_cacao_options);
+ vmlog_cacao_options = NULL;
}
void vmlog_cacao_init_lock(void)
name, strlen(name));
}
+void vmlog_cacao_init_options(void)
+{
+ vmlog_cacao_options = vmlog_opt_new();
+}
+
+void vmlog_cacao_set_prefix(const char *arg)
+{
+ vmlog_opt_set_prefix(vmlog_cacao_options, arg);
+}
+
+void vmlog_cacao_set_stringprefix(const char *arg)
+{
+ vmlog_opt_set_stringprefix(vmlog_cacao_options, arg);
+}
+
+void vmlog_cacao_set_ignoreprefix(const char *arg)
+{
+ vmlog_opt_set_ignoreprefix(vmlog_cacao_options, arg);
+}
+
/* vim: noet ts=8 sw=8
*/
#include <threads/native/threads.h>
-void vmlog_cacao_init(JavaVMInitArgs *vmargs);
+void vmlog_cacao_init_options(void);
+
+void vmlog_cacao_set_prefix(const char *arg);
+void vmlog_cacao_set_stringprefix(const char *arg);
+void vmlog_cacao_set_ignoreprefix(const char *arg);
+
+void vmlog_cacao_init(void);
void vmlog_cacao_init_lock(void);
}
+#if defined(ENABLE_VMLOG)
+void vmlog_cacao_set_prefix(const char *arg)
+{
+}
+
+void vmlog_cacao_set_stringprefix(const char *arg)
+{
+}
+
+void vmlog_cacao_set_ignoreprefix(const char *arg)
+{
+}
+#endif
+
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
jdwp = agentbypath = false;
#endif
-#if defined(ENABLE_VMLOG)
- vmlog_cacao_init(vm_args);
-#endif
-
#if defined(ENABLE_JNI)
/* Check the JNI version requested. */
/* First of all, parse the -XX options. */
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_init_options();
+#endif
+
options_xx(vm_args);
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_init();
+#endif
+
/* We need to check if the actual size of a java.lang.Class object
is smaller or equal than the assumption made in
src/vmcore/class.h. */
OPT_TraceJVMCalls,
OPT_TraceJVMCallsVerbose,
OPT_TraceLinkClass,
- OPT_TraceReplacement
+ OPT_TraceReplacement,
+ OPT_Vmlog,
+ OPT_VmlogStrings,
+ OPT_VmlogIgnore
};
{ "TraceReplacement", OPT_TraceReplacement, OPT_TYPE_VALUE, "trace on-stack replacement with the given verbosity level (default: 1)" },
#endif
+#if defined(ENABLE_VMLOG)
+ { "Vmlog", OPT_Vmlog, OPT_TYPE_VALUE, "prefix for vmlog trace files (enables vmlog)" },
+ { "VmlogStrings", OPT_VmlogStrings, OPT_TYPE_VALUE, "prefix of vmlog string file to load" },
+ { "VmlogIgnore", OPT_VmlogIgnore, OPT_TYPE_VALUE, "prefix of vmlog ignore file to load" },
+#endif
+
/* end marker */
{ NULL, -1, -1, NULL }
break;
#endif
+#if defined(ENABLE_VMLOG)
+ case OPT_Vmlog:
+ if (value == NULL)
+ vmlog_cacao_set_prefix("vmlog");
+ else
+ vmlog_cacao_set_prefix(value);
+ opt_verbosecall = 1;
+ opt_TraceJavaCalls = 1;
+ break;
+
+ case OPT_VmlogStrings:
+ if (value != NULL)
+ vmlog_cacao_set_stringprefix(value);
+ break;
+
+ case OPT_VmlogIgnore:
+ if (value != NULL)
+ vmlog_cacao_set_ignoreprefix(value);
+ break;
+#endif
+
default:
printf("Unknown -XX option: %s\n", name);
break;