WIP: deploy new logging flags in lib

This commit is contained in:
Christian Thaeter 2009-01-24 03:15:02 +01:00
parent 9aefc2e971
commit b9fc2d6522
12 changed files with 71 additions and 49 deletions

View file

@ -189,11 +189,11 @@ namespace lib {
} }
catch (lumiera::Error & ex) catch (lumiera::Error & ex)
{ {
WARN (operate, "Exception while closing AllocationCluster: %s",ex.what()); WARN (progress, "Exception while closing AllocationCluster: %s", ex.what());
} }
catch (...) catch (...)
{ {
ERROR (NOBUG_ON, "Unexpected fatal Exception while closing AllocationCluster."); ALERT (progress, "Unexpected fatal Exception while closing AllocationCluster.");
lumiera::error::lumiera_unexpectedException(); // terminate lumiera::error::lumiera_unexpectedException(); // terminate
} }
} }
@ -243,3 +243,11 @@ namespace lib {
} // namespace lib } // namespace lib
/*
// Local Variables:
// mode: C
// c-file-style: "gnu"
// indent-tabs-mode: nil
// End:
*/

View file

@ -24,7 +24,7 @@
#include "lib/cmdline.hpp" #include "lib/cmdline.hpp"
#include "lib/util.hpp" #include "lib/util.hpp"
#include "include/nobugcfg.h" #include "common/logging.h"
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>

View file

