From: Edwin Steiner Date: Fri, 15 Feb 2008 20:26:28 +0000 (+0100) Subject: * src/vmcore/options.c (options_xx): Integrated vmlog options handling. X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=cacao.git;a=commitdiff_plain;h=6f11fc095907717c6cba10ff5f54bbf50aed33a5 * src/vmcore/options.c (options_xx): Integrated vmlog options handling. * 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 --- diff --git a/contrib/vmlog/vmlog.c b/contrib/vmlog/vmlog.c index 8cfa0bc8c..d3f4d2f03 100644 --- a/contrib/vmlog/vmlog.c +++ b/contrib/vmlog/vmlog.c @@ -1714,6 +1714,15 @@ vmlog_log_entry * vmlog_ringbuf_prev(vmlog_ringbuf *ring,int prefetch) /*** 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; @@ -1768,6 +1777,21 @@ int vmlog_opt_parse_range(const char *arg,vmlog_seq_t *start,vmlog_seq_t *end) 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; @@ -1782,19 +1806,19 @@ static int vmlog_opt_parse_one_option(vmlog_options *opts, const char *arg, cons 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 { @@ -1814,7 +1838,7 @@ vmlog_options *vmlog_opt_parse_cmd_line(int *pargc,char **argv) assert(pargc); - VMLOG_XZNEW(opts,vmlog_options); + opts = vmlog_opt_new(); if (*pargc && argv[0]) opts->progname = vmlog_strdup(argv[0],strlen(argv[0])); @@ -1851,7 +1875,7 @@ vmlog_options *vmlog_opt_parse_vmargs(JavaVMInitArgs *vmargs) assert(vmargs); - VMLOG_XZNEW(opts,vmlog_options); + opts = vmlog_opt_new(); i = 0; while (i < vmargs->nOptions) { diff --git a/contrib/vmlog/vmlog.h b/contrib/vmlog/vmlog.h index 478717eb7..ee90081bb 100644 --- a/contrib/vmlog/vmlog.h +++ b/contrib/vmlog/vmlog.h @@ -257,6 +257,10 @@ vmlog_log_entry * vmlog_ringbuf_next(vmlog_ringbuf *ring,int prefetch); 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); diff --git a/contrib/vmlog/vmlog_cacao.c b/contrib/vmlog/vmlog_cacao.c index 276aee261..57de7f207 100644 --- a/contrib/vmlog/vmlog_cacao.c +++ b/contrib/vmlog/vmlog_cacao.c @@ -27,6 +27,7 @@ static vmlog_log *vmlog_global_log = NULL; static java_object_t *vmlog_global_lock = NULL; +static vmlog_options *vmlog_cacao_options = NULL; /*** locking *********************************************************/ @@ -39,28 +40,25 @@ static java_object_t *vmlog_global_lock = NULL; /*** 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) @@ -163,6 +161,26 @@ void vmlog_cacao_signl(const char *name) 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 */ diff --git a/contrib/vmlog/vmlog_cacao.h b/contrib/vmlog/vmlog_cacao.h index a58fcd979..7d455c657 100644 --- a/contrib/vmlog/vmlog_cacao.h +++ b/contrib/vmlog/vmlog_cacao.h @@ -21,7 +21,13 @@ #include -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); diff --git a/src/cacaoh/dummy.c b/src/cacaoh/dummy.c index 83c353f93..47d222bc4 100644 --- a/src/cacaoh/dummy.c +++ b/src/cacaoh/dummy.c @@ -774,6 +774,21 @@ void print_dynamic_super_statistics(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 diff --git a/src/vm/vm.c b/src/vm/vm.c index 3a117a6ff..cb74b4144 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -795,10 +795,6 @@ bool vm_create(JavaVMInitArgs *vm_args) jdwp = agentbypath = false; #endif -#if defined(ENABLE_VMLOG) - vmlog_cacao_init(vm_args); -#endif - #if defined(ENABLE_JNI) /* Check the JNI version requested. */ @@ -834,8 +830,16 @@ bool vm_create(JavaVMInitArgs *vm_args) /* 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. */ diff --git a/src/vmcore/options.c b/src/vmcore/options.c index f38c9a07f..32cbd9718 100644 --- a/src/vmcore/options.c +++ b/src/vmcore/options.c @@ -242,7 +242,10 @@ enum { OPT_TraceJVMCalls, OPT_TraceJVMCallsVerbose, OPT_TraceLinkClass, - OPT_TraceReplacement + OPT_TraceReplacement, + OPT_Vmlog, + OPT_VmlogStrings, + OPT_VmlogIgnore }; @@ -285,6 +288,12 @@ option_t options_XX[] = { { "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 } @@ -685,6 +694,27 @@ void options_xx(JavaVMInitArgs *vm_args) 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;