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中的好几处出现的地方


gcc 中-g对应的源代码和gdb有关的flags和变量 write_symbols_第1张图片


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++);
    }
gcc 中-g对应的源代码和gdb有关的flags和变量 write_symbols_第2张图片

你可能感兴趣的:(源代码,gcc)