00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00018 #ifndef LIBCWD_CLASS_ALLOC_FILTER_H
00019 #define LIBCWD_CLASS_ALLOC_FILTER_H
00020
00021 #ifndef LIBCWD_LIBRARIES_DEBUG_H
00022 #error "Don't include <libcwd/class_alloc_filter.h> directly, include the appropriate \"debug.h\" instead."
00023 #endif
00024
00025 #include <libcwd/config.h>
00026
00027 #if CWDEBUG_LOCATION
00028 #include <libcwd/class_location.h>
00029 #endif
00030
00031 #if CWDEBUG_ALLOC
00032
00033 #if CWDEBUG_LOCATION
00034 #include <libcwd/private_allocator.h>
00035 #endif
00036 #ifndef LIBCW_VECTOR
00037 #define LIBCW_VECTOR
00038 #include <vector>
00039 #endif
00040
00041 #endif // CWDEBUG_ALLOC
00042
00043 namespace libcwd {
00044
00049 typedef unsigned short int alloc_format_t;
00050
00051 #if CWDEBUG_LOCATION
00052 alloc_format_t const show_path = 1;
00053 alloc_format_t const show_objectfile = 2;
00054 alloc_format_t const show_function = 4;
00055 #endif
00056 #if CWDEBUG_ALLOC
00057 alloc_format_t const show_time = 8;
00058 alloc_format_t const show_allthreads = 16;
00059 #if CWDEBUG_LOCATION
00060 alloc_format_t const format_mask = (show_time|show_path|show_objectfile|show_function|show_allthreads);
00061 #else
00062 alloc_format_t const format_mask = (show_time|show_allthreads);
00063 #endif
00064 #endif // CWDEBUG_ALLOC
00065
00068 #if CWDEBUG_ALLOC
00069
00070 unsigned int const hide_untagged = 32;
00071 unsigned int const hide_unknown_loc = 64;
00072
00073 class dm_alloc_base_ct;
00074 class dm_alloc_copy_ct;
00075 #if CWDEBUG_MARKER
00076 class marker_ct;
00077 #endif
00078
00088 class alloc_filter_ct {
00089 private:
00090 #if CWDEBUG_LOCATION // No synchronization needed when not defined.
00091 static int S_next_id;
00092 static int S_id;
00093 int M_id;
00094 #endif
00095 friend class ::libcwd::dm_alloc_base_ct;
00096 friend class ::libcwd::dm_alloc_copy_ct;
00097 alloc_format_t M_flags;
00098 struct timeval M_start;
00099 struct timeval M_end;
00100 #if CWDEBUG_LOCATION
00101 typedef std::basic_string<char, std::char_traits<char>, _private_::auto_internal_allocator> string_type;
00102 typedef std::vector<string_type, _private_::auto_internal_allocator::rebind<string_type>::other> vector_type;
00103 vector_type M_objectfile_masks;
00104 vector_type M_sourcefile_masks;
00105 typedef std::vector<std::pair<string_type, string_type>,
00106 _private_::auto_internal_allocator::rebind<std::pair<string_type, string_type> >::other> vector_pair_type;
00107 vector_pair_type M_function_masks;
00108 #endif
00109 public:
00111 static struct timeval const no_time_limit;
00113 alloc_filter_ct(alloc_format_t flags = 0);
00115 void set_flags(alloc_format_t flags);
00117 alloc_format_t get_flags(void) const;
00119 struct timeval get_time_start(void) const;
00121 struct timeval get_time_end(void) const;
00122 #if CWDEBUG_LOCATION
00123
00127 std::vector<std::string> get_objectfile_list(void) const;
00128
00133 std::vector<std::string> get_sourcefile_list(void) const;
00134
00139 std::vector<std::pair<std::string, std::string> > get_function_list(void) const;
00140 #endif
00141
00150 void set_time_interval(struct timeval const& start, struct timeval const& end);
00151
00152 #if CWDEBUG_LOCATION
00153
00161 void hide_objectfiles_matching(std::vector<std::string> const& masks);
00162
00171 void hide_sourcefiles_matching(std::vector<std::string> const& masks);
00172
00190 void hide_functions_matching(std::vector<std::pair<std::string, std::string> > const& masks);
00191 #endif
00192
00199 void hide_untagged_allocations(bool hide = true) { if (hide) M_flags |= hide_untagged; else M_flags &= ~hide_untagged; }
00200
00207 void hide_unknown_locations(bool hide = true) { if (hide) M_flags |= hide_unknown_loc; else M_flags &= ~hide_unknown_loc; }
00208
00209 #if CWDEBUG_LOCATION
00210
00211 _private_::hidden_st check_hide(char const* filepath) const;
00212
00213
00214 _private_::hidden_st check_hide(object_file_ct const* object_file, char const* mangled_function_name) const;
00215 #endif
00216
00217 private:
00218 friend unsigned long list_allocations_on(debug_ct&, alloc_filter_ct const&);
00219 #if CWDEBUG_MARKER
00220 friend class marker_ct;
00221 #endif
00222 #if CWDEBUG_LOCATION
00223 void M_check_synchronization(void) const { if (M_id != S_id) M_synchronize(); }
00224 void M_synchronize(void) const;
00225 void M_synchronize_locations(void) const;
00226 #endif
00227 };
00228
00229 #endif // CWDEBUG_ALLOC
00230
00231 }
00232
00233 #endif // LIBCWD_CLASS_ALLOC_FILTER_H