Changeset: ddfdbcdbcc5a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ddfdbcdbcc5a
Modified Files:
clients/Tests/exports.stable.out
monetdb5/mal/mal.h
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_authorize.h
monetdb5/mal/mal_debugger.c
monetdb5/mal/mal_debugger.h
monetdb5/mal/mal_factory.c
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_profiler.c
monetdb5/modules/mal/clients.c
monetdb5/modules/mal/mdb.c
sql/backends/monet5/sql_assert.c
Branch: default
Log Message:
cleanup...unused code of the mal debugger
introduced MAL_ADMIN user (0) instead of directly use 0
clients stop now sets the qtimeout instead of the itrace,
more steps will follow to clean debugging (cmd and itrace)
to be only used for the debugging steps.
diffs (truncated from 522 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
@@ -1437,7 +1437,6 @@ str MCsuspendClient(int id);
int MCvalid(Client c);
str MDBStkDepth(Client cntxt, MalBlkPtr mb, MalStkPtr s, InstrPtr p);
str MDBStkTrace(Client cntxt, MalBlkPtr m, MalStkPtr s, InstrPtr p);
-int MDBdelay;
str MDBdummy(int *ret);
str MDBdump(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str MDBgetDebug(int *ret);
@@ -2383,13 +2382,8 @@ str maxRef;
str max_no_nilRef;
int mayhaveSideEffects(Client cntxt, MalBlkPtr mb, InstrPtr p, int strict);
void mdbDump(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-str mdbGrab(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str mdbRef;
-int mdbSession(void);
void mdbSetBreakRequest(Client cntxt, MalBlkPtr mb, str request, char cmd);
-int mdbSetTrap(Client cntxt, str modnme, str fcnnme, int flag);
-str mdbTrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-str mdbTrapClient(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
int memoryclaims;
lng memorypool;
str mergecandRef;
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 {
short keephistory; /* do we need the history at all */
int maxarg; /* keep track on the maximal
arguments used */
ptr replica; /* for the replicator tests */
- sht trap; /* call debugger when called */
lng starttime; /* track when the query started, for
resource management */
lng runtime; /* average execution time of block in
ticks */
int calls; /* number of calls */
@@ -246,13 +245,13 @@ typedef struct MALSTK {
* It is handy to administer the timing in the stack frame
* for use in profiling instructions.
*/
- struct timeval clock; /* time this stack was created */
- char cmd; /* debugger and runtime communication */
- char status; /* srunning 'R' uspended 'S', quiting 'Q' */
- int pcup; /* saved pc upon a recursive all */
- int tag; /* unique invocation call tag */
- struct MALSTK *up; /* stack trace list */
- struct MALBLK *blk; /* associated definition */
+ struct timeval clock; /* time this stack was created */
+ char cmd; /* debugger and runtime communication */
+ char status; /* srunning 'R' suspended 'S', quiting 'Q' */
+ int pcup; /* saved pc upon a recursive all */
+ int tag; /* unique invocation call tag */
+ struct MALSTK *up; /* stack trace list */
+ struct MALBLK *blk; /* associated definition */
ValRecord stk[FLEXIBLE_ARRAY_MEMBER];
} MalStack, *MalStkPtr;
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -98,7 +98,7 @@ AUTHrequireAdmin(Client cntxt) {
return(MAL_SUCCEED);
id = cntxt->user;
- if (id != 0) {
+ if (id != MAL_ADMIN) {
str user = NULL;
str tmp;
@@ -122,8 +122,8 @@ AUTHrequireAdminOrUser(Client cntxt, con
str user = NULL;
str tmp = MAL_SUCCEED;
- /* root? then all is well */
- if (id == 0)
+ /* MAL_ADMIN then all is well */
+ if (id == MAL_ADMIN)
return(MAL_SUCCEED);
rethrow("requireAdminOrUser", tmp, AUTHresolveUser(&user, id));
@@ -393,7 +393,7 @@ AUTHinitTables(const char *passwd) {
free(pw);
if (msg)
return msg;
- if (uid != 0)
+ if (uid != MAL_ADMIN)
throw(MAL, "initTables", INTERNAL_AUTHORIZATION " while
they were just created!");
/* normally, we'd commit here, but it's done already in
AUTHaddUser */
}
diff --git a/monetdb5/mal/mal_authorize.h b/monetdb5/mal/mal_authorize.h
--- a/monetdb5/mal/mal_authorize.h
+++ b/monetdb5/mal/mal_authorize.h
@@ -14,6 +14,8 @@
#include "mal_instruction.h"
#include "mal_client.h"
+#define MAL_ADMIN 0
+
mal_export str AUTHcheckCredentials(oid *ret, Client c, const char *user,
const char *passwd, const char *challenge, const char *algo);
mal_export str AUTHaddUser(oid *ret, Client c, const char *user, const char
*pass);
mal_export str AUTHremoveUser(Client c, const char *username);
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
@@ -21,16 +21,15 @@
#include "mal_namespace.h"
#include "mal_private.h"
-int MDBdelay; /* do not immediately react */
typedef struct {
MalBlkPtr brkBlock[MAXBREAKS];
- int brkPc[MAXBREAKS];
- int brkVar[MAXBREAKS];
- str brkMod[MAXBREAKS];
- str brkFcn[MAXBREAKS];
- char brkCmd[MAXBREAKS];
- str brkRequest[MAXBREAKS];
- int brkTop;
+ int brkPc[MAXBREAKS];
+ int brkVar[MAXBREAKS];
+ str brkMod[MAXBREAKS];
+ str brkFcn[MAXBREAKS];
+ char brkCmd[MAXBREAKS];
+ str brkRequest[MAXBREAKS];
+ int brkTop;
} mdbStateRecord, *mdbState;
typedef struct MDBSTATE{
@@ -259,21 +258,6 @@ mdbClrBreakRequest(Client cntxt, str req
mdb->brkTop = j;
}
-int
-mdbSetTrap(Client cntxt, str modnme, str fcnnme, int flag)
-{
- Symbol s;
- s = findSymbol(cntxt->usermodule, putName(modnme),
- putName(fcnnme));
- if (s == NULL)
- return -1;
- while (s) {
- s->def->trap = flag;
- s = s->peer;
- }
- return 0;
-}
-
/* utility to display an instruction being called and its stack position */
static void
printCall(Client cntxt, MalBlkPtr mb, MalStkPtr stk, int pc)
@@ -976,42 +960,16 @@ mdbDump(Client cntxt, MalBlkPtr mb, MalS
mdbBacktrace(cntxt, stk, i);
printStack(cntxt->fdout, mb, stk);
}
-static int mdbSessionActive;
-int mdbSession(void)
+
+static str
+mdbTrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
- return mdbSessionActive;
-}
-static Client trapped_cntxt;
-static MalBlkPtr trapped_mb;
-static MalStkPtr trapped_stk;
-static int trapped_pc;
-
-str mdbTrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
-{
- int cnt = 20; /* total 10 sec delay */
int pc = getPC(mb,p);
mnstr_printf(cntxt->fdout, "#trapped %s.%s[%d]\n",
getModuleId(mb->stmt[0]), getFunctionId(mb->stmt[0]),
pc);
printInstruction(cntxt->fdout, mb, stk, p, LIST_MAL_DEBUG);
cntxt->itrace = 'W';
- MT_lock_set(&mal_contextLock);
- if (trapped_mb) {
- mnstr_printf(cntxt->fdout, "#registry not available\n");
- mnstr_flush(cntxt->fdout);
- }
- while (trapped_mb && cnt-- > 0) {
- MT_lock_unset(&mal_contextLock);
- MT_sleep_ms(500);
- MT_lock_set(&mal_contextLock);
- }
- if (cnt > 0) {
- trapped_cntxt = cntxt;
- trapped_mb = mb;
- trapped_stk = stk;
- trapped_pc = pc;
- } /* else give up */
- MT_lock_unset(&mal_contextLock);
return MAL_SUCCEED;
}
@@ -1022,7 +980,6 @@ mdbStep(Client cntxt, MalBlkPtr mb, MalS
char ch;
stream *out = cntxt->fdout;
- mdbSessionActive = 1; /* for name completion */
/* mdbSanityCheck(cntxt, mb, stk, pc); expensive */
/* process should sleep */
if (cntxt->itrace == 'S') {
@@ -1042,12 +999,6 @@ mdbStep(Client cntxt, MalBlkPtr mb, MalS
}
if (stk->cmd == 0)
stk->cmd = 'n';
- /* a trapped call leads to process suspension */
- /* which can be used to attach a debugger */
- if (mb->trap) {
- mdbTrap(cntxt, mb, stk, getInstrPtr(mb,pc));
- return;
- }
p = getInstrPtr(mb, pc);
switch (stk->cmd) {
case 'c':
@@ -1067,8 +1018,6 @@ mdbStep(Client cntxt, MalBlkPtr mb, MalS
case 't':
printTraceCall(out, mb, stk, pc, LIST_MAL_CALL);
break;
- case 'C':
- mdbSessionActive = 0; /* for name completion */
}
if (mb->errors != MAL_SUCCEED) {
MalStkPtr su;
@@ -1079,72 +1028,9 @@ mdbStep(Client cntxt, MalBlkPtr mb, MalS
mnstr_printf(out, "mdb>#EOD\n");
stk->cmd = 'x'; /* will force a graceful termination */
}
- if (mdbSessionActive == 0)
- return;
- mdbSessionActive = 0; /* for name completion */
}
/*
- * Grabbing the execution state of a running query can be
- * useful to inspect its runtime environment. Ideally, any
- * suspended running MAL block should be accessed this way.
- */
-str
-mdbGrab(Client cntxt, MalBlkPtr mb1, MalStkPtr stk1, InstrPtr pc1)
-{
- Client c;
- MalBlkPtr mb;
- MalStkPtr stk;
- int pc, sve;
-
- (void) mb1;
- (void) stk1;
- (void) pc1;
-
- /* get hold of a suspended plan and run debugger */
- MT_lock_set(&mal_contextLock);
- if (trapped_mb == 0) {
- mnstr_printf(cntxt->fdout, "#no trapped function\n");
- MT_lock_unset(&mal_contextLock);
- return MAL_SUCCEED;
- }
- c = trapped_cntxt;
- mb = trapped_mb;
- stk = trapped_stk;
- pc = trapped_pc;
- trapped_cntxt = 0;
- trapped_mb = 0;
- trapped_stk = 0;
- trapped_pc = 0;
- MT_lock_unset(&mal_contextLock);
- mnstr_printf(cntxt->fdout, "#Debugging trapped function\n");
- mnstr_flush(cntxt->fdout);
- sve = stk->cmd;
- stk->cmd = 'n';
- mdbCommand(cntxt, mb, stk, getInstrPtr(mb, pc), pc);
- stk->cmd = sve;
- c->itrace = 0; /* wakeup target */
- return MAL_SUCCEED;
-}
-
-str
-mdbTrapClient(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
-{
- int id = *getArgReference_int(stk, p, 1);
- Client c;
-
- (void) cntxt;
- (void) mb;
- if (id < 0 || id >= MAL_MAXCLIENTS || mal_clients[id].mode == 0)
- throw(INVCRED, "mdb.trap", INVCRED_WRONG_ID);
- c = mal_clients + id;
-
- c->itrace = 'S';
- mnstr_printf(cntxt->fdout, "#process %d requested to suspend\n", id);
- mnstr_flush(cntxt->fdout);
- return MAL_SUCCEED;
-}
-/*
* It would come in handy if at any time you could activate
* the debugger on a specific function. This calls for the
* creation of a minimal execution environment first.
diff --git a/monetdb5/mal/mal_debugger.h b/monetdb5/mal/mal_debugger.h
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list