Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31142

Modified Files:
      Tag: MonetDB_5-0
        mal_client.mx mal_debugger.mx mal_import.mx mal_interpreter.mx 
        mal_module.mx mal_parser.mx mal_readline.mx 
Log Message:
Backporting rendering and debugging features to prepare for the new
MapiClient.
Testweb on mal and sql on my machine are clean


Index: mal_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_parser.mx,v
retrieving revision 1.199
retrieving revision 1.199.2.1
diff -u -d -r1.199 -r1.199.2.1
--- mal_parser.mx       29 May 2007 10:36:13 -0000      1.199
+++ mal_parser.mx       15 Aug 2007 20:18:05 -0000      1.199.2.1
@@ -39,7 +39,7 @@
 @+ The lexical analyzer
 The implementation of the lexical analyzer is straightforward:
 the input is taken from a client input buffer. It is assumed that
-this buffer contains the complete MIL structure to be parsed.
+this buffer contains the complete MAL structure to be parsed.
 @h
 #ifndef _MAL_PARSER_H
 #define _MAL_PARSER_H

Index: mal_import.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_import.mx,v
retrieving revision 1.67
retrieving revision 1.67.2.1
diff -u -d -r1.67 -r1.67.2.1
--- mal_import.mx       17 Apr 2007 17:02:31 -0000      1.67
+++ mal_import.mx       15 Aug 2007 20:18:02 -0000      1.67.2.1
@@ -202,10 +202,10 @@
 A recurring situation is to execute a stream of simple MAL instructions
 stored on a file or comes from standard input. We parse one MAL 
 instruction line at a time and attempt to execute it immediately.
-Note, this precludes entereing complex MAL structures on the primary
+Note, this precludes entering complex MAL structures on the primary
 input channel, because 1) this requires complex code to keep track
-that we are in 'definition mode' 2) this requires (too) carefull
-typing by the user, because he can not make an typeing error
+that we are in 'definition mode' 2) this requires (too) careful
+typing by the user, because he cannot make a typing error
 
 Therefore, all compound code fragments should be loaded and executed
 using the evalFile and callString command. It will parse the complete

Index: mal_client.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_client.mx,v
retrieving revision 1.152.2.1
retrieving revision 1.152.2.2
diff -u -d -r1.152.2.1 -r1.152.2.2
--- mal_client.mx       11 Jun 2007 15:37:11 -0000      1.152.2.1
+++ mal_client.mx       15 Aug 2007 20:18:01 -0000      1.152.2.2
@@ -139,11 +139,14 @@
 @h
        sht             flags;  /* resource tracing flags */
        lng     timer;  /* trace time in usec */
+       lng             bigfoot; /* maximum virtual memory use */
+       lng             vmfoot; /* virtual memory use */
 
 #define timerFlag      1
 #define memoryFlag     2
 #define ioFlag 4
 #define flowFlag       8
+#define bigfootFlag    16
 @-
 @}
 @-
@@ -433,6 +436,8 @@
        c->itrace = 0;
        c->debugOptimizer = c->debugScheduler= 0;
        c->timer = 0;
+       c->bigfoot = 0;
+       c->vmfoot = 0;
        c->errbuf = 0;
 
        c->cwd= GDKstrdup(monet_cwd);

Index: mal_module.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_module.mx,v
retrieving revision 1.48
retrieving revision 1.48.2.1
diff -u -d -r1.48 -r1.48.2.1
--- mal_module.mx       14 May 2007 07:58:49 -0000      1.48
+++ mal_module.mx       15 Aug 2007 20:18:05 -0000      1.48.2.1
@@ -792,7 +792,7 @@
        str modnme, fcnnme = 0;
        Module m1;
        Symbol s;
-       int len1 = 0,len2 = 0,fnd,f;
+       int len1 = 0,len2 = 0,fnd=0,f;
        char *t, **msg, buf[BUFSIZ];
        int top=0, i,j,k, sig = 0, doc = 0;
 
