Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
garsoft
test
CoreUtils
printBacktrace_test.cc
Go to the documentation of this file.
1
2
#include "CoreUtils/DebugUtils.h"
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
;
15
gar::debug::printBacktrace
(std::cout);
16
}
17
18
std::string
present
()
const
19
{
20
std::ostringstream sstr;
21
sstr <<
gar::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
;
32
gar::debug::printBacktrace
(std::cout);
33
a
.Do();
34
}
35
std::string
present
()
const
36
{
37
std::ostringstream sstr;
38
sstr <<
gar::debug::demangle
(
this
) <<
"["
<< ((
void
*)
this
) <<
"]"
;
39
return
sstr.str();
40
}
// present()
41
42
AClass
a
;
43
};
// BClass
44
45
46
struct
CClass
{
47
CClass
() {
Do
(); }
48
49
void
Do
()
50
{
51
std::cout <<
present
() <<
": Do()"
<<
std::endl
;
52
gar::debug::printBacktrace
(std::cout);
53
a
.Do();
54
}
55
std::string
present
()
const
56
{
57
std::ostringstream sstr;
58
sstr <<
gar::debug::demangle
(
this
) <<
"["
<< ((
void
*)
this
) <<
"]"
;
59
return
sstr.str();
60
}
// present()
61
62
AClass
a
;
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
gar::debug::demangle
std::string demangle(T const *=nullptr)
Outputs a demangled name for type T.
Definition:
DebugUtils.h:56
BClass::Do
void Do()
Definition:
printBacktrace_test.cc:29
string
std::string string
Definition:
nybbler.cc:12
BClass
Definition:
printBacktrace_test.cc:28
AClass::present
std::string present() const
Definition:
printBacktrace_test.cc:18
main
int main(int, char **)
Definition:
printBacktrace_test.cc:66
CClass::CClass
CClass()
Definition:
printBacktrace_test.cc:47
a
const double a
Definition:
gUpMuFluxGen.cxx:164
CClass::Do
void Do()
Definition:
printBacktrace_test.cc:49
BClass::a
AClass a
Definition:
printBacktrace_test.cc:42
gar::debug::printBacktrace
void printBacktrace(Stream &&out, unsigned int maxLines=5, std::string indent=" ", CallInfoPrinter::opt const *options=nullptr)
Prints the full backtrace into a stream.
Definition:
DebugUtils.h:249
CClass
Definition:
printBacktrace_test.cc:46
AClass::Do
void Do()
Definition:
printBacktrace_test.cc:12
AClass
Definition:
printBacktrace_test.cc:11
b
static bool * b
Definition:
config.cpp:1043
CClass::a
AClass a
Definition:
printBacktrace_test.cc:62
BClass::present
std::string present() const
Definition:
printBacktrace_test.cc:35
CClass::present
std::string present() const
Definition:
printBacktrace_test.cc:55
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11