00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00018 #ifndef LIBCWD_CLASS_OOAM_FILTER_H
00019 #define LIBCWD_CLASS_OOAM_FILTER_H
00020
00021 #ifndef LIBCWD_DEBUG_H
00022 #error "Don't include <libcwd/class_ooam_filter.h> directly, include the appropriate \"debug.h\" instead."
00023 #endif
00024
00025 #include <libcwd/config.h>
00026
00027 #if CWDEBUG_ALLOC
00028 namespace libcwd {
00029
00034 typedef unsigned short int ooam_format_t;
00035
00036 ooam_format_t const show_time = 1;
00037 #if CWDEBUG_LOCATION
00038 ooam_format_t const show_path = 2;
00039 ooam_format_t const show_objectfile = 4;
00040 #endif
00041 ooam_format_t const show_allthreads = 8;
00042 #if CWDEBUG_LOCATION
00043 ooam_format_t const format_mask = (show_time|show_path|show_objectfile|show_allthreads);
00044 #else
00045 ooam_format_t const format_mask = (show_time|show_allthreads);
00046 #endif
00047
00050 unsigned int const hide_untagged = 16;
00051 unsigned int const hide_unknown_loc = 32;
00052
00053 class dm_alloc_base_ct;
00054 class dm_alloc_copy_ct;
00055 #if CWDEBUG_MARKER
00056 class marker_ct;
00057 #endif
00058
00065 class ooam_filter_ct {
00066 private:
00067 #if CWDEBUG_LOCATION // No synchronization needed when not defined.
00068 static int S_next_id;
00069 static int S_id;
00070 int M_id;
00071 #endif
00072 friend class ::libcwd::dm_alloc_base_ct;
00073 friend class ::libcwd::dm_alloc_copy_ct;
00074 ooam_format_t M_flags;
00075 struct timeval M_start;
00076 struct timeval M_end;
00077 #if CWDEBUG_LOCATION
00078 std::vector<std::string> M_objectfile_masks;
00079 std::vector<std::string> M_sourcefile_masks;
00080 #endif
00081 public:
00083 static struct timeval const no_time_limit;
00085 ooam_filter_ct(ooam_format_t flags = 0);
00087 void set_flags(ooam_format_t flags);
00089 ooam_format_t get_flags(void) const;
00091 struct timeval get_time_start(void) const;
00093 struct timeval get_time_end(void) const;
00094 #if CWDEBUG_LOCATION
00095
00096 std::vector<std::string> get_objectfile_list(void) const;
00098 std::vector<std::string> get_sourcefile_list(void) const;
00099 #endif
00100
00109 void set_time_interval(struct timeval const& start, struct timeval const& end);
00110
00111 #if CWDEBUG_LOCATION
00112
00120 void hide_objectfiles_matching(std::vector<std::string> const& masks);
00121
00130 void hide_sourcefiles_matching(std::vector<std::string> const& masks);
00131 #endif
00132
00139 void hide_untagged_allocations(bool hide = true) { if (hide) M_flags |= hide_untagged; else M_flags &= ~hide_untagged; }
00140
00147 void hide_unknown_locations(bool hide = true) { if (hide) M_flags |= hide_unknown_loc; else M_flags &= ~hide_unknown_loc; }
00148
00149 #if CWDEBUG_LOCATION
00150
00151 _private_::hidden_st check_hide(char const* filepath) const;
00152 #endif
00153
00154 private:
00155 friend void list_allocations_on(debug_ct&, ooam_filter_ct const&);
00156 #if CWDEBUG_MARKER
00157 friend class marker_ct;
00158 #endif
00159 #if CWDEBUG_LOCATION
00160 void M_check_synchronization(void) const { if (M_id != S_id) M_synchronize(); }
00161 void M_synchronize(void) const;
00162 void M_synchronize_locations(void) const;
00163 #endif
00164 };
00165
00166 }
00167
00168 #endif // CWDEBUG_ALLOC
00169 #endif // LIBCWD_CLASS_OOAM_FILTER_H