Changeset: 4f87a70066d4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4f87a70066d4
Added Files:
        MonetDB5/modules/mal/mdb.c
        MonetDB5/optimizer/opt_aliases.c
        MonetDB5/optimizer/opt_candidates.c
        MonetDB5/optimizer/opt_coercion.c
        MonetDB5/optimizer/opt_commonTerms.c
        MonetDB5/optimizer/opt_constants.c
        MonetDB5/optimizer/opt_costModel.c
        MonetDB5/optimizer/opt_dataflow.c
        MonetDB5/optimizer/opt_deadcode.c
        MonetDB5/optimizer/opt_emptybind.c
        MonetDB5/optimizer/opt_evaluate.c
        MonetDB5/optimizer/opt_garbageCollector.c
        MonetDB5/optimizer/opt_generator.c
        MonetDB5/optimizer/opt_inline.c
        MonetDB5/optimizer/opt_jit.c
        MonetDB5/optimizer/opt_json.c
        MonetDB5/optimizer/opt_macro.c
        MonetDB5/optimizer/opt_matpack.c
        MonetDB5/optimizer/opt_mergetable.c
        MonetDB5/optimizer/opt_mitosis.c
        MonetDB5/optimizer/opt_multiplex.c
        MonetDB5/optimizer/opt_oltp.c
        MonetDB5/optimizer/opt_postfix.c
        MonetDB5/optimizer/opt_profiler.c
        MonetDB5/optimizer/opt_projectionpath.c
        MonetDB5/optimizer/opt_pushselect.c
        MonetDB5/optimizer/opt_querylog.c
        MonetDB5/optimizer/opt_reduce.c
        MonetDB5/optimizer/opt_remap.c
        MonetDB5/optimizer/opt_remoteQueries.c
        MonetDB5/optimizer/opt_reorder.c
        MonetDB5/optimizer/opt_volcano.c
        MonetDB5/optimizer/opt_wlc.c
Modified Files:
        MonetDB5/mal/mal.c
        MonetDB5/mal/mal.h
        gdk/gdk_tracer.h
        tools/mserver/mserver5.c
Branch: gdk-tracer
Log Message:

Added GDKtracer to optimizers


diffs (truncated from 10392 to 300 lines):

diff --git a/MonetDB5/mal/mal.c b/MonetDB5/mal/mal.c
--- a/MonetDB5/mal/mal.c
+++ b/MonetDB5/mal/mal.c
@@ -18,6 +18,9 @@ stream *maleventstream = 0;
 
 /* The compile time debugging flags are turned into bit masks, akin to GDK */
 lng MALdebug;
+
+/* CHECK */
+// Remove?
 lng OPTdebug;
 
 #ifdef HAVE_HGE
diff --git a/MonetDB5/mal/mal.h b/MonetDB5/mal/mal.h
--- a/MonetDB5/mal/mal.h
+++ b/MonetDB5/mal/mal.h
@@ -39,8 +39,12 @@
 #define MAXSCRIPT 64
 
 /* The compile time debugging flags are turned into bit masks, akin to GDK */
+/* CHECK */
+// Remove?
 mal_export lng OPTdebug;
 
+/* CHECK */
+// Remove?
 #define OPTaliases                     (1 )
 #define OPTcandidates          ((lng)1 << 1)
 #define OPTcoercion                    ((lng)1 << 2)
