LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 130 of file DebugUtils.h.

Constructor & Destructor Documentation

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

Default constructor: use default options.

Definition at line 158 of file DebugUtils.h.

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

Constructor: use specified options.

Definition at line 161 of file DebugUtils.h.

161 : options(opts) {}
opt options
Set of current options.
Definition: DebugUtils.h:155

Member Function Documentation

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

Returns a set of default options.

Definition at line 214 of file DebugUtils.h.

References lar::debug::CallInfoPrinter::opt::set().

215  {
216  opt options;
217  options.set(opt::demangled);
218  options.set(opt::library);
219  options.set(opt::shortLibrary);
220  options.set(opt::address);
221  return options;
222  }
Print the library name the function lives in.
Definition: DebugUtils.h:138
Print the instruction pointer memory address.
Definition: DebugUtils.h:136
Use demangled function names when possible.
Definition: DebugUtils.h:137
Print a shorter library name (base name only).
Definition: DebugUtils.h:139
opt options
Set of current options.
Definition: DebugUtils.h:155
opt & set(option_t o, bool set=true)
Set one option o to the specified set value (true by default).
Definition: DebugUtils.h:147
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 207 of file DebugUtils.h.

208  { print(std::forward<Stream>(out), info); }
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:168
template<typename Stream >
void lar::debug::CallInfoPrinter::print ( Stream &&  out,
CallInfo_t const &  info 
) const
inline

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

Definition at line 168 of file DebugUtils.h.

References lar::debug::CallInfo_t::address, lar::debug::CallInfo_t::function(), lar::debug::CallInfoPrinter::opt::has(), 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().

168  {
169  if (!info) {
170  out << info.original << " (?)";
171  return;
172  }
173 
174  if (info.mangledFunctionName.empty()) {
175  if (options.has(opt::library)) {
176  out << "in "
177  << (options.has(opt::shortLibrary)? info.shortLibrary(): info.libraryName);
178  }
179  else out << "unknown";
180  }
181  else {
182  // auto flags = out.flags(); // not available in message facility streams
183  out << info.function();
184  auto offset = info.offset;
185  if (offset && options.has(opt::offset)) {
186  out << " [";
187  if (offset > 0) out << '+';
188  else {
189  out << '-';
190  offset = -offset;
191  }
192  out << std::showbase << std::hex << offset << "]";
193  } // if has offset
194  // out << std::ios::setiosflags(flags);
195  if (!info.libraryName.empty() && options.has(opt::library)) {
196  out << " in "
197  << (options.has(opt::shortLibrary)? info.shortLibrary(): info.libraryName);
198  }
199  }
200  if (info.address && options.has(opt::address))
201  out << " at " << ((void*) info.address);
202  out << std::flush;
203  } // print()
Print the library name the function lives in.
Definition: DebugUtils.h:138
Print the instruction pointer memory address.
Definition: DebugUtils.h:136
bool has(option_t o) const
Returns whether the specified option is set.
Definition: DebugUtils.h:151
Print a shorter library name (base name only).
Definition: DebugUtils.h:139
opt options
Set of current options.
Definition: DebugUtils.h:155
Print the offset from the beginning of function.
Definition: DebugUtils.h:140
void lar::debug::CallInfoPrinter::setDefaultOptions ( )
inline

Sets this object to use a set of default options.

Definition at line 211 of file DebugUtils.h.

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

Override all the options.

Definition at line 164 of file DebugUtils.h.

164 { options = opts; }
opt options
Set of current options.
Definition: DebugUtils.h:155

Member Data Documentation

opt lar::debug::CallInfoPrinter::options

Set of current options.

Definition at line 155 of file DebugUtils.h.


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