14#include "arcane/utils/ArcanePrecomp.h"
16#include "arcane/utils/ValueConvert.h"
17#include "arcane/utils/NotImplementedException.h"
18#include "arcane/utils/PlatformUtils.h"
19#include "arcane/utils/FatalErrorException.h"
20#include "arcane/utils/TraceInfo.h"
22#include "arcane/FactoryService.h"
23#include "arcane/AbstractService.h"
25#include "arcane/utils/IProfilingService.h"
27#include "arcane/std/ProfilingInfo.h"
65 void switchEvent()
override;
70 void reset()
override;
75 bool m_is_initialized =
false;
83 ProfProfilingService);
88ProfPerformanceService::
89ProfPerformanceService(
const ServiceBuildInfo& sbi)
97ProfPerformanceService::
98~ProfPerformanceService()
106_setTimer(Integer usecond)
108 struct itimerval time_val;
109 struct itimerval otime_val;
110 time_val.it_value.tv_sec = 0;
111 time_val.it_value.tv_usec = usecond;
112 time_val.it_interval.tv_sec = 0;
113 time_val.it_interval.tv_usec = 0;
114 int r = setitimer(ITIMER_PROF,&time_val,&otime_val);
116 cout <<
"** ERROR in setitimer r=" << r <<
'\n';
126ProfInfos* global_infos =
nullptr;
127bool global_is_active =
false;
129int global_timer_period = 10000;
135 static bool is_in_handler =
false;
142 cout <<
"** WARNING: ProfHandler in pending exception\n";
146 cout <<
"** In handler\n";
149 is_in_handler =
true;
152 int overflow_event[MAX_COUNTER];
153 int nb_overflow_event = 1;
154 overflow_event[0] = 0;
156 unw_word_t func_ip = 0;
157 unw_word_t offset = 0;
162 unw_init_local(&cursor, &uc);
163 int current_func = 0;
169 while (unw_step(&cursor) > 0 && current_func<3) {
172 unw_get_reg(&cursor, UNW_REG_IP, &func_ip);
174 char func_name_buf[10000];
175 unw_get_proc_name(&cursor,func_name_buf,10000,&offset);
176 cout <<
"** I=" << current_func <<
" FUNC NAME=" << func_name_buf
177 <<
" ip=" << (
void*)func_ip <<
'\n';
183 global_infos->addEvent((
void*)(func_ip+offset),overflow_event,nb_overflow_event);
185 is_in_handler =
false;
192_arcaneProfilingSigFunc(
int signum)
197 if (global_is_active){
198 arcane_prof_handler();
202 _setTimer(global_timer_period);
212 if (m_is_initialized)
214 m_is_initialized =
true;
230 ::sigset(
SIGPROF,_arcaneProfilingSigFunc);
237void ProfPerformanceService::
281void ProfPerformanceService::
#define ARCANE_REGISTER_APPLICATION_FACTORY(aclass, ainterface, aname)
Enregistre un service de fabrique pour la classe aclass.
Classe de base d'un service.
Tableau d'items de types quelconques.
Interface d'un service de profiling.
Interface d'un gestionnaire de timer.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Structure contenant les informations pour créer un service.
static bool hasPendingException()
Indique si des exceptions sont en cours.
Exception lorsqu'une fonction n'est pas implémentée.
ITraceMng * traceMng() const
Gestionnaire de trace.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-