diff --git a/MonetDB5/modules/mal/mdb.c b/MonetDB5/modules/mal/mdb.c
new file mode 100644
--- /dev/null
+++ b/MonetDB5/modules/mal/mdb.c
@@ -0,0 +1,875 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+ */
+
+/*
+ * author Martin Kersten
+ * MAL debugger interface
+ * This module provides access to the functionality offered
+ * by the MonetDB debugger and interpreter status.
+ * It is primarilly used in interactive sessions to activate
+ * the debugger at a given point. Furthermore, the instructions
+ * provide the necessary handle to generate information
+ * for post-mortum analysis.
+ *
+ * To enable ease of debugging and performance monitoring, the MAL interpreter
+ * comes with a hardwired gdb-like text-based debugger.
+ * A limited set of instructions can be included in the programs themselves,
+ * but beware that debugging has a global effect. Any concurrent user
+ * will be affected by breakpoints being set.
+ *
+ * The prime scheme to inspect the MAL interpreter status is to use
+ * the MAL debugger directly. However, in case of automatic exception handling
+ * it helps to be able to obtain BAT versions of the critical information,
+ * such as stack frame table, stack trace,
+ * and the instruction(s) where an exception occurred.
+ * The inspection typically occurs in the exception handling part of the
+ * MAL block.
+ *
+ * Beware, a large class of internal errors can not easily captured this way.
+ * For example, bus-errors and segmentation faults lead to premature
+ * termination of the process. Similar, creation of the post-mortum
+ * information may fail due to an inconsistent state or insufficient resources.
+ */
+
+#include "monetdb_config.h"
+#include "mdb.h"
+#include "mal_authorize.h"
+#include "mal_function.h"
+
+#define MDBstatus(X) \
+       if( stk->cmd && X==0 ) \
+               mnstr_printf(cntxt->fdout,"#Monet Debugger off\n"); \
+       else if(stk->cmd==0 && X) \
+               mnstr_printf(cntxt->fdout,"#Monet Debugger on\n");
+
+static int
+pseudo(bat *ret, BAT *b, const char *X1, const char *X2, const char *X3) {
+       char buf[BUFSIZ];
+       snprintf(buf,BUFSIZ,"%s_%s_%s", X1,X2,X3);
+       if (BBPindex(buf) <= 0 && BBPrename(b->batCacheid, buf) != 0)
+               return -1;
+       if (BATroles(b,X2) != GDK_SUCCEED)
+               return -1;
+       *ret = b->batCacheid;
+       BBPkeepref(*ret);
+       return 0;
+}
+
+str
+MDBstart(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+       Client c;
+       int pid;
+
+       if( p->argc == 2){
+               /* debug running process */
+               pid = *getArgReference_int(stk, p, 1);
+               if( pid< 0 || pid >= MAL_MAXCLIENTS || mal_clients[pid].mode <= 
FINISHCLIENT)
+                       throw(MAL, "mdb.start", ILLEGAL_ARGUMENT " Illegal 
process id");
+               if( cntxt->user != MAL_ADMIN && mal_clients[pid].user != 
cntxt->user)
+                       throw(MAL, "mdb.start", "Access violation");
+               c= mal_clients+pid;
+               /* make client aware of being debugged */
+               cntxt= c;
+       } else
+       if ( stk->cmd == 0)
+               stk->cmd = 'n';
+       cntxt->itrace = stk->cmd;
+       (void) mb;
+       (void) p;
+       return MAL_SUCCEED;
+}
+
+str
+MDBstartFactory(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+       (void) cntxt;
+       (void) mb;
+       (void) stk;
+       (void) p;
+               throw(MAL, "mdb.start", SQLSTATE(0A000) PROGRAM_NYI);
+}
+
+str
+MDBstop(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+       stk->cmd = 0;
+       cntxt->itrace = 0;
+       mnstr_printf(cntxt->fdout,"mdb>#EOD\n");
+       (void) mb;
+       (void) p;
+       return MAL_SUCCEED;
+}
+
+static void
+MDBtraceFlag(Client cntxt, MalStkPtr stk, int b)
+{
+       if (b) {
+               stk->cmd = b;
+               cntxt->itrace = b;
+       } else {
+               stk->cmd = 0;
+               cntxt->itrace = 0;
+       }
+}
+
+str
+MDBsetTrace(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+       int b;
+
+       (void) cntxt;
+       (void) mb;              /* still unused */
+       b = *getArgReference_bit(stk, p, 1);
+       MDBtraceFlag(cntxt, stk, (b? (int) 't':0));
+       return MAL_SUCCEED;
+}
+
+str
+MDBgetVMsize(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+       lng *ret = getArgReference_lng(stk, p, 0);
+
+       (void) cntxt;
+       (void) mb;              /* still unused */
+       *ret = (lng) GDK_vm_maxsize / 1024/1024;
+       return MAL_SUCCEED;
+}
+
+/* Set the max VM in MBs */
+str
+MDBsetVMsize(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+       lng *ret = getArgReference_lng(stk, p, 0);
+
+       (void) cntxt;
+       (void) mb;              /* still unused */
+       *ret = (lng) GDK_vm_maxsize;
+       if( *getArgReference_lng(stk, p, 1) > 1024 )
+               GDK_vm_maxsize = (size_t) (*getArgReference_lng(stk, p, 1) * 
1024 * 1024);
+       return MAL_SUCCEED;
+}
+
+str
+MDBsetVarTrace(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+       str v;
+
+       (void) cntxt;
+       v = *getArgReference_str(stk, p, 1);
+       mdbSetBreakRequest(cntxt, mb, v, 't');
+       stk->cmd = 'c';
+       cntxt->itrace = 'c';
+       return MAL_SUCCEED;
+}
+
+str
+MDBgetDebug(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+       int *ret = getArgReference_int(stk,p,0);
+
+       (void) cntxt;
+       (void) mb;
+       (void) stk;
+       (void) p;
+    *ret = GDKdebug;
+    return MAL_SUCCEED;
+}
+
+str
+MDBsetDebug(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+       int *ret = getArgReference_int(stk,p,0);
+       int *flg = getArgReference_int(stk,p,1);
+
+       (void) cntxt;
+       (void) mb;
+       (void) stk;
+       (void) p;
+    GDKdebug = *flg;
+       *ret = GDKdebug;
+    return MAL_SUCCEED;
+}
+
+#define addFlag(NME, FLG, DSET) \
+       state =  (DSET & FLG)  > 0;\
+       if (BUNappend(flg, (void*) NME, false) != GDK_SUCCEED) goto bailout;\
+       if (BUNappend(val, &state, false) != GDK_SUCCEED) goto bailout;
+
+str
+MDBgetDebugFlags(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+       bat *f = getArgReference_bat(stk,p,0);
+    bat *v = getArgReference_bat(stk,p,1);
+       BAT *flg, *val;
+       bit state = 0;
+
+       (void) cntxt;
+       (void) mb;
+
+       flg = COLnew(0, TYPE_str, 256, TRANSIENT);
+       val = COLnew(0, TYPE_bit, 256, TRANSIENT);
+
+       if( flg == NULL || val == NULL){
+               BBPreclaim(flg);
+               BBPreclaim(val);
+               throw(MAL, "mdb.getDebugFlags",SQLSTATE(HY001) MAL_MALLOC_FAIL);
+       }
+       addFlag("threads", GRPthreads, GDKdebug);
+       addFlag("memory", GRPmemory, GDKdebug);
+       addFlag("properties", GRPproperties, GDKdebug);
+       addFlag("io", GRPio, GDKdebug);
+       addFlag("heaps", GRPheaps, GDKdebug);
+       addFlag("transactions", GRPtransactions, GDKdebug);
+       addFlag("modules", GRPmodules, GDKdebug);
+       addFlag("algorithms", GRPalgorithms, GDKdebug);
+       addFlag("performance", GRPperformance, GDKdebug);
+       addFlag("forcemito", GRPforcemito, GDKdebug);
+
+       /* CHECK */
+       // Remove those flags below
+    addFlag("aliases", OPTaliases, OPTdebug);
+       addFlag("candidates", OPTcandidates, OPTdebug);
+       addFlag("coercion", OPTcoercion, OPTdebug);
+       addFlag("commonterms", OPTcommonterms, OPTdebug);
+       addFlag("constants", OPTconstants, OPTdebug);
+       addFlag("costmodel", OPTcostmodel, OPTdebug);
+       addFlag("dataflow", OPTdataflow, OPTdebug);
+       addFlag("deadcode", OPTdeadcode, OPTdebug);
+       addFlag("emptybind", OPTemptybind, OPTdebug);
+       addFlag("evaluate", OPTevaluate, OPTdebug);
+       addFlag("garbagecollector", OPTgarbagecollector, OPTdebug);
+       addFlag("generator", OPTgenerator, OPTdebug);
+       addFlag("inline", OPTinline, OPTdebug);
+       addFlag("jit", OPTjit, OPTdebug);
+       addFlag("json", OPTjson, OPTdebug);
+       addFlag("macros", OPTmacros, OPTdebug);
+       addFlag("matpack", OPTmatpack, OPTdebug);
+       addFlag("mergetable", OPTmergetable, OPTdebug);
+       addFlag("mitosis", OPTmitosis, OPTdebug);
+       addFlag("multiplex", OPTmultiplex, OPTdebug);
+       addFlag("oltp", OPToltp, OPTdebug);
+       addFlag("pipes", OPTpipes, OPTdebug);
+       addFlag("postfix", OPTpostfix, OPTdebug);
+       addFlag("prelude", OPTprelude, OPTdebug);
+       addFlag("profiler", OPTprofiler, OPTdebug);
+       addFlag("projectionpath", OPTprojectionpath, OPTdebug);
+       addFlag("pushselect", OPTpushselect, OPTdebug);
+       addFlag("querylog", OPTquerylog, OPTdebug);
+       addFlag("reduce", OPTreduce, OPTdebug);
+       addFlag("remap", OPTremap, OPTdebug);
+       addFlag("remotequeries", OPTremotequeries, OPTdebug);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to