00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef STXXL_DEBUG_HEADER
00014 #define STXXL_DEBUG_HEADER
00015
00016 #ifdef STXXL_BOOST_CONFIG
00017 #include <boost/config.hpp>
00018 #endif
00019
00020 #include <stxxl/bits/namespace.h>
00021 #include <stxxl/bits/common/mutex.h>
00022 #include <stxxl/bits/compat_hash_map.h>
00023
00024
00025 __STXXL_BEGIN_NAMESPACE
00026
00027 class debugmon
00028 {
00029 #ifdef STXXL_DEBUGMON
00030
00031 struct tag
00032 {
00033 bool ongoing;
00034 char * end;
00035 size_t size;
00036 };
00037 struct hash_fct
00038 {
00039 inline size_t operator () (char * arg) const
00040 {
00041 return long(arg);
00042 }
00043 #ifdef BOOST_MSVC
00044 bool operator () (char * a, char * b) const
00045 {
00046 return (long(a) < long(b));
00047 }
00048 enum
00049 {
00050 bucket_size = 4,
00051 min_buckets = 8
00052 };
00053 #endif
00054 };
00055
00056 compat_hash_map<char *, tag, hash_fct>::result tags;
00057
00058 #ifdef STXXL_BOOST_THREADS
00059 boost::mutex mutex1;
00060 #else
00061 mutex mutex1;
00062 #endif
00063
00064 #endif // #ifdef STXXL_DEBUGMON
00065
00066 static debugmon * instance;
00067
00068 inline debugmon() { }
00069
00070 public:
00071 void block_allocated(char * ptr, char * end, size_t size);
00072 void block_deallocated(char * ptr);
00073 void io_started(char * ptr);
00074 void io_finished(char * ptr);
00075
00076 inline static debugmon * get_instance()
00077 {
00078 if (!instance)
00079 instance = new debugmon();
00080
00081 return instance;
00082 }
00083 };
00084
00085 #ifndef STXXL_DEBUGMON
00086 inline void debugmon::block_allocated(char * , char * , size_t )
00087 { }
00088 inline void debugmon::block_deallocated(char * )
00089 { }
00090 inline void debugmon::io_started(char * )
00091 { }
00092 inline void debugmon::io_finished(char * )
00093 { }
00094 #endif
00095
00096 __STXXL_END_NAMESPACE
00097
00098 #endif // !STXXL_DEBUG_HEADER