[svn:parrot] r42974 - in trunk: include/parrot src/runcore

cotto at svn.parrot.org cotto at svn.parrot.org
Thu Dec 10 07:18:56 UTC 2009


Author: cotto
Date: Thu Dec 10 07:18:56 2009
New Revision: 42974
URL: https://trac.parrot.org/parrot/changeset/42974

Log:
[profiling] use output abstraction to print cli args, start adding support for annotations

Modified:
   trunk/include/parrot/runcore_profiling.h
   trunk/src/runcore/profiling.c

Modified: trunk/include/parrot/runcore_profiling.h
==============================================================================
--- trunk/include/parrot/runcore_profiling.h	Thu Dec 10 05:38:53 2009	(r42973)
+++ trunk/include/parrot/runcore_profiling.h	Thu Dec 10 07:18:56 2009	(r42974)
@@ -32,6 +32,7 @@
 typedef enum Parrot_profiling_line {
     PPROF_LINE_CONTEXT_SWITCH,
     PPROF_LINE_OP,
+    PPROF_LINE_ANNOTATION,
     PPROF_LINE_VERSION,
     PPROF_LINE_CLI,
     PPROF_LINE_END_OF_RUNLOOP
@@ -48,6 +49,9 @@
     PPROF_DATA_OPNAME,
     PPROF_DATA_SUB_ADDR,
     PPROF_DATA_CTX_ADDR,
+    PPROF_DATA_ANNOTATION_NAME,
+    PPROF_DATA_ANNOTATION_VALUE,
+    PPROF_DATA_VERSION,
     PPROF_DATA_CLI,
     PPROF_DATA_MAX      /* this must be the last element */
 } Parrot_profiling_datatype;

Modified: trunk/src/runcore/profiling.c
==============================================================================
--- trunk/src/runcore/profiling.c	Thu Dec 10 05:38:53 2009	(r42973)
+++ trunk/src/runcore/profiling.c	Thu Dec 10 07:18:56 2009	(r42974)
@@ -267,18 +267,20 @@
         PMC    *iglobals     = interp->iglobals;
         PMC    *executable   = VTABLE_get_pmc_keyed_int(interp, iglobals,
                                                         IGLOBALS_EXECUTABLE);
-        STRING *command_line = Parrot_str_join(interp, CONST_STRING(interp, " "), argv);
-
-        char   *exec_cstr, *cli_cstr, *full_cli_cstr;
-
-        exec_cstr = Parrot_str_to_cstring(interp,
-                VTABLE_get_string(interp, executable));
-        cli_cstr  = Parrot_str_to_cstring(interp, command_line);
+        STRING *space    = CONST_STRING(interp, " ");
+        STRING *cli_args = Parrot_str_join(interp, space, argv);
+        STRING *cli_str;
+        char   *cli_cstr;
+
+        cli_str  = Parrot_str_concat(interp, VTABLE_get_string(interp,
+                                     executable), space, 0);
+        cli_str  = Parrot_str_concat(interp, cli_str, cli_args, 0);
+        cli_cstr = Parrot_str_to_cstring(interp, cli_str);
 
         /* CLI line won't reflect any options passed to the parrot binary. */
-        fprintf(runcore->profile_fd, "CLI:%s %s\n", exec_cstr, cli_cstr);
+        runcore->pprof_data[PPROF_DATA_CLI] = (PPROF_DATA) cli_cstr;
+        runcore->output_fn(runcore, PPROF_LINE_CLI);
 
-        Parrot_str_free_cstring(exec_cstr);
         Parrot_str_free_cstring(cli_cstr);
 
         Profiling_have_printed_cli_SET(runcore);
@@ -286,6 +288,7 @@
 
     if (Profiling_first_loop_TEST(runcore)) {
 
+        runcore->pprof_data[PPROF_DATA_VERSION] = (PPROF_DATA) PPROF_VERSION;
         runcore->output_fn(runcore, PPROF_LINE_VERSION);
 
         /* make all separate runloops appear to come from a single source */
@@ -485,7 +488,8 @@
             break;
 
         case PPROF_LINE_VERSION:
-            fprintf(runcore->profile_fd, "VERSION:%d\n", PPROF_VERSION);
+            fprintf(runcore->profile_fd, "VERSION:%d\n",
+                    (int) runcore->pprof_data[PPROF_DATA_VERSION]);
             break;
 
         case PPROF_LINE_END_OF_RUNLOOP:


More information about the parrot-commits mailing list