LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar::debug::CallInfoPrinter Class Reference

Class handling the output of information in a CallInfo_t object. More...

#include "DebugUtils.h"

Classes

struct  opt
 Set of options for printing. More...
 

Public Member Functions

 CallInfoPrinter ()
 Default constructor: use default options. More...
 
 CallInfoPrinter (opt opts)
 Constructor: use specified options. More...
 
void setOptions (opt opts)
 Override all the options. More...
 
template<typename Stream >
void print (Stream &&out, CallInfo_t const &info) const
 Print the content of info into the stream out, using the current options. More...
 
template<typename Stream >
void operator() (Stream &&out, CallInfo_t const &info) const
 Print the content of info into the stream out, using the current options. More...
 
void setDefaultOptions ()
 Sets this object to use a set of default options. More...
 

Static Public Member Functions

static opt defaultOptions ()
 Returns a set of default options. More...
 

Public Attributes

opt options
 Set of current options. More...
 

Detailed Description

Class handling the output of information in a CallInfo_t object.

This class has a "default" print function (also replicated as a call operator), and a set of options that can be tweaked to change the amount of information and format to be printed.

Definition at line 128 of file DebugUtils.h.

Constructor & Destructor Documentation

lar::debug::CallInfoPrinter::CallInfoPrinter ( )
inline

Default constructor: use default options.

Definition at line 159 of file DebugUtils.h.

159 { setDefaultOptions(); }
void setDefaultOptions()
Sets this object to use a set of default options.
Definition: DebugUtils.h:179
lar::debug::CallInfoPrinter::CallInfoPrinter ( opt  opts)
inline

Constructor: use specified options.

Definition at line 162 of file DebugUtils.h.

162 : options(opts) {}
opt options
Set of current options.
Definition: DebugUtils.h:156

Member Function Documentation

static opt lar::debug::CallInfoPrinter::defaultOptions ( )
inlinestatic

Returns a set of default options.

Definition at line 182 of file DebugUtils.h.

References lar::debug::operator<<(), and lar::debug::CallInfoPrinter::opt::set().

183  {
184  opt options;
185  options.set(opt::demangled);
186  options.set(opt::library);
187  options.set(opt::shortLibrary);
188  options.set(opt::address);
189  return options;
190  }
Print the library name the function lives in.
Definition: DebugUtils.h:136
Print the instruction pointer memory address.
Definition: DebugUtils.h:134
Use demangled function names when possible.
Definition: DebugUtils.h:135
Print a shorter library name (base name only).
Definition: DebugUtils.h:137
opt options
Set of current options.
Definition: DebugUtils.h:156
opt & set(option_t o, bool set=true)
Set one option o to the specified set value (true by default).
Definition: DebugUtils.h:145
template<typename Stream >
void lar::debug::CallInfoPrinter::operator() ( Stream &&  out,
CallInfo_t const &  info 
) const
inline

Print the content of info into the stream out, using the current options.

Definition at line 173 of file DebugUtils.h.

174  {
175  print(std::forward<Stream>(out), info);
176  }
void print(Stream &&out, CallInfo_t const &info) const
Print the content of info into the stream out, using the current options.
Definition: DebugUtils.h:350
template<typename Stream >
void lar::debug::CallInfoPrinter::print ( Stream &&  out,
CallInfo_t const &  info 
) const

Print the content of info into the stream out, using the current options.

Definition at line 350 of file DebugUtils.h.

References lar::debug::CallInfo_t::address, lar::debug::CallInfo_t::function(), lar::debug::CallInfo_t::libraryName, lar::debug::CallInfo_t::mangledFunctionName, lar::debug::CallInfo_t::offset, lar::debug::CallInfo_t::original, and lar::debug::CallInfo_t::shortLibrary().

351  {
352  if (!info) {
353  out << info.original << " (?)";
354  return;
355  }
356 
357  if (info.mangledFunctionName.empty()) {
358  if (options.has(opt::library)) {
359  out << "in " << (options.has(opt::shortLibrary) ? info.shortLibrary() : info.libraryName);
360  }
361  else
362  out << "unknown";
363  }
364  else {
365  // auto flags = out.flags(); // not available in message facility streams
366  out << info.function();
367  auto offset = info.offset;
368  if (offset && options.has(opt::offset)) {
369  out << " [";
370  if (offset > 0)
371  out << '+';
372  else {
373  out << '-';
374  offset = -offset;
375  }
376  out << std::showbase << std::hex << offset << "]";
377  } // if has offset
378  // out << std::ios::setiosflags(flags);
379  if (!info.libraryName.empty() && options.has(opt::library)) {
380  out << " in " << (options.has(opt::shortLibrary) ? info.shortLibrary() : info.libraryName);
381  }
382  }
383  if (info.address && options.has(opt::address)) out << " at " << ((void*)info.address);
384  out << std::flush;
385  } // CallInfoPrinter::print()
Print the library name the function lives in.
Definition: DebugUtils.h:136
Print the instruction pointer memory address.
Definition: DebugUtils.h:134
bool has(option_t o) const
Returns whether the specified option is set.
Definition: DebugUtils.h:152
Print a shorter library name (base name only).
Definition: DebugUtils.h:137
opt options
Set of current options.
Definition: DebugUtils.h:156
Print the offset from the beginning of function.
Definition: DebugUtils.h:138
void lar::debug::CallInfoPrinter::setDefaultOptions ( )
inline

Sets this object to use a set of default options.

Definition at line 179 of file DebugUtils.h.

179 { options = defaultOptions(); }
static opt defaultOptions()
Returns a set of default options.
Definition: DebugUtils.h:182
opt options
Set of current options.
Definition: DebugUtils.h:156
void lar::debug::CallInfoPrinter::setOptions ( opt  opts)
inline

Override all the options.

Definition at line 165 of file DebugUtils.h.

165 { options = opts; }
opt options
Set of current options.
Definition: DebugUtils.h:156

Member Data Documentation

opt lar::debug::CallInfoPrinter::options

Set of current options.

Definition at line 156 of file DebugUtils.h.


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