gcc 中-g对应的源代码和gdb有关的flags和变量 write_symbols

flags.h 中有write_symbols的定义

/* 1 => write gdb debugging output (using symout.c).
   2 => write dbx debugging output (using dbxout.c).
   3 => write sdb debugging output (using sdbout.c).  */
enum debugger { NO_DEBUG = 0, GDB_DEBUG = 1, DBX_DEBUG = 2, SDB_DEBUG = 3,
        EXTENDED_DBX_DEBUG = 4 };

extern enum debugger write_symbols;


toplev.c   中有对-g的处理

    else if (!strcmp (str, "gg"))

      write_symbols = GDB_DEBUG;
#ifdef DBX_DEBUGGING_INFO
    else if (!strcmp (str, "g0"))
      write_symbols = DBX_DEBUG;
    else if (!strcmp (str, "G0"))
      write_symbols = DBX_DEBUG;
    else if (!strcmp (str, "g"))
      {
        write_symbols = DBX_DEBUG;
        use_gdb_dbx_extensions = 1;
      }
    else if (!strcmp (str, "G"))
      {
        write_symbols = DBX_DEBUG;
        use_gdb_dbx_extensions = 1;
      }
#endif
#ifdef SDB_DEBUGGING_INFO
    else if (!strcmp (str, "g"))
      write_symbols = SDB_DEBUG;
    else if (!strcmp (str, "G"))
      write_symbols = SDB_DEBUG;
    else if (!strcmp (str, "g0"))
      write_symbols = SDB_DEBUG;
    else if (!strcmp (str, "G0"))
      write_symbols = SDB_DEBUG;
#endif
    else if (!strcmp (str, "symout"))
      {
        if (write_symbols == NO_DEBUG)
          write_symbols = GDB_DEBUG;
        sym_file_name = argv[++i];
      }


stmt.c中出现了一次:

  /* Initialize the RTL mechanism.  */
  init_emit (write_symbols);

emit.c中的对应的函数

/* Initialize data structures and variables in this file
   before generating rtl for each function.
   WRITE_SYMBOLS is nonzero if any kind of debugging info
   is to be generated.  */

void
init_emit (write_symbols)
     int write_symbols;
{
  first_insn = NULL;
  last_insn = NULL;
  sequence_stack = NULL;
  cur_insn_uid = 1;
  reg_rtx_no = FIRST_PSEUDO_REGISTER;
  last_linenum = 0;
  last_filename = 0;
  first_label_num = label_num;

  no_line_numbers = ! write_symbols;
 
  /* Init the tables that describe all the pseudo regs.  */

  regno_pointer_flag_length = FIRST_PSEUDO_REGISTER + 100;

  regno_pointer_flag
    = (char *) oballoc (regno_pointer_flag_length);
  bzero (regno_pointer_flag, regno_pointer_flag_length);

  regno_reg_rtx
    = (rtx *) oballoc (regno_pointer_flag_length * sizeof (rtx));
  bzero (regno_reg_rtx, regno_pointer_flag_length * sizeof (rtx));
}

final.c中的好几处出现的地方



toplev.c中调用了final_start_function()函数

  TIMEVAR (final_time,
       {
         assemble_function (decl);
         final_start_function (insns, asm_out_file,
                   write_symbols, optimize);
         final (insns, asm_out_file,
            write_symbols, optimize, 0);
         final_end_function (insns, asm_out_file,
                 write_symbols, optimize);
         fflush (asm_out_file);
       });

filnal.c文件中有对write_symbols的使用

void
final_start_function (first, file, write_symbols, optimize)
     rtx first;
     FILE *file;
     enum debugger write_symbols;
     int optimize;
{
  block_depth = 0;

  this_is_asm_operands = 0;

  /* Record beginning of the symbol-block that's the entire function.  */

  if (write_symbols == GDB_DEBUG)
    {
      pending_blocks[block_depth++] = next_block_index;
      fprintf (file, "\t.gdbbeg %d\n", next_block_index++);
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值