Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::LibUnwindStackTraceService Class Reference

Function call trace service using libunwind. More...

Inheritance diagram for Arcane::LibUnwindStackTraceService:
Collaboration diagram for Arcane::LibUnwindStackTraceService:

Classes

struct  ProcInfo
 Information about a memory address. More...

Public Member Functions

 LibUnwindStackTraceService (const ServiceBuildInfo &sbi)
 LibUnwindStackTraceService (ITraceMng *tm)
void build () override
StackTrace stackTrace (int first_function) override
 Character string indicating the call stack.
StackTrace stackTraceFunction (int function_index) override
 Returns the current call stack.
Public Member Functions inherited from Arcane::TraceAccessor
 TraceAccessor (ITraceMng *m)
 Constructs an accessor via the trace manager m.
 TraceAccessor (const TraceAccessor &rhs)
 Copy constructor.
TraceAccessoroperator= (const TraceAccessor &rhs)
 Copy assignment operator.
virtual ~TraceAccessor ()
 Frees resources.
ITraceMngtraceMng () const
 Trace manager.
TraceMessage info () const
 Flow for an information message.
TraceMessage pinfo () const
 Flow for a parallel information message.
TraceMessage info (char category) const
 Flow for an information message of a given category.
TraceMessage pinfo (char category) const
 Flow for a parallel information message of a given category.
TraceMessage info (bool v) const
 Flow for an information message.
TraceMessage warning () const
 Flow for a warning message.
TraceMessage pwarning () const
TraceMessage error () const
 Flow for an error message.
TraceMessage perror () const
TraceMessage log () const
 Flow for a log message.
TraceMessage plog () const
 Flow for a log message.
TraceMessage logdate () const
 Flow for a log message preceded by the date.
TraceMessage fatal () const
 Flow for a fatal error message.
TraceMessage pfatal () const
 Flow for a parallel fatal error message.
TraceMessageDbg debug (Trace::eDebugLevel=Trace::Medium) const
 Flow for a debug message.
Trace::eDebugLevel configDbgLevel () const
 Debug level of the configuration file.
TraceMessage info (Int32 verbose_level) const
 Flow for an information message of a given level.
TraceMessage linfo () const
 Flow for an information message with the local information level of this instance.
TraceMessage linfo (Int32 relative_level) const
 Flow for an information message with the local information level of this instance.
void fatalMessage (const StandaloneTraceMessage &o) const

Private Types

using ProcInfoMap = std::map<unw_word_t, ProcInfo>

Private Member Functions

ProcInfo _getFuncInfo (unw_word_t ip, unw_cursor_t *cursor)
ProcInfo _getFuncInfo (const void *ip)
 Retrieves the function name via dladdr.
String _getGDBStack ()
StackTrace _backtraceStackTrace (const FixedStackFrameArray &stack_frames)
 Call stack via the backtrace function.
String _generateFileAndOffset (const FixedStackFrameArray &stack_frames)
 Generates a list of file names and offsets for a call stack.
FixedStackFrameArray _backtraceStackFrame (int first_function)
 Call stack via the backtrace function.

Private Attributes

ProcInfoMap m_proc_name_map
std::mutex m_proc_name_map_mutex
bool m_want_gdb_info = false
bool m_use_backtrace = false
DWHandler m_dw_handler

Additional Inherited Members

Protected Member Functions inherited from Arcane::TraceAccessor
void _setLocalVerboseLevel (Int32 v)
Int32 _localVerboseLevel () const

Detailed Description

Function call trace service using libunwind.

Definition at line 178 of file LibUnwindStackTraceService.cc.

Member Typedef Documentation

◆ ProcInfoMap

using Arcane::LibUnwindStackTraceService::ProcInfoMap = std::map<unw_word_t, ProcInfo>
private

Definition at line 243 of file LibUnwindStackTraceService.cc.

Constructor & Destructor Documentation

◆ LibUnwindStackTraceService() [1/2]

Arcane::LibUnwindStackTraceService::LibUnwindStackTraceService ( const ServiceBuildInfo & sbi)
inlineexplicit

Definition at line 216 of file LibUnwindStackTraceService.cc.

◆ LibUnwindStackTraceService() [2/2]

Arcane::LibUnwindStackTraceService::LibUnwindStackTraceService ( ITraceMng * tm)
inlineexplicit

Definition at line 220 of file LibUnwindStackTraceService.cc.

Member Function Documentation

