Content #
现在要调试二叉树代码,大体结构如下:
struct node {...};
typedef struct node *nsp;
nsp root;
nsp makenode(int x){...}
void insert(nsp *btp, int x){...}
void printtree(nsp bt){...}
int main(){...}
主要的功能都在insert函数中,printtree函数实现了打印二叉树的功能,请问在GDB中如何设置可以最方便来调试二叉树程序?
在insert函数的结束位置设置断点,在该断点自动执行如下代码:
commands 2
>printf "****** current tree ******\n"
>call printtree(root)
>end