All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
printBacktrace_test.cc
Go to the documentation of this file.
1 
3 
4 // C/C++ standard libraries
5 #include <iostream>
6 #include <sstream>
7 #include <string>
8 #include <vector>
9 
10 
11 struct AClass {
12  void Do()
13  {
14  std::cout << present() << ": Do()" << std::endl;
16  }
17 
18  std::string present() const
19  {
20  std::ostringstream sstr;
21  sstr << lar::debug::demangle(this) << "[" << ((void*) this) << "]";
22  return sstr.str();
23  } // present()
24 
25 }; // AClass
26 
27 
28 struct BClass {
29  void Do()
30  {
31  std::cout << present() << ": Do()" << std::endl;
33  a.Do();
34  }
35  std::string present() const
36  {
37  std::ostringstream sstr;
38  sstr << lar::debug::demangle(this) << "[" << ((void*) this) << "]";
39  return sstr.str();
40  } // present()
41 
43 }; // BClass
44 
45 
46 struct CClass {
47  CClass() { Do(); }
48 
49  void Do()
50  {
51  std::cout << present() << ": Do()" << std::endl;
53  a.Do();
54  }
55  std::string present() const
56  {
57  std::ostringstream sstr;
58  sstr << lar::debug::demangle(this) << "[" << ((void*) this) << "]";
59  return sstr.str();
60  } // present()
61 
63 }; // CClass
64 
65 
66 int main(int /* argc */, char** /* argv */) {
67 
68  AClass a;
69  a.Do();
70 
71  BClass b;
72  b.Do();
73 
74  // create test classes in a deeper, non-local context
75  std::vector<CClass> v [[gnu::unused]] (2);
76 
77  return 0;
78 } // main()
79 
80 
std::string demangle(T const *=nullptr)
Outputs a demangled name for type T.
Definition: DebugUtils.h:348
std::string present() const
process_name gaushit a
Functions to help debugging by instrumenting code.
int main(int argc, char **argv)
void printBacktrace(Stream &&out, BacktracePrintOptions options)
Prints the full backtrace into a stream.
Definition: DebugUtils.h:403
std::string present() const
BEGIN_PROLOG could also be cout
std::string present() const