diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-20 15:27:19 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-20 15:27:19 +0000 |
commit | 897a6853118de669be90a451a7319a219cde6feb (patch) | |
tree | b4e3d46af5a681db4f93f7e9d7c80132a981d06d | |
parent | 3ecce195ac8e50115a44c6d416fd42bbfa03aafe (diff) | |
download | rsyslog-897a6853118de669be90a451a7319a219cde6feb.tar.gz rsyslog-897a6853118de669be90a451a7319a219cde6feb.tar.xz rsyslog-897a6853118de669be90a451a7319a219cde6feb.zip |
added vmop class (stage for expression execution)
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | debug.c | 6 | ||||
-rw-r--r-- | obj-types.h | 8 | ||||
-rw-r--r-- | syslogd.c | 2 | ||||
-rw-r--r-- | vmop.c | 97 | ||||
-rw-r--r-- | vmop.h | 50 |
6 files changed, 160 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am index d5dd3ba8..c02dfe4d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,6 +5,8 @@ rfc3195d_SOURCES = rfc3195d.c rsyslog.h rsyslogd_SOURCES = \ syslogd.c \ syslogd.h \ + vmop.c \ + vmop.h \ debug.c \ debug.h \ glbl.h \ @@ -57,7 +57,7 @@ static dbgThrdInfo_t *dbgGetThrdInfo(void); /* static data (some time to be replaced) */ int Debug; /* debug flag - read-only after startup */ int debugging_on = 0; /* read-only, except on sig USR1 */ -static int bLogFuncFlow = 0; /* shall the function entry and exit be logged to the debug log? */ +static int bLogFuncFlow = 1; /* shall the function entry and exit be logged to the debug log? */ static int bLogAllocFree = 0; /* shall calls to (m/c)alloc and free be logged to the debug log? */ static int bPrintFuncDBOnExit = 0; /* shall the function entry and exit be logged to the debug log? */ static int bPrintMutexAction = 0; /* shall mutex calls be printed to the debug log? */ @@ -930,7 +930,7 @@ int dbgEntrFunc(dbgFuncDB_t *pFuncDB, int line) /* when we reach this point, we have a fully-initialized FuncDB! */ //if(bLogFuncFlow) /* quick debug hack... select the best for you! */ - if(bLogFuncFlow && !strcmp((char*)pFuncDB->file, "expr.c")) /* quick debug hack... select the best for you! */ + if(bLogFuncFlow && !strcmp((char*)pFuncDB->file, "omlibdbi.c")) /* quick debug hack... select the best for you! */ dbgprintf("%s:%d: %s: enter\n", pFuncDB->file, pFuncDB->line, pFuncDB->func); if(pThrd->stackPtr >= (int) (sizeof(pThrd->callStack) / sizeof(dbgFuncDB_t*))) { dbgprintf("%s:%d: %s: debug module: call stack for this thread full, suspending call tracking\n", @@ -960,7 +960,7 @@ void dbgExitFunc(dbgFuncDB_t *pFuncDB, int iStackPtrRestore) dbgFuncDBPrintActiveMutexes(pFuncDB, "WARNING: mutex still owned by us as we exit function, mutex: ", pthread_self()); //if(bLogFuncFlow) /* quick debug hack... select the best for you! */ - if(bLogFuncFlow && !strcmp((char*)pFuncDB->file, "expr.c")) /* quick debug hack... select the best for you! */ + if(bLogFuncFlow && !strcmp((char*)pFuncDB->file, "omlibdbi.c")) /* quick debug hack... select the best for you! */ dbgprintf("%s:%d: %s: exit\n", pFuncDB->file, pFuncDB->line, pFuncDB->func); pThrd->stackPtr = iStackPtrRestore; if(pThrd->stackPtr < 0) { diff --git a/obj-types.h b/obj-types.h index 831dd897..a473060d 100644 --- a/obj-types.h +++ b/obj-types.h @@ -42,9 +42,13 @@ typedef enum { /* IDs of known object "types/classes" */ OBJctok = 6, OBJctok_token = 7, OBJvar = 8, - OBJexpr = 9 /* remeber to UPDATE OBJ_NUM_IDS (below) if you add one! */ + OBJvmop = 9, + OBJvmprg = 10, + OBJvm = 11, + OBJvmstk = 12, + OBJexpr = 13 /* remeber to UPDATE OBJ_NUM_IDS (below) if you add one! */ } objID_t; -#define OBJ_NUM_IDS 10 +#define OBJ_NUM_IDS 14 typedef enum { /* IDs of base methods supported by all objects - used for jump table, so * they must start at zero and be incremented. -- rgerahrds, 2008-01-04 @@ -170,6 +170,7 @@ #include "expr.h" #include "ctok.h" #include "conf.h" +#include "vmop.h" /* We define our own set of syslog defintions so that we * do not need to rely on (possibly different) implementations. @@ -3416,6 +3417,7 @@ static rsRetVal InitGlobalClasses(void) CHKiRet(wtiClassInit()); CHKiRet(wtpClassInit()); CHKiRet(queueClassInit()); + CHKiRet(vmopClassInit()); CHKiRet(varClassInit()); CHKiRet(ctok_tokenClassInit()); CHKiRet(ctokClassInit()); @@ -0,0 +1,97 @@ +/* vmop.c - abstracts an operation (instructed) supported by the + * rsyslog virtual machine + * + * Module begun 2008-02-20 by Rainer Gerhards + * + * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH. + * + * This file is part of rsyslog. + * + * Rsyslog is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Rsyslog is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * + * A copy of the GPL can be found in the file "COPYING" in this distribution. + */ + +#include "config.h" +#include <stdlib.h> +#include <assert.h> + +#include "rsyslog.h" +#include "obj.h" +#include "vmop.h" + +/* static data */ +DEFobjStaticHelpers + + +/* Standard-Constructor + */ +BEGINobjConstruct(vmop) /* be sure to specify the object type also in END macro! */ +ENDobjConstruct(vmop) + + +/* ConstructionFinalizer + * rgerhards, 2008-01-09 + */ +rsRetVal vmopConstructFinalize(vmop_t *pThis) +{ + DEFiRet; + ISOBJ_TYPE_assert(pThis, vmop); + RETiRet; +} + + +/* destructor for the vmop object */ +BEGINobjDestruct(vmop) /* be sure to specify the object type also in END and CODESTART macros! */ +CODESTARTobjDestruct(vmop) +ENDobjDestruct(vmop) + + +/* set operand (variant case) + * rgerhards, 2008-02-20 + */ +rsRetVal +vmopSetVar(vmop_t *pThis, var_t *pVar) +{ + DEFiRet; + ISOBJ_TYPE_assert(pThis, vmop); + ISOBJ_TYPE_assert(pVar, var); + pThis->operand.pVar = pVar; + RETiRet; +} + + +/* set operation + * rgerhards, 2008-02-20 + */ +rsRetVal +vmopSetOpcode(vmop_t *pThis, opcode_t opcode) +{ + DEFiRet; + ISOBJ_TYPE_assert(pThis, vmop); + pThis->opcode = opcode; + RETiRet; +} + + +/* Initialize the vmop class. Must be called as the very first method + * before anything else is called inside this class. + * rgerhards, 2008-02-19 + */ +BEGINObjClassInit(vmop, 1) /* class, version */ + OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, vmopConstructFinalize); +ENDObjClassInit(vmop) + +/* vi:set ai: + */ @@ -0,0 +1,50 @@ +/* The vmop object. + * + * Copyright 2008 Rainer Gerhards and Adiscon GmbH. + * + * This file is part of rsyslog. + * + * Rsyslog is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Rsyslog is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>. + * + * A copy of the GPL can be found in the file "COPYING" in this distribution. + */ +#ifndef INCLUDED_VMOP_H +#define INCLUDED_VMOP_H + +/* machine instructions types */ +typedef enum { /* do NOT start at 0 to detect uninitialized types after calloc() */ + opcode_INVALID = 0, + opcode_PUSH = 1 +} opcode_t; + +/* the vmop object */ +typedef struct vmop_s { + BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */ + opcode_t opcode; + union { + var_t *pVar; + /* TODO: add function pointer */ + } operand; +} vmop_t; + + +/* prototypes */ +rsRetVal vmopConstruct(vmop_t **ppThis); +rsRetVal vmopConstructFinalize(vmop_t __attribute__((unused)) *pThis); +rsRetVal vmopDestruct(vmop_t **ppThis); +rsRetVal vmopSetOpcode(vmop_t *pThis, opcode_t opcode); +rsRetVal vmopSetVar(vmop_t *pThis, var_t *pVar); +PROTOTYPEObjClassInit(vmop); + +#endif /* #ifndef INCLUDED_VMOP_H */ |