14#include "arcane/utils/String.h" 
   15#include "arcane/utils/IStackTraceService.h" 
   16#include "arcane/utils/ISymbolizerService.h" 
   17#include "arcane/utils/NotImplementedException.h" 
   18#include "arcane/utils/StringBuilder.h" 
   20#include "arcane/AbstractService.h" 
   21#include "arcane/ServiceFactory.h" 
   56    _getStack(first_function,frames);
 
   61    return _getStackSymbols(frames);
 
   70    ::SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_INCLUDE_32BIT_MODULES | SYMOPT_UNDNAME | SYMOPT_LOAD_LINES);
 
   71    if (!::SymInitialize(::GetCurrentProcess(), 
nullptr, 
true)) {
 
   80  bool m_is_init = 
false;
 
   81  bool m_is_good = 
false;
 
 
   87void DbgHelpSymContainer::
 
   91  PVOID addrs[FixedStackFrameArray::MAX_FRAME] = { 0 };
 
   92  USHORT nb_frame = CaptureStackBackTrace(first_function + 2, FixedStackFrameArray::MAX_FRAME, addrs, NULL);
 
   93  for (USHORT i = 0; i < nb_frame; i++) {
 
   94    frames.
addFrame(StackFrame((intptr_t)addrs[i]));
 
  101String DbgHelpSymContainer::
 
  108  int nb_frame = frames.size();
 
  109  for (USHORT i = 0; i < nb_frame; i++) {
 
  110    DWORD64 addr = (DWORD64)frames[i].address();
 
  114    ULONG64 buffer[(
sizeof(SYMBOL_INFO) + 1024 + 
sizeof(ULONG64) - 1) / 
sizeof(ULONG64)] = { 0 };
 
  115    SYMBOL_INFO* info = (SYMBOL_INFO*)buffer;
 
  116    info->SizeOfStruct = 
sizeof(SYMBOL_INFO);
 
  117    info->MaxNameLen = 1024;
 
  120    DWORD64 displacement = 0;
 
  121    if (::SymFromAddr(::GetCurrentProcess(), addr, &displacement, info)) {
 
  124      DWORD line_displacement = 0;
 
  125      IMAGEHLP_LINE64 line = {};
 
  126      line.SizeOfStruct = 
sizeof(IMAGEHLP_LINE64);
 
  127      BOOL has_line = SymGetLineFromAddr64(GetCurrentProcess(), addr, &line_displacement, &line);
 
  128      sb.append(std::string_view(info->Name, info->NameLen));
 
  132        sb.append(line.FileName);
 
  134        sb.append(String::fromNumber(line.LineNumber));
 
  139  return sb.toString();
 
  147  std::shared_ptr<DbgHelpSymContainer> m_sym_container;
 
  148  std::shared_ptr<DbgHelpSymContainer> _getStaticContainer()
 
  150    if (!m_sym_container.get())
 
  151      m_sym_container = std::make_shared<DbgHelpSymContainer>();
 
  152    return m_sym_container;
 
  164class ARCANE_STD_EXPORT DbgHelpStackTraceService
 
  179   StackTrace stackTrace(
int first_function) 
override;
 
  180   StackTrace stackTraceFunction(
int function_index) 
override;
 
  183   std::shared_ptr<DbgHelpSymContainer> m_sym_container;
 
  186     if (!m_sym_container.get())
 
  187       m_sym_container = _getStaticContainer();
 
  188     return m_sym_container.get();
 
 
  200  String text = c->getStackSymbols(frames.view());
 
 
  221class ARCANE_STD_EXPORT DbgHelpSymbolizerService
 
  237    return _getContainer()->getStackSymbols(frames);
 
 
  241  std::shared_ptr<DbgHelpSymContainer> m_sym_container;
 
  244    if (!m_sym_container.get())
 
  245      m_sym_container = _getStaticContainer();
 
  246    return m_sym_container.get();
 
 
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro pour déclarer une interface lors de l'enregistrement d'un service.
AbstractService(const ServiceBuildInfo &)
Constructeur à partir d'un ServiceBuildInfo.
Vue constante d'un tableau de type T.
Service de trace des appels de fonctions utilisant 'DbgHelp'.
StackTrace stackTrace(int first_function) override
Chaîne de caractère indiquant la pile d'appel.
void build() override
Construction de niveau build du service.
StackTrace stackTraceFunction(int function_index) override
Nom d'une fonction dans la pile d'appel.
Service de trace des appels de fonctions utilisant la libunwind.
void build() override
Construction de niveau build du service.
String stackTrace(ConstArrayView< StackFrame > frames) override
Informations pour la pile d'appel frames.
Conserve une liste de taille fixe maximale de StackFrame.
void addFrame(const StackFrame &frame)
Ajoute frame à la liste des frames. Si nbFrame() est supérieur ou égal à MAX_FRAME,...
Interface d'un service de trace des appels de fonctions.
Interface d'un service de récupération des symboles du code source.
Structure contenant les informations pour créer un service.
Propriétés de création d'un service.
Informations sur la pile d'appel des fonctions.
Chaîne de caractères unicode.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro pour enregistrer un service.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
@ ST_Application
Le service s'utilise au niveau de l'application.