I had a binary tree program i wanted to debug. I looked for a gdb script that can print all the nodes of a binary tree but could not find a working one. So i wrote one myself. Sample C program. #include <stdio.h> #include <malloc.h> typedef struct node_ { int key; struct node_ *left; struct node_ *right; } node_t; node_t *insert_internal (node_t *root, node_t *new_node) { if (NULL == root) return new_node; if (new_node->key > root->key) { root->right = insert_internal(root->right, new_node); } else { root->left = insert_internal(root->left, new_node); } return root; } node_t *insert (node_t *root, int key) { node_t *new_node = (node_t *) malloc(sizeof(node_t)); ...