Changeset: d3610b3c8d05 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d3610b3c8d05
Modified Files:
        clients/Tests/exports.stable.out
        monetdb5/mal/mal.h
        monetdb5/mal/mal_debugger.c
        monetdb5/mal/mal_function.c
        monetdb5/mal/mal_function.h
        monetdb5/mal/mal_instruction.c
        monetdb5/modules/mal/mdb.c
        monetdb5/modules/mal/mdb.h
        monetdb5/modules/mal/mdb.mal
Branch: default
Log Message:

Remove old dot file generation
- This is very old code used in the first stethoscope
- A better approach is to use the stethoscope JSON output
and the mapiclients/dotfile.py


diffs (truncated from 382 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1376,7 +1376,6 @@ str MDBsetDebug(int *ret, int *flg);
 str MDBsetDebugStr(int *ret, str *nme);
 str MDBsetTrace(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
 str MDBsetVarTrace(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
-str MDBshowFlowGraph(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
 str MDBstart(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
 str MDBstartFactory(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
 str MDBstop(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
@@ -2479,7 +2478,6 @@ void showAllScenarios(stream *f);
 void showCurrentScenario(void);
 void showErrors(Client cntxt);
 void showException(stream *out, enum malexception, const char *, _In_z_ 
_Printf_format_string_ const char *, ...) __attribute__((__format__(__printf__, 
4, 5)));
-void showFlowGraph(MalBlkPtr mb, MalStkPtr stk, str fname);
 void showMalBlkHistory(stream *out, MalBlkPtr mb);
 void showOptimizerHistory(void);
 void showOptimizerStep(str fnme, int i, int flg);
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -211,7 +211,6 @@ typedef struct MALBLK {
        int flowfixed;                  /* all flow instructions are fixed */
        struct MALBLK *history; /* of optimizer actions */
        short keephistory;              /* do we need the history at all */
-       short dotfile;                  /* send dot file to stethoscope? */
        int maxarg;                             /* keep track on the maximal 
arguments used */
        ptr replica;                    /* for the replicator tests */
        sht trap;                               /* call debugger when called */
diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c
--- a/monetdb5/mal/mal_debugger.c
+++ b/monetdb5/mal/mal_debugger.c
@@ -701,39 +701,6 @@ retryRead:
                                mb = stk->blk;
                                break;
                        }
-                       if (strncmp(b, "dot", 3) == 0) {
-                               /* produce the dot file for graphical display */
-                               /* its argument is the optimizer level followed 
by filename*/
-                               MalBlkPtr mdot;
-                               char fname[2 * PATHLENGTH] = "";
-                               char name[PATHLENGTH], *nme;
-
-                               skipWord(cntxt, b);
-                               nme = b;
-                               skipNonBlanc(cntxt, b);
-                               strncpy(name, nme, PATHLENGTH - 1);
-                               if (b - nme < PATHLENGTH)
-                                       name[ b - nme] = 0;
-                               mdot = mdbLocateMalBlk(cntxt, mb, name, out);
-                               skipBlanc(cntxt, b);
-                               if (mdot == NULL)
-                                       mdot = mb;
-                               snprintf(name, PATHLENGTH, "/%s.%s.dot", 
getModuleId(getInstrPtr(mdot, 0)), getFunctionId(getInstrPtr(mdot, 0)));
-                               /* optional file */
-                               skipBlanc(cntxt, b);
-                               if (*b == 0) {
-                                       snprintf(fname, sizeof(fname), "%s%s", 
monet_cwd, name);
-                               } else if (*b != '/') {
-                                       snprintf(fname, sizeof(fname), "%s%s", 
monet_cwd, name);
-                               } else if (b[strlen(b) - 1] == '/') {
-                                       snprintf(fname, sizeof(fname), "%s%s", 
b, name + 1);
-                               } else
-                                       snprintf(fname, sizeof(fname), "%s", b);
-
-                               showFlowGraph(mdot, 0, fname);
-                               mnstr_printf(out, "#dot file '%s' created\n", 
fname);
-                               break;
-                       }
                        skipWord(cntxt, b);
                        /* get rid of break point */
                        if (*b && !isspace((int) *b) && !isdigit((int) *b))
diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -864,193 +864,3 @@ void chkDeclarations(stream *out, MalBlk
                }
        }
 }
-
-/*
- * Data flow analysis.
- * Flow graph display is handy for debugging and analysis.
- * A better flow analysis is needed, which takes into account barrier blocks 
- */
-static void
-showOutFlow(MalBlkPtr mb, int pc, int varid, stream *f)
-{
-       InstrPtr p;
-       int i, k, found;
-
-       for (i = pc + 1; i < mb->stop - 1; i++) {
-               p = getInstrPtr(mb, i);
-               found = 0;
-               for (k = 0; k < p->argc; k++) {
-                       if (p->argv[k] == varid) {
-                               mnstr_printf(f, "n%d -> n%d\n", pc, i);
-                               found++;
-                       }
-               }
-               /* stop as soon you find a re-assignment */
-               for (k = 0; k < p->retc; k++) {
-                       if (getArg(p, k) == varid)
-                               i = mb->stop;
-               }
-               /* or a side-effect usage */
-               if (found &&
-                       (p->retc == 0 || getArgType(mb, p, 0) == TYPE_void))
-                       i = mb->stop;
-       }
-}
-
-static void
-showInFlow(MalBlkPtr mb, int pc, int varid, stream *f)
-{
-       InstrPtr p;
-       int i, k;
-
-       /* find last use, needed for operations with side effects */
-       for (i = pc - 1; i >= 0; i--) {
-               p = getInstrPtr(mb, i);
-               for (k = 0; k < p->argc; k++) {
-                       if (p->argv[k] == varid ) {
-                               mnstr_printf(f, "n%d -> n%d\n", i, pc);
-                               return;
-                       }
-               }
-       }
-}
-
-/*
- * We only display the minimal debugging information. The remainder
- * can be obtained through the profiler.
- */
-static void
-showFlowDetails(MalBlkPtr mb, MalStkPtr stk, InstrPtr p, int pc, stream *f)
-{
-       (void) mb;     /* fool the compiler */
-       (void) stk;     /* fool the compiler */
-       mnstr_printf(f, "n%d [fontsize=8, shape=box, label=\"%s\"]\n", pc, 
getFunctionId(p) ? getFunctionId(p) : "<noname>");
-}
-
-/* Produce a file with the flow graph in dot format.
- */
-#define MAXFLOWGRAPHS 128
-
-static int getFlowGraphs(MalBlkPtr mb, MalStkPtr stk, MalBlkPtr *mblist, 
MalStkPtr *stklist,int top){
-       int i;
-       InstrPtr p;
-
-       for ( i=0; i<top; i++)
-       if ( mblist[i] == mb)
-               return top;
-
-       if ( top == MAXFLOWGRAPHS)
-               return top; /* just bail out */
-       mblist[top] = mb;
-       stklist[top++] = stk;
-       for (i=1; i < mb->stop; i++){
-               p = getInstrPtr(mb,i);
-               if ( p->token == FCNcall || p->token == FACcall )
-                       top =getFlowGraphs(p->blk, 0,mblist, stklist, top);
-       }
-       return top;
-}
-
-void
-showFlowGraph(MalBlkPtr mb, MalStkPtr stk, str fname)
-{
-       stream *f;
-       InstrPtr p;
-       int i, j,k;
-       char mapimode = 0;
-       buffer *bufstr = NULL;
-       MalBlkPtr mblist[MAXFLOWGRAPHS];
-       MalStkPtr stklist[MAXFLOWGRAPHS];
-       int top =0;
-
-       (void) stk;     /* fool the compiler */
-
-       memset(mblist, 0, sizeof(mblist));
-       memset(stklist, 0, sizeof(stklist));
-
-       if (idcmp(fname, "stdout") == 0) {
-               f = GDKout;
-       } else if (idcmp(fname, "stdout-mapi") == 0) {
-               bufstr = buffer_create(8096);
-               f = buffer_wastream(bufstr, "bufstr_write");
-               mapimode = 1;
-       } else {
-               f = open_wastream(fname);
-       }
-       if ( f == NULL)
-               return;
-
-       top = getFlowGraphs(mb,stk,mblist,stklist,0);
-       for( j=0; j< top; j++){
-               mb = mblist[j];
-               stk = stklist[j];
-               if (mb == 0 )
-                       continue; /* already sent */
-               p = getInstrPtr(mb, 0);
-               mnstr_printf(f, "digraph %s {\n", getFunctionId(p));
-               p = getInstrPtr(mb, 0);
-               showFlowDetails(mb, stk, p, 0, f);
-               for (k = p->retc; k < p->argc; k++) {
-                       showOutFlow(mb, 0, p->argv[k], f);
-               }
-               for (i = 1; i < mb->stop; i++) {
-                       p = getInstrPtr(mb, i);
-
-                       showFlowDetails(mb, stk, p, i, f);
-
-                       for (k = 0; k < p->retc; k++)
-                               showOutFlow(mb, i, p->argv[k], f);
-
-                       if (p->retc == 0 || getArgType(mb, p, 0) == TYPE_void) 
/* assume side effects */
-                               for (k = p->retc; k < p->argc; k++)
-                                       if (getArgType(mb, p, k) != TYPE_void &&
-                                               !isVarConstant(mb, getArg(p, 
k)))
-                                               showOutFlow(mb, i, p->argv[k], 
f);
-
-                       if (getFunctionId(p) == 0)
-                               for (k = 0; k < p->retc; k++)
-                                       if (getArgType(mb, p, k) != TYPE_void)
-                                               showInFlow(mb, i, p->argv[k], 
f);
-                       if (p->token == ENDsymbol)
-                               break;
-               }
-               mnstr_printf(f, "}\n");
-               mb->dotfile++;
-       }
-
-       if (mapimode == 1) {
-               size_t maxlen = 0;
-               size_t rows = 0;
-               str buf = buffer_get_buf(bufstr);
-               str line, oline;
-
-               /* calculate width of column, and the number of tuples */
-               oline = buf;
-               while ((line = strchr(oline, '\n')) != NULL) {
-                       if ((size_t) (line - oline) > maxlen)
-                               maxlen = line - oline;
-                       rows++;
-                       oline = line + 1;
-               } /* see printf before this mapimode if, last line ends with \n 
*/
-
-               /* write mapi header */
-               if ( f == GDKout) {
-                       mnstr_printf(f, "&1 0 " SZFMT " 1 " SZFMT "\n",
-                                       /* type id rows columns tuples */ rows, 
rows);
-                       mnstr_printf(f, "%% .dot # table_name\n");
-                       mnstr_printf(f, "%% dot # name\n");
-                       mnstr_printf(f, "%% clob # type\n");
-                       mnstr_printf(f, "%% " SZFMT " # length\n", maxlen);
-               }
-               oline = buf;
-               while ((line = strchr(oline, '\n')) != NULL) {
-                       *line++ = '\0';
-                       mnstr_printf(GDKout, "=%s\n", oline);
-                       oline = line;
-               }
-               free(buf);
-       }
-       if (f != GDKout) 
-                       close_stream(f);
-}
-
diff --git a/monetdb5/mal/mal_function.h b/monetdb5/mal/mal_function.h
--- a/monetdb5/mal/mal_function.h
+++ b/monetdb5/mal/mal_function.h
@@ -34,7 +34,6 @@ mal_export void setVariableScope(MalBlkP
 
 mal_export void printFunction(stream *fd, MalBlkPtr mb, MalStkPtr stk, int 
flg);
 mal_export void debugFunction(stream *fd, MalBlkPtr mb, MalStkPtr stk, int 
flg, int first, int size);
-mal_export void showFlowGraph(MalBlkPtr mb, MalStkPtr stk, str fname);
 
 #include "mal_exception.h"
 
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -115,7 +115,6 @@ newMalBlk(int maxvars, int maxstmts)
        mb->alternative = NULL;
        mb->history = NULL;
        mb->keephistory = 0;
-       mb->dotfile = 0;
        mb->maxarg = MAXARG;            /* the minimum for each instruction */
        mb->typefixed = 0;
        mb->flowfixed = 0;
@@ -231,7 +230,6 @@ copyMalBlk(MalBlkPtr old)
        mb->alternative = old->alternative;
        mb->history = NULL;
        mb->keephistory = old->keephistory;
-       mb->dotfile = old->dotfile;
        mb->var = (VarPtr *) GDKzalloc(sizeof(VarPtr) * old->vsize);
        mb->activeClients = 1;
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to