DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ers::LocalContext Class Reference

#include <LocalContext.hpp>

Inheritance diagram for ers::LocalContext:
[legend]
Collaboration diagram for ers::LocalContext:
[legend]

Public Member Functions

 LocalContext (const char *package_name, const char *filename, int line_number, const char *function_name, bool debug=false)
virtual ~LocalContext ()
virtual Contextclone () const
const char * cwd () const
const char * file_name () const
const char * function_name () const
const char * host_name () const
int line_number () const
const char * package_name () const
pid_t process_id () const
pid_t thread_id () const
void *const * stack_symbols () const
int stack_size () const
int user_id () const
const char * user_name () const
const char * application_name () const
Public Member Functions inherited from ers::Context
virtual ~Context ()
std::string position (int verbosity=ers::Configuration::instance().verbosity_level()) const
std::vector< std::string > stack () const

Static Public Member Functions

static void resetProcessContext ()

Private Attributes

const char *const m_package_name
const char *const m_file_name
const char *const m_function_name
const int m_line_number
const pid_t m_thread_id
void * m_stack [64]
const int m_stack_size

Static Private Attributes

static const LocalProcessContext c_process

Detailed Description

Definition at line 60 of file LocalContext.hpp.

Constructor & Destructor Documentation

◆ LocalContext()

ers::LocalContext::LocalContext ( const char * package_name,
const char * filename,
int line_number,
const char * function_name,
bool debug = false )

creates a new instance of a local context for an issue. This constructor should not be called directly, instead one should use the ERS_HERE macro.

Parameters
package_namename of the current sw package
filenamename of the source code file
line_numberline_number in the source code
function_namename of the current function

Definition at line 87 of file LocalContext.cpp.

98 m_stack_size( debug ? backtrace( m_stack, std::size(m_stack) ) : 0)
99{ ; }
pid_t gettid()
const char * function_name() const
int line_number() const
const char *const m_file_name
const char *const m_function_name
const char * package_name() const
const pid_t m_thread_id
const char *const m_package_name
void debug(const Issue &issue, int level=debug_level())
Definition ers.hpp:85

◆ ~LocalContext()

virtual ers::LocalContext::~LocalContext ( )
inlinevirtual

Definition at line 77 of file LocalContext.hpp.

78 { ; }

Member Function Documentation

◆ application_name()

const char * ers::LocalContext::application_name ( ) const
virtual
Returns
application name

Implements ers::Context.

Definition at line 102 of file LocalContext.cpp.

103{
104 static int pid = ::getpid();
105 static const char * env = ::getenv( "DUNEDAQ_APPLICATION_NAME" ) ? ::getenv( "DUNEDAQ_APPLICATION_NAME" ) : "Undefined";
106
107 if (pid != ::getpid()) {
108 pid = ::getpid();
109 env = ::getenv( "DUNEDAQ_APPLICATION_NAME" ) ? ::getenv( "DUNEDAQ_APPLICATION_NAME" ) : "Undefined";
110 }
111 return env;
112}

◆ clone()

virtual Context * ers::LocalContext::clone ( ) const
inlinevirtual

<

Returns
copy of the current context

Implements ers::Context.

Definition at line 80 of file LocalContext.hpp.

81 { return new LocalContext( *this ); }
LocalContext(const char *package_name, const char *filename, int line_number, const char *function_name, bool debug=false)

◆ cwd()

const char * ers::LocalContext::cwd ( ) const
inlinevirtual

<

Returns
current working directory of the process

Implements ers::Context.

Definition at line 83 of file LocalContext.hpp.

84 { return c_process.m_cwd; }
static const LocalProcessContext c_process

◆ file_name()

const char * ers::LocalContext::file_name ( ) const
inlinevirtual

<

Returns
name of the file which created the issue

Implements ers::Context.

Definition at line 86 of file LocalContext.hpp.

87 { return m_file_name; }

◆ function_name()

const char * ers::LocalContext::function_name ( ) const
inlinevirtual

<

Returns
name of the function which created the issue

Implements ers::Context.

Definition at line 89 of file LocalContext.hpp.

90 { return m_function_name; }

◆ host_name()

const char * ers::LocalContext::host_name ( ) const
inlinevirtual

<

Returns
host where the process is running

Implements ers::Context.

Definition at line 92 of file LocalContext.hpp.

93 { return c_process.m_host_name; }

◆ line_number()

int ers::LocalContext::line_number ( ) const
inlinevirtual

<

Returns
line number, in which the issue has been created

Implements ers::Context.

Definition at line 95 of file LocalContext.hpp.

96 { return m_line_number; }

◆ package_name()

const char * ers::LocalContext::package_name ( ) const
inlinevirtual

<

Returns
CMT package name

Implements ers::Context.

Definition at line 98 of file LocalContext.hpp.

99 { return m_package_name; }

◆ process_id()

pid_t ers::LocalContext::process_id ( ) const
inlinevirtual

<

Returns
process id

Implements ers::Context.

Definition at line 101 of file LocalContext.hpp.

102 { return ::getpid(); }

◆ resetProcessContext()

void ers::LocalContext::resetProcessContext ( )
static

◆ stack_size()

int ers::LocalContext::stack_size ( ) const
inlinevirtual

<

Returns
number of frames in stack

Implements ers::Context.

Definition at line 110 of file LocalContext.hpp.

111 { return m_stack_size; }

◆ stack_symbols()

void *const * ers::LocalContext::stack_symbols ( ) const
inlinevirtual

<

Returns
stack frames

Implements ers::Context.

Definition at line 107 of file LocalContext.hpp.

108 { return m_stack; }

◆ thread_id()

pid_t ers::LocalContext::thread_id ( ) const
inlinevirtual

<

Returns
thread id

Implements ers::Context.

Definition at line 104 of file LocalContext.hpp.

105 { return m_thread_id; }

◆ user_id()

int ers::LocalContext::user_id ( ) const
inlinevirtual

<

Returns
user id

Implements ers::Context.

Definition at line 113 of file LocalContext.hpp.

114 { return c_process.m_uid; }

◆ user_name()

const char * ers::LocalContext::user_name ( ) const
inlinevirtual

<

Returns
user name

Implements ers::Context.

Definition at line 116 of file LocalContext.hpp.

117 { return c_process.m_uname; }

Member Data Documentation

◆ c_process

const ers::LocalProcessContext ers::LocalContext::c_process
staticprivate

Definition at line 124 of file LocalContext.hpp.

◆ m_file_name

const char* const ers::LocalContext::m_file_name
private

source file-name

Definition at line 127 of file LocalContext.hpp.

◆ m_function_name

const char* const ers::LocalContext::m_function_name
private

source function name

Definition at line 128 of file LocalContext.hpp.

◆ m_line_number

const int ers::LocalContext::m_line_number
private

source line-number

Definition at line 129 of file LocalContext.hpp.

◆ m_package_name

const char* const ers::LocalContext::m_package_name
private

source package name

Definition at line 126 of file LocalContext.hpp.

◆ m_stack

void* ers::LocalContext::m_stack[64]
private

stack frames

Definition at line 131 of file LocalContext.hpp.

◆ m_stack_size

const int ers::LocalContext::m_stack_size
private

stack frames number

Definition at line 132 of file LocalContext.hpp.

◆ m_thread_id

const pid_t ers::LocalContext::m_thread_id
private

thread id

Definition at line 130 of file LocalContext.hpp.


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