00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00018 #ifndef LIBCWD_CLASS_LOCATION_H
00019 #define LIBCWD_CLASS_LOCATION_H
00020
00021 #ifndef LIBCWD_CONFIG_H
00022 #include <libcwd/config.h>
00023 #endif
00024
00025 #if CWDEBUG_LOCATION
00026
00027 #ifndef LIBCWD_PRIVATE_STRUCT_TSD_H
00028 #include <libcwd/private_struct_TSD.h>
00029 #endif
00030 #ifndef LIBCWD_CLASS_OBJECT_FILE_H
00031 #include <libcwd/class_object_file.h>
00032 #endif
00033 #ifndef LIBCW_LOCKABLE_AUTO_PTR_H
00034 #include <libcwd/lockable_auto_ptr.h>
00035 #endif
00036 #ifndef LIBCW_STRING
00037 #define LIBCW_STRING
00038 #include <string>
00039 #endif
00040 #ifndef LIBCW_IOSFWD
00041 #define LIBCW_IOSFWD
00042 #include <iosfwd>
00043 #endif
00044
00045 namespace libcwd {
00046
00047 namespace _private_ {
00048
00049 enum hidden_st {
00050 filtered_location,
00051 unfiltered_location,
00052 new_location
00053 };
00054
00055 }
00056
00061 extern char const* const unknown_function_c;
00062
00073 class location_ct {
00074 protected:
00075 lockable_auto_ptr<char, true> M_filepath;
00076 union {
00077 char* M_filename;
00078 void const* M_initialization_delayed;
00079 };
00080 unsigned int M_line;
00081 char const* M_func;
00082 object_file_ct const* M_object_file;
00083 bool M_known;
00084 private:
00085 #if CWDEBUG_ALLOC
00086 friend class ooam_filter_ct;
00087 mutable _private_::hidden_st M_hide;
00088 #endif
00089
00090 protected:
00091
00092
00093 static char const* const S_uninitialized_location_ct_c;
00094 static char const* const S_pre_ios_initialization_c;
00095 static char const* const S_pre_libcwd_initialization_c;
00096 static char const* const S_cleared_location_ct_c;
00097
00098 public:
00099 location_ct(void const* addr);
00100
00101 #if LIBCWD_THREAD_SAFE
00102 location_ct(void const* addr LIBCWD_COMMA_TSD_PARAM);
00103
00104 #endif
00105 ~location_ct();
00106
00113 location_ct(void);
00114
00124 location_ct(location_ct const& location);
00125
00135 location_ct& operator=(location_ct const& location);
00136
00144 void lock_ownership(void) { if (M_known) M_filepath.lock(); }
00145
00149 void pc_location(void const* pc);
00150
00151
00152 void M_pc_location(void const* addr LIBCWD_COMMA_TSD_PARAM);
00153
00157 void clear(void);
00158
00159 public:
00160
00165 bool is_known(void) const;
00166
00173 std::string file(void) const;
00174
00176 unsigned int line(void) const;
00177
00184 char const* mangled_function_name(void) const;
00185
00187 size_t filename_length(void) const { return M_known ? strlen(M_filename) : 0; }
00189 size_t filepath_length(void) const { return M_known ? strlen(M_filepath.get()) : 0; }
00190
00196 object_file_ct const* object_file(void) const { return M_object_file; }
00197
00198
00200 void print_filepath_on(std::ostream& os) const;
00202 void print_filename_on(std::ostream& os) const;
00203 friend std::ostream& operator<<(std::ostream& os, location_ct const& location);
00204
00205
00206
00207 bool initialization_delayed(void) const { return (!M_object_file && (M_func == S_pre_ios_initialization_c || M_func == S_pre_libcwd_initialization_c)); }
00208 #if CWDEBUG_ALLOC
00209 void handle_delayed_initialization(ooam_filter_ct const& filter);
00210 bool hide_from_alloc_list(void) const { return M_hide == _private_::filtered_location; }
00211 bool new_location(void) const { return M_hide == _private_::new_location; }
00212 void synchronize_with(ooam_filter_ct const&) const;
00213 #endif
00214 };
00215
00217
00218 }
00219
00220 #endif // CWDEBUG_LOCATION
00221 #endif // LIBCWD_CLASS_LOCATION_H