From 8e507223c0e991a6b4f3f0fadd6490b12d8e7dc6 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Tue, 20 Jul 2021 00:57:22 +0000 Subject: [PATCH] added more log options in std.c --- moo/kernel/System.moo | 9 ++++++- moo/lib/moo.h | 30 +++++++++++----------- moo/lib/std.c | 59 ++++++++++++++++++++++++++++--------------- 3 files changed, 62 insertions(+), 36 deletions(-) diff --git a/moo/kernel/System.moo b/moo/kernel/System.moo index 8c52139..48b8ab8 100644 --- a/moo/kernel/System.moo +++ b/moo/kernel/System.moo @@ -166,28 +166,35 @@ class System(Apex) // TODO: Do i have to protected this in an exception handler??? //TODO: Execute Handler for signo. - System logNl: "Interrupt dectected - signal no - " & signo asString. + System logNl: "Interrupt detected - signal no - " & signo asString. +System logNl: "WWWWWWWWWWWWWWWWWWWWWWWWW ". // user-defined signal handler is not allowed for 16rFF if (signo == 16rFF) { goto done }. +System logNl: "OHHHHHHHHHHHHHH ". ifnot (self.shr isEmpty) { +System logNl: "About to execute handler for the signal detected - " & signo asString. self.shr do: [ :handler | handler value: signo ]. } else { +System logNl: "Jumping to done detected - signal no - " & signo asString. if (signo == 2) { goto done }. }. }. +System logNl: "Waiting for signal on os_intr_sem...". os_intr_sem wait. }. done: +System logNl: "Jumped to done detected - signal no - " & signo asString. nil. ] ensure: [ | pid proc oldps | +System logNl: "Aborting signal handler......". // stop subscribing to signals. os_intr_sem signal. os_intr_sem unsignal. diff --git a/moo/lib/moo.h b/moo/lib/moo.h index 4409e01..c425127 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -1105,26 +1105,26 @@ struct moo_dbgi_method_t enum moo_log_mask_t { - MOO_LOG_DEBUG = (1u << 0), - MOO_LOG_INFO = (1u << 1), - MOO_LOG_WARN = (1u << 2), - MOO_LOG_ERROR = (1u << 3), - MOO_LOG_FATAL = (1u << 4), + MOO_LOG_DEBUG = ((moo_bitmask_t)1 << 0), + MOO_LOG_INFO = ((moo_bitmask_t)1 << 1), + MOO_LOG_WARN = ((moo_bitmask_t)1 << 2), + MOO_LOG_ERROR = ((moo_bitmask_t)1 << 3), + MOO_LOG_FATAL = ((moo_bitmask_t)1 << 4), - MOO_LOG_UNTYPED = (1u << 6), /* only to be used by MOO_DEBUGx() and MOO_INFOx() */ - MOO_LOG_COMPILER = (1u << 7), - MOO_LOG_VM = (1u << 8), - MOO_LOG_MNEMONIC = (1u << 9), /* bytecode mnemonic */ - MOO_LOG_GC = (1u << 10), - MOO_LOG_IC = (1u << 11), /* instruction cycle, fetch-decode-execute */ - MOO_LOG_PRIMITIVE = (1u << 12), - MOO_LOG_APP = (1u << 13), /* moo applications, set by moo logging primitive */ + MOO_LOG_UNTYPED = ((moo_bitmask_t)1 << 6), /* only to be used by MOO_DEBUGx() and MOO_INFOx() */ + MOO_LOG_COMPILER = ((moo_bitmask_t)1 << 7), + MOO_LOG_VM = ((moo_bitmask_t)1 << 8), + MOO_LOG_MNEMONIC = ((moo_bitmask_t)1 << 9), /* bytecode mnemonic */ + MOO_LOG_GC = ((moo_bitmask_t)1 << 10), + MOO_LOG_IC = ((moo_bitmask_t)1 << 11), /* instruction cycle, fetch-decode-execute */ + MOO_LOG_PRIMITIVE = ((moo_bitmask_t)1 << 12), + MOO_LOG_APP = ((moo_bitmask_t)1 << 13), /* moo applications, set by moo logging primitive */ MOO_LOG_ALL_LEVELS = (MOO_LOG_DEBUG | MOO_LOG_INFO | MOO_LOG_WARN | MOO_LOG_ERROR | MOO_LOG_FATAL), MOO_LOG_ALL_TYPES = (MOO_LOG_UNTYPED | MOO_LOG_COMPILER | MOO_LOG_VM | MOO_LOG_MNEMONIC | MOO_LOG_GC | MOO_LOG_IC | MOO_LOG_PRIMITIVE | MOO_LOG_APP), - MOO_LOG_STDOUT = (1u << 14), /* write log messages to stdout without timestamp. MOO_LOG_STDOUT wins over MOO_LOG_STDERR. */ - MOO_LOG_STDERR = (1u << 15) /* write log messages to stderr without timestamp. */ + MOO_LOG_STDOUT = ((moo_bitmask_t)1 << 14), /* write log messages to stdout without timestamp. MOO_LOG_STDOUT wins over MOO_LOG_STDERR. */ + MOO_LOG_STDERR = ((moo_bitmask_t)1 << 15) /* write log messages to stderr without timestamp. */ }; typedef enum moo_log_mask_t moo_log_mask_t; diff --git a/moo/lib/std.c b/moo/lib/std.c index 50629ae..9eafa4e 100644 --- a/moo/lib/std.c +++ b/moo/lib/std.c @@ -3958,29 +3958,42 @@ static LONG WINAPI msw_exception_filter (struct _EXCEPTION_POINTERS* exinfo) static struct { const char* name; + int op; moo_bitmask_t mask; } log_mask_table[] = { - { "app", MOO_LOG_APP }, - { "compiler", MOO_LOG_COMPILER }, - { "vm", MOO_LOG_VM }, - { "mnemonic", MOO_LOG_MNEMONIC }, - { "gc", MOO_LOG_GC }, - { "ic", MOO_LOG_IC }, - { "primitive", MOO_LOG_PRIMITIVE }, - { "all", MOO_LOG_ALL_TYPES }, + { "app", 0, MOO_LOG_APP }, + { "compiler", 0, MOO_LOG_COMPILER }, + { "vm", 0, MOO_LOG_VM }, + { "mnemonic", 0, MOO_LOG_MNEMONIC }, + { "gc", 0, MOO_LOG_GC }, + { "ic", 0, MOO_LOG_IC }, + { "primitive", 0, MOO_LOG_PRIMITIVE }, + { "all", 0, MOO_LOG_ALL_TYPES }, - { "fatal", MOO_LOG_FATAL }, - { "error", MOO_LOG_ERROR }, - { "warn", MOO_LOG_WARN }, - { "info", MOO_LOG_INFO }, - { "debug", MOO_LOG_DEBUG }, + { "fatal", 0, MOO_LOG_FATAL }, + { "error", 0, MOO_LOG_ERROR }, + { "warn", 0, MOO_LOG_WARN }, + { "info", 0, MOO_LOG_INFO }, + { "debug", 0, MOO_LOG_DEBUG }, - { "fatal+", MOO_LOG_FATAL }, - { "error+", MOO_LOG_FATAL | MOO_LOG_ERROR }, - { "warn+", MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN }, - { "info+", MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO }, - { "debug+", MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO | MOO_LOG_DEBUG } + { "fatal+", 0, MOO_LOG_FATAL }, + { "error+", 0, MOO_LOG_FATAL | MOO_LOG_ERROR }, + { "warn+", 0, MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN }, + { "info+", 0, MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO }, + { "debug+", 0, MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO | MOO_LOG_DEBUG }, + + { "fatal-", 0, MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO | MOO_LOG_DEBUG }, + { "error-", 0, MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO | MOO_LOG_DEBUG }, + { "warn-", 0, MOO_LOG_WARN | MOO_LOG_INFO | MOO_LOG_DEBUG }, + { "info-", 0, MOO_LOG_INFO | MOO_LOG_DEBUG }, + { "debug-", 0, MOO_LOG_DEBUG }, + + { "-fatal", 1, ~MOO_LOG_FATAL }, + { "-error", 1, ~MOO_LOG_ERROR }, + { "-warn", 1, ~MOO_LOG_WARN }, + { "-info", 1, ~MOO_LOG_INFO }, + { "-debug", 1, ~MOO_LOG_DEBUG }, }; static struct @@ -4021,7 +4034,10 @@ static int parse_logoptb (moo_t* moo, const moo_bch_t* str, moo_oow_t* xpathlen, { if (moo_comp_bchars_bcstr(flt, len, log_mask_table[i].name) == 0) { - logmask |= log_mask_table[i].mask; + if (log_mask_table[i].op) + logmask &= log_mask_table[i].mask; + else + logmask |= log_mask_table[i].mask; break; } } @@ -4076,7 +4092,10 @@ static int parse_logoptu (moo_t* moo, const moo_uch_t* str, moo_oow_t* xpathlen, { if (moo_comp_uchars_bcstr(flt, len, log_mask_table[i].name) == 0) { - logmask |= log_mask_table[i].mask; + if (log_mask_table[i].op) + logmask &= log_mask_table[i].mask; + else + logmask |= log_mask_table[i].mask; break; } }