首页 > 代码库 > gcc源代码分析,debug_tree()函数,又一利器啊
gcc源代码分析,debug_tree()函数,又一利器啊
gcc源代码分析,debug_rtx()函数,利器啊
print-tree.c
#include "config.h"
#include "tree.h"
#include <stdio.h>
/* Names of tree components.
Used for printing out the tree and error messages. */
#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
char *tree_code_name[] = {
#include "tree.def"
};
#undef DEFTREECODE
同样的debug_tree()函数放在哪里才有用是个重要而有用的问题,
只有看完相关的代码才能知道。
我认为放到expr.c文件中比较好。
if (mode != Pmode && modifier == EXPAND_SUM)
modifier = EXPAND_NORMAL;
fprintf(stderr ,"expand_expr code = %x\n",code);
debug_tree (exp);
/* Ensure we reference a volatile object even if value is ignored. */
if (ignore && TREE_THIS_VOLATILE (exp)
&& mode != VOIDmode && mode != BLKmode)
{
target = gen_reg_rtx (mode);
temp = expand_expr (exp, target, VOIDmode, modifier);
if (temp != target)
emit_move_insn (target, temp);
return target;
}
switch (code) /*再这个关键的分支处,之前打印出语法树是个明智的选择*/
{
case PARM_DECL:
if (DECL_RTL (exp) == 0)
{
error_with_decl (exp, "prior parameter‘s size depends on `%s‘");
return const0_rtx;
}
case FUNCTION_DECL:
case VAR_DECL:
gcc源代码分析,debug_tree()函数,又一利器啊