@ -25,7 +25,7 @@
#define LUMIERA_ERROR_HPP_ #define LUMIERA_ERROR_HPP_
#include <string> #include <string>
#include "include/nobugcfg.h" #include "common/logging.h"
#include "include/lifecycle.h" #include "include/lifecycle.h"
#include "lib/error.h" #include "lib/error.h"
@ -165,6 +165,7 @@ namespace lumiera {
* if NoBug is used, redefine some macros * if NoBug is used, redefine some macros
* to rather throw Lumiera Errors instead of aborting * to rather throw Lumiera Errors instead of aborting
*/ */
#if 0 /*This will not work, nobug aborts are hard and may hold some locks, we discussed that before -- cehteh */
#ifdef NOBUG_ABORT #ifdef NOBUG_ABORT
#undef NOBUG_ABORT #undef NOBUG_ABORT
#define LUMIERA_NOBUG_LOCATION \ #define LUMIERA_NOBUG_LOCATION \
@ -172,6 +173,6 @@ namespace lumiera {
#define NOBUG_ABORT \ #define NOBUG_ABORT \
lumiera::error::assertion_terminate (LUMIERA_NOBUG_LOCATION); lumiera::error::assertion_terminate (LUMIERA_NOBUG_LOCATION);
#endif #endif
#endif
#endif // LUMIERA_ERROR_HPP_ #endif // LUMIERA_ERROR_HPP_

View file

@ -21,6 +21,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "common/logging.h"
#include "lib/psplay.h" #include "lib/psplay.h"
#include <stdio.h> #include <stdio.h>
@ -28,7 +29,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <nobug.h> #include <nobug.h>
NOBUG_DEFINE_FLAG (psplay); //NOBUG_DEFINE_FLAG (psplay);
#ifndef PSPLAY_TRAIL_DEPTH #ifndef PSPLAY_TRAIL_DEPTH
#define PSPLAY_TRAIL_DEPTH 128 #define PSPLAY_TRAIL_DEPTH 128
@ -68,8 +69,8 @@ static inline uint32_t psplay_fast_prng ()
PSplay PSplay
psplay_init (PSplay self, psplay_cmp_fn cmp, psplay_key_fn key, psplay_delete_fn del) psplay_init (PSplay self, psplay_cmp_fn cmp, psplay_key_fn key, psplay_delete_fn del)
{ {
NOBUG_INIT_FLAG (psplay); //NOBUG_INIT_FLAG (psplay);
TRACE (psplay); TRACE (psplay_dbg);
REQUIRE (cmp); REQUIRE (cmp);
REQUIRE (key); REQUIRE (key);
@ -103,7 +104,7 @@ psplay_new (psplay_cmp_fn cmp, psplay_key_fn key, psplay_delete_fn del)
PSplay PSplay
psplay_destroy (PSplay self) psplay_destroy (PSplay self)
{ {
TRACE (psplay); TRACE (psplay_dbg);
if (self) while (self->tree) if (self) while (self->tree)
{ {
PSplaynode n = psplay_remove (self, self->tree); PSplaynode n = psplay_remove (self, self->tree);
@ -159,7 +160,7 @@ trailidx (unsigned n)
static inline void static inline void
psplay_splay (PSplay self, struct psplaytrail* trail, unsigned splayfactor) psplay_splay (PSplay self, struct psplaytrail* trail, unsigned splayfactor)
{ {
TRACE (psplay, "%p %u", self, splayfactor); TRACE (psplay_dbg, "%p %u", self, splayfactor);
if (trail->dir < 0) trail->dir = - trail->dir; if (trail->dir < 0) trail->dir = - trail->dir;
@ -170,17 +171,17 @@ psplay_splay (PSplay self, struct psplaytrail* trail, unsigned splayfactor)
PSplaynode grandparent = *trail->trail [trailidx (depth-2)]; PSplaynode grandparent = *trail->trail [trailidx (depth-2)];
unsigned r = PSPLAY_FORMULA; unsigned r = PSPLAY_FORMULA;
TRACE (psplay, "r is %u", r); TRACE (psplay_dbg, "r is %u", r);
if (parent == grandparent->left) if (parent == grandparent->left)
{ {
TRACE (psplay, "ZIG.."); TRACE (psplay_dbg, "ZIG..");
if (node == parent->left) if (node == parent->left)
{ {
TRACE (psplay, "..ZIG"); TRACE (psplay_dbg, "..ZIG");
if (r < PSPLAY_PROB_ZIGZIG) if (r < PSPLAY_PROB_ZIGZIG)
{ {
TRACE (psplay, "BREAK"); TRACE (psplay_dbg, "BREAK");
return; return;
} }
@ -192,10 +193,10 @@ psplay_splay (PSplay self, struct psplaytrail* trail, unsigned splayfactor)
} }
else else
{ {
TRACE (psplay, "..ZAG"); TRACE (psplay_dbg, "..ZAG");
if (r < PSPLAY_PROB_ZIGZAG) if (r < PSPLAY_PROB_ZIGZAG)
{ {
TRACE (psplay, "BREAK"); TRACE (psplay_dbg, "BREAK");
return; return;
} }
@ -208,13 +209,13 @@ psplay_splay (PSplay self, struct psplaytrail* trail, unsigned splayfactor)
} }
else else
{ {
TRACE (psplay, "ZAG.."); TRACE (psplay_dbg, "ZAG..");
if (node == parent->left) if (node == parent->left)
{ {
TRACE (psplay, "..ZIG"); TRACE (psplay_dbg, "..ZIG");
if (r < PSPLAY_PROB_ZIGZAG) if (r < PSPLAY_PROB_ZIGZAG)
{ {
TRACE (psplay, "BREAK"); TRACE (psplay_dbg, "BREAK");
return; return;
} }
@ -226,10 +227,10 @@ psplay_splay (PSplay self, struct psplaytrail* trail, unsigned splayfactor)
} }
else else
{ {
TRACE (psplay, "..ZAG"); TRACE (psplay_dbg, "..ZAG");
if (r < PSPLAY_PROB_ZIGZIG) if (r < PSPLAY_PROB_ZIGZIG)
{ {
TRACE (psplay, "BREAK"); TRACE (psplay_dbg, "BREAK");
return; return;
} }
@ -248,7 +249,7 @@ psplay_splay (PSplay self, struct psplaytrail* trail, unsigned splayfactor)
PSplaynode PSplaynode
psplay_insert (PSplay self, PSplaynode node, int splayfactor) psplay_insert (PSplay self, PSplaynode node, int splayfactor)
{ {
TRACE (psplay); TRACE (psplay_dbg);
PSplaynode n = self->tree; PSplaynode n = self->tree;
struct psplaytrail trail; struct psplaytrail trail;
@ -301,7 +302,7 @@ psplay_insert (PSplay self, PSplaynode node, int splayfactor)
PSplaynode PSplaynode
psplay_find (PSplay self, const void* key, int splayfactor) psplay_find (PSplay self, const void* key, int splayfactor)
{ {
TRACE (psplay); TRACE (psplay_dbg);
PSplaynode node = self->tree; PSplaynode node = self->tree;
struct psplaytrail trail; struct psplaytrail trail;
trail.dir = 0; trail.dir = 0;
@ -341,7 +342,7 @@ psplay_find (PSplay self, const void* key, int splayfactor)
PSplaynode PSplaynode
psplay_remove (PSplay self, PSplaynode node) psplay_remove (PSplay self, PSplaynode node)
{ {
TRACE (psplay); TRACE (psplay_dbg);
if (!node) return NULL; if (!node) return NULL;
PSplaynode* r = self->found_parent; PSplaynode* r = self->found_parent;
@ -350,7 +351,7 @@ psplay_remove (PSplay self, PSplaynode node)
{ {
if (!psplay_find (self, self->key (node), 0)) if (!psplay_find (self, self->key (node), 0))
{ {
WARN (psplay, "node %p is not in splay tree %p", node, self); WARN (psplay_dbg, "node %p is not in splay tree %p", node, self);
return NULL; return NULL;
} }
r = self->found_parent; r = self->found_parent;

View file

@ -23,7 +23,7 @@
#include "lib/query.hpp" #include "lib/query.hpp"
#include "lib/util.hpp" #include "lib/util.hpp"
#include "include/nobugcfg.h" #include "common/logging.h"
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>

View file

@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "common/logging.h"
#include "lib/llist.h" #include "lib/llist.h"
#include "lib/mutex.h" #include "lib/mutex.h"
#include "lib/safeclib.h" #include "lib/safeclib.h"
@ -27,7 +28,7 @@
#include <unistd.h> #include <unistd.h>
NOBUG_DEFINE_FLAG (resourcecollector); /* TODO: make this a hierachy, derrive from PARENT (library) ? */ //NOBUG_DEFINE_FLAG (resourcecollector); /* TODO: make this a hierachy, derrive from PARENT (library) ? */
llist lumiera_resourcecollector_registry[LUMIERA_RESOURCE_END]; llist lumiera_resourcecollector_registry[LUMIERA_RESOURCE_END];
lumiera_mutex lumiera_resourcecollector_lock; lumiera_mutex lumiera_resourcecollector_lock;
@ -44,13 +45,13 @@ struct lumiera_resourcehandler_struct
static void static void
lumiera_resourcecollector_init_ (void) lumiera_resourcecollector_init_ (void)
{ {
NOBUG_INIT_FLAG (resourcecollector); //NOBUG_INIT_FLAG (resourcecollector);
TRACE (resourcecollector); TRACE (resourcecollector_dbg);
for (int i = 0; i < LUMIERA_RESOURCE_END; ++i) for (int i = 0; i < LUMIERA_RESOURCE_END; ++i)
llist_init (&lumiera_resourcecollector_registry[i]); llist_init (&lumiera_resourcecollector_registry[i]);
lumiera_mutex_init (&lumiera_resourcecollector_lock, "resourcecollector", &NOBUG_FLAG(resourcecollector)); lumiera_mutex_init (&lumiera_resourcecollector_lock, "resourcecollector", &NOBUG_FLAG(mutex_dbg));
} }
@ -58,25 +59,25 @@ lumiera_resourcecollector_init_ (void)
void void
lumiera_resourcecollector_destroy (void) lumiera_resourcecollector_destroy (void)
{ {
TRACE (resourcecollector); TRACE (resourcecollector_dbg);
for (int i = 0; i < LUMIERA_RESOURCE_END; ++i) for (int i = 0; i < LUMIERA_RESOURCE_END; ++i)
LLIST_WHILE_HEAD (&lumiera_resourcecollector_registry[i], head) LLIST_WHILE_HEAD (&lumiera_resourcecollector_registry[i], head)
lumiera_resourcehandler_unregister ((LumieraResourcehandler)head); lumiera_resourcehandler_unregister ((LumieraResourcehandler)head);
lumiera_mutex_destroy (&lumiera_resourcecollector_lock, &NOBUG_FLAG(resourcecollector)); lumiera_mutex_destroy (&lumiera_resourcecollector_lock, &NOBUG_FLAG(mutex_dbg));
} }
int int
lumiera_resourcecollector_run (enum lumiera_resource which, enum lumiera_resource_try* iteration, void* context) lumiera_resourcecollector_run (enum lumiera_resource which, enum lumiera_resource_try* iteration, void* context)
{ {
TRACE (resourcecollector); TRACE (resourcecollector_dbg);
if (lumiera_resourcecollector_once == PTHREAD_ONCE_INIT) if (lumiera_resourcecollector_once == PTHREAD_ONCE_INIT)
pthread_once (&lumiera_resourcecollector_once, lumiera_resourcecollector_init_); pthread_once (&lumiera_resourcecollector_once, lumiera_resourcecollector_init_);
LUMIERA_MUTEX_SECTION (resourcecollector, &lumiera_resourcecollector_lock) LUMIERA_MUTEX_SECTION (mutex_sync, &lumiera_resourcecollector_lock)
{ {
for (enum lumiera_resource_try progress = LUMIERA_RESOURCE_NONE; progress < *iteration; ++*iteration) for (enum lumiera_resource_try progress = LUMIERA_RESOURCE_NONE; progress < *iteration; ++*iteration)
{ {
@ -99,7 +100,7 @@ lumiera_resourcecollector_run (enum lumiera_resource which, enum lumiera_resourc
} }
else else
{ {
ERROR (resourcecollector, "PANIC, Not enough resources %d", which); ALERT (resourcecollector, "PANIC, Not enough resources %d", which);
for (int i = 0; i < LUMIERA_RESOURCE_END; ++i) for (int i = 0; i < LUMIERA_RESOURCE_END; ++i)
LLIST_FOREACH (&lumiera_resourcecollector_registry[i], node) LLIST_FOREACH (&lumiera_resourcecollector_registry[i], node)
{ {
@ -122,7 +123,7 @@ lumiera_resourcecollector_register_handler (enum lumiera_resource resource, lumi
if (lumiera_resourcecollector_once == PTHREAD_ONCE_INIT) if (lumiera_resourcecollector_once == PTHREAD_ONCE_INIT)
pthread_once (&lumiera_resourcecollector_once, lumiera_resourcecollector_init_); pthread_once (&lumiera_resourcecollector_once, lumiera_resourcecollector_init_);
TRACE (resourcecollector); TRACE (resourcecollector_dbg);
LumieraResourcehandler self = lumiera_malloc (sizeof (*self)); LumieraResourcehandler self = lumiera_malloc (sizeof (*self));
@ -130,7 +131,7 @@ lumiera_resourcecollector_register_handler (enum lumiera_resource resource, lumi
self->handler = handler; self->handler = handler;
self->data = data; self->data = data;
LUMIERA_MUTEX_SECTION (resourcecollector, &lumiera_resourcecollector_lock) LUMIERA_MUTEX_SECTION (mutex_sync, &lumiera_resourcecollector_lock)
{ {
llist_insert_tail (&lumiera_resourcecollector_registry[resource], &self->node); llist_insert_tail (&lumiera_resourcecollector_registry[resource], &self->node);
} }
@ -142,11 +143,11 @@ lumiera_resourcecollector_register_handler (enum lumiera_resource resource, lumi
void void
lumiera_resourcehandler_unregister (LumieraResourcehandler self) lumiera_resourcehandler_unregister (LumieraResourcehandler self)
{ {
TRACE (resourcecollector); TRACE (resourcecollector_dbg);
if (self) if (self)
{ {
LUMIERA_MUTEX_SECTION (resourcecollector, &lumiera_resourcecollector_lock) LUMIERA_MUTEX_SECTION (mutex_sync, &lumiera_resourcecollector_lock)
{ {
llist_unlink (&self->node); llist_unlink (&self->node);
self->handler (LUMIERA_RESOURCE_UNREGISTER, self->data, NULL); self->handler (LUMIERA_RESOURCE_UNREGISTER, self->data, NULL);
@ -160,10 +161,10 @@ lumiera_resourcehandler_unregister (LumieraResourcehandler self)
LumieraResourcehandler LumieraResourcehandler
lumiera_resourcecollector_handler_find (enum lumiera_resource resource, lumiera_resource_handler_fn handler, void* data) lumiera_resourcecollector_handler_find (enum lumiera_resource resource, lumiera_resource_handler_fn handler, void* data)
{ {
TRACE (resourcecollector); TRACE (resourcecollector_dbg);
LumieraResourcehandler self = NULL; LumieraResourcehandler self = NULL;
LUMIERA_MUTEX_SECTION (resourcecollector, &lumiera_resourcecollector_lock) LUMIERA_MUTEX_SECTION (mutex_sync, &lumiera_resourcecollector_lock)
{ {
LLIST_FOREACH (&lumiera_resourcecollector_registry[resource], node) LLIST_FOREACH (&lumiera_resourcecollector_registry[resource], node)
{ {

View file

@ -23,7 +23,7 @@
#include <nobug.h> #include <nobug.h>
NOBUG_DECLARE_FLAG (resourcecollector); //NOBUG_DECLARE_FLAG (resourcecollector);
/** /**
* Resources known to the resource collector * Resources known to the resource collector

View file

@ -37,12 +37,10 @@ This code is heavily inspired by
#include "lib/singletonpolicies.hpp" // several Policies usable together with SingletonFactory #include "lib/singletonpolicies.hpp" // several Policies usable together with SingletonFactory
#include "include/nobugcfg.h" #include "common/logging.h"
#include "lib/util.hpp" #include "lib/util.hpp"
#include "lib/sync-classlock.hpp" #include "lib/sync-classlock.hpp"
namespace lumiera { namespace lumiera {
/** /**
@ -72,6 +70,7 @@ namespace lumiera {
static PType pInstance_; static PType pInstance_;
static bool isDead_; static bool isDead_;
public: public:
/** Interface to be used by SingletonFactory's clients. /** Interface to be used by SingletonFactory's clients.
@ -83,7 +82,12 @@ namespace lumiera {
{ {
if (!pInstance_) if (!pInstance_)
{ {
NOBUG_INIT;
FIXME ("NoBug wasnt even basically initialized here, the old ON_BASIC_INIT did not initialize it in proper order"
" so I explicitly init it here (calling init multiple times does not harm) --cehteh"
" nb maybe as exception we can use an explicit mutex here since pthread mutexes can be statically initialized");
ThreadLock guard SIDEEFFECT; ThreadLock guard SIDEEFFECT;
if (!pInstance_) if (!pInstance_)
{ {
if (isDead_) if (isDead_)
@ -144,3 +148,10 @@ namespace lumiera {
} // namespace lumiera } // namespace lumiera
#endif #endif
/*
// Local Variables:
// mode: C++
// c-file-style: "gnu"
// indent-tabs-mode: nil
// End:
*/

View file

@ -115,7 +115,7 @@ namespace lib {
} }
public: public:
ClassLock() : Lock (getPerClassMonitor()) {} ClassLock(...) : Lock (getPerClassMonitor()) {}
uint use_count() { return nifty::Holder<PerClassMonitor>::accessed_; } uint use_count() { return nifty::Holder<PerClassMonitor>::accessed_; }
}; };

View file

@ -67,7 +67,7 @@
#ifndef LIB_SYNC_H #ifndef LIB_SYNC_H
#define LIB_SYNC_H #define LIB_SYNC_H
#include "include/nobugcfg.h" #include "common/logging.h"
#include "lib/error.hpp" #include "lib/error.hpp"
#include "lib/util.hpp" #include "lib/util.hpp"

View file

@ -28,7 +28,7 @@
#include "pre.hpp" #include "pre.hpp"
#include "include/nobugcfg.h" #include "common/logging.h"
#include "lib/test/suite.hpp" #include "lib/test/suite.hpp"
#include "lib/util.hpp" #include "lib/util.hpp"

View file

@ -30,7 +30,7 @@
#include <sstream> #include <sstream>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include "include/nobugcfg.h" #include "common/logging.h"
#include "lib/cmdline.hpp" #include "lib/cmdline.hpp"
#include "lib/test/suite.hpp" #include "lib/test/suite.hpp"
#include "lib/test/run.hpp" #include "lib/test/run.hpp"