@@ -868,44 +868,53 @@
                                if( completion ) {
                                        snprintf(buf,BUFSIZ," %s.%s", 
                                                ((*modnme=='*' || *modnme==0)? 
m->name:modnme),s->name);
-                                       if( tstDuplicate(msg,buf) ) continue;
+                                       if( tstDuplicate(msg,buf+1) ) continue;
                                } else
                                if( doc) {
+                                       char *v;
+
                                        
fcnDefinition(s->def,s->def->stmt[0],buf,FALSE);
                                        buf[0]=' ';
+
+                                       v= strstr(buf,"address");
+                                       if( v) *v=0;
+                                       if( tstDuplicate(msg,buf+1) ) continue;
+
+                                       fnd=0;
+                                       for(f=0;f<top;f++)
+                                       if( msg[f] && strcmp(buf+1, msg[f]) == 
0 ) fnd++;
+                                       if(fnd) continue;
+
+                                       msg[top++]= GDKstrdup(buf+1);
+                                       if( top >=998) return msg;
+                                       if(v){
+                                               *v='a';
+                                               msg[top++]= GDKstrdup(v);
+                                               if( top >=998) return msg;
+                                       }
+
                                        if( s->def->help) {
-                                               char *v,*w;
-                                               v= strchr(buf,0);
-                                               *v++ = '\\';
-                                               *v++ = 'n';
+                                               char *w;
+                                               strcpy(buf+1,"comment ");
+                                               v= buf+1+8;
                                                for( w= s->def->help; *w && v 
<buf+BUFSIZ-1; w++)
                                                if( *w == '\n'){
-                                                       *v++ = '\\';
-                                                       *v++ = 'n';
-                                                       w++;
-                                                       if( isspace((int) *w)) {
-                                                               for(; *w && 
isspace((int) *w); w++);
-                                                               w--;
-                                                       }
+                                                       /*ignore */
                                                } else *v++ = *w;
-                                               *v++ = '\\';
-                                               *v++ = 'n';
                                                *v = 0;
                                        }
-                                       if( tstDuplicate(msg,buf) ) continue;
+                                       *v++ ='\n';
+                                       *v=0;
                                } else if( strcmp(fcnnme,s->name)==0 || 
*fcnnme=='*' ) {
                                        
fcnDefinition(s->def,s->def->stmt[0],buf,FALSE);
                                        buf[0]=' ';
                                        t= strstr(buf,"address");
                                        if( t) *t= 0;
                                } 
-                               fnd=0;
-                               for(f=0;f<top;f++)
-                               if( msg[f] && strcmp(buf+1, msg[f]) == 0 ) 
fnd++;
                                if( fnd == 0 && buf[1]){
                                        msg[top++] = GDKstrdup(buf+1);
                                        msg[top] = 0;
-                                       if( top ==999) return msg;
+                                       if( top >=998) return msg;
                                }
                        }
                        m= m->sibling;

Index: mal_debugger.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_debugger.mx,v
retrieving revision 1.195
retrieving revision 1.195.2.1
diff -u -d -r1.195 -r1.195.2.1
--- mal_debugger.mx     3 May 2007 09:26:21 -0000       1.195
+++ mal_debugger.mx     15 Aug 2007 20:18:01 -0000      1.195.2.1
@@ -24,6 +24,10 @@
 it passes the compiler we have to resort to a debugger to
 assess its behavior.
 
+Note, the MAL debugger described here can be used in conjunction
+with the textual interface client @emph{MapiClient} only.
+The JDBC protocol does not permit passing through information that
+'violates' the protocol.
 @menu
 * Program Debugging ::
 * Handling Breakpoints::
@@ -87,7 +91,7 @@
        down             -- go down the stack
        up               -- go up the stack
        trace <var>      -- trace assignment to variables
-       set @verb{ { }timer,flow,io,[EMAIL PROTECTED] } } -- set trace switches
+       set @verb{ { }timer,flow,io,memory,[EMAIL PROTECTED] } } -- set trace 
switches
        unset            -- turn off switches
        help             -- this message
 mdb>
@@ -234,6 +238,9 @@
 @item io
 keeps track on the amount of physical IO
 and is used to detect operators consuming excessive amounts of space.
[EMAIL PROTECTED] bigfoot
+keeps track of the current and maximum virtual memory footprint 
+of the BATs.[incomplete]
 @end table
 
 The snippet below shows setting the @sc{memory} and @sc{timer}
@@ -466,6 +473,7 @@
 mal_export void mdbCommand(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
p, int pc);
 mal_export int mdbSession(void);
 mal_export void mdbStep(Client cntxt, MalBlkPtr mb, MalStkPtr stk, int pc);
