00001 //================================================================================================== 00002 // Copyright (C) 2010 Brian Tietz sdbtietz at yahoo dot com 00003 // 00004 // This program is free software; you can redistribute it and/or modify it under the terms of the 00005 // GNU General Public License as published by the Free Software Foundation, version 2.0 of the 00006 // License. 00007 // 00008 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 00009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00010 // General Public License for more details. 00011 // 00012 // You should have received a copy of the GNU General Public License along with this program; if 00013 // not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00014 // 02110-1301, USA. 00015 // 00016 // For commercial software, the copyright holder (Brian Tietz, email sdbtietz at yahoo dot com) 00017 // reserves the right and is willing to waive the proprietary source code disclosure aspects of that 00018 // license as applied to the UT library in exchange for either substantial contributions to the 00019 // development of the UT library or other forms of compensation. Any such waiver must be 00020 // established in writing between the copyright holder and the commercial entity obtaining such a 00021 // waiver. 00022 //================================================================================================== 00023 00024 00025 #ifndef _UT_DEBUG_SYMBOL_INFO_CACHE_H_ 00026 #define _UT_DEBUG_SYMBOL_INFO_CACHE_H_ 00027 00028 // \cond DOXYGEN_DOCUMENT_NEVER 00029 00030 00031 //================================================================================================== 00032 //=== Project headers 00033 //================================================================================================== 00034 #include "UTMutex.h" 00035 #include "UTLists.h" 00036 #include "UTPath.h" 00037 #include "UTDebugSymbolInfo.h" 00038 00039 00040 //================================================================================================== 00041 class DebugSymbolInfoCacheEntry_t 00042 //================================================================================================== 00043 : public BTreeNode_t< DebugSymbolInfoCacheEntry_t, const void* > 00044 { 00045 //---------------------------------------------------------------------------------------------- 00046 public: 00047 //---------------------------------------------------------------------------------------------- 00048 DebugSymbolInfoCacheEntry_t( const void* address, 00049 const String_t* function_name, 00050 uint offset_into_function, 00051 uint line_number, 00052 const Path_t* file_name ); 00053 00054 void SetAddr( DebugSymbolInfo_t* debug_symbol_info, 00055 bool collect_file_name, 00056 bool file_leaf_name_only ); 00057 inline int Compare(const void* address) const; 00058 inline operator const void*() const; 00059 00060 //---------------------------------------------------------------------------------------------- 00061 private: 00062 //---------------------------------------------------------------------------------------------- 00063 const void* m_address; 00064 const String_t* m_function_name; 00065 uint m_offset_into_function; 00066 uint m_line_number; 00067 const Path_t* m_file_name; 00068 }; 00069 00070 00071 //================================================================================================== 00072 class DebugSymbolFunctionName_t 00073 //================================================================================================== 00074 : public String_t, 00075 public BTreeNode_t< DebugSymbolFunctionName_t, const utf8* > 00076 { 00077 //---------------------------------------------------------------------------------------------- 00078 public: 00079 //---------------------------------------------------------------------------------------------- 00080 inline DebugSymbolFunctionName_t(const utf8* name); 00081 }; 00082 00083 00084 //================================================================================================== 00085 class DebugSymbolFileName_t 00086 //================================================================================================== 00087 : public Path_t, 00088 public BTreeNode_t< DebugSymbolFileName_t, const utf8* > 00089 { 00090 //---------------------------------------------------------------------------------------------- 00091 public: 00092 //---------------------------------------------------------------------------------------------- 00093 inline DebugSymbolFileName_t(const utf8* name); 00094 }; 00095 00096 00097 //================================================================================================== 00098 class DebugSymbolInfoCache_t 00099 //================================================================================================== 00100 { 00101 //---------------------------------------------------------------------------------------------- 00102 public: 00103 //---------------------------------------------------------------------------------------------- 00104 DebugSymbolInfoCache_t(); 00105 ~DebugSymbolInfoCache_t(); 00106 00107 inline void Lock(); 00108 inline void Unlock(); 00109 bool SetAddr( DebugSymbolInfo_t* debug_symbol_info, 00110 const void* address, 00111 bool collect_file_name, 00112 bool file_leaf_name_only ); 00113 void SetAddr( const void* address, 00114 const utf8* function_name, 00115 uint offset_into_function, 00116 uint line_number, 00117 const utf8* file_name ); 00118 00119 void ReleaseAll(); 00120 00121 //---------------------------------------------------------------------------------------------- 00122 private: 00123 //---------------------------------------------------------------------------------------------- 00124 Mutex_t m_mutex; 00125 OwnedBTree_t< DebugSymbolInfoCacheEntry_t, const void* > m_symbols; 00126 OwnedBTree_t< DebugSymbolFunctionName_t, const utf8* > m_function_names; 00127 OwnedBTree_t< DebugSymbolFileName_t, const utf8* > m_file_names; 00128 }; 00129 00130 00131 00132 00133 //================================================================================================== 00134 //================================================================================================== 00135 //=== 00136 //=== Inline function implementations: class DebugSymbolInfoCache_t 00137 //=== 00138 //================================================================================================== 00139 //================================================================================================== 00140 inline void 00141 DebugSymbolInfoCache_t::Lock() 00142 { 00143 m_mutex.Lock(); 00144 } 00145 00146 00147 inline void 00148 DebugSymbolInfoCache_t::Unlock() 00149 { 00150 m_mutex.Unlock(); 00151 } 00152 00153 00154 00155 00156 //================================================================================================== 00157 //================================================================================================== 00158 //=== 00159 //=== Inline function implementations: class DebugSymbolInfoCacheEntry_t 00160 //=== 00161 //================================================================================================== 00162 //================================================================================================== 00163 inline int 00164 DebugSymbolInfoCacheEntry_t::Compare(const void* address) const 00165 { 00166 if(m_address < address) 00167 return -1; 00168 if(m_address > address) 00169 return 1; 00170 return 0; 00171 } 00172 00173 00174 inline 00175 DebugSymbolInfoCacheEntry_t::operator const void*() const 00176 { 00177 return m_address; 00178 } 00179 00180 00181 00182 00183 //================================================================================================== 00184 //================================================================================================== 00185 //=== 00186 //=== Inline function implementations: class DebugSymbolFunctionName_t 00187 //=== 00188 //================================================================================================== 00189 //================================================================================================== 00190 inline 00191 DebugSymbolFunctionName_t::DebugSymbolFunctionName_t(const utf8* name) 00192 : String_t(name) 00193 { } 00194 00195 00196 00197 00198 //================================================================================================== 00199 //================================================================================================== 00200 //=== 00201 //=== Inline function implementations: class DebugSymbolFileName_t 00202 //=== 00203 //================================================================================================== 00204 //================================================================================================== 00205 inline 00206 DebugSymbolFileName_t::DebugSymbolFileName_t(const utf8* name) 00207 : Path_t(name) 00208 { } 00209 00210 00211 // \endcond 00212 00213 #endif // _UT_DEBUG_SYMBOL_INFO_CACHE_H_