This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Preprocessing debugging technique

Hi,

Is there any way to debug template's source code?

Dave

 

  • There is no direct solution.  But there are two techniques that are helpful.

    This technique helps you see the instantiation of function templates.  When you build with the options --opt_level=0 (or higher) and --src_interlist, the compiler does 2 things.  One, it does not delete the auto-generated assembly file.  This file has the same name as the C++ source file, with the extension changed to .asm.  Second, it inserts comments in the assembly that are a lower level representation of the original C++ source.  When using these options for this purpose, you will probably prefer --opt_level=0 over higher levels, even though this can cost you cycles and memory.

    A technique for seeing the instantiation of data templates appears in this wiki article.  I presume you build with EABI.  If that is true, then ignore the main point of the article.  You will experience none of the problems it describes.  But pay close attention to how it shows whether data templates are instantiated or not.  You can apply those same techniques.

    Thanks and regards,

    -George

  • But is there any way to the fully expanded, plain code like version?

  • Dave Smith62 said:
    But is there any way to the fully expanded, plain code like version?

    What do you mean by "fully expanded" and "plain code"?  I'm guessing you mean you want the compiler to transform C++ templates to C++ code that doesn't use the template keyword.  The term for this is "lowering."  The TI compiler does not lower C++ templates to C++ code, it lowers them to data structures equivalent to C code.  This is done completely internal to the compiler and is not actually generated as a file.  Even if it were, it's quite difficult to understand without knowing how C++ features are implemented at the compiler level.  It is certainly possible to make a tool to lower C++ templates to C++, but I don't know of one offhand.

    As to debugging: are you not able to step through the template functions?  This should certainly be possible if debugging was enabled during compilation.