43 ProfFuncInfo() : m_index(0), m_do_stack(
false), m_has_func_name(
false)
46 for( Integer i=0; i<MAX_COUNTER; ++i )
50 Int32 index()
const {
return m_index; }
51 void setIndex(Int32 v) { m_index = v; }
52 bool hasFuncName()
const {
return m_has_func_name; }
53 void setHasFuncName(
bool v) { m_has_func_name = v; }
61 Int64 m_counters[MAX_COUNTER];
64 char m_func_name[MAX_FUNC_LEN+10];
75 for( Integer i=0; i<MAX_STACK; ++i )
76 m_funcs_info_indexes[i] = (-1);
81 return ::memcmp(m_funcs_info_indexes,
pfi.m_funcs_info_indexes,MAX_STACK*
sizeof(Int32))<0;
84 Int32 m_funcs_info_indexes[MAX_STACK];
136 typedef size_t size_type;
144 template<
typename _Tp1>
156 template<
typename _Tp1>
157 StaticAlloc(
const StaticAlloc<_Tp1>&) ARCANE_NOEXCEPT { }
159 ~StaticAlloc() ARCANE_NOEXCEPT { }
161 void construct(pointer __p,
const _Tp& __val)
162 { ::new((
void *)__p) _Tp(__val); }
164 void destroy(pointer __p) { __p->~_Tp(); }
166 pointer allocate(size_type ,
const void* = 0)
169 pointer p = &m_buf[m_buf_index];
172 if (m_buf_index>=(
int)(0.9*MAX_STATIC_ALLOC))
173 cout <<
"** WARNING: allocate near max memory\n";
174 if (m_buf_index>=MAX_STATIC_ALLOC)
175 throw FatalErrorException(
"StaticAlloc",
"max static alloc reached");
178 void deallocate(pointer, size_type)
185 static _Tp m_buf[MAX_STATIC_ALLOC];
186 static int m_buf_index ;
210 return this->m_nb_count >
pfi.m_nb_count;
212 const ProfStackInfo& stackInfo()
const {
return m_stack_info; }
213 Int64 nbCount()
const {
return m_nb_count; }
231 const char* func_name;
242#if defined(ARCCORE_OS_WIN32) || defined(ARCCORE_OS_MACOS)
243 typedef std::map<void*,ProfAddrInfo> AddrMap;
244 typedef std::map<Int64,ProfFuncInfo*> FuncMap;
245 typedef std::map<ProfStackInfo,Int64> StackMap;
256 void startProfiling();
258 void stopProfiling();
261 void setFunctionDepth(
int v);
262 void setPeriod(
int v);
263 void setNbEventBeforeGettingStack(Integer v) { m_nb_event_before_getting_stack = v; }
264 Int64 nbEventBeforeGettingStack()
const {
return m_nb_event_before_getting_stack; }
268 StackMap m_stack_map;
269 Int64 m_total_event = 0;
270 Int64 m_total_stack = 0;
271 Int64 m_counters[MAX_COUNTER];
272 Int32 m_current_func_info = 0;
273 ProfFuncInfo m_func_info_buffer[MAX_FUNC];
275 Int64 m_nb_event_before_getting_stack = 5000;
276 int m_function_depth = 3;
277 bool m_use_backtrace =
false;
278 bool m_use_libunwind =
false;
279 MonoFuncAddrGetter* m_mono_func_getter =
nullptr;
280 bool m_is_started =
false;
281 IFuncInfoProvider* m_default_func_info_provider =
nullptr;
282 IFuncInfoProvider* m_libunwind_func_info_provider =
nullptr;
283 IFuncInfoProvider* m_backtrace_func_info_provider =
nullptr;
284 IFuncInfoProvider* m_func_info_provider =
nullptr;
288 void _addEvent(
void* address,
int overflow_event[MAX_COUNTER],
int nb_overflow_event,
289 IStackInfoProvider& stack_info,Integer function_depth);
290 bool _getFunc(
void* addr,FuncAddrInfo&
info);
291 void _sortFunctions(std::set<ProfFuncInfo*,ProfFuncComparer>& sorted_func);
295 ProfFuncInfo* _getNextFuncInfo();
296 ProfFuncInfo& _funcInfoFromIndex(
Int32 index) {
return m_func_info_buffer[index]; }
297 void _storeAddress(
void* address,
bool is_counter0,
int overflow_event[MAX_COUNTER],
int nb_overflow_event,
298 bool* do_add,
bool* do_stack,
bool* func_already_added);
299 void _checkNotStarted();