Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
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 132 of file DebugUtils.h.

Constructor & Destructor Documentation

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

Default constructor: use default options.

Definition at line 160 of file DebugUtils.h.

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

Constructor: use specified options.

Definition at line 163 of file DebugUtils.h.

163 : options(opts) {}
opt options
Set of current options.
Definition: DebugUtils.h:157
opts
Definition: ECLAPI.py:241

Member Function Documentation

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

Returns a set of default options.

Definition at line 181 of file DebugUtils.h.

182  {
183  opt options;
184  options.set(opt::demangled);
185  options.set(opt::library);
186  options.set(opt::shortLibrary);
187  options.set(opt::address);
188  return options;
189  }
Print the library name the function lives in.
Definition: DebugUtils.h:140
opt
Definition: train.py:196
Print the instruction pointer memory address.
Definition: DebugUtils.h:138
Use demangled function names when possible.
Definition: DebugUtils.h:139
Print a shorter library name (base name only).
Definition: DebugUtils.h:141
opt options
Set of current options.
Definition: DebugUtils.h:157
opt & set(option_t o, bool set=true)
Set one option o to the specified set value (true by default).
Definition: DebugUtils.h:149
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 174 of file DebugUtils.h.

175  { 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:354
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 354 of file DebugUtils.h.

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

Sets this object to use a set of default options.

Definition at line 178 of file DebugUtils.h.

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

Override all the options.

Definition at line 166 of file DebugUtils.h.

166 { options = opts; }
opt options
Set of current options.
Definition: DebugUtils.h:157
opts
Definition: ECLAPI.py:241

Member Data Documentation

opt lar::debug::CallInfoPrinter::options

Set of current options.

Definition at line 157 of file DebugUtils.h.


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