⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mips-tdump.c

📁 GCC编译器源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    case bt_Float:		/* float (real) */      strcpy (p1, "float");      break;    case bt_Double:		/* Double (real) */      strcpy (p1, "double");      break;      /* Structures add 1-2 aux words:	 1st word is [ST_RFDESCAPE, offset] pointer to struct def;	 2nd word is file index if 1st word rfd is ST_RFDESCAPE.  */    case bt_Struct:		/* Structure (Record) */      emit_aggregate (p1, aux_ptr[index], aux_ptr[index+1], "struct", fdp);      used_ptr[index] = 1;      if (aux_ptr[index].rndx.rfd == ST_RFDESCAPE)	used_ptr[++index] = 1;      index++;			/* skip aux words */      break;      /* Unions add 1-2 aux words:	 1st word is [ST_RFDESCAPE, offset] pointer to union def;	 2nd word is file index if 1st word rfd is ST_RFDESCAPE.  */    case bt_Union:		/* Union */      emit_aggregate (p1, aux_ptr[index], aux_ptr[index+1], "union", fdp);      used_ptr[index] = 1;      if (aux_ptr[index].rndx.rfd == ST_RFDESCAPE)	used_ptr[++index] = 1;      index++;			/* skip aux words */      break;      /* Enumerations add 1-2 aux words:	 1st word is [ST_RFDESCAPE, offset] pointer to enum def;	 2nd word is file index if 1st word rfd is ST_RFDESCAPE.  */    case bt_Enum:		/* Enumeration */      emit_aggregate (p1, aux_ptr[index], aux_ptr[index+1], "enum", fdp);      used_ptr[index] = 1;      if (aux_ptr[index].rndx.rfd == ST_RFDESCAPE)	used_ptr[++index] = 1;      index++;			/* skip aux words */      break;    case bt_Typedef:		/* defined via a typedef, isymRef points */      strcpy (p1, "typedef");      break;    case bt_Range:		/* subrange of int */      strcpy (p1, "subrange");      break;    case bt_Set:		/* pascal sets */      strcpy (p1, "set");      break;    case bt_Complex:		/* fortran complex */      strcpy (p1, "complex");      break;    case bt_DComplex:		/* fortran double complex */      strcpy (p1, "double complex");      break;    case bt_Indirect:		/* forward or unnamed typedef */      strcpy (p1, "forward/unnamed typedef");      break;    case bt_FixedDec:		/* Fixed Decimal */      strcpy (p1, "fixed decimal");      break;    case bt_FloatDec:		/* Float Decimal */      strcpy (p1, "float decimal");      break;    case bt_String:		/* Varying Length Character String */      strcpy (p1, "string");      break;    case bt_Bit:		/* Aligned Bit String */      strcpy (p1, "bit");      break;    case bt_Picture:		/* Picture */      strcpy (p1, "picture");      break;    case bt_Void:		/* Void */      strcpy (p1, "void");      break;    default:      sprintf (p1, "Unknown basic type %d", (int) basic_type);      break;    }  p1 += strlen (buffer1);  /*   * If this is a bitfield, get the bitsize.   */  if (u.ti.fBitfield)    {      int bitsize;      used_ptr[index] = 1;      bitsize = aux_ptr[index++].width;      sprintf (p1, " : %d", bitsize);      p1 += strlen (buffer1);    }  /*   * Deal with any qualifiers.   */  if (qualifiers[0].type != tq_Nil)    {      /*       * Snarf up any array bounds in the correct order.  Arrays       * store 5 successive words in the aux. table:       *	word 0	RNDXR to type of the bounds (ie, int)       *	word 1	Current file descriptor index       *	word 2	low bound       *	word 3	high bound (or -1 if [])       *	word 4	stride size in bits       */      for (i = 0; i < 7; i++)	{	  if (qualifiers[i].type == tq_Array)	    {	      qualifiers[i].low_bound  = aux_ptr[index+2].dnLow;	      qualifiers[i].high_bound = aux_ptr[index+3].dnHigh;	      qualifiers[i].stride     = aux_ptr[index+4].width;	      used_ptr[index] = 1;	      used_ptr[index+1] = 1;	      used_ptr[index+2] = 1;	      used_ptr[index+3] = 1;	      used_ptr[index+4] = 1;	      index += 5;	    }	}      /*       * Now print out the qualifiers.       */      for (i = 0; i < 6; i++)	{	  switch (qualifiers[i].type)	    {	    case tq_Nil:	    case tq_Max:	      break;	    case tq_Ptr:	      strcpy (p2, "ptr to ");	      p2 += sizeof ("ptr to ")-1;	      break;	    case tq_Vol:	      strcpy (p2, "volatile ");	      p2 += sizeof ("volatile ")-1;	      break;	    case tq_Far:	      strcpy (p2, "far ");	      p2 += sizeof ("far ")-1;	      break;	    case tq_Proc:	      strcpy (p2, "func. ret. ");	      p2 += sizeof ("func. ret. ");	      break;	    case tq_Array:	      {		int first_array = i;		int j;		/* Print array bounds reversed (ie, in the order the C		   programmer writes them).  C is such a fun language....  */		while (i < 5 && qualifiers[i+1].type == tq_Array)		  i++;		for (j = i; j >= first_array; j--)		  {		    strcpy (p2, "array [");		    p2 += sizeof ("array [")-1;		    if (qualifiers[j].low_bound != 0)		      sprintf (p2,			       "%ld:%ld {%ld bits}",			       (long) qualifiers[j].low_bound,			       (long) qualifiers[j].high_bound,			       (long) qualifiers[j].stride);		    else if (qualifiers[j].high_bound != -1)		      sprintf (p2,			       "%ld {%ld bits}",			       (long) (qualifiers[j].high_bound + 1),			       (long) (qualifiers[j].stride));		    else		      sprintf (p2, " {%ld bits}", (long) (qualifiers[j].stride));		    p2 += strlen (p2);		    strcpy (p2, "] of ");		    p2 += sizeof ("] of ")-1;		  }	      }	      break;	    }	}    }  strcpy (p2, buffer1);  return buffer2;}/* Print out the global file header for object files.  */voidprint_global_hdr (ptr)     struct filehdr *ptr;{  char *time = ctime ((time_t *)&ptr->f_timdat);  ushort flags = ptr->f_flags;  printf("Global file header:\n");  printf("    %-*s 0x%x\n",    24, "magic number",	     (ushort) ptr->f_magic);  printf("    %-*s %d\n",      24, "# sections",	     (int)    ptr->f_nscns);  printf("    %-*s %ld, %s",   24, "timestamp",		     (long)   ptr->f_timdat, time);  printf("    %-*s %ld\n",     24, "symbolic header offset", (long)   ptr->f_symptr);  printf("    %-*s %ld\n",     24, "symbolic header size",   (long)   ptr->f_nsyms);  printf("    %-*s %ld\n",     24, "optional header",	     (long)   ptr->f_opthdr);  printf("    %-*s 0x%x",     24, "flags",		     (ushort) flags);  if ((flags & F_RELFLG) != 0)    printf (", F_RELFLG");  if ((flags & F_EXEC) != 0)    printf (", F_EXEC");  if ((flags & F_LNNO) != 0)    printf (", F_LNNO");  if ((flags & F_LSYMS) != 0)    printf (", F_LSYMS");  if ((flags & F_MINMAL) != 0)    printf (", F_MINMAL");  if ((flags & F_UPDATE) != 0)    printf (", F_UPDATE");  if ((flags & F_SWABD) != 0)    printf (", F_SWABD");  if ((flags & F_AR16WR) != 0)    printf (", F_AR16WR");  if ((flags & F_AR32WR) != 0)    printf (", F_AR32WR");  if ((flags & F_AR32W) != 0)    printf (", F_AR32W");  if ((flags & F_PATCH) != 0)    printf (", F_PATCH/F_NODF");  printf ("\n\n");}/* Print out the symbolic header.  */voidprint_sym_hdr (sym_ptr)     HDRR *sym_ptr;{  int width = 20;  printf("Symbolic header, magic number = 0x%04x, vstamp = %d.%d:\n\n",	 sym_ptr->magic & 0xffff,	 (sym_ptr->vstamp & 0xffff) >> 8,	 sym_ptr->vstamp & 0xff);  printf("    %-*s %11s %11s %11s\n", width, "Info", "Offset", "Number", "Bytes");  printf("    %-*s %11s %11s %11s\n", width, "====", "======", "======", "=====\n");  printf("    %-*s %11ld %11ld %11ld [%d]\n", width, "Line numbers",	 (long) sym_ptr->cbLineOffset,	 (long) sym_ptr->cbLine,	 (long) sym_ptr->cbLine,	 (int) sym_ptr->ilineMax);  printf("    %-*s %11ld %11ld %11ld\n", width, "Dense numbers",	 (long) sym_ptr->cbDnOffset,	 (long) sym_ptr->idnMax,	 (long) (sym_ptr->idnMax * sizeof (DNR)));  printf("    %-*s %11ld %11ld %11ld\n", width, "Procedures Tables",	 (long) sym_ptr->cbPdOffset,	 (long) sym_ptr->ipdMax,	 (long) (sym_ptr->ipdMax * sizeof (PDR)));  printf("    %-*s %11ld %11ld %11ld\n", width, "Local Symbols",	 (long) sym_ptr->cbSymOffset,	 (long) sym_ptr->isymMax,	 (long) (sym_ptr->isymMax * sizeof (SYMR)));  printf("    %-*s %11ld %11ld %11ld\n", width, "Optimization Symbols",	 (long) sym_ptr->cbOptOffset,	 (long) sym_ptr->ioptMax,	 (long) (sym_ptr->ioptMax * sizeof (OPTR)));  printf("    %-*s %11ld %11ld %11ld\n", width, "Auxiliary Symbols",	 (long) sym_ptr->cbAuxOffset,	 (long) sym_ptr->iauxMax,	 (long) (sym_ptr->iauxMax * sizeof (AUXU)));  printf("    %-*s %11ld %11ld %11ld\n", width, "Local Strings",	 (long) sym_ptr->cbSsOffset,	 (long) sym_ptr->issMax,	 (long) sym_ptr->issMax);  printf("    %-*s %11ld %11ld %11ld\n", width, "External Strings",	 (long) sym_ptr->cbSsExtOffset,	 (long) sym_ptr->issExtMax,	 (long) sym_ptr->issExtMax);  printf("    %-*s %11ld %11ld %11ld\n", width, "File Tables",	 (long) sym_ptr->cbFdOffset,	 (long) sym_ptr->ifdMax,	 (long) (sym_ptr->ifdMax * sizeof (FDR)));  printf("    %-*s %11ld %11ld %11ld\n", width, "Relative Files",	 (long) sym_ptr->cbRfdOffset,	 (long) sym_ptr->crfd,	 (long) (sym_ptr->crfd * sizeof (ulong)));  printf("    %-*s %11ld %11ld %11ld\n", width, "External Symbols",	 (long) sym_ptr->cbExtOffset,	 (long) sym_ptr->iextMax,	 (long) (sym_ptr->iextMax * sizeof (EXTR)));}/* Print out a symbol.  */voidprint_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp)     SYMR *sym_ptr;     int number;     char *strbase;     AUXU *aux_base;     int ifd;     FDR *fdp;{  sc_t storage_class = (sc_t) sym_ptr->sc;  st_t symbol_type   = (st_t) sym_ptr->st;  ulong index	     = sym_ptr->index;  char *used_ptr     = aux_used + (aux_base - aux_symbols);  scope_t *scope_ptr;  printf ("\n    Symbol# %d: \"%s\"\n", number, sym_ptr->iss + strbase);  if (aux_base != (AUXU *) 0 && index != indexNil)    switch (symbol_type)      {      case st_Nil:      case st_Label:	break;      case st_File:      case st_Block:	printf ("      End+1 symbol: %ld\n", index);	if (want_scope)	  {	    if (free_scope == (scope_t *) 0)	      scope_ptr = (scope_t *) malloc (sizeof (scope_t));	    else	      {		scope_ptr = free_scope;		free_scope = scope_ptr->prev;	      }	    scope_ptr->open_sym = number;	    scope_ptr->st = symbol_type;	    scope_ptr->sc = storage_class;	    scope_ptr->prev = cur_scope;	    cur_scope = scope_ptr;	  }	break;      case st_End:	if (storage_class == sc_Text || storage_class == sc_Info)	  printf ("      First symbol: %ld\n", index);	else	  {	    used_ptr[index] = 1;	    printf ("      First symbol: %ld\n", aux_base[index].isym);	  }	if (want_scope)	  {	    if (cur_scope == (scope_t *) 0)	      printf ("      Can't pop end scope\n");	    else	      {		scope_ptr = cur_scope;		cur_scope = scope_ptr->prev;		scope_ptr->prev = free_scope;		free_scope = scope_ptr;	      }	  }	break;      case st_Proc:      case st_StaticProc:	if (MIPS_IS_STAB(sym_ptr))	  ;	else if (ifd == -1)		/* local symbol */	  {	    used_ptr[index] = used_ptr[index+1] = 1;	    printf ("      End+1 symbol: %-7ld   Type:  %s\n",		    aux_base[index].isym,		    type_to_string (aux_base, index+1, fdp));	  }	else			/* global symbol */	  printf ("      Local symbol: %ld\n", index);	if (want_scope)	  {	    if (free_scope == (scope_t *) 0)	      scope_ptr = (scope_t *) malloc (sizeof (scope_t));	    else	      {		scope_ptr = free_scope;		free_scope = scope_ptr->prev;	      }	    scope_ptr->open_sym = number;	    scope_ptr->st = symbol_type;	    scope_ptr->sc = storage_class;	    scope_ptr->prev = cur_scope;	    cur_scope = scope_ptr;	  }	break;#ifdef stStruct      case st_Struct:      case st_Union:      case st_Enum:	printf ("      End+1 symbol: %lu\n", index);	break;#endif      default:	if (!MIPS_IS_STAB (sym_ptr))	  {	    used_ptr[index] = 1;	    printf ("      Type: %s\n",		    type_to_string (aux_base, index, fdp));	  }	break;      }  if (want_scope)    {      printf ("      Scopes:  ");      if (cur_scope == (scope_t *) 0)	printf (" none\n");      else	{	  for (scope_ptr = cur_scope;	       scope_ptr != (scope_t *) 0;	       scope_ptr = scope_ptr->prev)	    {	      char *class;	      if (scope_ptr->st == st_Proc || scope_ptr->st == st_StaticProc)		class = "func.";	      else if (scope_ptr->st == st_File)		class = "file";	      else if (scope_ptr->st == st_Block && scope_ptr->sc == sc_Text)		class = "block";	      else if (scope_ptr->st == st_Block && scope_ptr->sc == sc_Info)		class = "type";	      else		class = "???";	      printf (" %ld [%s]", scope_ptr->open_sym, class);	    }	  printf ("\n");	}    }  printf ("      Value: %-13ld    ",	  (long)sym_ptr->value);  if (ifd == -1)    printf ("String index: %ld\n", (long)sym_ptr->iss);  else    printf ("String index: %-11ld Ifd: %d\n",	    (long)sym_ptr->iss, ifd);  printf ("      Symbol type: %-11sStorage class: %-11s",	  st_to_string (symbol_type), sc_to_string (storage_class));  if (MIPS_IS_STAB(sym_ptr))    {      register int i = sizeof(stab_names) / sizeof(stab_names[0]);      char *stab_name = "stab";      short code = MIPS_UNMARK_STAB(sym_ptr->index);      while (--i >= 0)	if (stab_names[i].code == code)	  {	    stab_name = stab_names[i].string;	    break;	  }      printf ("Index: 0x%lx (%s)\n", (long)sym_ptr->index, stab_name);    }  else if (sym_ptr->st == stLabel && sym_ptr->index != indexNil)    printf ("Index: %ld (line#)\n", (long)sym_ptr->index);  else    printf ("Index: %ld\n", (long)sym_ptr->index);}/* Print out a word from the aux. table in various formats.  */voidprint_aux (u, auxi, used)     AUXU u;     int auxi;     int used;{  printf ("\t%s#%-5d %11ld, [%4ld/%7ld], [%2d %1d:%1d %1x:%1x:%1x:%1x:%1x:%1x]\n",

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -