debugging and profiling c++ template...
TRANSCRIPT
![Page 1: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/1.jpg)
Debugging and Profiling C++ Template Metaprograms
Zoltán Porkolá[email protected]
Ericsson HungaryEötvös Loránd University, Budapest
![Page 2: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/2.jpg)
2015.02.27. C++ Russia 2015 2
● C++ Template Metaprogramming● Possible debugging and profiling techiques● Templight back-end tool● Front-end tools● 3rd party applications – please, contribute!● Vision
Agenda
![Page 3: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/3.jpg)
2015.02.27. C++ Russia 2015 3
C++ Template Metaprograms
● Expression templates (since 1995!)● Active libraries, compile-time adaption● Static interface checking● Simulating language extensions● DSL embedding● Many other areas ...
![Page 4: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/4.jpg)
2015.02.27. C++ Russia 2015 4
Motivation – a personal view
template <class T, class S>? max( T a, S b) // How to define the return value?{ if ( a > b ) return a; else return b;}
int main(){ short is = 3; long il = 2; double d = 3.14; cout << max( il, is); cout << max( is, d); }
![Page 5: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/5.jpg)
2015.02.27. C++ Russia 2015 5
Compile-time vs. Run-time
Compile-time Run-timeCompile-time
![Page 6: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/6.jpg)
2015.02.27. C++ Russia 2015 6
Compile-time vs. Run-time
Compile-time Run-timeCompile-time
3 < 3.14
![Page 7: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/7.jpg)
2015.02.27. C++ Russia 2015 7
Compile-time vs. Run-time
Compile-time Run-timeCompile-time
3 > 2L
3 < 3.14
-1.0 < 0
![Page 8: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/8.jpg)
2015.02.27. C++ Russia 2015 8
Compile-time vs. Run-time
Compile-time Run-timeCompile-time
3 > 2L
3 < 3.14
-1.0 < 0int
std::string
double
long
![Page 9: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/9.jpg)
2015.02.27. C++ Russia 2015 9
Motivation
template <class T, class S>? max( T a, S b) // How to define the return value?{ if ( a > b ) return a; else return b;}
int main(){ short is = 3; long il = 2; double d = 3.14; cout << max( il, is); // long is ''better'' than short cout << max( is, d); // double is ''better'' than short }
![Page 10: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/10.jpg)
2015.02.27. C++ Russia 2015 10
Compile-time vs. Run-time
Run-time
3 > 2L
3 < 3.14
-1.0 < 0int
std::string
double
long
Template design time
Compile-timeTemplate Instantiation
![Page 11: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/11.jpg)
2015.02.27. C++ Russia 2015 11
Compile-time vs. Run-time
Run-timeCompile-timeTemplate Instantiation
3 > 2L
3 < 3.14
-1.0 < 0int
std::string
double
long
T
S
Template design time
![Page 12: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/12.jpg)
2015.02.27. C++ Russia 2015 12
Compile-time vs. Run-time
Run-time
3 > 2L
3 < 3.14
-1.0 < 0int
std::string
double
long
T
S
sizeof(T) < sizeof(S)
Template design time
Compile-timeTemplate Instantiation
![Page 13: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/13.jpg)
2015.02.27. C++ Russia 2015 13
Compile-time vs. Run-time
Run-time
3 > 2L
3 < 3.14
-1.0 < 0int
std::string
double
long
T
S
sizeof(T) < sizeof(S)
Template design time
Compile-timeTemplate Instantiation
![Page 14: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/14.jpg)
2015.02.27. C++ Russia 2015 14
Motivation
template <class T, class S>? max( T a, S b) // How to define the return value?{ if ( a > b ) return a; else return b;}
int main(){ short is = 3; long il = 2; double d = 3.14; cout << max( il, is); // long is ''better'' than short cout << max( is, d); // double is ''better'' than short }
![Page 15: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/15.jpg)
2015.02.27. C++ Russia 2015 15
(de)Motivation
template <class T, class S>auto max( T a, S b) -> decltype(a+b) // C++11{ if ( a > b ) return a; else return b;}
int main(){ short is = 3; long il = 2; double d = 3.14; cout << max( il, is); // -> long cout << max( is, d); // -> double}
![Page 16: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/16.jpg)
2015.02.27. C++ Russia 2015 16
(de)Motivation
template <class T, class S>typename std::common_type<T,S>::value max( T a, S b) // C++11{ if ( a > b ) return a; else return b;}
int main(){ short is = 3; long il = 2; double d = 3.14; cout << max( il, is); // -> long cout << max( is, d); // -> double}
![Page 17: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/17.jpg)
2015.02.27. C++ Russia 2015 17
● Run-time ● Compile-time
![Page 18: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/18.jpg)
2015.02.27. C++ Russia 2015 18
● Functions● Values, literals● Data structures● If/else ● Loop● Assignment● May depend on input
● Run-time ● Compile-time
![Page 19: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/19.jpg)
2015.02.27. C++ Russia 2015 19
● Functions● Values, literals● Data structures● If/else ● Loop● Assignment● May depend on input
● Metafunctions (type)● Const, enum,constexpr● Typelist (type)● Pattern matching● Recursion● Ref. Transparency● Deterministic
● Run-time ● Compile-time
![Page 20: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/20.jpg)
2015.02.27. C++ Russia 2015 20
● Imperative● Object-oriented● Generative● (some) Functional
● Run-time ● Compile-time
![Page 21: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/21.jpg)
2015.02.27. C++ Russia 2015 21
● Imperative● Object-oriented● Generative● (some) Functional
● Pure Functional
● Run-time ● Compile-time
![Page 22: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/22.jpg)
2015.02.27. C++ Russia 2015 22
The usual factorial program ...
template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N };};template <> struct Factorial<0> { enum { value = 1 };};int main() { const int fact5 = Factorial<5>::value;}
![Page 23: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/23.jpg)
2015.02.27. C++ Russia 2015 23
Bugs!!! ...
![Page 24: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/24.jpg)
2015.02.27. C++ Russia 2015 24
The java programmer ...
template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N };};template <> struct Factorial<0> { enum { value = 1 };} //;int main() { const int fact5 = Factorial<5>::value;}
![Page 25: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/25.jpg)
2015.02.27. C++ Russia 2015 25
The java programmer ...
template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N };};template <> struct Factorial<0> { enum { value = 1 };} //;int main() { const int fact5 = Factorial<5>::value;}
$ clang++ fact.cpp fact.cpp:14:2: error: expected ';' after class} ^ ;1 error generated.
![Page 26: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/26.jpg)
2015.02.27. C++ Russia 2015 26
The vim user ...
template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N };};template <> struct Factorial<0> { enum { ivalue = 1 };};int main() { const int fact5 = Factorial<5>::value;}
![Page 27: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/27.jpg)
2015.02.27. C++ Russia 2015 27
The vim user ...
template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N };};template <> struct Factorial<0> { enum { ivalue = 1 };};int main() { const int fact5 = Factorial<5>::value;}
$ clang++ fact.cpp fact.cpp:5:34: error: no member named 'value' in 'Factorial<0>' enum { value = Factorial<N-1>::value * N }; ~~~~~~~~~~~~~~~~^fact.cpp:5:18: note: in instantiation of template class 'Factorial<1>' requested here enum { value = Factorial<N-1>::value * N }; ^fact.cpp:5:18: note: in instantiation of template class 'Factorial<2>' requested here enum { value = Factorial<N-1>::value * N }; ^fact.cpp:5:18: note: in instantiation of template class 'Factorial<3>' requested here enum { value = Factorial<N-1>::value * N }; ^fact.cpp:5:18: note: in instantiation of template class 'Factorial<4>' requested here enum { value = Factorial<N-1>::value * N }; ^fact.cpp:16:21: note: in instantiation of template class 'Factorial<5>' requested here const int fact5 = Factorial<5>::value; ^1 error generated.
![Page 28: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/28.jpg)
2015.02.27. C++ Russia 2015 28
The negative approach ...
template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N };};template <> struct Factorial<0> { enum { value = 1 };};int main() { const int fact5 = Factorial<-5>::value;}
![Page 29: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/29.jpg)
2015.02.27. C++ Russia 2015 29
The negative approach ...
template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N };};template <> struct Factorial<0> { enum { value = 1 };};int main() { const int fact5 = Factorial<-5>::value;}
$ clang++ fact4.cpp fact4.cpp:6:18: fatal error: recursive template instantiation exceeded maximum depth of 512 enum { value = Factorial<N-1>::value * N }; ^fact4.cpp:6:18: note: in instantiation of template class 'Factorial<-517>' requested here enum { value = Factorial<N-1>::value * N };
Fact4.cpp:6:18: note: (skipping 503 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
fact4.cpp:18:21: note: in instantiation of template class 'Factorial<-5>' requested here const int fact5 = Factorial<-5>::value; ^fact4.cpp:6:18: note: use -ftemplate-depth=N to increase recursive template instantiation depth enum { value = Factorial<N-1>::value * N }; ^1 error generated.
![Page 30: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/30.jpg)
2015.02.27. C++ Russia 2015 30
The greedy ...
template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N };};template <> struct Factorial<0> { enum { value = 1 };};int main() { const int fact5 = Factorial<-5>::value;}
$ clang++ -ftemplate-depth=10000 fact4.cpp
![Page 31: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/31.jpg)
2015.02.27. C++ Russia 2015 31
The greedy ...
template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N };};template <> struct Factorial<0> { enum { value = 1 };};int main() { const int fact5 = Factorial<-5>::value;}
$ clang++ -ftemplate-depth=10000 fact4.cpp $ clang++ -ftemplate-depth=10000 fact4.cpp clang: error: unable to execute command: Segmentation faultclang: error: clang frontend command failed due to signal (use -v to see invocation)clang version 3.2 (branches/release_32 180710)Target: x86_64-unknown-linux-gnuThread model: posixclang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.clang: note: diagnostic msg: ********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:Preprocessed source(s) and associated run script(s) are located at:clang: note: diagnostic msg: /tmp/fact4-iy6zKp.cppclang: note: diagnostic msg: /tmp/fact4-iy6zKp.shclang: note: diagnostic msg:
********************
![Page 32: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/32.jpg)
2015.02.27. C++ Russia 2015 32
We need tools● C++ syntax is not designed for metaprogramming● Compilers are not optimised for detecting and
reporting template metaprogram errors● Compilers are not optimised for template
metaprogram execution● Compiler internals are black box for most
programmers● Programmers have less experience with template
metaprograms
![Page 33: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/33.jpg)
2015.02.27. C++ Russia 2015 33
Tool support
● Pretty good support for run-time C++
![Page 34: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/34.jpg)
2015.02.27. C++ Russia 2015 34
Tool support
● Pretty good support for run-time C++● Static analyzers, lint-like tools● Debuggers● Profilers● Code comprehension tools● Style checkers
![Page 35: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/35.jpg)
2015.02.27. C++ Russia 2015 35
Tool support
● Pretty good support for run-time C++● Static analyzers, lint-like tools● Debuggers● Profilers● Code comprehension tools● Style checkers
● Tools for template metaprogramming
![Page 36: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/36.jpg)
2015.02.27. C++ Russia 2015 36
Tool support
● Pretty good support for run-time C++● Static analyzers, lint-like tools● Debuggers● Profilers● Code comprehension tools● Style checkers
● Tools for template metaprogramming● ?
![Page 37: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/37.jpg)
2015.02.27. C++ Russia 2015 37
Tool support
Run-time Compile-time
![Page 38: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/38.jpg)
2015.02.27. C++ Russia 2015 38
Tool support
Run-time Compile-time
![Page 39: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/39.jpg)
2015.02.27. C++ Russia 2015 39
Tool support
Run-time Compile-time
![Page 40: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/40.jpg)
2015.02.27. C++ Russia 2015 40
Tool support
Run-time Compile-time
![Page 41: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/41.jpg)
2015.02.27. C++ Russia 2015 41
Tool support
Run-time Compile-time
![Page 42: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/42.jpg)
2015.02.27. C++ Russia 2015 42
Related work● Debugging
● Static assert/Concept check (Siek-Lumsdaine, McNamara-Smaragdakis, Alexandrescu, others...)
● Warning generation (many attempt)● Instrumentation
● Profiling● Measuring full compilation (Gurtovoy-Abrahams)● Measuring warning apperance (Watanabe)
● Visualize● Source execution● Instantiation graph
![Page 43: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/43.jpg)
2015.02.27. C++ Russia 2015 43
Preprocessor
Instrumentator
Compiler
Warning parser
Positioner
#line mappingTrace file
Position correct trace
Instrumented source
Preprocessed source
template<int i>struct Factorial{/* ---------------- begin inserted ----------- */struct _TEMPLIGHT_0s { int a; };enum { _TEMPLIGHT_0 =Templight::ReportTemplateBegin<_TEMPLIGHT_0s, &_TEMPLIGHT_0s::a>::Value};/* ----------------- end inserted ------------ */enum { value = Factorial<i-1>::value };/* ---------------- begin inserted ----------- */struct _TEMPLIGHT_1s { int a; };enum { _TEMPLIGHT_1 =Templight::ReportTemplateEnd<_TEMPLIGHT_1s, &_TEMPLIGHT_1s::a>::Value};/* ----------------- end inserted ------------ */};template<>struct Factorial<1>{/* ---------------- begin inserted ----------- */struct _TEMPLIGHT_2s { int a; };enum { _TEMPLIGHT_2 =Templight::ReportTemplateBegin<_TEMPLIGHT_2s, &_TEMPLIGHT_2s::a>::Value};/* ----------------- end inserted ------------ */enum { value = 1 };/* ---------------- begin inserted ----------- */struct _TEMPLIGHT_3s { int a; };enum { _TEMPLIGHT_3 =Templight::ReportTemplateEnd<_TEMPLIGHT_3s, &_TEMPLIGHT_3s::a>::Value};/* ----------------- end inserted ------------ */};
GPCE 2006: Porkoláb, Mihalicza, Sipos: Debugging C++ template metaprograms
![Page 44: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/44.jpg)
2015.02.27. C++ Russia 2015 44
Instrumentation
● Advantages● Light-way approach (compared to compiler hack)● Grammar support (we used wave)● Easier to port: just change the warning generator
![Page 45: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/45.jpg)
2015.02.27. C++ Russia 2015 45
Instrumentation
● Advantages● Light-way approach (compared to compiler hack)● Grammar support (we used wave)● Easier to port: just change the warning generator
● Disadvantages● Complex constructs are hard (e.g. inheritance)● Serious distortion in profiling information ● Memoization not detected
![Page 46: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/46.jpg)
2015.02.27. C++ Russia 2015 46
Templight 2.0● Based on LLVM/Clang compiler infrastructure● Patch to
● Detect/measure instantiation● Detect memoization● Put timestamp on events● Measure memory consumption (optional)
● Emit trace in various formats (txt, YAML, XML)● Front-end tools
● Visual debugger● Profiler data viewer
![Page 47: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/47.jpg)
2015.02.27. C++ Russia 2015 47
Templight 2.0
Trace
C++
C++
C++
Templight patch
3rd party tools
Clang source
Interactive debugger/visualizer
Instantiation time and memory profiler
![Page 48: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/48.jpg)
2015.02.27. C++ Russia 2015 48
Installation
● Visit http://plc.inf.elte.hu/templight● Download templight-<timestamp>.tar.gz
● Contains clang patch and the two frontends
● Download Clang source● Patch and build clang● Build front-end tools (optional)
● >=Qt 4.6 and >=Graphviz 2.28.0 required● $ qmake; make
![Page 49: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/49.jpg)
2015.02.27. C++ Russia 2015 49
How to usetemplate<int N>struct Fib{ static const int value = Fib<N-2>::value + Fib<N-1>::value;};template<>struct Fib<0>{ static const int value = 0;};template<>struct Fib<1>{ static const int value = 1;};int main(){ static const int fib5 = Fib<5>::value;}
![Page 50: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/50.jpg)
2015.02.27. C++ Russia 2015 50
How to use$ clang++ -templight fib.cpp
$ lsfib.cpp.trace.xml
$ wc fib.cpp.trace.xml 123 275 3838 fib.cpp.trace.xml
$ head fib.cpp.trace.xml <?xml version="1.0" standalone="yes"?><Trace><TemplateBegin> <Kind>TemplateInstantiation</Kind> <Context context = "Fib<5>"/> <PointOfInstantiation>fib.cpp|22|14</PointOfInstantiation> <TimeStamp time = "421998401.188854"/> <MemoryUsage bytes = "0"/></TemplateBegin><TemplateBegin>
![Page 51: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/51.jpg)
2015.02.27. C++ Russia 2015 51
![Page 52: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/52.jpg)
2015.02.27. C++ Russia 2015 52
![Page 53: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/53.jpg)
2015.02.27. C++ Russia 2015 53
![Page 54: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/54.jpg)
2015.02.27. C++ Russia 2015 54
![Page 55: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/55.jpg)
2015.02.27. C++ Russia 2015 55
![Page 56: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/56.jpg)
2015.02.27. C++ Russia 2015 56
![Page 57: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/57.jpg)
2015.02.27. C++ Russia 2015 57
![Page 58: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/58.jpg)
2015.02.27. C++ Russia 2015 58
![Page 59: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/59.jpg)
2015.02.27. C++ Russia 2015 59
![Page 60: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/60.jpg)
2015.02.27. C++ Russia 2015 60
![Page 61: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/61.jpg)
2015.02.27. C++ Russia 2015 61
![Page 62: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/62.jpg)
2015.02.27. C++ Russia 2015 62
![Page 63: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/63.jpg)
2015.02.27. C++ Russia 2015 63
![Page 64: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/64.jpg)
2015.02.27. C++ Russia 2015 64
Filters#include <iostream>
template<int N>struct Fib{ static const int value = Fib<N-2>::value + Fib<N-1>::value;};template<>struct Fib<0>{ static const int value = 0;};template<>struct Fib<1>{ static const int value = 1;};int main(){ std::cout << Fib<5>::value << std::endl; return 0;}
![Page 65: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/65.jpg)
2015.02.27. C++ Russia 2015 65
Filters$ clang++ -templight fib.cpp
$ lsfib.cpp.trace.xml
$ wc fib.cpp.trace.xml 18291 41765 738233 fib.cpp.trace.xml
$ head fib.cpp.trace.xml <?xml version="1.0" standalone="yes"?><Trace><TemplateBegin> <Kind>DefaultTemplateArgumentInstantiation</Kind> <Context context = "std::basic_string"/> <PointOfInstantiation>/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../include/c++/4.7/bits/stringfwd.h|64|11</PointOfInstantiation> <TimeStamp time = "421999330.595354"/>
![Page 66: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/66.jpg)
2015.02.27. C++ Russia 2015 66
![Page 67: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/67.jpg)
2015.02.27. C++ Russia 2015 67
![Page 68: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/68.jpg)
2015.02.27. C++ Russia 2015 68
![Page 69: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/69.jpg)
2015.02.27. C++ Russia 2015 69
![Page 70: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/70.jpg)
2015.02.27. C++ Russia 2015 70
![Page 71: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/71.jpg)
2015.02.27. C++ Russia 2015 71
![Page 72: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/72.jpg)
2015.02.27. C++ Russia 2015 72
![Page 73: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/73.jpg)
2015.02.27. C++ Russia 2015 73
![Page 74: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/74.jpg)
2015.02.27. C++ Russia 2015 74
![Page 75: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/75.jpg)
2015.02.27. C++ Russia 2015 75
Memory usage$ clang++ -templight-memory fib.cpp
$ lsfib.cpp.memory.trace.xml
$ wc fib.cpp.memory.trace.xml 18291 41765 756365 fib5.cpp.memory.trace.xml
0$ head fib.cpp.trace.xml <?xml version="1.0" standalone="yes"?><Trace><TemplateBegin> <Kind>TemplateInstantiation</Kind> <Context context = "Fib<5>"/> <PointOfInstantiation>fib.cpp|22|14</PointOfInstantiation> <TimeStamp time = "421998401.188854"/> <MemoryUsage bytes = "647664"/></TemplateBegin><TemplateBegin>
![Page 76: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/76.jpg)
2015.02.27. C++ Russia 2015 76
Distortion
● Safe-mode is installed● Invalid profiling info● Flush messages even the compiler crashes
● Internal buffer collects events● Heap allocated, not growing, size = 500.000 ● Flush at end of compilation● Distorsion < 3%● clang++ -templight -trace-capacity=1000000
![Page 77: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/77.jpg)
2015.02.27. C++ Russia 2015 77
Forks, Applications
● Martin Schulze modified client toolshttp://github.com/schulmar/Templar
● Malte Skarupke's blog: comparing instantiation time of unique_ptr, boost::flat_map, etc. http://probablydance.com/2014/04/05/reinventing-the-wheel-for-better-compile-time/
● Ábel Sinkovics: comparing lazy and greedy metaprograms
![Page 78: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/78.jpg)
2015.02.27. C++ Russia 2015 78
Evaluation of lazyness
● Ábel Sinkovics
![Page 79: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/79.jpg)
2015.02.27. C++ Russia 2015 79
Metashell – interactive TMP REPL● Ábel Sinkovics and András Kucsma● Metashell https://github.com/sabel83/metashell● Online demo: http://abel.web.elte.hu/shell
![Page 80: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/80.jpg)
2015.02.27. C++ Russia 2015 80
Mikael Persson's Templight fork
● https://github.com/mikael-s-persson/templight● https://github.com/mikael-s-persson/templight-tools
● Refactored and greatly improved Templight
● Patch is under review● Tools: KCacheGrind format
![Page 81: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/81.jpg)
2015.02.27. C++ Russia 2015 81
Our vision
Trace
3rd party tools
Debugger/visualizer
Other tools
![Page 82: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/82.jpg)
2015.02.27. C++ Russia 2015 82
Summary
● Tool support for C++ metaprogramming● Debugger/profiler requires compiler support● Templight 2.0 based on clang● Mikael's patch for clang is under review● Please use it, give us feadback● Compiler vendors, will you support Templight?
![Page 83: Debugging and Profiling C++ Template Metaprogramsaszt.inf.elte.hu/~gsd/cpp-russia/CppRussia2015Porkolab.pdf · Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb](https://reader031.vdocuments.site/reader031/viewer/2022040604/5ea77392c1b910714a3ad90c/html5/thumbnails/83.jpg)
2015.02.27. C++ Russia 2015 83
Debugging and Profiling C++ Template Metaprogramshttp://plc.inf.elte.hu/templight
Thank you!