Changeset: eb60063512a8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/eb60063512a8 Removed Files: monetdb5/mal/mal_debugger.c monetdb5/mal/mal_debugger.h Modified Files: monetdb5/modules/mal/inspect.c monetdb5/modules/mal/manual.c monetdb5/optimizer/opt_support.c monetdb5/optimizer/optimizer.c sql/backends/monet5/sql_execute.c sql/backends/monet5/sql_optimizer.c sql/backends/monet5/sql_scenario.c Branch: simplify_scenario Log Message:
removed mal_debugger files diffs (truncated from 1580 to 300 lines): diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c deleted file mode 100644 --- a/monetdb5/mal/mal_debugger.c +++ /dev/null @@ -1,1461 +0,0 @@ -/* - * SPDX-License-Identifier: MPL-2.0 - * - * 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 - 2023 MonetDB B.V. - */ - -/* - * (author) M.L. Kersten - * For documentation see website. - */ -#include "monetdb_config.h" -#include "mal.h" -#include "mal_debugger.h" -#include "mal_scenario.h" -#include "mal_interpreter.h" /* for getArgReference() */ -#include "mal_listing.h" -#include "mal_function.h" -#include "mal_parser.h" -#include "mal_namespace.h" -#include "mal_private.h" - -typedef struct { - MalBlkPtr brkBlock[MAXBREAKS]; - int brkPc[MAXBREAKS]; - int brkVar[MAXBREAKS]; - const char *brkMod[MAXBREAKS]; - const char *brkFcn[MAXBREAKS]; - char brkCmd[MAXBREAKS]; - str brkRequest[MAXBREAKS]; - int brkTop; -} mdbStateRecord, *mdbState; - -typedef struct MDBSTATE{ - MalBlkPtr mb; - MalStkPtr stk; - InstrPtr p; - int pc; -} MdbState; - -#define skipBlanc(c, X) while (*(X) && isspace((unsigned char) *X)) { X++; } -#define skipNonBlanc(c, X) while (*(X) && !isspace((unsigned char) *X)) { X++; } -#define skipWord(c, X) while (*(X) && (isalnum((unsigned char) *X))) { X++; } \ - skipBlanc(c, X); - -#define skipModule(C,B)\ -{\ - skipWord(C, B); \ - skipBlanc(C, B); \ - c = strchr(B,'.'); \ - if( c ){ \ - B = c + 1; \ - skipWord(cntxt, B); \ - skipBlanc(cntxt, B); \ - } \ - c = strchr(B,']'); \ - if (c) \ - B = c + 1; \ -} - -/* Utilities - * Dumping a stack on a file is primarilly used for debugging. - * Printing the stack requires access to both the symbol table and - * the stackframes in most cases. - * Beware that a stack frame need not be initialized with null values. - * It has been zeroed upon creation. - * - * The routine can also be used to inspect the symbol table of - * arbitrary functions. - */ -static void -printStackHdr(stream *f, MalBlkPtr mb, ValPtr v, int index) -{ - if (v == 0 && isVarConstant(mb, index)) - v = &getVarConstant(mb, index); - mnstr_printf(f, "#[%2d] %5s", index, getVarName(mb,index)); - mnstr_printf(f, " (%d,%d,%d) = ", getBeginScope(mb,index), getLastUpdate(mb,index),getEndScope(mb, index)); - if (v) - ATOMprint(v->vtype, VALptr(v), f); -} - -static void -printBATproperties(stream *f, BAT *b) -{ - mnstr_printf(f, " count=" BUNFMT " lrefs=%d ", - BATcount(b), BBP_lrefs(b->batCacheid)); - if (BBP_refs(b->batCacheid) - 1) - mnstr_printf(f, " refs=%d ", BBP_refs(b->batCacheid)); - if (b->theap->refs) - mnstr_printf(f, " views=%llu", (unsigned long long) ATOMIC_GET(&b->theap->refs)); - if (b->tvheap->refs) - mnstr_printf(f, " shared vheaps=%llu", (unsigned long long) ATOMIC_GET(&b->tvheap->refs)); - if (b->theap->parentid != b->batCacheid) - mnstr_printf(f, "view on %s ", BBP_logical(b->theap->parentid)); -} - -static void -printBATelm(stream *f, bat i, BUN cnt, BUN first) -{ - BAT *b, *bs = NULL; - str tpe; - - b = BATdescriptor(i); - if (b) { - tpe = getTypeName(newBatType(b->ttype)); - mnstr_printf(f, ":%s ", tpe); - GDKfree(tpe); - printBATproperties(f, b); - /* perform property checking */ - BATassertProps(b); - mnstr_printf(f, "\n"); - if (cnt && BATcount(b) > 0) { - if (cnt < BATcount(b)) { - mnstr_printf(f, "Sample " BUNFMT " out of " BUNFMT "\n", cnt, BATcount(b)); - } - /* cut out a portion of the BAT for display */ - bs = BATslice(b, first, first + cnt); - /* get the void values */ - if (bs == NULL) - mnstr_printf(f, "Failed to take chunk\n"); - else { - if (BATprint(f, bs) != GDK_SUCCEED) - mnstr_printf(f, "Failed to print chunk\n"); - BBPunfix(bs->batCacheid); - } - } - - BBPunfix(b->batCacheid); - } else - mnstr_printf(f, "\n"); -} - -static void -printStackElm(stream *f, MalBlkPtr mb, ValPtr v, int index, BUN cnt, BUN first) -{ - str nme, nmeOnStk; - VarPtr n = getVar(mb, index); - - printStackHdr(f, mb, v, index); - - if (v && v->vtype == TYPE_bat) { - bat i = v->val.bval; - BAT *b = BBPquickdesc(i); - - if (b) { - nme = getTypeName(newBatType(b->ttype)); - mnstr_printf(f, " :%s rows="BUNFMT, nme, BATcount(b)); - } else { - nme = getTypeName(n->type); - mnstr_printf(f, " :%s", nme); - } - } else { - nme = getTypeName(n->type); - mnstr_printf(f, " :%s", nme); - } - nmeOnStk = v ? getTypeName(v->vtype) : GDKstrdup(nme); - /* check for type errors */ - if (nmeOnStk && strcmp(nmeOnStk, nme) && strncmp(nmeOnStk, "BAT", 3)) - mnstr_printf(f, "!%s ", nmeOnStk); - mnstr_printf(f, " %s", (isVarConstant(mb, index) ? " constant" : "")); - mnstr_printf(f, " %s", (isVarTypedef(mb, index) ? " type variable" : "")); - GDKfree(nme); - mnstr_printf(f, "\n"); - GDKfree(nmeOnStk); - - if (cnt && v && (isaBatType(n->type) || v->vtype == TYPE_bat) && !is_bat_nil(v->val.bval)) { - printBATelm(f,v->val.bval,cnt,first); - } -} - -void -printStack(stream *f, MalBlkPtr mb, MalStkPtr s) -{ - int i = 0; - - setVariableScope(mb); - if (s) { - mnstr_printf(f, "#Stack '%s' size=%d top=%d\n", - getInstrPtr(mb, 0)->fcnname, s->stksize, s->stktop); - for (; i < mb->vtop; i++) - printStackElm(f, mb, s->stk + i, i, 0, 0); - } else - for (; i < mb->vtop; i++) - printStackElm(f, mb, 0, i, 0, 0); -} - -/* utility to display an instruction being called and its stack position */ -static void -printCall(Client cntxt, MalBlkPtr mb, MalStkPtr stk, int pc) -{ - str msg; - msg = instruction2str(mb, stk, getInstrPtr(mb, pc), LIST_MAL_CALL); - mnstr_printf(cntxt->fdout, "#%s at %s.%s[%d]\n", (msg?msg:"failed instruction2str()") , - getModuleId(getInstrPtr(mb, 0)), - getFunctionId(getInstrPtr(mb, 0)), pc); - GDKfree(msg); -} - -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->pcup; - } -} - -void -mdbDump(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) -{ - int i = getPC(mb, pci); - mnstr_printf(cntxt->fdout, "!MDB dump of instruction %d\n", i); - if( i < 0) - return; - printFunction(cntxt->fdout, mb, stk, LIST_MAL_ALL); - mdbBacktrace(cntxt, stk, i); - printStack(cntxt->fdout, mb, stk); -} - -static inline char * -pre(const char *s1, const char *s2, char *buf) -{ - snprintf(buf, 64, "%s%s", s1, s2); - return buf; -} - -static inline char * -local_itoa(ssize_t i, char *buf) -{ - snprintf(buf, 32, "%zd", i); - return buf; -} -static inline char * -local_utoa(size_t i, char *buf) -{ - snprintf(buf, 32, "%zu", i); - return buf; -} - -static inline char * -oidtostr(oid i, char *p, size_t len) -{ - if (OIDtoStr(&p, &len, &i, false) < 0) - return NULL; - return p; -} - -static gdk_return -infoHeap(BAT *bk, BAT*bv, Heap *hp, str nme) -{ - char buf[1024], *p = buf; - - if (!hp) - return GDK_SUCCEED; - while (*nme) - *p++ = *nme++; - strcpy(p, "free"); - if (BUNappend(bk, buf, false) != GDK_SUCCEED || - BUNappend(bv, local_utoa(hp->free, buf), false) != GDK_SUCCEED) - return GDK_FAIL; - strcpy(p, "size"); - if (BUNappend(bk, buf, false) != GDK_SUCCEED || - BUNappend(bv, local_utoa(hp->size, buf), false) != GDK_SUCCEED) - return GDK_FAIL; - strcpy(p, "storage"); - if (BUNappend(bk, buf, false) != GDK_SUCCEED || - BUNappend(bv, (hp->base == NULL || hp->base == (char*)1) ? "absent" : (hp->storage == STORE_MMAP) ? (hp->filename[0] ? "memory mapped" : "anonymous vm") : (hp->storage == STORE_PRIV) ? "private map" : "malloced", false) != GDK_SUCCEED) - return GDK_FAIL; - strcpy(p, "newstorage"); - if (BUNappend(bk, buf, false) != GDK_SUCCEED || - BUNappend(bv, (hp->newstorage == STORE_MEM) ? "malloced" : (hp->newstorage == STORE_PRIV) ? "private map" : "memory mapped", false) != GDK_SUCCEED) - return GDK_FAIL; - strcpy(p, "filename"); - if (BUNappend(bk, buf, false) != GDK_SUCCEED || - BUNappend(bv, hp->filename[0] ? hp->filename : "no file", false) != GDK_SUCCEED) - return GDK_FAIL; - return GDK_SUCCEED; -} - -#define COLLISION (8 * sizeof(size_t)) - -static gdk_return -HASHinfo(BAT *bk, BAT *bv, Hash *h, str s) -{ - BUN i; - BUN j; - BUN k; - BUN cnt[COLLISION + 1]; - char buf[32]; - char prebuf[64]; - _______________________________________________ checkin-list mailing list -- [email protected] To unsubscribe send an email to [email protected]
