Changeset: df580cbbd466 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=df580cbbd466
Modified Files:
        monetdb5/mal/mal.c
        monetdb5/mal/mal.h
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_profiler.h
        tools/mserver/mserver5.c
Branch: default
Log Message:

Add --trace option for mserver
With this flag you trigger the mal profiler to generate the events
during the complete session. It can be used to ease debugging
complex queries and gdb tracing.


diffs (142 lines):

diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -177,6 +177,7 @@
 
 char monet_cwd[PATHLENGTH] = { 0 };
 size_t monet_memory;
+int            mal_trace;              /* enable profile events on console */
 
 #include "mal_stack.h"
 #include "mal_linker.h"
@@ -189,6 +190,7 @@ size_t monet_memory;
 #include "mal_sabaoth.h"
 #include "mal_recycle.h"
 #include "mal_dataflow.h"
+#include "mal_profiler.h"
 
 MT_Lock     mal_contextLock MT_LOCK_INITIALIZER("mal_contextLock");
 MT_Lock     mal_namespaceLock MT_LOCK_INITIALIZER("mal_namespaceLock");
@@ -254,6 +256,19 @@ int mal_init(void){
        RECYCLEinit();
        if( malBootstrap() == 0)
                return -1;
+       /* set up the profiler if needed, output sent to console */
+       if ( mal_trace) {
+               setFilterAll();
+               openProfilerStream(mal_clients[0].fdout);
+               activateCounter("thread");
+               activateCounter("start");
+               activateCounter("ticks");
+               activateCounter("time");
+               activateCounter("event");
+               activateCounter("pc");
+               activateCounter("stmt");
+               startProfiling();
+       }
        return 0;
 }
 /*
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -18,7 +18,7 @@
  */
 
 /*
- * @+ Monet Basic Definitions
+ * @+ MonetDB Basic Definitions
  * Definitions that need to included in every file of the Monet system,
  * as well as in user defined module implementations.
  */
@@ -38,11 +38,10 @@
 #endif
 
 /*
- * @+ Monet Calling Options
+ * @+ MonetDB Calling Options
  * The number of invocation arguments is kept to a minimum.
  * See `man mserver5` or tools/mserver/mserver5.1
  * for additional system variable settings.
- * @
  */
 #define MAXSCRIPT 64
 #define MEMORY_THRESHOLD  0.8
@@ -51,6 +50,7 @@ mal_export char     monet_cwd[PATHLENGTH
 mal_export size_t      monet_memory;
 mal_export lng                 memorypool;      /* memory claimed by 
concurrent threads */
 mal_export int                 memoryclaims;    /* number of threads active 
with expensive operations */
+mal_export int         mal_trace;              /* enable profile events on 
console */
 
 /*
    See gdk/gdk.mx for the definition of all debug masks.
@@ -65,7 +65,6 @@ mal_export int                memoryclaims;    /* num
 #define GRPtransactions (TMMASK | DELTAMASK | TEMMASK)
 #define GRPmodules (LOADMASK)
 #define GRPalgorithms (ALGOMASK | ESTIMASK)
-#define GRPxproperties 0 /* (XPROPMASK) */
 #define GRPperformance (JOINPROPMASK | DEADBEEFMASK)
 #define GRPoptimizers  (OPTMASK)
 #define GRPforcemito (FORCEMITOMASK)
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -634,11 +634,17 @@ MPresetProfiler(stream *fdout)
 {
        if (fdout != eventstream)
                return;
+       if (mal_trace)
+               return;
        MT_lock_set(&mal_profileLock, "profileLock");
        eventstream = 0;
        MT_lock_unset(&mal_profileLock, "profileLock");
 }
 
+void setFilterAll(void){
+       profileAll = 1;
+}
+
 /*
  * Extern sources may dump information on the profiler stream
 */
diff --git a/monetdb5/mal/mal_profiler.h b/monetdb5/mal/mal_profiler.h
--- a/monetdb5/mal/mal_profiler.h
+++ b/monetdb5/mal/mal_profiler.h
@@ -85,6 +85,7 @@ mal_export void clrFilter(Module cntxt, 
 mal_export void setFilterVariable(MalBlkPtr mb, int i);
 mal_export void clrFilterVariable(MalBlkPtr mb, int i);
 mal_export stream *getProfilerStream(void);
+mal_export void setFilterAll(void);
 
 mal_export void MPresetProfiler(stream *fdout);
 
diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c
--- a/tools/mserver/mserver5.c
+++ b/tools/mserver/mserver5.c
@@ -107,6 +107,7 @@ usage(char *prog, int xit)
 #endif
        fprintf(stderr, "     --performance\n");
        fprintf(stderr, "     --optimizers\n");
+       fprintf(stderr, "     --trace\n");
        fprintf(stderr, "     --forcemito\n");
        fprintf(stderr, "     --debug=<bitmask>\n");
 
@@ -230,6 +231,7 @@ main(int argc, char **av)
                { "properties", 0, 0, 0 },
                { "io", 0, 0, 0 },
                { "transactions", 0, 0, 0 },
+               { "trace", 0, 0, 0 },
                { "modules", 0, 0, 0 },
                { "algorithms", 0, 0, 0 },
                { "optimizers", 0, 0, 0 },
@@ -369,6 +371,10 @@ main(int argc, char **av)
                                grpdebug |= GRPthreads;
                                break;
                        }
+                       if (strcmp(long_options[option_index].name, "trace") == 
0) {
+                               mal_trace =1;
+                               break;
+                       }
                        if (strcmp(long_options[option_index].name, "heaps") == 
0) {
                                grpdebug |= GRPheaps;
                                break;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to