|
Boost : |
Subject: Re: [boost] GDB-like debugger for template metaprograms
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2014-11-29 12:56:36
On 26/11/2014 21:22, Abel Sinkovics wrote:
> Hi,
>
> Metashell 2.0.0 has a template metaprogram debugger with a GDB-like
> interface (thanks to András Kucsma), which can be useful for Boost
> developers. It can show you how your metaprogram is executed
> step-by-step. You can set breakpoints, step into or over the
> metafunction calls and inspect the "template metaprogramming stack
> trace" at any point during this: the chain of recursive template
> instantiations that lead to that point. Here is an example:
>
> > #include <boost/mpl/transform.hpp>
> > #include <boost/mpl/vector_c.hpp>
> > #include <boost/mpl/plus.hpp>
> > #include <boost/mpl/lambda.hpp>
> > #include <boost/mpl/int.hpp>
> > using namespace boost::mpl;
> > #msh mdb transform<vector_c<int, 1, 2, 3, 4, 5>, plus<_1,
> int_<1>>>::type
> For help, type "help".
> Metaprogram started
> (mdb) rbreak ^boost::mpl::plus
> Breakpoint "^boost::mpl::plus" will stop the execution on 25 locations
> (mdb) continue
> Breakpoint "^boost::mpl::plus" reached
> boost::mpl::plus<mpl_::integral_c<int, 1>, mpl_::int_<1>, mpl_::na,
> mpl_::na, mpl_::na> (Memoization)
> (mdb) bt
> #0 boost::mpl::plus<mpl_::integral_c<int, 1>, mpl_::int_<1>, mpl_::na,
> mpl_::na, mpl_::na> (Memoization)
> #1 boost::mpl::quote_impl<boost::mpl::plus<mpl_::integral_c<int, 1>,
> mpl_::int_<1>, mpl_::na, mpl_::na, mpl_::na>, true> (TemplateInstantiation)
> #2 boost::mpl::quote5<plus, mpl_::void_>::apply<mpl_::integral_c<int,
> 1>, mpl_::int_<1>, mpl_::na, mpl_::na, mpl_::na> (TemplateInstantiation)
> #3 boost::mpl::apply_wrap5<boost::mpl::quote5<plus, mpl_::void_>,
> mpl_::integral_c<int, 1>, mpl_::int_<1>, mpl_::na, mpl_::na, mpl_::na>
> (TemplateInstantiation)
> ...
> #19 transform<vector_c<int, 1, 2, 3, 4, 5>, plus<_1, int_<1>>>::type
From a glance, it appears to be missing important things to make it useful:
- pretty printing complex types so that you can actually read them
I don't think the formatter thing is a solution.
Consider an arbitrarily deep expression template tree, for example.
- easily get the source responsible for the instantiation
full path and line information for each element in the backtrace is
needed. Ideally you want to output that in a format where most smart
editors can directly recognize it and jump there in a click.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk