Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Elena Zannoni <ezannoni@redhat.com>
To: Klee Dienes <klee@apple.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] New function type_code_name.
Date: Fri, 03 Jan 2003 21:11:00 -0000	[thread overview]
Message-ID: <15893.64896.302784.545074@localhost.redhat.com> (raw)
In-Reply-To: <B87A936F-0D67-11D7-9BDD-00039396EEB8@apple.com>

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 */


  parent reply	other threads:[~2003-01-03 21:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-11 17:41 Klee Dienes
2002-12-12  9:12 ` Richard Earnshaw
2002-12-14  2:32 ` Daniel Jacobowitz
2003-01-03 21:11 ` Elena Zannoni [this message]
2003-01-03 21:35   ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15893.64896.302784.545074@localhost.redhat.com \
    --to=ezannoni@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=klee@apple.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox