[cfe-dev] [Templight] Templight "v2" with gdb-style debugger

Nick Lewycky nlewycky at google.com
Wed Jan 7 19:34:46 PST 2015


On 6 January 2015 at 13:09, Porkolab Zoltan <gsd at caesar.elte.hu> wrote:

>
> Hi all,
>
> First of all, Nick: many thanks for helping us. Mikael did a huge work
> refactoring templight and now there are even clients eager to use it:
> https://github.com/sabel83/metashell
>
> On Tue, 6 Jan 2015, Nick Lewycky wrote:
>
>  On 11 March 2014 18:28, Mikael Persson <mikael.s.persson at gmail.com>
>> wrote:
>>
>> Hi Mikael,
>>
>> Sorry to lead with this, but it's important. The llvm project requires
>> that
>> patches be submitted by their author (or authors). If you grabbed the
>> original templight code and refactored it, then it may be coauthored
>> between
>> you and the original authors. Our policy requires that an author submit
>> their own code, not mail in someone else's,
>> see http://llvm.org/docs/DeveloperPolicy.html#attribution-of-changes for
>> specifics.
>>
>
> We completely support Mikael's work on refactoring the original templight.
> Naturally, we happy to adopt Mikael as a co-author or give him any kind of
> authorization to submit this patch.


That is good to hear!

      Changes to existing Clang code-base:
>>
>>
> [...]
>
>   (5) Added callbacks for begin / end of template instantiations. These
>> were added in all the places where the original Templight code had
>> templight calls. This replaces the original templight tracing calls.
>>
>>
>> At a high level, I think that what we currently do in Sema by tracking
>> template instantiations as a stack (Sema::ActiveTemplateInstantiations)
>> should be available in the AST after instantiation is complete. Then we
>> could query the AST to ask why something was instantiated instead of
>> tracing
>> the act of instantiation. Is there any use case for templight where this
>> wouldn't work?
>>
>
> Don't forget, this is a template debugger and profiler function.
>

Got it. I did forget about profiling.

As a debugger we want to follow the chain of template related events even
> if the instantiation was not successfully finished. Unpaired begin-end
> instantiation events may happen and are reported in templight.


I'm not sure what you're describing. Do these ever occur in a way that is
not a bug in clang?

Moreover, this strategy allows templight to work in "safe mode": emitting
> events immediatelly as they happened. This way we have the last events even
> if the compiler crashes - which unfortunatelly may happen for template
> metaprograms.
>

> As a profiler templight assigns timestamps for beginning/end events to
> measure the time clang has spent on that instantiation.
>

I think a template debugger would be a great new major feature for clang,
and I've heard requests for it in person. However, it seems that different
people have different ideas of what exactly "template debugger" means. I
don't know of any effort which is farther along than templight, which
suggests that you have real uses for template debugging rather than
hypothetical users.

Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150107/4dde565b/attachment.html>


More information about the cfe-dev mailing list