Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
gar::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

gar::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:212
gar::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
opts
Definition: ECLAPI.py:241

Member Function Documentation

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

Returns a set of default options.

Definition at line 215 of file DebugUtils.h.

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

209  { 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 gar::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.

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
197  << " in "
198  << (options.has(opt::shortLibrary)? info.shortLibrary(): info.libraryName);
199  }
200  }
201  if (info.address && options.has(opt::address))
202  out << " at " << ((void*) info.address);
203  out << std::flush;
204  } // print()
QTextStream & hex(QTextStream &s)
print the offset from the beginning of function
Definition: DebugUtils.h:140
QTextStream & flush(QTextStream &s)
opt options
set of current options
Definition: DebugUtils.h:155
print a shorter library name (base name only)
Definition: DebugUtils.h:139
print the instruction pointer memory address
Definition: DebugUtils.h:136
print the library name the function lives in
Definition: DebugUtils.h:138
bool has(option_t o) const
Returns whether the specified option is set.
Definition: DebugUtils.h:151
void gar::debug::CallInfoPrinter::setDefaultOptions ( )
inline

Sets this object to use a set of default options.

Definition at line 212 of file DebugUtils.h.

212 { options = defaultOptions(); }
static opt defaultOptions()
Returns a set of default options.
Definition: DebugUtils.h:215
opt options
set of current options
Definition: DebugUtils.h:155
void gar::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
opts
Definition: ECLAPI.py:241

Member Data Documentation

opt gar::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: