#include <Context.h>
Public Member Functions | |
const std::string & | compilation () const |
const std::string & | compilation () const |
const std::string & | compiler () const |
const std::string & | compiler () const |
Context (const std::string &filename, int line_number, const std::string &function_name, const std::string &compiler_name, const std::string &compiler_version, const std::string &compilation_time, const std::string &compilation_date, const std::string &package) | |
Context (const std::string &filename, int line_number, const std::string &function_name, const std::string &compiler_name, const std::string &compiler_version, const std::string &compilation_time, const std::string &compilation_date, const std::string &package) | |
const std::string & | file () const throw () |
const std::string & | file () const throw () |
const std::string & | function () const throw () |
const std::string & | function () const throw () |
int | line () const throw () |
int | line () const throw () |
const std::string & | package_name () const throw () |
const std::string & | package_name () const throw () |
const std::string & | position () const |
const std::string & | position () const |
std::vector< std::string > | qualifiers () const throw () |
std::vector< std::string > | qualifiers () const throw () |
const std::string & | stack_frame (int i) const |
const std::string & | stack_frame (int i) const |
int | stack_frames () const throw () |
int | stack_frames () const throw () |
Static Public Member Functions | |
void | add_qualifier (const std::string &qualif) |
void | add_qualifier (const std::string &qualif) |
int | debug_level () |
int | debug_level () |
const Context * | empty () |
const Context * | empty () |
std::string & | host_type () |
type of target host | |
std::string & | host_type () |
type of target host | |
Static Protected Member Functions | |
void | build_host_type () |
void | build_host_type () |
Protected Attributes | |
std::string | m_compilation |
std::string | m_compilation_date |
std::string | m_compilation_time |
std::string | m_compiler |
std::string | m_compiler_name |
std::string | m_compiler_version |
std::string | m_file_name |
std::string | m_function_name |
int | m_line_number |
std::string | m_package_name |
std::string | m_position |
std::vector< std::string > | m_stack_frames |
std::vector< std::string > | m_stack_frames |
Static Protected Attributes | |
std::vector< std::string > | default_qualifiers |
std::vector< std::string > | default_qualifiers |
Context * | empty_instance |
Context * | empty_instance = 0 |
std::string | s_host_type |
This class encapsulates Context information for an issue. The context of an issue is the location in the code the issue was constructed. The context acts as an encapsulator for compilator generted information like:
The current context can be obtained using the macro ERS_HERE
An empty context can be obtained using the macro ERS_EMPTY
|
Constructor - defines an Issue context. This constructor should generally not be called directly, instead use the macro
00074 { 00075 this->m_file_name = filename ; 00076 this->m_line_number = line_number ; 00077 this->m_function_name = function_name ; 00078 this->m_compiler_name = compiler_name ; 00079 this->m_compiler_version = compiler_version ; 00080 this->m_compilation_date = compilation_date ; 00081 this->m_compilation_time = compilation_time ; 00082 this->m_package_name = package_name ; 00083 #if defined(__GNU_LIBRARY__) 00084 void * array[128] ; 00085 const int n_size = backtrace (array,128) ; 00086 char ** symbols = backtrace_symbols(array, n_size); 00087 for (int i = 1; i < n_size; i++) { // we start at 1, current position is noise 00088 this->m_stack_frames.push_back(symbols[i]); 00089 } // for 00090 free(symbols); 00091 #endif 00092 } // Context
|
|
|
|
|
|
00056 { 00057 default_qualifiers.push_back(qualif) ; 00058 } // add_qualifier
|
|
stack frames |
|
stack frames 00189 { 00190 std::ostringstream plateform_s ; 00191 #if defined(__linux__) 00192 plateform_s << "linux" ; 00193 #endif 00194 #if defined(__OpenBSD__) 00195 plateform_s << "OpenBSD" ; 00196 #endif 00197 #if defined(__FreeBSD__) 00198 plateform_s << "FreeBSD" ; 00199 #endif 00200 #if defined(__APPLE__) && defined(__MACH__) 00201 plateform_s << "Darwin" ; 00202 #endif 00203 #if defined(__SOLARIS__) 00204 plateform_s << "Solaris" ; 00205 #endif 00206 plateform_s << "/" ; 00207 #if defined(__POWERPC__) || defined(__ppc__ ) || defined( __PPC__ ) || defined( powerpc ) || defined( ppc ) 00208 plateform_s << "PowerPC" ; 00209 #endif 00210 #if defined(__i386__) || defined(__INTEL__) || defined( intel ) || defined( _M_IX86 ) 00211 plateform_s << "i386" ; 00212 #endif 00213 #if defined(sparc) || defined(__sparc) 00214 plateform_s << "Sparc" ; 00215 #endif 00216 s_host_type= plateform_s.str(); 00217 } // build_host_type
|
|
|
|
00168 { 00169 if (m_compilation.empty()) { 00170 std::ostringstream compilation_s ; 00171 if (! m_compilation_time.empty()) { 00172 compilation_s << m_compilation_time << " " ; 00173 } // compilation time 00174 if (! m_compilation_date.empty()) { 00175 compilation_s << m_compilation_date ; 00176 } // compilation date 00177 m_compilation = compilation_s.str(); 00178 } // if 00179 return m_compilation ; 00180 } // compilation
|
|
|
|
00151 { 00152 if (m_compiler.empty()) { 00153 if (! m_compiler_name.empty()) { 00154 std::ostringstream compiler_s ; 00155 compiler_s << m_compiler_name << " " << m_compiler_version ; 00156 m_compiler = compiler_s.str(); 00157 } else { 00158 m_compiler = "unknown" ; 00159 } 00160 } // build cache 00161 return m_compiler ; 00162 } // compiler
|
|
|
|
Gives the current debug level
00048 { 00049 #if defined(DEBUG_LEVEL) 00050 return DEBUG_LEVEL ; 00051 #else 00052 return -1 ; 00053 #endif 00054 } // debug_level
|
|
|
|
Returns the empty instance
00027 { 00028 if (! empty_instance) { 00029 std::string empty = "" ; 00030 empty_instance = new ers::Context(empty,0,empty,empty,empty,empty,empty,empty) ; 00031 } // if 00032 return empty_instance ; 00033 } // empty
|
|
|
|
00098 { 00099 return m_file_name ; 00100 } // file
|
|
|
|
00114 { 00115 return m_function_name ; 00116 } // function
|
|
type of target host
|
|
type of target host Tries to gues the host name
00039 { 00040 if (s_host_type.empty()) build_host_type() ; 00041 return s_host_type ; 00042 } // plateform
|
|
|
|
00106 { 00107 return m_line_number ; 00108 } // line
|
|
|
|
00185 { 00186 return m_package_name ; 00187 } // package_name
|
|
|
|
00124 { 00125 if (m_position.empty()) { 00126 std::ostringstream position_s ; 00127 if (! m_package_name.empty()) { 00128 position_s << m_package_name << ":" ; 00129 } 00130 if (! m_file_name.empty()) { 00131 const std::string::size_type p = m_file_name.rfind('/') ; 00132 if (std::string::npos == p) { 00133 position_s << m_file_name ; 00134 } else { 00135 position_s << (m_file_name.substr(p+1)) ; 00136 } // 00137 position_s << ":" << m_line_number << " "; 00138 } 00139 if (! m_function_name.empty()) { 00140 position_s << "(" << m_function_name << ")" ; 00141 } // if 00142 m_position = position_s.str(); 00143 } // cached version not calculated 00144 return m_position ; 00145 } // position
|
|
|
|
00232 { 00233 std::vector<std::string> qualif = default_qualifiers ; 00234 if (! m_package_name.empty()) { 00235 qualif.push_back(m_package_name) ; 00236 } // if 00237 return qualif ; 00238 } // qualifiers
|
|
|
|
00223 { 00224 return m_stack_frames[i] ; 00225 } // stack_frame
|
|
|
|
00219 { 00220 return m_stack_frames.size(); 00221 } // stack_frames
|
|
vector of default qualifiers |
|
vector of default qualifiers |
|
|
|
|
|
compilation (cache) |
|
compilation date |
|
compilation time |
|
compilation string (cache) |
|
compiler name |
|
compiler version |
|
source file-name |
|
source function name (can be pretty printed or not) |
|
source line-number |
|
|
|
code position (cache) |
|
|
|
|
|
host_type |