◆ _backtraceStackFrame()

FixedStackFrameArray Arcane::LibUnwindStackTraceService::_backtraceStackFrame ( int first_function)
private

Call stack via the backtrace function.

Definition at line 489 of file LibUnwindStackTraceService.cc.

References Arcane::FixedStackFrameArray::addFrame().

Referenced by stackTrace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _backtraceStackTrace()

StackTrace Arcane::LibUnwindStackTraceService::_backtraceStackTrace ( const FixedStackFrameArray & stack_frames)
private

Call stack via the backtrace function.

Definition at line 506 of file LibUnwindStackTraceService.cc.

References Arcane::TraceAccessor::pinfo().

Referenced by stackTrace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _generateFileAndOffset()

String Arcane::LibUnwindStackTraceService::_generateFileAndOffset ( const FixedStackFrameArray & stack_frames)
private

Generates a list of file names and offsets for a call stack.

Generates a character string containing for each address in the call stack stack_frames the name of the file containing the symbol and the offset of this address in that file.

The output format allows reading by tools such as addr2line or llmv-symbolizer.

Definition at line 541 of file LibUnwindStackTraceService.cc.

References Arcane::TraceAccessor::pinfo().

Referenced by stackTrace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _getFuncInfo() [1/2]

LibUnwindStackTraceService::ProcInfo Arcane::LibUnwindStackTraceService::_getFuncInfo ( const void * addr)
private

Retrieves the function name via dladdr.

Todo
: make thread-safe

Definition at line 317 of file LibUnwindStackTraceService.cc.

References Arcane::LibUnwindStackTraceService::ProcInfo::m_name.

◆ _getFuncInfo() [2/2]

LibUnwindStackTraceService::ProcInfo Arcane::LibUnwindStackTraceService::_getFuncInfo ( unw_word_t ip,
unw_cursor_t * cursor )
private

Definition at line 261 of file LibUnwindStackTraceService.cc.

◆ _getGDBStack()

String Arcane::LibUnwindStackTraceService::_getGDBStack ( )
private

Definition at line 358 of file LibUnwindStackTraceService.cc.

◆ build()

void Arcane::LibUnwindStackTraceService::build ( )
inlineoverridevirtual

Implements Arcane::IStackTraceService.

Definition at line 227 of file LibUnwindStackTraceService.cc.

◆ stackTrace()

StackTrace Arcane::LibUnwindStackTraceService::stackTrace ( int first_function)
overridevirtual

Character string indicating the call stack.

Implements Arcane::IStackTraceService.

Definition at line 381 of file LibUnwindStackTraceService.cc.

References _backtraceStackFrame(), _backtraceStackTrace(), _generateFileAndOffset(), Arcane::FixedStackFrameArray::addFrame(), Arcane::platform::getSymbolizerService(), Arcane::LibUnwindStackTraceService::ProcInfo::m_name, and Arcane::ISymbolizerService::stackTrace().

Here is the call graph for this function:

◆ stackTraceFunction()

StackTrace Arcane::LibUnwindStackTraceService::stackTraceFunction ( int function_index)
overridevirtual

Returns the current call stack.

The first function_index functions of the stack are ignored.

Implements Arcane::IStackTraceService.

Definition at line 455 of file LibUnwindStackTraceService.cc.

References Arcane::LibUnwindStackTraceService::ProcInfo::m_name, and Arcane::StringBuilder::toString().

Here is the call graph for this function:

Member Data Documentation

◆ m_dw_handler

DWHandler Arcane::LibUnwindStackTraceService::m_dw_handler
private

Definition at line 249 of file LibUnwindStackTraceService.cc.

◆ m_proc_name_map

ProcInfoMap Arcane::LibUnwindStackTraceService::m_proc_name_map
private

Definition at line 244 of file LibUnwindStackTraceService.cc.

◆ m_proc_name_map_mutex

std::mutex Arcane::LibUnwindStackTraceService::m_proc_name_map_mutex
private

Definition at line 245 of file LibUnwindStackTraceService.cc.

◆ m_use_backtrace

bool Arcane::LibUnwindStackTraceService::m_use_backtrace = false
private

Definition at line 248 of file LibUnwindStackTraceService.cc.

◆ m_want_gdb_info

bool Arcane::LibUnwindStackTraceService::m_want_gdb_info = false
private

Definition at line 247 of file LibUnwindStackTraceService.cc.


The documentation for this class was generated from the following file: