Templates and Instantiations

The debugger has no knowledge of templates that may occur in your program. However, you can usually debug template instantiations the same way as the equivalent non-instantiated class or function.

Debugging of template instantiations is illustrated using the following source text:

 

(idb) list 144:13

    144 template <class NODETYPE>

    145 void List<NODETYPE>::append(NODETYPE* const node)

    146 {

    147

    148     if (!_firstNode)

    149         _firstNode = node;

    150     else {

    151         Node* currentNode = _firstNode;

    152         while (currentNode->getNextNode())

    153             currentNode = currentNode->getNextNode();

    154 currentNode->setNextNode(node);

    155     }

    156 }

 

Normal debugging commands then apply to the instantiation (not the template as such):

 

(idb) whatis List<Node>::append

void List<Node>::append(class Node* const)

(idb) stop in List<Node>::append

[#1: stop in void List<Node>::append(class Node* const)]

(idb) run

[1] stopped at [void List<Node>::append(class Node* const):148 0x0804c55e]

    148     if (!_firstNode)

(idb) where 2

>0  0x0804c55e in ((List<Node>*)0xbfffbaa8)->List<Node>::append(node=0x805e5f8) "src/x_list.cxx":148

#1  0x08052edc in main() "src/x_list.cxx":187