SEGGER Embedded Studio debugger type interpretation files are used by the debugger to provide list and string displays of C++ template container types. The files are structured using XML syntax for its simple construction and parsing.

Consider the following C++ template type

template <class _Type> class VeryBasicArray
{
private:
    size_t m_Count;
    _Type *m_pData; 
public:
    VeryBasicArray(size_t count)
        : m_Count(count)
       , m_pData(new _Type[count])
    {
    }
}

VeryBasicArray<int> basicArray(5);

To display a variable of this type as a list the type interpretation file contains the following entry

<List Name="VeryBasicArray&lt;*&gt;"
        Head="(($(T)*)HEAD).m_pData"        
        Data="(*($(T0)*)CURRENT)"
        Length="(($(T)*)HEAD).m_Count"
        Next="CURRENT+sizeof($(T0))"/>

The Name attribute is used to match the template type name note that the &lt and &gt xml entities are used to match the template argument.

When an entry has been matched the head of the list is located by evaluating the debugger expression in the Head attribute. The debugger expressions can contain macros that refer to the matched template type and will use the symbols HEAD and CURRENT.

The macro $(T) refers to the instantiated template type, for the above example $(T)=VeryBasicArray<int>.

The template arguments are referred to using macros $(T0), for the above example $(T0)=int.

The symbol HEAD is the address of the variable being displayed, for the above example if the variable basicArray is allocated at address 0x20004000 then the Head expression

  ((VeryBasicArray<int>*)0x20004000).m_pData

will be evaluated by the debugger, note that the . operator and the -> operator are equivalent in debugger expressions.

To display an element the debugger will evaluate the Data expression. This expression contains the symbol CURRENT which is the address of the element to display, for the above example the first element is at the address basicArray.m_pData which is allocated at address 0x20008000 then the Data expression

  (*(int*)0x20008000)

will be evaluated by the debugger.

To increment the CURRENT symbol the Next expression

  0x20008000+sizeof(int)

will be evaluated by the debugger.

Before the CURRENT symbol is incremented the debugger needs to check if it is at the end of list. The can be done either as a Condition expression or as a Length expression

  ((VeryBasicArray<int>*)0x20004000).m_Count

The String display is simpler than the List display since the characters are contiguous and optionally null terminated. The Data and Length expressions are supported, for example

<String Name="string"
        Data="*(($(T) *)HEAD)._M_start_of_storage._M_data"
        Length="(($(T) *)HEAD)._M_finish-(($(T) *)HEAD)._M_start_of_storage._M_data"/>

is used to display STLPort std::string types.