+mal_export void mdbDump(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 mal_export void mdbHelp(stream *f);
 mal_export void printStackElm(stream *f, MalBlkPtr mb, VarPtr n, ValPtr v, int 
index, size_t cnt, int first, int lifespan);
 mal_export void printBATelm(stream *f, int i, size_t cnt, size_t first);
@@ -751,7 +759,7 @@
 {
        str msg;
        msg = call2str(mb, stk, pc, cntxt->flags);
-       stream_printf(cntxt->fdout, "%s at %s.%s[%d]\n", msg, 
+       stream_printf(cntxt->fdout, "#%s at %s.%s[%d]\n", msg, 
                getModuleId(getInstrPtr(mb,0)),
                getFunctionId(getInstrPtr(mb,0)),pc);
        GDKfree(msg);
@@ -822,6 +830,15 @@
        return m;
 }
 
+static void
+mdbBacktrace(Client cntxt, MalStkPtr stk, int pci){
+       for (; stk != NULL; stk = stk->up) {
+               printCall(cntxt, stk->blk, stk, pci);
+               if (stk->up)
+                       pci = stk->up->pcup;
+       }
+}
+
 void
 mdbCommand(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p, int pc)
 {
@@ -911,6 +928,7 @@
                                su->cmd = 0;
                        cntxt->itrace = 0;
                        cntxt->flags = 0;
+                       stream_printf(out,"mdb>#EOD\n");
                        /* MDBstatus(0); */
                        cntxt->prompt = oldprompt;
                        cntxt->promptlength = oldpromptlength;
@@ -970,6 +988,10 @@
                                                                        
resource.ru_oublock);
 #endif
                                }
+                               if( strncmp("bigfoot",b,7)==0){
+                                       /* calculate the virtual memory 
footprint */
+                                       cntxt->flags |= bigfootFlag;
+                               }
                                continue;
                        }
                        stk->cmd = *b;
@@ -1093,9 +1115,12 @@
                                /* the 'dense' qualification only shows entries 
with a hard ref */
                                for (; i < limit; i++)
                                        if (BBP_logical(i) && BBP_cache(i) ) {
+                                               BAT *bd= BATdescriptor(i);
                                                if( *b=='d' && BBP_refs(i)==0) 
continue;
-                                               stream_printf(out, "[%d] %s 
lref = %d ref= %d ", 
-                                                       i, BBP_logical(i), 
BBP_lrefs(i), BBP_refs(i));
+                                               stream_printf(out, "[%d] %s 
lref = %d ref= %d views=%d ", 
+                                                       i, BBP_logical(i), 
BBP_lrefs(i), BBP_refs(i), 
+                                                       bd->batSharecnt);
+                                               BBPunfix(i);
                                                stream_printf(out, " dirty=%d", 
BATdirty(BBP_cache(i)));
                                                if( *BBP_logical(i) =='.')
                                                        stream_printf(out, " 
zombie ");
@@ -1256,13 +1281,15 @@
                        if( strncmp("unset",b,5)){
                                skipWord(cntxt, b);
                                skipBlanc(cntxt, b);
-                               if( strncmp("flow",b,1) == 0)
+                               if( strncmp("flow",b,4) == 0)
                                        cntxt->flags &= ~flowFlag;
-                               if( strncmp("memory",b,1) == 0)
+                               if( strncmp("memory",b,6) == 0)
                                        cntxt->flags &= ~memoryFlag;
-                               if (strncmp("timer", b, 1) == 0)
+                               if (strncmp("timer", b, 5) == 0)
                                        cntxt->flags &= ~timerFlag;
-                               if (strncmp("io", b, 1) == 0) 
+                               if (strncmp("bigfoot", b, 7) == 0)
+                                       cntxt->flags &= ~bigfootFlag;
+                               if (strncmp("io", b, 2) == 0) 
                                        cntxt->flags &= ~ioFlag;
                                continue;
                        }
@@ -1275,16 +1302,7 @@
                        continue;
                case 'w':
                {
-                       MalStkPtr w;
-                       MalBlkPtr mw = mb;
-                       int pci = pc;   /*  how to find enclosing pc */
-
-                       for (w = stk; w != NULL; w = w->up) {
-                               mw = w->blk;
-                               printCall(cntxt, mw, w, pci);
-                               if (w->up)
-                                       pci = w->up->pcup;
-                       }
+                       mdbBacktrace(cntxt, stk, pc);
                        continue;
                }
 @-
@@ -1357,6 +1375,15 @@
        cntxt->promptlength = oldpromptlength;
 }
 
+void 
+mdbDump(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){
+       Client cntxt= MCgetClient();
+       int i= getPC(mb,pci);
+       stream_printf(cntxt->fdout,"!MDB dump of instruction %d\n",i);
+       printFunction(cntxt->fdout, mb, LIST_MAL_ALL | LIST_MAL_PROPS);
+       mdbBacktrace(cntxt, stk, i);
+       printStack(cntxt->fdout,mb,stk,0);
+}
 static int mdbSessionActive;
 int mdbSession(){
        return mdbSessionActive;
@@ -1618,9 +1645,9 @@
                b = BATdescriptor(v->val.ival);
                if (b) {
                        /* ignore ref count of this call */
-                       stream_printf(f, " count=%d lrefs=%d refs=%d", 
+                       stream_printf(f, " count=%d lrefs=%d refs=%d views=%d", 
                                BATcount(b), BBP_lrefs(ABS(b->batCacheid)), 
-                               BBP_refs(ABS(b->batCacheid)) - 1);
+                               BBP_refs(ABS(b->batCacheid)) - 1, 
b->batSharecnt);
                        BBPunfix(b->batCacheid);
                }
        } 

Index: mal_interpreter.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_interpreter.mx,v
retrieving revision 1.190
retrieving revision 1.190.2.1
diff -u -d -r1.190 -r1.190.2.1
--- mal_interpreter.mx  1 Jun 2007 06:48:28 -0000       1.190
+++ mal_interpreter.mx  15 Aug 2007 20:18:03 -0000      1.190.2.1
@@ -57,6 +57,7 @@
 mal_export void garbageCollector(MalBlkPtr mb, MalStkPtr stk, int flag);
 mal_export void releaseBAT(MalBlkPtr mb, MalStkPtr stk, int bid);
 mal_export int getVolume(MalStkPtr stk, InstrPtr pci, int rd);
+mal_export void updateBigFoot(Client cntxt, int bid, int add);
 
 mal_export ptr getArgValue(MalStkPtr stk, InstrPtr pci, int k);
 mal_export ptr getArgReference(MalStkPtr stk, InstrPtr pci, int k);
@@ -73,6 +74,7 @@
                int stoppc, MalStkPtr stk, MalStkPtr env, InstrPtr pcicaller);
 static str setDynamicType(MalBlkPtr mb, VarPtr v, int tpe, int pc);
 static void showVolume(Client cntxt, MalStkPtr stk, InstrPtr pci, int rd);
