* src/vmcore/options.c (options_xx): Integrated vmlog options handling.
authorEdwin Steiner <edwin.steiner@gmx.net>
Fri, 15 Feb 2008 20:26:28 +0000 (21:26 +0100)
committerEdwin Steiner <edwin.steiner@gmx.net>
Fri, 15 Feb 2008 20:26:28 +0000 (21:26 +0100)
* 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

contrib/vmlog/vmlog.c
contrib/vmlog/vmlog.h
contrib/vmlog/vmlog_cacao.c
contrib/vmlog/vmlog_cacao.h
src/cacaoh/dummy.c
src/vm/vm.c
src/vmcore/options.c

index 8cfa0bc8cce9e39b0d87836792725b137ee20408..d3f4d2f03f2bd132021b2dd2a1215ed8f5cc65b6 100644 (file)
@@ -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) {
index 478717eb7453ba3cb5925198df2d61e5966e8076..ee90081bb08fc5f6b7e565d42daa21cd679b8095 100644 (file)
@@ -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);
index 276aee261451f332d88d7c9476c1642b8aa65453..57de7f2074c134eb4b6663b62568f2f785d67577 100644 (file)
@@ -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
  */
 
index a58fcd979be82c3c438978252d5bde9c73ff7c37..7d455c657a14031ec5654ba73de30fb19d7a5786 100644 (file)
 
 #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);
 
index 83c353f935c3408834f78a85d6d12c0edb1ba08d..47d222bc446cb1d2e1d6d439675e2c71119bdf34 100644 (file)
@@ -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
index 3a117a6ff63a0f10df86067602b3076bf3f2245a..cb74b4144c3cb2c232d3c837c8bbe9374a504c35 100644 (file)
@@ -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. */
index f38c9a07f1b6ee3861b7df9995bc994d169706c5..32cbd97187952ace8c8677f4aee55806b46f7f2e 100644 (file)
@@ -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;