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

📄 valprint.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
	fprintf_filtered (stream, ")");      type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);      if (passed_a_ptr)	{	  type_print_args (type, stream);	}      break;    case TYPE_CODE_PTR:    case TYPE_CODE_REF:      type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0);      break;    case TYPE_CODE_FUNC:      type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,				 passed_a_ptr, 0);      if (passed_a_ptr)	fprintf_filtered (stream, ")");      if (!demangled_args)	fprintf_filtered (stream, "()");      break;    case TYPE_CODE_UNDEF:    case TYPE_CODE_STRUCT:    case TYPE_CODE_UNION:    case TYPE_CODE_ENUM:    case TYPE_CODE_INT:    case TYPE_CODE_FLT:    case TYPE_CODE_VOID:    case TYPE_CODE_ERROR:    case TYPE_CODE_CHAR:    case TYPE_CODE_BOOL:    case TYPE_CODE_SET:    case TYPE_CODE_RANGE:    case TYPE_CODE_PASCAL_ARRAY:      /* These types do not need a suffix.  They are listed so that	 gcc -Wall will report types that may not have been considered.  */      break;    }}/* Print the name of the type (or the ultimate pointer target,   function value or array element), or the description of a   structure or union.   SHOW nonzero means don't print this type as just its name;   show its real definition even if it has a name.   SHOW zero means print just typename or struct tag if there is one   SHOW negative means abbreviate structure elements.   SHOW is decremented for printing of structure elements.   LEVEL is the depth to indent by.   We increase it for some recursive calls.  */static voidtype_print_base (type, stream, show, level)     struct type *type;     FILE *stream;     int show;     int level;{  char *name;  register int i;  register int len;  register int lastval;  char *mangled_name;  char *demangled_name;  enum {s_none, s_public, s_private, s_protected} section_type;  QUIT;  wrap_here ("    ");  if (type == NULL)    {      fputs_filtered ("<type unknown>", stream);      return;    }  /* When SHOW is zero or less, and there is a valid type name, then always     just print the type name directly from the type. */  if ((show <= 0) && (TYPE_NAME (type) != NULL))    {      fputs_filtered (TYPE_NAME (type), stream);      return;    }  switch (TYPE_CODE (type))    {    case TYPE_CODE_ARRAY:    case TYPE_CODE_PTR:    case TYPE_CODE_MEMBER:    case TYPE_CODE_REF:    case TYPE_CODE_FUNC:    case TYPE_CODE_METHOD:      type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);      break;    case TYPE_CODE_STRUCT:      fprintf_filtered (stream,			HAVE_CPLUS_STRUCT (type) ? "class " : "struct ");      goto struct_union;    case TYPE_CODE_UNION:      fprintf_filtered (stream, "union ");    struct_union:      if (name = type_name_no_tag (type))	{	  fputs_filtered (name, stream);	  fputs_filtered (" ", stream);	  wrap_here ("    ");	}      if (show < 0)	fprintf_filtered (stream, "{...}");      else	{	  check_stub_type (type);	  	  type_print_derivation_info (stream, type);	  	  fprintf_filtered (stream, "{\n");	  if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))	    {	      if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)		fprintfi_filtered (level + 4, stream, "<incomplete type>\n");	      else		fprintfi_filtered (level + 4, stream, "<no data fields>\n");	    }	  /* Start off with no specific section type, so we can print	     one for the first field we find, and use that section type	     thereafter until we find another type. */	  section_type = s_none;	  /* If there is a base class for this type,	     do not print the field that it occupies.  */	  len = TYPE_NFIELDS (type);	  for (i = TYPE_N_BASECLASSES (type); i < len; i++)	    {	      QUIT;	      /* Don't print out virtual function table.  */	      if ((TYPE_FIELD_NAME (type, i))[5] == CPLUS_MARKER &&		  !strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5))		continue;	      /* If this is a C++ class we can print the various C++ section		 labels. */	      if (HAVE_CPLUS_STRUCT (type))		{		  if (TYPE_FIELD_PROTECTED (type, i))		    {		      if (section_type != s_protected)			{			  section_type = s_protected;			  fprintfi_filtered (level + 2, stream,					     "protected:\n");			}		    }		  else if (TYPE_FIELD_PRIVATE (type, i))		    {		      if (section_type != s_private)			{			  section_type = s_private;			  fprintfi_filtered (level + 2, stream, "private:\n");			}		    }		  else		    {		      if (section_type != s_public)			{			  section_type = s_public;			  fprintfi_filtered (level + 2, stream, "public:\n");			}		    }		}	      print_spaces_filtered (level + 4, stream);	      if (TYPE_FIELD_STATIC (type, i))		{		  fprintf_filtered (stream, "static ");		}	      type_print_1 (TYPE_FIELD_TYPE (type, i),			    TYPE_FIELD_NAME (type, i),			    stream, show - 1, level + 4);	      if (!TYPE_FIELD_STATIC (type, i)		  && TYPE_FIELD_PACKED (type, i))		{		  /* It is a bitfield.  This code does not attempt		     to look at the bitpos and reconstruct filler,		     unnamed fields.  This would lead to misleading		     results if the compiler does not put out fields		     for such things (I don't know what it does).  */		  fprintf_filtered (stream, " : %d",				    TYPE_FIELD_BITSIZE (type, i));		}	      fprintf_filtered (stream, ";\n");	    }	  /* If there are both fields and methods, put a space between. */	  len = TYPE_NFN_FIELDS (type);	  if (len && section_type != s_none)	     fprintf_filtered (stream, "\n");	  /* C++: print out the methods */	  for (i = 0; i < len; i++)	    {	      struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);	      int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);	      char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);	      int is_constructor = name && strcmp(method_name, name) == 0;	      for (j = 0; j < len2; j++)		{		  QUIT;		  if (TYPE_FN_FIELD_PROTECTED (f, j))		    {		      if (section_type != s_protected)			{			  section_type = s_protected;			  fprintfi_filtered (level + 2, stream,					     "protected:\n");			}		    }		  else if (TYPE_FN_FIELD_PRIVATE (f, j))		    {		      if (section_type != s_private)			{			  section_type = s_private;			  fprintfi_filtered (level + 2, stream, "private:\n");			}		    }		  else		    {		      if (section_type != s_public)			{			  section_type = s_public;			  fprintfi_filtered (level + 2, stream, "public:\n");			}		    }		  print_spaces_filtered (level + 4, stream);		  if (TYPE_FN_FIELD_VIRTUAL_P (f, j))		    fprintf_filtered (stream, "virtual ");		  else if (TYPE_FN_FIELD_STATIC_P (f, j))		    fprintf_filtered (stream, "static ");		  if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)		    {		      /* Keep GDB from crashing here.  */		      fprintf (stream, "<undefined type> %s;\n",			       TYPE_FN_FIELD_PHYSNAME (f, j));		      break;		    }		  else if (!is_constructor)		    {		      type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),				  "", stream, 0);		      fputs_filtered (" ", stream);		    }		  if (TYPE_FN_FIELD_STUB (f, j))		    {		      /* Build something we can demangle.  */		      mangled_name = gdb_mangle_name (type, i, j);		      demangled_name =			  cplus_demangle (mangled_name,					  DMGL_ANSI | DMGL_PARAMS);		      if (demangled_name == NULL)			fprintf_filtered (stream, "<badly mangled name %s>",			    mangled_name);		      else 			{			  fprintf_filtered (stream, "%s",			      strchr (demangled_name, ':') + 2);			  free (demangled_name);			}		      free (mangled_name);		    }		  else if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'		        && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER)		    type_print_method_args		      (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",		       method_name, 0, stream);		  else		    type_print_method_args		      (TYPE_FN_FIELD_ARGS (f, j), "",		       method_name,		       TYPE_FN_FIELD_STATIC_P (f, j), stream);		  fprintf_filtered (stream, ";\n");		}	    }	  fprintfi_filtered (level, stream, "}");	}      break;    case TYPE_CODE_ENUM:      fprintf_filtered (stream, "enum ");      if (name = type_name_no_tag (type))	{	  fputs_filtered (name, stream);	  fputs_filtered (" ", stream);	}      wrap_here ("    ");      if (show < 0)	fprintf_filtered (stream, "{...}");      else	{	  fprintf_filtered (stream, "{");	  len = TYPE_NFIELDS (type);	  lastval = 0;	  for (i = 0; i < len; i++)	    {	      QUIT;	      if (i) fprintf_filtered (stream, ", ");	      wrap_here ("    ");	      fputs_filtered (TYPE_FIELD_NAME (type, i), stream);	      if (lastval != TYPE_FIELD_BITPOS (type, i))		{		  fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i));		  lastval = TYPE_FIELD_BITPOS (type, i);		}	      lastval++;	    }	  fprintf_filtered (stream, "}");	}      break;    case TYPE_CODE_VOID:      fprintf_filtered (stream, "void");      break;    case TYPE_CODE_UNDEF:      fprintf_filtered (stream, "struct <unknown>");      break;    case TYPE_CODE_ERROR:      fprintf_filtered (stream, "<unknown type>");      break;    case TYPE_CODE_RANGE:      /* This should not occur */      fprintf_filtered (stream, "<range type>");      break;    default:      /* Handle types not explicitly handled by the other cases,	 such as fundamental types.  For these, just print whatever	 the type name is, as recorded in the type itself.  If there	 is no type name, then complain. */      if (TYPE_NAME (type) != NULL)	{	  fputs_filtered (TYPE_NAME (type), stream);	}      else	{	  error ("Invalid type code (%d) in symbol table.", TYPE_CODE (type));	}      break;    }}#if 0/* Validate an input or output radix setting, and make sure the user   knows what they really did here.  Radix setting is confusing, e.g.   setting the input radix to "10" never changes it!  *//* ARGSUSED */static voidset_input_radix (args, from_tty, c)     char *args;     int from_tty;     struct cmd_list_element *c;{  unsigned radix = *(unsigned *)c->var;  if (from_tty)    printf_filtered ("Input radix set to decimal %d, hex %x, octal %o\n",	radix, radix, radix);}#endif/* ARGSUSED */static voidset_output_radix (args, from_tty, c)     char *args;     int from_tty;     struct cmd_list_element *c;{  unsigned radix = *(unsigned *)c->var;  if (from_tty)    printf_filtered ("Output radix set to decimal %d, hex %x, octal %o\n",	radix, radix, radix);  /* FIXME, we really should be able to validate the setting BEFORE     it takes effect.  */  switch (radix)    {    case 16:      output_format = 'x';      break;    case 10:      output_format = 0;      break;    case 8:      output_format = 'o';		/* octal */      break;    default:      output_format = 0;      error ("Unsupported radix ``decimal %d''; using decimal output",	      radix);    }}/* Both at once */static voidset_radix (arg, from_tty, c)     char *arg;     int from_tty;     struct cmd_list_element *c;{  unsigned radix = *(unsigned *)c->var;  if (from_tty)    printf_filtered ("Radix set to decimal %d, hex %x, octal %o\n",	radix, radix, radix);  input_radix = radix;  output_radix = radix;  set_output_radix (arg, 0, c);}/*ARGSUSED*/static voidset_print (arg, from_tty)     char *arg;     int from_tty;{  printf ("\"set print\" must be followed by the name of a print subcommand.\n");  help_list (setprintlist, "set print ", -1, stdout);}/*ARGSUSED*/static voidshow_print (args, from_tty)     char *args;     int from_tty;{  cmd_show_list (showprintlist, from_tty, "");}void_initialize_valprint (){  struct cmd_list_element *c;  add_prefix_cmd ("print", no_class, set_print,		  "Generic command for setting how things print.",		  &setprintlist, "set print ", 0, &setlist);  add_alias_cmd ("p", "print", no_class, 1, &setlist);   add_alias_cmd ("pr", "print", no_class, 1, &setlist); /* prefer set print														   to     set prompt */  add_prefix_cmd ("print", no_class, show_print,		  "Generic command for showing print settings.",		  &showprintlist, "show print ", 0, &showlist);  add_alias_cmd ("p", "print", no_class, 1, &showlist);   add_alias_cmd ("pr", "print", no_class, 1, &showlist);   add_show_from_set    (add_set_cmd ("elements", no_class, var_uinteger, (char *)&print_max,		  "Set limit on string chars or array elements to print.\n\\"set print elements 0\" causes there to be no limit.",		  &setprintlist),     &showprintlist);  add_show_from_set    (add_set_cmd ("pretty", class_support, var_boolean, (char *)&prettyprint,		  "Set prettyprinting of structures.",		  &setprintlist),     &showprintlist);  add_show_from_set    (add_set_cmd ("union", class_support, var_boolean, (char *)&unionprint,		  "Set printing of unions interior to structures.",		  &setprintlist),     &showprintlist);    add_show_from_set    (add_set_cmd ("vtbl", class_support, var_boolean, (char *)&vtblprint,		  "Set printing of C++ virtual function tables.",		  &setprintlist),     &showprintlist);  add_show_from_set    (add_set_cmd ("array", class_support, var_boolean, (char *)&arrayprint,		  "Set prettyprinting of arrays.",		  &setprintlist),     &showprintlist);  add_show_from_set    (add_set_cmd ("object", class_support, var_boolean, (char *)&objectprint,	  "Set printing of object's derived type based on vtable info.",		  &setprintlist),     &showprintlist);  add_show_from_set    (add_set_cmd ("address", class_support, var_boolean, (char *)&addressprint,		  "Set printing of addresses.",		  &setprintlist),     &showprintlist);#if 0  /* The "show radix" cmd isn't good enough to show two separate values.     The rest of the code works, but the show part is confusing, so don't     let them be set separately 'til we work out "show".  */  c = add_set_cmd ("input-radix", class_support, var_uinteger,		   (char *)&input_radix,		  "Set default input radix for entering numbers.",		  &setlist);  add_show_from_set (c, &showlist);  c->function = set_input_radix;  c = add_set_cmd ("output-radix", class_support, var_uinteger,		   (char *)&output_radix,		  "Set default output radix for printing of values.",		  &setlist);  add_show_from_set (c, &showlist);  c->function = set_output_radix;#endif   c = add_set_cmd ("radix", class_support, var_uinteger,		   (char *)&output_radix,		  "Set default input and output number radix.",		  &setlist);  add_show_from_set (c, &showlist);  c->function.sfunc = set_radix;  /* Give people the defaults which they are used to.  */  prettyprint = 0;  unionprint = 1;  vtblprint = 0;  arrayprint = 0;  addressprint = 1;  objectprint = 0;  print_max = 200;  obstack_begin (&dont_print_obstack, 32 * sizeof (struct type *));}

⌨️ 快捷键说明

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