This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] New function type_code_name.


Klee Dienes writes:
 > This patch moves the type-printing code from recursive_dump_type() into 
 > the new function type_code_name().  It's handy when one wants to use 
 > the type code of a type in debugging or warning/error messages.
 > 
 > 2002-12-11  Klee Dienes  <kdienes@apple.com>
 > 
 >         * gdbtypes.h (type_code_name): Add prototype.

Why is this exported? Could it be made static? Maybe you are coming up
with another patch that uses it in another file? If so, I would prefer
to export the function only then.

thanks
Elena


 >         * gdbtypes.c (type_code_name): New function.  Returns a
 >         constant string containing the ASCII name of the type code.
 >         (recursive_dump_type): Use type_code_name.
 > 
 > Index: gdbtypes.c
 > ===================================================================
 > RCS file: /cvs/Darwin/src/live/cygnus/src/gdb/gdbtypes.c,v
 > retrieving revision 1.25
 > diff -u -r1.25 gdbtypes.c
 > --- gdbtypes.c	2002/12/01 04:40:19	1.25
 > +++ gdbtypes.c	2002/12/12 00:06:45
 > @@ -3046,6 +3046,64 @@
 >  
 >  static struct obstack dont_print_type_obstack;
 >  
 > +const char *type_code_name (int code)
 > +{
 > +  switch (code)
 > +    {
 > +    case TYPE_CODE_UNDEF:
 > +      return "TYPE_CODE_UNDEF";
 > +    case TYPE_CODE_PTR:
 > +      return "TYPE_CODE_PTR";
 > +    case TYPE_CODE_ARRAY:
 > +      return "TYPE_CODE_ARRAY";
 > +    case TYPE_CODE_STRUCT:
 > +      return "TYPE_CODE_STRUCT";
 > +    case TYPE_CODE_UNION:
 > +      return "TYPE_CODE_UNION";
 > +    case TYPE_CODE_ENUM:
 > +      return "TYPE_CODE_ENUM";
 > +    case TYPE_CODE_FUNC:
 > +      return "TYPE_CODE_FUNC";
 > +    case TYPE_CODE_INT:
 > +      return "TYPE_CODE_INT";
 > +    case TYPE_CODE_FLT:
 > +      return "TYPE_CODE_FLT";
 > +    case TYPE_CODE_VOID:
 > +      return "TYPE_CODE_VOID";
 > +    case TYPE_CODE_SET:
 > +      return "TYPE_CODE_SET";
 > +    case TYPE_CODE_RANGE:
 > +      return "TYPE_CODE_RANGE";
 > +    case TYPE_CODE_STRING:
 > +      return "TYPE_CODE_STRING";
 > +    case TYPE_CODE_BITSTRING:
 > +      return "TYPE_CODE_BITSTRING";
 > +    case TYPE_CODE_ERROR:
 > +      return "TYPE_CODE_ERROR";
 > +    case TYPE_CODE_MEMBER:
 > +      return "TYPE_CODE_MEMBER";
 > +    case TYPE_CODE_METHOD:
 > +      return "TYPE_CODE_METHOD";
 > +    case TYPE_CODE_REF:
 > +      return "TYPE_CODE_REF";
 > +    case TYPE_CODE_CHAR:
 > +      return "TYPE_CODE_CHAR";
 > +    case TYPE_CODE_BOOL:
 > +      return "TYPE_CODE_BOOL";
 > +    case TYPE_CODE_COMPLEX:
 > +      return "TYPE_CODE_COMPLEX";
 > +    case TYPE_CODE_TYPEDEF:
 > +      return "TYPE_CODE_TYPEDEF";
 > +    case TYPE_CODE_TEMPLATE:
 > +      return "TYPE_CODE_TEMPLATE";
 > +    case TYPE_CODE_TEMPLATE_ARG:
 > +      return "TYPE_CODE_TEMPLATE_ARG";
 > +    default:
 > +      return "UNKNOWN TYPE CODE";
 > +    }
 > +}
 > +
 > +
 >  void
 >  recursive_dump_type (struct type *type, int spaces)
 >  {
 > @@ -3088,85 +3146,8 @@
 >  		    TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) : "<NULL>");
 >    gdb_print_host_address (TYPE_TAG_NAME (type), gdb_stdout);
 >    printf_filtered (")\n");
 > -  printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type));
 > -  switch (TYPE_CODE (type))
 > -    {
 > -    case TYPE_CODE_UNDEF:
 > -      printf_filtered ("(TYPE_CODE_UNDEF)");
 > -      break;
 > -    case TYPE_CODE_PTR:
 > -      printf_filtered ("(TYPE_CODE_PTR)");
 > -      break;
 > -    case TYPE_CODE_ARRAY:
 > -      printf_filtered ("(TYPE_CODE_ARRAY)");
 > -      break;
 > -    case TYPE_CODE_STRUCT:
 > -      printf_filtered ("(TYPE_CODE_STRUCT)");
 > -      break;
 > -    case TYPE_CODE_UNION:
 > -      printf_filtered ("(TYPE_CODE_UNION)");
 > -      break;
 > -    case TYPE_CODE_ENUM:
 > -      printf_filtered ("(TYPE_CODE_ENUM)");
 > -      break;
 > -    case TYPE_CODE_FUNC:
 > -      printf_filtered ("(TYPE_CODE_FUNC)");
 > -      break;
 > -    case TYPE_CODE_INT:
 > -      printf_filtered ("(TYPE_CODE_INT)");
 > -      break;
 > -    case TYPE_CODE_FLT:
 > -      printf_filtered ("(TYPE_CODE_FLT)");
 > -      break;
 > -    case TYPE_CODE_VOID:
 > -      printf_filtered ("(TYPE_CODE_VOID)");
 > -      break;
 > -    case TYPE_CODE_SET:
 > -      printf_filtered ("(TYPE_CODE_SET)");
 > -      break;
 > -    case TYPE_CODE_RANGE:
 > -      printf_filtered ("(TYPE_CODE_RANGE)");
 > -      break;
 > -    case TYPE_CODE_STRING:
 > -      printf_filtered ("(TYPE_CODE_STRING)");
 > -      break;
 > -    case TYPE_CODE_BITSTRING:
 > -      printf_filtered ("(TYPE_CODE_BITSTRING)");
 > -      break;
 > -    case TYPE_CODE_ERROR:
 > -      printf_filtered ("(TYPE_CODE_ERROR)");
 > -      break;
 > -    case TYPE_CODE_MEMBER:
 > -      printf_filtered ("(TYPE_CODE_MEMBER)");
 > -      break;
 > -    case TYPE_CODE_METHOD:
 > -      printf_filtered ("(TYPE_CODE_METHOD)");
 > -      break;
 > -    case TYPE_CODE_REF:
 > -      printf_filtered ("(TYPE_CODE_REF)");
 > -      break;
 > -    case TYPE_CODE_CHAR:
 > -      printf_filtered ("(TYPE_CODE_CHAR)");
 > -      break;
 > -    case TYPE_CODE_BOOL:
 > -      printf_filtered ("(TYPE_CODE_BOOL)");
 > -      break;
 > -    case TYPE_CODE_COMPLEX:
 > -      printf_filtered ("(TYPE_CODE_COMPLEX)");
 > -      break;
 > -    case TYPE_CODE_TYPEDEF:
 > -      printf_filtered ("(TYPE_CODE_TYPEDEF)");
 > -      break;
 > -    case TYPE_CODE_TEMPLATE:
 > -      printf_filtered ("(TYPE_CODE_TEMPLATE)");
 > -      break;
 > -    case TYPE_CODE_TEMPLATE_ARG:
 > -      printf_filtered ("(TYPE_CODE_TEMPLATE_ARG)");
 > -      break;
 > -    default:
 > -      printf_filtered ("(UNKNOWN TYPE CODE)");
 > -      break;
 > -    }
 > +  printfi_filtered (spaces, "code 0x%x (%s)", TYPE_CODE (type),
 > +		    type_code_name (TYPE_CODE (type)));
 >    puts_filtered ("\n");
 >    printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type));
 >    printfi_filtered (spaces, "upper_bound_type 0x%x ",
 > Index: gdbtypes.h
 > ===================================================================
 > RCS file: /cvs/Darwin/src/live/cygnus/src/gdb/gdbtypes.h,v
 > retrieving revision 1.17
 > diff -u -r1.17 gdbtypes.h
 > --- gdbtypes.h	2002/12/01 04:40:20	1.17
 > +++ gdbtypes.h	2002/12/12 00:06:49
 > @@ -1261,6 +1261,8 @@
 >  
 >  extern int rank_one_type (struct type *, struct type *);
 >  
 > +extern const char *type_code_name (int code);
 > +
 >  extern void recursive_dump_type (struct type *, int);
 >  
 >  /* printcmd.c */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]