+static void displayVolume(Client cntxt, lng vol);
 @-
 We can speed up the copying, provided we ignore copying ptr-based
 objects.
@@ -960,6 +962,8 @@
                for(i=0; i<pci->retc; i++)
                if( stk->stk[getArg(pci,i)].vtype == TYPE_bat){
                        bat bid = stk->stk[getArg(pci,i)].val.br.id;
+                       /* update the bigfoot information */
+                       updateBigFoot(cntxt, bid, TRUE);
                        /* BAT *b;*/
                        if( backup[i] ){
                                if( backup[i]== bid){
@@ -968,6 +972,7 @@
                                        BBPreleaselref(backup[i]);
                                } else { 
                                        /* possible garbage collect the 
variable */
+                                       updateBigFoot(cntxt, backup[i], FALSE);
                                        BBPdecref(backup[i],TRUE);
                                }
                                backup[i]=0;
@@ -1565,16 +1570,16 @@
 @= timingHndlr
 if( cntxt->flags && stk->cmd != 't' && stk->cmd != 'C'){
        if( cntxt->flags & timerFlag)
-               stream_printf(cntxt->fdout,"#%6d usec",GDKusec()-cntxt->timer);
+               stream_printf(cntxt->fdout,"[%6d usec ",GDKusec()-cntxt->timer);
 #ifdef HAVE_SYS_RESOURCE_H
        if( cntxt-> flags & ioFlag){
                struct  rusage resource;
                getrusage(RUSAGE_SELF, &resource);
                if(     resource.ru_inblock - oldinblock 
                 ||     resource.ru_oublock - oldoublock ) {
-                       stream_printf(cntxt->fdout,"# %3d R",
+                       stream_printf(cntxt->fdout," %3d R",
                                resource.ru_inblock- oldinblock);
-                       stream_printf(cntxt->fdout," %3d W",
+                       stream_printf(cntxt->fdout," %3d W ",
                                resource.ru_oublock- oldoublock);
                }
        }
@@ -1583,21 +1588,50 @@
                struct mallinfo memory;
                memory= MT_mallinfo();
                if( memory.arena- oldMemory.arena > 0)
-                       stream_printf(cntxt->fdout,"# %6d bytes",
+                       stream_printf(cntxt->fdout," %6d bytes ",
                                memory.arena-oldMemory.arena );
        }
        if( cntxt->flags & flowFlag){
                /* calculate the read/write byte flow */
-               stream_printf(cntxt->fdout,"# ");
                showVolume(cntxt,stk,pci,0);
+               stream_printf(cntxt->fdout,"/");
                showVolume(cntxt,stk,pci,1);
+               stream_printf(cntxt->fdout," ");
                /* showVolume(cntxt,stk,pci,2);*/
        }
-       if( cntxt->flags & timerFlag){
-               printTraceCall(cntxt->fdout,mb,stk,stkpc, cntxt->flags);
+       if( cntxt->flags & bigfootFlag){
+               displayVolume(cntxt,cntxt->vmfoot);
+               stream_printf(cntxt->fdout,":");
+               displayVolume(cntxt,cntxt->bigfoot);
+               stream_printf(cntxt->fdout," ");
+       }
+       {str line;
+       line= call2str(mb,stk,stkpc,cntxt->flags);
+       stream_printf(cntxt->fdout, " %s ]\n", line);
+       GDKfree(line);
+       }
+       if( cntxt->flags & timerFlag)
                cntxt->timer = GDKusec();
-       } else if( cntxt->flags & flowFlag){
-               stream_printf(cntxt->fdout,"\n");
+}
[EMAIL PROTECTED]
+The bigfoot memory tracker keeps track on the space
+occupancy of BATs. It ignores for the time being the heaps.
[EMAIL PROTECTED]
+void updateBigFoot(Client cntxt, int bid, int add)
+{
+       BAT *b;
+
+       if( BBP_lrefs(bid)==1 ){
+               b= BATdescriptor(bid);
+               if( b==0) return;
+               /* count it once ! */
+               if( add){
+                       cntxt->vmfoot += BATcount(b) * BUNsize(b);
+               } else
+                       cntxt->vmfoot -= BATcount(b) * BUNsize(b);
+               if( cntxt->vmfoot > cntxt->bigfoot)
+                       cntxt->bigfoot= cntxt->vmfoot;
+               BBPunfix(b->batCacheid);
        }
 }
 @-
@@ -1623,18 +1657,21 @@
        return vol;
 }
 
-void showVolume(Client cntxt, MalStkPtr stk, InstrPtr pci, int rd){
-       int vol;
-       vol= getVolume(stk,pci,rd);
+void displayVolume(Client cntxt, lng vol){
        if( vol <1024)
-               stream_printf(cntxt->fdout,"%3d",vol);
+               stream_printf(cntxt->fdout,LLFMT,vol);
        else
        if( vol <1024*1024)
-               stream_printf(cntxt->fdout,"%3dK",vol/1024);
+               stream_printf(cntxt->fdout,LLFMT "K",vol/1024);
        else
        if( vol <1024* 1024*1024)
-               stream_printf(cntxt->fdout,"%3dM",vol/1024/1024);
+               stream_printf(cntxt->fdout, LLFMT "M",vol/1024/1024);
        else
-               stream_printf(cntxt->fdout,"%3dG",vol/1024/1024/1024);
+               stream_printf(cntxt->fdout, LLFMT "G",vol/1024/1024/1024);
+}
+void showVolume(Client cntxt, MalStkPtr stk, InstrPtr pci, int rd){
+       int vol;
+       vol= getVolume(stk,pci,rd);
+       displayVolume(cntxt,vol);
 }
 @}

Index: mal_readline.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_readline.mx,v
retrieving revision 1.48
retrieving revision 1.48.2.1
diff -u -d -r1.48 -r1.48.2.1
--- mal_readline.mx     14 May 2007 07:58:49 -0000      1.48
+++ mal_readline.mx     15 Aug 2007 20:18:06 -0000      1.48.2.1
@@ -14,7 +14,7 @@
 @' Portions created by CWI are Copyright (C) 1997-2007 CWI.
 @' All Rights Reserved.
 @- Online help
-The textual interface @value{mclient} supports a limited
+The textual interface @value{MapiClient} supports a limited
 form of online help commands.
 The argument is a (partial) operator call,
 which is looked up in the symbol table.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to