xref: /dflybsd-src/contrib/gdb-7/gdb/c-lang.c (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* C language support routines for GDB, the GNU debugger.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 1992-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    This file is part of GDB.
65796c8dcSSimon Schubert 
75796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
85796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
95796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
105796c8dcSSimon Schubert    (at your option) any later version.
115796c8dcSSimon Schubert 
125796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
135796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
145796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
155796c8dcSSimon Schubert    GNU General Public License for more details.
165796c8dcSSimon Schubert 
175796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
185796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
195796c8dcSSimon Schubert 
205796c8dcSSimon Schubert #include "defs.h"
215796c8dcSSimon Schubert #include "symtab.h"
225796c8dcSSimon Schubert #include "gdbtypes.h"
235796c8dcSSimon Schubert #include "expression.h"
245796c8dcSSimon Schubert #include "parser-defs.h"
255796c8dcSSimon Schubert #include "language.h"
265796c8dcSSimon Schubert #include "c-lang.h"
275796c8dcSSimon Schubert #include "valprint.h"
285796c8dcSSimon Schubert #include "macroscope.h"
295796c8dcSSimon Schubert #include "gdb_assert.h"
305796c8dcSSimon Schubert #include "charset.h"
315796c8dcSSimon Schubert #include "gdb_string.h"
325796c8dcSSimon Schubert #include "demangle.h"
335796c8dcSSimon Schubert #include "cp-abi.h"
345796c8dcSSimon Schubert #include "cp-support.h"
355796c8dcSSimon Schubert #include "gdb_obstack.h"
365796c8dcSSimon Schubert #include <ctype.h>
37c50c785cSJohn Marino #include "exceptions.h"
385796c8dcSSimon Schubert 
395796c8dcSSimon Schubert extern void _initialize_c_language (void);
405796c8dcSSimon Schubert 
415796c8dcSSimon Schubert /* Given a C string type, STR_TYPE, return the corresponding target
425796c8dcSSimon Schubert    character set name.  */
435796c8dcSSimon Schubert 
445796c8dcSSimon Schubert static const char *
charset_for_string_type(enum c_string_type str_type,struct gdbarch * gdbarch)455796c8dcSSimon Schubert charset_for_string_type (enum c_string_type str_type,
46cf7f2e2dSJohn Marino 			 struct gdbarch *gdbarch)
475796c8dcSSimon Schubert {
485796c8dcSSimon Schubert   switch (str_type & ~C_CHAR)
495796c8dcSSimon Schubert     {
505796c8dcSSimon Schubert     case C_STRING:
51cf7f2e2dSJohn Marino       return target_charset (gdbarch);
525796c8dcSSimon Schubert     case C_WIDE_STRING:
53cf7f2e2dSJohn Marino       return target_wide_charset (gdbarch);
545796c8dcSSimon Schubert     case C_STRING_16:
55cf7f2e2dSJohn Marino       /* FIXME: UTF-16 is not always correct.  */
56cf7f2e2dSJohn Marino       if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
57cf7f2e2dSJohn Marino 	return "UTF-16BE";
585796c8dcSSimon Schubert       else
59cf7f2e2dSJohn Marino 	return "UTF-16LE";
605796c8dcSSimon Schubert     case C_STRING_32:
61cf7f2e2dSJohn Marino       /* FIXME: UTF-32 is not always correct.  */
62cf7f2e2dSJohn Marino       if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
63cf7f2e2dSJohn Marino 	return "UTF-32BE";
645796c8dcSSimon Schubert       else
65cf7f2e2dSJohn Marino 	return "UTF-32LE";
665796c8dcSSimon Schubert     }
67c50c785cSJohn Marino   internal_error (__FILE__, __LINE__, _("unhandled c_string_type"));
685796c8dcSSimon Schubert }
695796c8dcSSimon Schubert 
705796c8dcSSimon Schubert /* Classify ELTTYPE according to what kind of character it is.  Return
715796c8dcSSimon Schubert    the enum constant representing the character type.  Also set
725796c8dcSSimon Schubert    *ENCODING to the name of the character set to use when converting
73c50c785cSJohn Marino    characters of this type in target BYTE_ORDER to the host character
74c50c785cSJohn Marino    set.  */
755796c8dcSSimon Schubert 
765796c8dcSSimon Schubert static enum c_string_type
classify_type(struct type * elttype,struct gdbarch * gdbarch,const char ** encoding)77cf7f2e2dSJohn Marino classify_type (struct type *elttype, struct gdbarch *gdbarch,
785796c8dcSSimon Schubert 	       const char **encoding)
795796c8dcSSimon Schubert {
805796c8dcSSimon Schubert   enum c_string_type result;
815796c8dcSSimon Schubert 
825796c8dcSSimon Schubert   /* We loop because ELTTYPE may be a typedef, and we want to
835796c8dcSSimon Schubert      successively peel each typedef until we reach a type we
845796c8dcSSimon Schubert      understand.  We don't use CHECK_TYPEDEF because that will strip
855796c8dcSSimon Schubert      all typedefs at once -- but in C, wchar_t is itself a typedef, so
865796c8dcSSimon Schubert      that would do the wrong thing.  */
875796c8dcSSimon Schubert   while (elttype)
885796c8dcSSimon Schubert     {
89*ef5ccd6cSJohn Marino       const char *name = TYPE_NAME (elttype);
905796c8dcSSimon Schubert 
915796c8dcSSimon Schubert       if (TYPE_CODE (elttype) == TYPE_CODE_CHAR || !name)
925796c8dcSSimon Schubert 	{
935796c8dcSSimon Schubert 	  result = C_CHAR;
945796c8dcSSimon Schubert 	  goto done;
955796c8dcSSimon Schubert 	}
965796c8dcSSimon Schubert 
975796c8dcSSimon Schubert       if (!strcmp (name, "wchar_t"))
985796c8dcSSimon Schubert 	{
995796c8dcSSimon Schubert 	  result = C_WIDE_CHAR;
1005796c8dcSSimon Schubert 	  goto done;
1015796c8dcSSimon Schubert 	}
1025796c8dcSSimon Schubert 
1035796c8dcSSimon Schubert       if (!strcmp (name, "char16_t"))
1045796c8dcSSimon Schubert 	{
1055796c8dcSSimon Schubert 	  result = C_CHAR_16;
1065796c8dcSSimon Schubert 	  goto done;
1075796c8dcSSimon Schubert 	}
1085796c8dcSSimon Schubert 
1095796c8dcSSimon Schubert       if (!strcmp (name, "char32_t"))
1105796c8dcSSimon Schubert 	{
1115796c8dcSSimon Schubert 	  result = C_CHAR_32;
1125796c8dcSSimon Schubert 	  goto done;
1135796c8dcSSimon Schubert 	}
1145796c8dcSSimon Schubert 
1155796c8dcSSimon Schubert       if (TYPE_CODE (elttype) != TYPE_CODE_TYPEDEF)
1165796c8dcSSimon Schubert 	break;
1175796c8dcSSimon Schubert 
1185796c8dcSSimon Schubert       /* Call for side effects.  */
1195796c8dcSSimon Schubert       check_typedef (elttype);
1205796c8dcSSimon Schubert 
1215796c8dcSSimon Schubert       if (TYPE_TARGET_TYPE (elttype))
1225796c8dcSSimon Schubert 	elttype = TYPE_TARGET_TYPE (elttype);
1235796c8dcSSimon Schubert       else
1245796c8dcSSimon Schubert 	{
1255796c8dcSSimon Schubert 	  /* Perhaps check_typedef did not update the target type.  In
1265796c8dcSSimon Schubert 	     this case, force the lookup again and hope it works out.
1275796c8dcSSimon Schubert 	     It never will for C, but it might for C++.  */
1285796c8dcSSimon Schubert 	  CHECK_TYPEDEF (elttype);
1295796c8dcSSimon Schubert 	}
1305796c8dcSSimon Schubert     }
1315796c8dcSSimon Schubert 
1325796c8dcSSimon Schubert   /* Punt.  */
1335796c8dcSSimon Schubert   result = C_CHAR;
1345796c8dcSSimon Schubert 
1355796c8dcSSimon Schubert  done:
1365796c8dcSSimon Schubert   if (encoding)
137cf7f2e2dSJohn Marino     *encoding = charset_for_string_type (result, gdbarch);
1385796c8dcSSimon Schubert 
1395796c8dcSSimon Schubert   return result;
1405796c8dcSSimon Schubert }
1415796c8dcSSimon Schubert 
142c50c785cSJohn Marino /* Print the character C on STREAM as part of the contents of a
143c50c785cSJohn Marino    literal string whose delimiter is QUOTER.  Note that that format
144c50c785cSJohn Marino    for printing characters and strings is language specific.  */
1455796c8dcSSimon Schubert 
146cf7f2e2dSJohn Marino void
c_emit_char(int c,struct type * type,struct ui_file * stream,int quoter)147cf7f2e2dSJohn Marino c_emit_char (int c, struct type *type,
148cf7f2e2dSJohn Marino 	     struct ui_file *stream, int quoter)
1495796c8dcSSimon Schubert {
1505796c8dcSSimon Schubert   const char *encoding;
1515796c8dcSSimon Schubert 
152cf7f2e2dSJohn Marino   classify_type (type, get_type_arch (type), &encoding);
153a45ae5f8SJohn Marino   generic_emit_char (c, type, stream, quoter, encoding);
1545796c8dcSSimon Schubert }
1555796c8dcSSimon Schubert 
1565796c8dcSSimon Schubert void
c_printchar(int c,struct type * type,struct ui_file * stream)1575796c8dcSSimon Schubert c_printchar (int c, struct type *type, struct ui_file *stream)
1585796c8dcSSimon Schubert {
1595796c8dcSSimon Schubert   enum c_string_type str_type;
1605796c8dcSSimon Schubert 
161cf7f2e2dSJohn Marino   str_type = classify_type (type, get_type_arch (type), NULL);
1625796c8dcSSimon Schubert   switch (str_type)
1635796c8dcSSimon Schubert     {
1645796c8dcSSimon Schubert     case C_CHAR:
1655796c8dcSSimon Schubert       break;
1665796c8dcSSimon Schubert     case C_WIDE_CHAR:
1675796c8dcSSimon Schubert       fputc_filtered ('L', stream);
1685796c8dcSSimon Schubert       break;
1695796c8dcSSimon Schubert     case C_CHAR_16:
1705796c8dcSSimon Schubert       fputc_filtered ('u', stream);
1715796c8dcSSimon Schubert       break;
1725796c8dcSSimon Schubert     case C_CHAR_32:
1735796c8dcSSimon Schubert       fputc_filtered ('U', stream);
1745796c8dcSSimon Schubert       break;
1755796c8dcSSimon Schubert     }
1765796c8dcSSimon Schubert 
1775796c8dcSSimon Schubert   fputc_filtered ('\'', stream);
1785796c8dcSSimon Schubert   LA_EMIT_CHAR (c, type, stream, '\'');
1795796c8dcSSimon Schubert   fputc_filtered ('\'', stream);
1805796c8dcSSimon Schubert }
1815796c8dcSSimon Schubert 
182c50c785cSJohn Marino /* Print the character string STRING, printing at most LENGTH
183c50c785cSJohn Marino    characters.  LENGTH is -1 if the string is nul terminated.  Each
184c50c785cSJohn Marino    character is WIDTH bytes long.  Printing stops early if the number
185c50c785cSJohn Marino    hits print_max; repeat counts are printed as appropriate.  Print
186c50c785cSJohn Marino    ellipses at the end if we had to stop before printing LENGTH
187c50c785cSJohn Marino    characters, or if FORCE_ELLIPSES.  */
1885796c8dcSSimon Schubert 
1895796c8dcSSimon Schubert void
c_printstr(struct ui_file * stream,struct type * type,const gdb_byte * string,unsigned int length,const char * user_encoding,int force_ellipses,const struct value_print_options * options)190c50c785cSJohn Marino c_printstr (struct ui_file *stream, struct type *type,
191c50c785cSJohn Marino 	    const gdb_byte *string, unsigned int length,
192c50c785cSJohn Marino 	    const char *user_encoding, int force_ellipses,
1935796c8dcSSimon Schubert 	    const struct value_print_options *options)
1945796c8dcSSimon Schubert {
195a45ae5f8SJohn Marino   enum c_string_type str_type;
196a45ae5f8SJohn Marino   const char *type_encoding;
197a45ae5f8SJohn Marino   const char *encoding;
198a45ae5f8SJohn Marino 
199cf7f2e2dSJohn Marino   str_type = (classify_type (type, get_type_arch (type), &type_encoding)
200cf7f2e2dSJohn Marino 	      & ~C_CHAR);
2015796c8dcSSimon Schubert   switch (str_type)
2025796c8dcSSimon Schubert     {
2035796c8dcSSimon Schubert     case C_STRING:
2045796c8dcSSimon Schubert       break;
2055796c8dcSSimon Schubert     case C_WIDE_STRING:
2065796c8dcSSimon Schubert       fputs_filtered ("L", stream);
2075796c8dcSSimon Schubert       break;
2085796c8dcSSimon Schubert     case C_STRING_16:
2095796c8dcSSimon Schubert       fputs_filtered ("u", stream);
2105796c8dcSSimon Schubert       break;
2115796c8dcSSimon Schubert     case C_STRING_32:
2125796c8dcSSimon Schubert       fputs_filtered ("U", stream);
2135796c8dcSSimon Schubert       break;
2145796c8dcSSimon Schubert     }
2155796c8dcSSimon Schubert 
216a45ae5f8SJohn Marino   encoding = (user_encoding && *user_encoding) ? user_encoding : type_encoding;
217cf7f2e2dSJohn Marino 
218a45ae5f8SJohn Marino   generic_printstr (stream, type, string, length, encoding, force_ellipses,
219a45ae5f8SJohn Marino 		    '"', 1, options);
2205796c8dcSSimon Schubert }
2215796c8dcSSimon Schubert 
2225796c8dcSSimon Schubert /* Obtain a C string from the inferior storing it in a newly allocated
223c50c785cSJohn Marino    buffer in BUFFER, which should be freed by the caller.  If the in-
224c50c785cSJohn Marino    and out-parameter *LENGTH is specified at -1, the string is read
2255796c8dcSSimon Schubert    until a null character of the appropriate width is found, otherwise
226c50c785cSJohn Marino    the string is read to the length of characters specified.  The size
227c50c785cSJohn Marino    of a character is determined by the length of the target type of
228c50c785cSJohn Marino    the pointer or array.  If VALUE is an array with a known length,
229c50c785cSJohn Marino    the function will not read past the end of the array.  On
230c50c785cSJohn Marino    completion, *LENGTH will be set to the size of the string read in
2315796c8dcSSimon Schubert    characters.  (If a length of -1 is specified, the length returned
2325796c8dcSSimon Schubert    will not include the null character).  CHARSET is always set to the
2335796c8dcSSimon Schubert    target charset.  */
2345796c8dcSSimon Schubert 
2355796c8dcSSimon Schubert void
c_get_string(struct value * value,gdb_byte ** buffer,int * length,struct type ** char_type,const char ** charset)236c50c785cSJohn Marino c_get_string (struct value *value, gdb_byte **buffer,
237c50c785cSJohn Marino 	      int *length, struct type **char_type,
238c50c785cSJohn Marino 	      const char **charset)
2395796c8dcSSimon Schubert {
2405796c8dcSSimon Schubert   int err, width;
2415796c8dcSSimon Schubert   unsigned int fetchlimit;
2425796c8dcSSimon Schubert   struct type *type = check_typedef (value_type (value));
2435796c8dcSSimon Schubert   struct type *element_type = TYPE_TARGET_TYPE (type);
2445796c8dcSSimon Schubert   int req_length = *length;
245c50c785cSJohn Marino   enum bfd_endian byte_order
246c50c785cSJohn Marino     = gdbarch_byte_order (get_type_arch (type));
2475796c8dcSSimon Schubert 
2485796c8dcSSimon Schubert   if (element_type == NULL)
2495796c8dcSSimon Schubert     goto error;
2505796c8dcSSimon Schubert 
2515796c8dcSSimon Schubert   if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
2525796c8dcSSimon Schubert     {
253c50c785cSJohn Marino       /* If we know the size of the array, we can use it as a limit on
254c50c785cSJohn Marino 	 the number of characters to be fetched.  */
2555796c8dcSSimon Schubert       if (TYPE_NFIELDS (type) == 1
2565796c8dcSSimon Schubert 	  && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_RANGE)
2575796c8dcSSimon Schubert 	{
2585796c8dcSSimon Schubert 	  LONGEST low_bound, high_bound;
2595796c8dcSSimon Schubert 
2605796c8dcSSimon Schubert 	  get_discrete_bounds (TYPE_FIELD_TYPE (type, 0),
2615796c8dcSSimon Schubert 			       &low_bound, &high_bound);
2625796c8dcSSimon Schubert 	  fetchlimit = high_bound - low_bound + 1;
2635796c8dcSSimon Schubert 	}
2645796c8dcSSimon Schubert       else
2655796c8dcSSimon Schubert 	fetchlimit = UINT_MAX;
2665796c8dcSSimon Schubert     }
2675796c8dcSSimon Schubert   else if (TYPE_CODE (type) == TYPE_CODE_PTR)
2685796c8dcSSimon Schubert     fetchlimit = UINT_MAX;
2695796c8dcSSimon Schubert   else
2705796c8dcSSimon Schubert     /* We work only with arrays and pointers.  */
2715796c8dcSSimon Schubert     goto error;
2725796c8dcSSimon Schubert 
273cf7f2e2dSJohn Marino   if (! c_textual_element_type (element_type, 0))
2745796c8dcSSimon Schubert     goto error;
275*ef5ccd6cSJohn Marino   classify_type (element_type, get_type_arch (element_type), charset);
2765796c8dcSSimon Schubert   width = TYPE_LENGTH (element_type);
2775796c8dcSSimon Schubert 
278c50c785cSJohn Marino   /* If the string lives in GDB's memory instead of the inferior's,
279c50c785cSJohn Marino      then we just need to copy it to BUFFER.  Also, since such strings
280c50c785cSJohn Marino      are arrays with known size, FETCHLIMIT will hold the size of the
281c50c785cSJohn Marino      array.  */
2825796c8dcSSimon Schubert   if ((VALUE_LVAL (value) == not_lval
2835796c8dcSSimon Schubert        || VALUE_LVAL (value) == lval_internalvar)
2845796c8dcSSimon Schubert       && fetchlimit != UINT_MAX)
2855796c8dcSSimon Schubert     {
2865796c8dcSSimon Schubert       int i;
2875796c8dcSSimon Schubert       const gdb_byte *contents = value_contents (value);
2885796c8dcSSimon Schubert 
2895796c8dcSSimon Schubert       /* If a length is specified, use that.  */
2905796c8dcSSimon Schubert       if (*length >= 0)
2915796c8dcSSimon Schubert 	i  = *length;
2925796c8dcSSimon Schubert       else
2935796c8dcSSimon Schubert  	/* Otherwise, look for a null character.  */
2945796c8dcSSimon Schubert  	for (i = 0; i < fetchlimit; i++)
295c50c785cSJohn Marino 	  if (extract_unsigned_integer (contents + i * width,
296c50c785cSJohn Marino 					width, byte_order) == 0)
2975796c8dcSSimon Schubert  	    break;
2985796c8dcSSimon Schubert 
2995796c8dcSSimon Schubert       /* I is now either a user-defined length, the number of non-null
3005796c8dcSSimon Schubert  	 characters, or FETCHLIMIT.  */
3015796c8dcSSimon Schubert       *length = i * width;
3025796c8dcSSimon Schubert       *buffer = xmalloc (*length);
3035796c8dcSSimon Schubert       memcpy (*buffer, contents, *length);
3045796c8dcSSimon Schubert       err = 0;
3055796c8dcSSimon Schubert     }
3065796c8dcSSimon Schubert   else
3075796c8dcSSimon Schubert     {
308c50c785cSJohn Marino       CORE_ADDR addr = value_as_address (value);
309c50c785cSJohn Marino 
310c50c785cSJohn Marino       err = read_string (addr, *length, width, fetchlimit,
3115796c8dcSSimon Schubert 			 byte_order, buffer, length);
3125796c8dcSSimon Schubert       if (err)
3135796c8dcSSimon Schubert 	{
3145796c8dcSSimon Schubert 	  xfree (*buffer);
315c50c785cSJohn Marino 	  if (err == EIO)
316c50c785cSJohn Marino 	    throw_error (MEMORY_ERROR, "Address %s out of bounds",
317c50c785cSJohn Marino 			 paddress (get_type_arch (type), addr));
318c50c785cSJohn Marino 	  else
3195796c8dcSSimon Schubert 	    error (_("Error reading string from inferior: %s"),
3205796c8dcSSimon Schubert 		   safe_strerror (err));
3215796c8dcSSimon Schubert 	}
3225796c8dcSSimon Schubert     }
3235796c8dcSSimon Schubert 
3245796c8dcSSimon Schubert   /* If the LENGTH is specified at -1, we want to return the string
3255796c8dcSSimon Schubert      length up to the terminating null character.  If an actual length
3265796c8dcSSimon Schubert      was specified, we want to return the length of exactly what was
3275796c8dcSSimon Schubert      read.  */
3285796c8dcSSimon Schubert   if (req_length == -1)
3295796c8dcSSimon Schubert     /* If the last character is null, subtract it from LENGTH.  */
3305796c8dcSSimon Schubert     if (*length > 0
331c50c785cSJohn Marino  	&& extract_unsigned_integer (*buffer + *length - width,
332c50c785cSJohn Marino 				     width, byte_order) == 0)
3335796c8dcSSimon Schubert       *length -= width;
3345796c8dcSSimon Schubert 
3355796c8dcSSimon Schubert   /* The read_string function will return the number of bytes read.
3365796c8dcSSimon Schubert      If length returned from read_string was > 0, return the number of
3375796c8dcSSimon Schubert      characters read by dividing the number of bytes by width.  */
3385796c8dcSSimon Schubert   if (*length != 0)
3395796c8dcSSimon Schubert      *length = *length / width;
3405796c8dcSSimon Schubert 
341cf7f2e2dSJohn Marino   *char_type = element_type;
3425796c8dcSSimon Schubert 
3435796c8dcSSimon Schubert   return;
3445796c8dcSSimon Schubert 
3455796c8dcSSimon Schubert  error:
3465796c8dcSSimon Schubert   {
3475796c8dcSSimon Schubert     char *type_str;
3485796c8dcSSimon Schubert 
3495796c8dcSSimon Schubert     type_str = type_to_string (type);
3505796c8dcSSimon Schubert     if (type_str)
3515796c8dcSSimon Schubert       {
3525796c8dcSSimon Schubert 	make_cleanup (xfree, type_str);
3535796c8dcSSimon Schubert 	error (_("Trying to read string with inappropriate type `%s'."),
3545796c8dcSSimon Schubert 	       type_str);
3555796c8dcSSimon Schubert       }
3565796c8dcSSimon Schubert     else
3575796c8dcSSimon Schubert       error (_("Trying to read string with inappropriate type."));
3585796c8dcSSimon Schubert   }
3595796c8dcSSimon Schubert }
3605796c8dcSSimon Schubert 
3615796c8dcSSimon Schubert 
3625796c8dcSSimon Schubert /* Evaluating C and C++ expressions.  */
3635796c8dcSSimon Schubert 
3645796c8dcSSimon Schubert /* Convert a UCN.  The digits of the UCN start at P and extend no
3655796c8dcSSimon Schubert    farther than LIMIT.  DEST_CHARSET is the name of the character set
3665796c8dcSSimon Schubert    into which the UCN should be converted.  The results are written to
3675796c8dcSSimon Schubert    OUTPUT.  LENGTH is the maximum length of the UCN, either 4 or 8.
3685796c8dcSSimon Schubert    Returns a pointer to just after the final digit of the UCN.  */
3695796c8dcSSimon Schubert 
3705796c8dcSSimon Schubert static char *
convert_ucn(char * p,char * limit,const char * dest_charset,struct obstack * output,int length)3715796c8dcSSimon Schubert convert_ucn (char *p, char *limit, const char *dest_charset,
3725796c8dcSSimon Schubert 	     struct obstack *output, int length)
3735796c8dcSSimon Schubert {
3745796c8dcSSimon Schubert   unsigned long result = 0;
3755796c8dcSSimon Schubert   gdb_byte data[4];
3765796c8dcSSimon Schubert   int i;
3775796c8dcSSimon Schubert 
3785796c8dcSSimon Schubert   for (i = 0; i < length && p < limit && isxdigit (*p); ++i, ++p)
3795796c8dcSSimon Schubert     result = (result << 4) + host_hex_value (*p);
3805796c8dcSSimon Schubert 
3815796c8dcSSimon Schubert   for (i = 3; i >= 0; --i)
3825796c8dcSSimon Schubert     {
3835796c8dcSSimon Schubert       data[i] = result & 0xff;
3845796c8dcSSimon Schubert       result >>= 8;
3855796c8dcSSimon Schubert     }
3865796c8dcSSimon Schubert 
387c50c785cSJohn Marino   convert_between_encodings ("UTF-32BE", dest_charset, data,
388c50c785cSJohn Marino 			     4, 4, output, translit_none);
3895796c8dcSSimon Schubert 
3905796c8dcSSimon Schubert   return p;
3915796c8dcSSimon Schubert }
3925796c8dcSSimon Schubert 
3935796c8dcSSimon Schubert /* Emit a character, VALUE, which was specified numerically, to
3945796c8dcSSimon Schubert    OUTPUT.  TYPE is the target character type.  */
3955796c8dcSSimon Schubert 
3965796c8dcSSimon Schubert static void
emit_numeric_character(struct type * type,unsigned long value,struct obstack * output)3975796c8dcSSimon Schubert emit_numeric_character (struct type *type, unsigned long value,
3985796c8dcSSimon Schubert 			struct obstack *output)
3995796c8dcSSimon Schubert {
4005796c8dcSSimon Schubert   gdb_byte *buffer;
4015796c8dcSSimon Schubert 
4025796c8dcSSimon Schubert   buffer = alloca (TYPE_LENGTH (type));
4035796c8dcSSimon Schubert   pack_long (buffer, type, value);
4045796c8dcSSimon Schubert   obstack_grow (output, buffer, TYPE_LENGTH (type));
4055796c8dcSSimon Schubert }
4065796c8dcSSimon Schubert 
4075796c8dcSSimon Schubert /* Convert an octal escape sequence.  TYPE is the target character
4085796c8dcSSimon Schubert    type.  The digits of the escape sequence begin at P and extend no
4095796c8dcSSimon Schubert    farther than LIMIT.  The result is written to OUTPUT.  Returns a
4105796c8dcSSimon Schubert    pointer to just after the final digit of the escape sequence.  */
4115796c8dcSSimon Schubert 
4125796c8dcSSimon Schubert static char *
convert_octal(struct type * type,char * p,char * limit,struct obstack * output)413c50c785cSJohn Marino convert_octal (struct type *type, char *p,
414c50c785cSJohn Marino 	       char *limit, struct obstack *output)
4155796c8dcSSimon Schubert {
4165796c8dcSSimon Schubert   int i;
4175796c8dcSSimon Schubert   unsigned long value = 0;
4185796c8dcSSimon Schubert 
4195796c8dcSSimon Schubert   for (i = 0;
4205796c8dcSSimon Schubert        i < 3 && p < limit && isdigit (*p) && *p != '8' && *p != '9';
4215796c8dcSSimon Schubert        ++i)
4225796c8dcSSimon Schubert     {
4235796c8dcSSimon Schubert       value = 8 * value + host_hex_value (*p);
4245796c8dcSSimon Schubert       ++p;
4255796c8dcSSimon Schubert     }
4265796c8dcSSimon Schubert 
4275796c8dcSSimon Schubert   emit_numeric_character (type, value, output);
4285796c8dcSSimon Schubert 
4295796c8dcSSimon Schubert   return p;
4305796c8dcSSimon Schubert }
4315796c8dcSSimon Schubert 
4325796c8dcSSimon Schubert /* Convert a hex escape sequence.  TYPE is the target character type.
4335796c8dcSSimon Schubert    The digits of the escape sequence begin at P and extend no farther
4345796c8dcSSimon Schubert    than LIMIT.  The result is written to OUTPUT.  Returns a pointer to
4355796c8dcSSimon Schubert    just after the final digit of the escape sequence.  */
4365796c8dcSSimon Schubert 
4375796c8dcSSimon Schubert static char *
convert_hex(struct type * type,char * p,char * limit,struct obstack * output)438c50c785cSJohn Marino convert_hex (struct type *type, char *p,
439c50c785cSJohn Marino 	     char *limit, struct obstack *output)
4405796c8dcSSimon Schubert {
4415796c8dcSSimon Schubert   unsigned long value = 0;
4425796c8dcSSimon Schubert 
4435796c8dcSSimon Schubert   while (p < limit && isxdigit (*p))
4445796c8dcSSimon Schubert     {
4455796c8dcSSimon Schubert       value = 16 * value + host_hex_value (*p);
4465796c8dcSSimon Schubert       ++p;
4475796c8dcSSimon Schubert     }
4485796c8dcSSimon Schubert 
4495796c8dcSSimon Schubert   emit_numeric_character (type, value, output);
4505796c8dcSSimon Schubert 
4515796c8dcSSimon Schubert   return p;
4525796c8dcSSimon Schubert }
4535796c8dcSSimon Schubert 
4545796c8dcSSimon Schubert #define ADVANCE					\
4555796c8dcSSimon Schubert   do {						\
4565796c8dcSSimon Schubert     ++p;					\
4575796c8dcSSimon Schubert     if (p == limit)				\
4585796c8dcSSimon Schubert       error (_("Malformed escape sequence"));	\
4595796c8dcSSimon Schubert   } while (0)
4605796c8dcSSimon Schubert 
4615796c8dcSSimon Schubert /* Convert an escape sequence to a target format.  TYPE is the target
4625796c8dcSSimon Schubert    character type to use, and DEST_CHARSET is the name of the target
4635796c8dcSSimon Schubert    character set.  The backslash of the escape sequence is at *P, and
4645796c8dcSSimon Schubert    the escape sequence will not extend past LIMIT.  The results are
4655796c8dcSSimon Schubert    written to OUTPUT.  Returns a pointer to just past the final
4665796c8dcSSimon Schubert    character of the escape sequence.  */
4675796c8dcSSimon Schubert 
4685796c8dcSSimon Schubert static char *
convert_escape(struct type * type,const char * dest_charset,char * p,char * limit,struct obstack * output)4695796c8dcSSimon Schubert convert_escape (struct type *type, const char *dest_charset,
4705796c8dcSSimon Schubert 		char *p, char *limit, struct obstack *output)
4715796c8dcSSimon Schubert {
4725796c8dcSSimon Schubert   /* Skip the backslash.  */
4735796c8dcSSimon Schubert   ADVANCE;
4745796c8dcSSimon Schubert 
4755796c8dcSSimon Schubert   switch (*p)
4765796c8dcSSimon Schubert     {
4775796c8dcSSimon Schubert     case '\\':
4785796c8dcSSimon Schubert       obstack_1grow (output, '\\');
4795796c8dcSSimon Schubert       ++p;
4805796c8dcSSimon Schubert       break;
4815796c8dcSSimon Schubert 
4825796c8dcSSimon Schubert     case 'x':
4835796c8dcSSimon Schubert       ADVANCE;
4845796c8dcSSimon Schubert       if (!isxdigit (*p))
4855796c8dcSSimon Schubert 	error (_("\\x used with no following hex digits."));
4865796c8dcSSimon Schubert       p = convert_hex (type, p, limit, output);
4875796c8dcSSimon Schubert       break;
4885796c8dcSSimon Schubert 
4895796c8dcSSimon Schubert     case '0':
4905796c8dcSSimon Schubert     case '1':
4915796c8dcSSimon Schubert     case '2':
4925796c8dcSSimon Schubert     case '3':
4935796c8dcSSimon Schubert     case '4':
4945796c8dcSSimon Schubert     case '5':
4955796c8dcSSimon Schubert     case '6':
4965796c8dcSSimon Schubert     case '7':
4975796c8dcSSimon Schubert       p = convert_octal (type, p, limit, output);
4985796c8dcSSimon Schubert       break;
4995796c8dcSSimon Schubert 
5005796c8dcSSimon Schubert     case 'u':
5015796c8dcSSimon Schubert     case 'U':
5025796c8dcSSimon Schubert       {
5035796c8dcSSimon Schubert 	int length = *p == 'u' ? 4 : 8;
504cf7f2e2dSJohn Marino 
5055796c8dcSSimon Schubert 	ADVANCE;
5065796c8dcSSimon Schubert 	if (!isxdigit (*p))
5075796c8dcSSimon Schubert 	  error (_("\\u used with no following hex digits"));
5085796c8dcSSimon Schubert 	p = convert_ucn (p, limit, dest_charset, output, length);
5095796c8dcSSimon Schubert       }
5105796c8dcSSimon Schubert     }
5115796c8dcSSimon Schubert 
5125796c8dcSSimon Schubert   return p;
5135796c8dcSSimon Schubert }
5145796c8dcSSimon Schubert 
5155796c8dcSSimon Schubert /* Given a single string from a (C-specific) OP_STRING list, convert
5165796c8dcSSimon Schubert    it to a target string, handling escape sequences specially.  The
5175796c8dcSSimon Schubert    output is written to OUTPUT.  DATA is the input string, which has
5185796c8dcSSimon Schubert    length LEN.  DEST_CHARSET is the name of the target character set,
5195796c8dcSSimon Schubert    and TYPE is the type of target character to use.  */
5205796c8dcSSimon Schubert 
5215796c8dcSSimon Schubert static void
parse_one_string(struct obstack * output,char * data,int len,const char * dest_charset,struct type * type)5225796c8dcSSimon Schubert parse_one_string (struct obstack *output, char *data, int len,
5235796c8dcSSimon Schubert 		  const char *dest_charset, struct type *type)
5245796c8dcSSimon Schubert {
5255796c8dcSSimon Schubert   char *limit;
5265796c8dcSSimon Schubert 
5275796c8dcSSimon Schubert   limit = data + len;
5285796c8dcSSimon Schubert 
5295796c8dcSSimon Schubert   while (data < limit)
5305796c8dcSSimon Schubert     {
5315796c8dcSSimon Schubert       char *p = data;
532cf7f2e2dSJohn Marino 
5335796c8dcSSimon Schubert       /* Look for next escape, or the end of the input.  */
5345796c8dcSSimon Schubert       while (p < limit && *p != '\\')
5355796c8dcSSimon Schubert 	++p;
5365796c8dcSSimon Schubert       /* If we saw a run of characters, convert them all.  */
5375796c8dcSSimon Schubert       if (p > data)
5385796c8dcSSimon Schubert 	convert_between_encodings (host_charset (), dest_charset,
539*ef5ccd6cSJohn Marino 				   (gdb_byte *) data, p - data, 1,
540c50c785cSJohn Marino 				   output, translit_none);
5415796c8dcSSimon Schubert       /* If we saw an escape, convert it.  */
5425796c8dcSSimon Schubert       if (p < limit)
5435796c8dcSSimon Schubert 	p = convert_escape (type, dest_charset, p, limit, output);
5445796c8dcSSimon Schubert       data = p;
5455796c8dcSSimon Schubert     }
5465796c8dcSSimon Schubert }
5475796c8dcSSimon Schubert 
5485796c8dcSSimon Schubert /* Expression evaluator for the C language family.  Most operations
5495796c8dcSSimon Schubert    are delegated to evaluate_subexp_standard; see that function for a
5505796c8dcSSimon Schubert    description of the arguments.  */
5515796c8dcSSimon Schubert 
552c50c785cSJohn Marino struct value *
evaluate_subexp_c(struct type * expect_type,struct expression * exp,int * pos,enum noside noside)5535796c8dcSSimon Schubert evaluate_subexp_c (struct type *expect_type, struct expression *exp,
5545796c8dcSSimon Schubert 		   int *pos, enum noside noside)
5555796c8dcSSimon Schubert {
5565796c8dcSSimon Schubert   enum exp_opcode op = exp->elts[*pos].opcode;
5575796c8dcSSimon Schubert 
5585796c8dcSSimon Schubert   switch (op)
5595796c8dcSSimon Schubert     {
5605796c8dcSSimon Schubert     case OP_STRING:
5615796c8dcSSimon Schubert       {
5625796c8dcSSimon Schubert 	int oplen, limit;
5635796c8dcSSimon Schubert 	struct type *type;
5645796c8dcSSimon Schubert 	struct obstack output;
5655796c8dcSSimon Schubert 	struct cleanup *cleanup;
5665796c8dcSSimon Schubert 	struct value *result;
5675796c8dcSSimon Schubert 	enum c_string_type dest_type;
5685796c8dcSSimon Schubert 	const char *dest_charset;
569c50c785cSJohn Marino 	int satisfy_expected = 0;
5705796c8dcSSimon Schubert 
5715796c8dcSSimon Schubert 	obstack_init (&output);
5725796c8dcSSimon Schubert 	cleanup = make_cleanup_obstack_free (&output);
5735796c8dcSSimon Schubert 
5745796c8dcSSimon Schubert 	++*pos;
5755796c8dcSSimon Schubert 	oplen = longest_to_int (exp->elts[*pos].longconst);
5765796c8dcSSimon Schubert 
5775796c8dcSSimon Schubert 	++*pos;
5785796c8dcSSimon Schubert 	limit = *pos + BYTES_TO_EXP_ELEM (oplen + 1);
5795796c8dcSSimon Schubert 	dest_type
5805796c8dcSSimon Schubert 	  = (enum c_string_type) longest_to_int (exp->elts[*pos].longconst);
5815796c8dcSSimon Schubert 	switch (dest_type & ~C_CHAR)
5825796c8dcSSimon Schubert 	  {
5835796c8dcSSimon Schubert 	  case C_STRING:
5845796c8dcSSimon Schubert 	    type = language_string_char_type (exp->language_defn,
5855796c8dcSSimon Schubert 					      exp->gdbarch);
5865796c8dcSSimon Schubert 	    break;
5875796c8dcSSimon Schubert 	  case C_WIDE_STRING:
5885796c8dcSSimon Schubert 	    type = lookup_typename (exp->language_defn, exp->gdbarch,
5895796c8dcSSimon Schubert 				    "wchar_t", NULL, 0);
5905796c8dcSSimon Schubert 	    break;
5915796c8dcSSimon Schubert 	  case C_STRING_16:
5925796c8dcSSimon Schubert 	    type = lookup_typename (exp->language_defn, exp->gdbarch,
5935796c8dcSSimon Schubert 				    "char16_t", NULL, 0);
5945796c8dcSSimon Schubert 	    break;
5955796c8dcSSimon Schubert 	  case C_STRING_32:
5965796c8dcSSimon Schubert 	    type = lookup_typename (exp->language_defn, exp->gdbarch,
5975796c8dcSSimon Schubert 				    "char32_t", NULL, 0);
5985796c8dcSSimon Schubert 	    break;
5995796c8dcSSimon Schubert 	  default:
600c50c785cSJohn Marino 	    internal_error (__FILE__, __LINE__, _("unhandled c_string_type"));
6015796c8dcSSimon Schubert 	  }
6025796c8dcSSimon Schubert 
6035796c8dcSSimon Schubert 	/* Ensure TYPE_LENGTH is valid for TYPE.  */
6045796c8dcSSimon Schubert 	check_typedef (type);
6055796c8dcSSimon Schubert 
606c50c785cSJohn Marino 	/* If the caller expects an array of some integral type,
607c50c785cSJohn Marino 	   satisfy them.  If something odder is expected, rely on the
608c50c785cSJohn Marino 	   caller to cast.  */
609c50c785cSJohn Marino 	if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_ARRAY)
610c50c785cSJohn Marino 	  {
611c50c785cSJohn Marino 	    struct type *element_type
612c50c785cSJohn Marino 	      = check_typedef (TYPE_TARGET_TYPE (expect_type));
613c50c785cSJohn Marino 
614c50c785cSJohn Marino 	    if (TYPE_CODE (element_type) == TYPE_CODE_INT
615c50c785cSJohn Marino 		|| TYPE_CODE (element_type) == TYPE_CODE_CHAR)
616c50c785cSJohn Marino 	      {
617c50c785cSJohn Marino 		type = element_type;
618c50c785cSJohn Marino 		satisfy_expected = 1;
619c50c785cSJohn Marino 	      }
620c50c785cSJohn Marino 	  }
621c50c785cSJohn Marino 
622cf7f2e2dSJohn Marino 	dest_charset = charset_for_string_type (dest_type, exp->gdbarch);
6235796c8dcSSimon Schubert 
6245796c8dcSSimon Schubert 	++*pos;
6255796c8dcSSimon Schubert 	while (*pos < limit)
6265796c8dcSSimon Schubert 	  {
6275796c8dcSSimon Schubert 	    int len;
6285796c8dcSSimon Schubert 
6295796c8dcSSimon Schubert 	    len = longest_to_int (exp->elts[*pos].longconst);
6305796c8dcSSimon Schubert 
6315796c8dcSSimon Schubert 	    ++*pos;
6325796c8dcSSimon Schubert 	    if (noside != EVAL_SKIP)
6335796c8dcSSimon Schubert 	      parse_one_string (&output, &exp->elts[*pos].string, len,
6345796c8dcSSimon Schubert 				dest_charset, type);
6355796c8dcSSimon Schubert 	    *pos += BYTES_TO_EXP_ELEM (len);
6365796c8dcSSimon Schubert 	  }
6375796c8dcSSimon Schubert 
6385796c8dcSSimon Schubert 	/* Skip the trailing length and opcode.  */
6395796c8dcSSimon Schubert 	*pos += 2;
6405796c8dcSSimon Schubert 
6415796c8dcSSimon Schubert 	if (noside == EVAL_SKIP)
6425796c8dcSSimon Schubert 	  {
6435796c8dcSSimon Schubert 	    /* Return a dummy value of the appropriate type.  */
644c50c785cSJohn Marino 	    if (expect_type != NULL)
645c50c785cSJohn Marino 	      result = allocate_value (expect_type);
646c50c785cSJohn Marino 	    else if ((dest_type & C_CHAR) != 0)
6475796c8dcSSimon Schubert 	      result = allocate_value (type);
6485796c8dcSSimon Schubert 	    else
6495796c8dcSSimon Schubert 	      result = value_cstring ("", 0, type);
6505796c8dcSSimon Schubert 	    do_cleanups (cleanup);
6515796c8dcSSimon Schubert 	    return result;
6525796c8dcSSimon Schubert 	  }
6535796c8dcSSimon Schubert 
6545796c8dcSSimon Schubert 	if ((dest_type & C_CHAR) != 0)
6555796c8dcSSimon Schubert 	  {
6565796c8dcSSimon Schubert 	    LONGEST value;
6575796c8dcSSimon Schubert 
6585796c8dcSSimon Schubert 	    if (obstack_object_size (&output) != TYPE_LENGTH (type))
659c50c785cSJohn Marino 	      error (_("Could not convert character "
660c50c785cSJohn Marino 		       "constant to target character set"));
6615796c8dcSSimon Schubert 	    value = unpack_long (type, obstack_base (&output));
6625796c8dcSSimon Schubert 	    result = value_from_longest (type, value);
6635796c8dcSSimon Schubert 	  }
6645796c8dcSSimon Schubert 	else
6655796c8dcSSimon Schubert 	  {
6665796c8dcSSimon Schubert 	    int i;
667cf7f2e2dSJohn Marino 
6685796c8dcSSimon Schubert 	    /* Write the terminating character.  */
6695796c8dcSSimon Schubert 	    for (i = 0; i < TYPE_LENGTH (type); ++i)
6705796c8dcSSimon Schubert 	      obstack_1grow (&output, 0);
671c50c785cSJohn Marino 
672c50c785cSJohn Marino 	    if (satisfy_expected)
673c50c785cSJohn Marino 	      {
674c50c785cSJohn Marino 		LONGEST low_bound, high_bound;
675c50c785cSJohn Marino 		int element_size = TYPE_LENGTH (type);
676c50c785cSJohn Marino 
677c50c785cSJohn Marino 		if (get_discrete_bounds (TYPE_INDEX_TYPE (expect_type),
678c50c785cSJohn Marino 					 &low_bound, &high_bound) < 0)
679c50c785cSJohn Marino 		  {
680c50c785cSJohn Marino 		    low_bound = 0;
681c50c785cSJohn Marino 		    high_bound = (TYPE_LENGTH (expect_type) / element_size) - 1;
682c50c785cSJohn Marino 		  }
683c50c785cSJohn Marino 		if (obstack_object_size (&output) / element_size
684c50c785cSJohn Marino 		    > (high_bound - low_bound + 1))
685c50c785cSJohn Marino 		  error (_("Too many array elements"));
686c50c785cSJohn Marino 
687c50c785cSJohn Marino 		result = allocate_value (expect_type);
688c50c785cSJohn Marino 		memcpy (value_contents_raw (result), obstack_base (&output),
689c50c785cSJohn Marino 			obstack_object_size (&output));
690c50c785cSJohn Marino 	      }
691c50c785cSJohn Marino 	    else
6925796c8dcSSimon Schubert 	      result = value_cstring (obstack_base (&output),
6935796c8dcSSimon Schubert 				      obstack_object_size (&output),
6945796c8dcSSimon Schubert 				      type);
6955796c8dcSSimon Schubert 	  }
6965796c8dcSSimon Schubert 	do_cleanups (cleanup);
6975796c8dcSSimon Schubert 	return result;
6985796c8dcSSimon Schubert       }
6995796c8dcSSimon Schubert       break;
7005796c8dcSSimon Schubert 
7015796c8dcSSimon Schubert     default:
7025796c8dcSSimon Schubert       break;
7035796c8dcSSimon Schubert     }
7045796c8dcSSimon Schubert   return evaluate_subexp_standard (expect_type, exp, pos, noside);
7055796c8dcSSimon Schubert }
7065796c8dcSSimon Schubert 
7075796c8dcSSimon Schubert 
7085796c8dcSSimon Schubert 
7095796c8dcSSimon Schubert /* Table mapping opcodes into strings for printing operators
7105796c8dcSSimon Schubert    and precedences of the operators.  */
7115796c8dcSSimon Schubert 
7125796c8dcSSimon Schubert const struct op_print c_op_print_tab[] =
7135796c8dcSSimon Schubert {
7145796c8dcSSimon Schubert   {",", BINOP_COMMA, PREC_COMMA, 0},
7155796c8dcSSimon Schubert   {"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
7165796c8dcSSimon Schubert   {"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
7175796c8dcSSimon Schubert   {"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
7185796c8dcSSimon Schubert   {"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
7195796c8dcSSimon Schubert   {"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
7205796c8dcSSimon Schubert   {"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
7215796c8dcSSimon Schubert   {"==", BINOP_EQUAL, PREC_EQUAL, 0},
7225796c8dcSSimon Schubert   {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
7235796c8dcSSimon Schubert   {"<=", BINOP_LEQ, PREC_ORDER, 0},
7245796c8dcSSimon Schubert   {">=", BINOP_GEQ, PREC_ORDER, 0},
7255796c8dcSSimon Schubert   {">", BINOP_GTR, PREC_ORDER, 0},
7265796c8dcSSimon Schubert   {"<", BINOP_LESS, PREC_ORDER, 0},
7275796c8dcSSimon Schubert   {">>", BINOP_RSH, PREC_SHIFT, 0},
7285796c8dcSSimon Schubert   {"<<", BINOP_LSH, PREC_SHIFT, 0},
7295796c8dcSSimon Schubert   {"+", BINOP_ADD, PREC_ADD, 0},
7305796c8dcSSimon Schubert   {"-", BINOP_SUB, PREC_ADD, 0},
7315796c8dcSSimon Schubert   {"*", BINOP_MUL, PREC_MUL, 0},
7325796c8dcSSimon Schubert   {"/", BINOP_DIV, PREC_MUL, 0},
7335796c8dcSSimon Schubert   {"%", BINOP_REM, PREC_MUL, 0},
7345796c8dcSSimon Schubert   {"@", BINOP_REPEAT, PREC_REPEAT, 0},
735*ef5ccd6cSJohn Marino   {"+", UNOP_PLUS, PREC_PREFIX, 0},
7365796c8dcSSimon Schubert   {"-", UNOP_NEG, PREC_PREFIX, 0},
7375796c8dcSSimon Schubert   {"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
7385796c8dcSSimon Schubert   {"~", UNOP_COMPLEMENT, PREC_PREFIX, 0},
7395796c8dcSSimon Schubert   {"*", UNOP_IND, PREC_PREFIX, 0},
7405796c8dcSSimon Schubert   {"&", UNOP_ADDR, PREC_PREFIX, 0},
7415796c8dcSSimon Schubert   {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
7425796c8dcSSimon Schubert   {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
7435796c8dcSSimon Schubert   {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
7445796c8dcSSimon Schubert   {NULL, 0, 0, 0}
7455796c8dcSSimon Schubert };
7465796c8dcSSimon Schubert 
7475796c8dcSSimon Schubert enum c_primitive_types {
7485796c8dcSSimon Schubert   c_primitive_type_int,
7495796c8dcSSimon Schubert   c_primitive_type_long,
7505796c8dcSSimon Schubert   c_primitive_type_short,
7515796c8dcSSimon Schubert   c_primitive_type_char,
7525796c8dcSSimon Schubert   c_primitive_type_float,
7535796c8dcSSimon Schubert   c_primitive_type_double,
7545796c8dcSSimon Schubert   c_primitive_type_void,
7555796c8dcSSimon Schubert   c_primitive_type_long_long,
7565796c8dcSSimon Schubert   c_primitive_type_signed_char,
7575796c8dcSSimon Schubert   c_primitive_type_unsigned_char,
7585796c8dcSSimon Schubert   c_primitive_type_unsigned_short,
7595796c8dcSSimon Schubert   c_primitive_type_unsigned_int,
7605796c8dcSSimon Schubert   c_primitive_type_unsigned_long,
7615796c8dcSSimon Schubert   c_primitive_type_unsigned_long_long,
7625796c8dcSSimon Schubert   c_primitive_type_long_double,
7635796c8dcSSimon Schubert   c_primitive_type_complex,
7645796c8dcSSimon Schubert   c_primitive_type_double_complex,
7655796c8dcSSimon Schubert   c_primitive_type_decfloat,
7665796c8dcSSimon Schubert   c_primitive_type_decdouble,
7675796c8dcSSimon Schubert   c_primitive_type_declong,
7685796c8dcSSimon Schubert   nr_c_primitive_types
7695796c8dcSSimon Schubert };
7705796c8dcSSimon Schubert 
7715796c8dcSSimon Schubert void
c_language_arch_info(struct gdbarch * gdbarch,struct language_arch_info * lai)7725796c8dcSSimon Schubert c_language_arch_info (struct gdbarch *gdbarch,
7735796c8dcSSimon Schubert 		      struct language_arch_info *lai)
7745796c8dcSSimon Schubert {
7755796c8dcSSimon Schubert   const struct builtin_type *builtin = builtin_type (gdbarch);
776cf7f2e2dSJohn Marino 
7775796c8dcSSimon Schubert   lai->string_char_type = builtin->builtin_char;
7785796c8dcSSimon Schubert   lai->primitive_type_vector
7795796c8dcSSimon Schubert     = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_c_primitive_types + 1,
7805796c8dcSSimon Schubert 			      struct type *);
7815796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_int] = builtin->builtin_int;
7825796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_long] = builtin->builtin_long;
7835796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_short] = builtin->builtin_short;
7845796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_char] = builtin->builtin_char;
7855796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_float] = builtin->builtin_float;
7865796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_double] = builtin->builtin_double;
7875796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_void] = builtin->builtin_void;
7885796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_long_long] = builtin->builtin_long_long;
7895796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_signed_char] = builtin->builtin_signed_char;
7905796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_unsigned_char] = builtin->builtin_unsigned_char;
7915796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_unsigned_short] = builtin->builtin_unsigned_short;
7925796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_unsigned_int] = builtin->builtin_unsigned_int;
7935796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_unsigned_long] = builtin->builtin_unsigned_long;
7945796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_unsigned_long_long] = builtin->builtin_unsigned_long_long;
7955796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_long_double] = builtin->builtin_long_double;
7965796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_complex] = builtin->builtin_complex;
7975796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_double_complex] = builtin->builtin_double_complex;
7985796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_decfloat] = builtin->builtin_decfloat;
7995796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_decdouble] = builtin->builtin_decdouble;
8005796c8dcSSimon Schubert   lai->primitive_type_vector [c_primitive_type_declong] = builtin->builtin_declong;
8015796c8dcSSimon Schubert 
8025796c8dcSSimon Schubert   lai->bool_type_default = builtin->builtin_int;
8035796c8dcSSimon Schubert }
8045796c8dcSSimon Schubert 
805cf7f2e2dSJohn Marino const struct exp_descriptor exp_descriptor_c =
8065796c8dcSSimon Schubert {
8075796c8dcSSimon Schubert   print_subexp_standard,
8085796c8dcSSimon Schubert   operator_length_standard,
809cf7f2e2dSJohn Marino   operator_check_standard,
8105796c8dcSSimon Schubert   op_name_standard,
8115796c8dcSSimon Schubert   dump_subexp_body_standard,
8125796c8dcSSimon Schubert   evaluate_subexp_c
8135796c8dcSSimon Schubert };
8145796c8dcSSimon Schubert 
8155796c8dcSSimon Schubert const struct language_defn c_language_defn =
8165796c8dcSSimon Schubert {
8175796c8dcSSimon Schubert   "c",				/* Language name */
8185796c8dcSSimon Schubert   language_c,
8195796c8dcSSimon Schubert   range_check_off,
8205796c8dcSSimon Schubert   case_sensitive_on,
8215796c8dcSSimon Schubert   array_row_major,
8225796c8dcSSimon Schubert   macro_expansion_c,
8235796c8dcSSimon Schubert   &exp_descriptor_c,
8245796c8dcSSimon Schubert   c_parse,
8255796c8dcSSimon Schubert   c_error,
8265796c8dcSSimon Schubert   null_post_parser,
8275796c8dcSSimon Schubert   c_printchar,			/* Print a character constant */
8285796c8dcSSimon Schubert   c_printstr,			/* Function to print string constant */
8295796c8dcSSimon Schubert   c_emit_char,			/* Print a single char */
8305796c8dcSSimon Schubert   c_print_type,			/* Print a type using appropriate syntax */
8315796c8dcSSimon Schubert   c_print_typedef,		/* Print a typedef using appropriate syntax */
8325796c8dcSSimon Schubert   c_val_print,			/* Print a value using appropriate syntax */
8335796c8dcSSimon Schubert   c_value_print,		/* Print a top-level value */
834*ef5ccd6cSJohn Marino   default_read_var_value,	/* la_read_var_value */
8355796c8dcSSimon Schubert   NULL,				/* Language specific skip_trampoline */
8365796c8dcSSimon Schubert   NULL,				/* name_of_this */
8375796c8dcSSimon Schubert   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
8385796c8dcSSimon Schubert   basic_lookup_transparent_type,/* lookup_transparent_type */
8395796c8dcSSimon Schubert   NULL,				/* Language specific symbol demangler */
840c50c785cSJohn Marino   NULL,				/* Language specific
841c50c785cSJohn Marino 				   class_name_from_physname */
8425796c8dcSSimon Schubert   c_op_print_tab,		/* expression operators for printing */
8435796c8dcSSimon Schubert   1,				/* c-style arrays */
8445796c8dcSSimon Schubert   0,				/* String lower bound */
8455796c8dcSSimon Schubert   default_word_break_characters,
8465796c8dcSSimon Schubert   default_make_symbol_completion_list,
8475796c8dcSSimon Schubert   c_language_arch_info,
8485796c8dcSSimon Schubert   default_print_array_index,
8495796c8dcSSimon Schubert   default_pass_by_reference,
8505796c8dcSSimon Schubert   c_get_string,
851*ef5ccd6cSJohn Marino   NULL,				/* la_get_symbol_name_cmp */
852a45ae5f8SJohn Marino   iterate_over_symbols,
8535796c8dcSSimon Schubert   LANG_MAGIC
8545796c8dcSSimon Schubert };
8555796c8dcSSimon Schubert 
8565796c8dcSSimon Schubert enum cplus_primitive_types {
8575796c8dcSSimon Schubert   cplus_primitive_type_int,
8585796c8dcSSimon Schubert   cplus_primitive_type_long,
8595796c8dcSSimon Schubert   cplus_primitive_type_short,
8605796c8dcSSimon Schubert   cplus_primitive_type_char,
8615796c8dcSSimon Schubert   cplus_primitive_type_float,
8625796c8dcSSimon Schubert   cplus_primitive_type_double,
8635796c8dcSSimon Schubert   cplus_primitive_type_void,
8645796c8dcSSimon Schubert   cplus_primitive_type_long_long,
8655796c8dcSSimon Schubert   cplus_primitive_type_signed_char,
8665796c8dcSSimon Schubert   cplus_primitive_type_unsigned_char,
8675796c8dcSSimon Schubert   cplus_primitive_type_unsigned_short,
8685796c8dcSSimon Schubert   cplus_primitive_type_unsigned_int,
8695796c8dcSSimon Schubert   cplus_primitive_type_unsigned_long,
8705796c8dcSSimon Schubert   cplus_primitive_type_unsigned_long_long,
8715796c8dcSSimon Schubert   cplus_primitive_type_long_double,
8725796c8dcSSimon Schubert   cplus_primitive_type_complex,
8735796c8dcSSimon Schubert   cplus_primitive_type_double_complex,
8745796c8dcSSimon Schubert   cplus_primitive_type_bool,
8755796c8dcSSimon Schubert   cplus_primitive_type_decfloat,
8765796c8dcSSimon Schubert   cplus_primitive_type_decdouble,
8775796c8dcSSimon Schubert   cplus_primitive_type_declong,
8785796c8dcSSimon Schubert   nr_cplus_primitive_types
8795796c8dcSSimon Schubert };
8805796c8dcSSimon Schubert 
8815796c8dcSSimon Schubert static void
cplus_language_arch_info(struct gdbarch * gdbarch,struct language_arch_info * lai)8825796c8dcSSimon Schubert cplus_language_arch_info (struct gdbarch *gdbarch,
8835796c8dcSSimon Schubert 			  struct language_arch_info *lai)
8845796c8dcSSimon Schubert {
8855796c8dcSSimon Schubert   const struct builtin_type *builtin = builtin_type (gdbarch);
886cf7f2e2dSJohn Marino 
8875796c8dcSSimon Schubert   lai->string_char_type = builtin->builtin_char;
8885796c8dcSSimon Schubert   lai->primitive_type_vector
8895796c8dcSSimon Schubert     = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_cplus_primitive_types + 1,
8905796c8dcSSimon Schubert 			      struct type *);
8915796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_int]
8925796c8dcSSimon Schubert     = builtin->builtin_int;
8935796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_long]
8945796c8dcSSimon Schubert     = builtin->builtin_long;
8955796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_short]
8965796c8dcSSimon Schubert     = builtin->builtin_short;
8975796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_char]
8985796c8dcSSimon Schubert     = builtin->builtin_char;
8995796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_float]
9005796c8dcSSimon Schubert     = builtin->builtin_float;
9015796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_double]
9025796c8dcSSimon Schubert     = builtin->builtin_double;
9035796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_void]
9045796c8dcSSimon Schubert     = builtin->builtin_void;
9055796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_long_long]
9065796c8dcSSimon Schubert     = builtin->builtin_long_long;
9075796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_signed_char]
9085796c8dcSSimon Schubert     = builtin->builtin_signed_char;
9095796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_unsigned_char]
9105796c8dcSSimon Schubert     = builtin->builtin_unsigned_char;
9115796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_unsigned_short]
9125796c8dcSSimon Schubert     = builtin->builtin_unsigned_short;
9135796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_unsigned_int]
9145796c8dcSSimon Schubert     = builtin->builtin_unsigned_int;
9155796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_unsigned_long]
9165796c8dcSSimon Schubert     = builtin->builtin_unsigned_long;
9175796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_unsigned_long_long]
9185796c8dcSSimon Schubert     = builtin->builtin_unsigned_long_long;
9195796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_long_double]
9205796c8dcSSimon Schubert     = builtin->builtin_long_double;
9215796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_complex]
9225796c8dcSSimon Schubert     = builtin->builtin_complex;
9235796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_double_complex]
9245796c8dcSSimon Schubert     = builtin->builtin_double_complex;
9255796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_bool]
9265796c8dcSSimon Schubert     = builtin->builtin_bool;
9275796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_decfloat]
9285796c8dcSSimon Schubert     = builtin->builtin_decfloat;
9295796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_decdouble]
9305796c8dcSSimon Schubert     = builtin->builtin_decdouble;
9315796c8dcSSimon Schubert   lai->primitive_type_vector [cplus_primitive_type_declong]
9325796c8dcSSimon Schubert     = builtin->builtin_declong;
9335796c8dcSSimon Schubert 
9345796c8dcSSimon Schubert   lai->bool_type_symbol = "bool";
9355796c8dcSSimon Schubert   lai->bool_type_default = builtin->builtin_bool;
9365796c8dcSSimon Schubert }
9375796c8dcSSimon Schubert 
9385796c8dcSSimon Schubert const struct language_defn cplus_language_defn =
9395796c8dcSSimon Schubert {
9405796c8dcSSimon Schubert   "c++",			/* Language name */
9415796c8dcSSimon Schubert   language_cplus,
9425796c8dcSSimon Schubert   range_check_off,
9435796c8dcSSimon Schubert   case_sensitive_on,
9445796c8dcSSimon Schubert   array_row_major,
9455796c8dcSSimon Schubert   macro_expansion_c,
9465796c8dcSSimon Schubert   &exp_descriptor_c,
9475796c8dcSSimon Schubert   c_parse,
9485796c8dcSSimon Schubert   c_error,
9495796c8dcSSimon Schubert   null_post_parser,
9505796c8dcSSimon Schubert   c_printchar,			/* Print a character constant */
9515796c8dcSSimon Schubert   c_printstr,			/* Function to print string constant */
9525796c8dcSSimon Schubert   c_emit_char,			/* Print a single char */
9535796c8dcSSimon Schubert   c_print_type,			/* Print a type using appropriate syntax */
9545796c8dcSSimon Schubert   c_print_typedef,		/* Print a typedef using appropriate syntax */
9555796c8dcSSimon Schubert   c_val_print,			/* Print a value using appropriate syntax */
9565796c8dcSSimon Schubert   c_value_print,		/* Print a top-level value */
957*ef5ccd6cSJohn Marino   default_read_var_value,	/* la_read_var_value */
9585796c8dcSSimon Schubert   cplus_skip_trampoline,	/* Language specific skip_trampoline */
9595796c8dcSSimon Schubert   "this",                       /* name_of_this */
9605796c8dcSSimon Schubert   cp_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
9615796c8dcSSimon Schubert   cp_lookup_transparent_type,   /* lookup_transparent_type */
9625796c8dcSSimon Schubert   cplus_demangle,		/* Language specific symbol demangler */
963c50c785cSJohn Marino   cp_class_name_from_physname,  /* Language specific
964c50c785cSJohn Marino 				   class_name_from_physname */
9655796c8dcSSimon Schubert   c_op_print_tab,		/* expression operators for printing */
9665796c8dcSSimon Schubert   1,				/* c-style arrays */
9675796c8dcSSimon Schubert   0,				/* String lower bound */
9685796c8dcSSimon Schubert   default_word_break_characters,
9695796c8dcSSimon Schubert   default_make_symbol_completion_list,
9705796c8dcSSimon Schubert   cplus_language_arch_info,
9715796c8dcSSimon Schubert   default_print_array_index,
9725796c8dcSSimon Schubert   cp_pass_by_reference,
9735796c8dcSSimon Schubert   c_get_string,
974*ef5ccd6cSJohn Marino   NULL,				/* la_get_symbol_name_cmp */
975a45ae5f8SJohn Marino   iterate_over_symbols,
9765796c8dcSSimon Schubert   LANG_MAGIC
9775796c8dcSSimon Schubert };
9785796c8dcSSimon Schubert 
9795796c8dcSSimon Schubert const struct language_defn asm_language_defn =
9805796c8dcSSimon Schubert {
9815796c8dcSSimon Schubert   "asm",			/* Language name */
9825796c8dcSSimon Schubert   language_asm,
9835796c8dcSSimon Schubert   range_check_off,
9845796c8dcSSimon Schubert   case_sensitive_on,
9855796c8dcSSimon Schubert   array_row_major,
9865796c8dcSSimon Schubert   macro_expansion_c,
9875796c8dcSSimon Schubert   &exp_descriptor_c,
9885796c8dcSSimon Schubert   c_parse,
9895796c8dcSSimon Schubert   c_error,
9905796c8dcSSimon Schubert   null_post_parser,
9915796c8dcSSimon Schubert   c_printchar,			/* Print a character constant */
9925796c8dcSSimon Schubert   c_printstr,			/* Function to print string constant */
9935796c8dcSSimon Schubert   c_emit_char,			/* Print a single char */
9945796c8dcSSimon Schubert   c_print_type,			/* Print a type using appropriate syntax */
9955796c8dcSSimon Schubert   c_print_typedef,		/* Print a typedef using appropriate syntax */
9965796c8dcSSimon Schubert   c_val_print,			/* Print a value using appropriate syntax */
9975796c8dcSSimon Schubert   c_value_print,		/* Print a top-level value */
998*ef5ccd6cSJohn Marino   default_read_var_value,	/* la_read_var_value */
9995796c8dcSSimon Schubert   NULL,				/* Language specific skip_trampoline */
10005796c8dcSSimon Schubert   NULL,				/* name_of_this */
10015796c8dcSSimon Schubert   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
10025796c8dcSSimon Schubert   basic_lookup_transparent_type,/* lookup_transparent_type */
10035796c8dcSSimon Schubert   NULL,				/* Language specific symbol demangler */
1004c50c785cSJohn Marino   NULL,				/* Language specific
1005c50c785cSJohn Marino 				   class_name_from_physname */
10065796c8dcSSimon Schubert   c_op_print_tab,		/* expression operators for printing */
10075796c8dcSSimon Schubert   1,				/* c-style arrays */
10085796c8dcSSimon Schubert   0,				/* String lower bound */
10095796c8dcSSimon Schubert   default_word_break_characters,
10105796c8dcSSimon Schubert   default_make_symbol_completion_list,
10115796c8dcSSimon Schubert   c_language_arch_info, 	/* FIXME: la_language_arch_info.  */
10125796c8dcSSimon Schubert   default_print_array_index,
10135796c8dcSSimon Schubert   default_pass_by_reference,
10145796c8dcSSimon Schubert   c_get_string,
1015*ef5ccd6cSJohn Marino   NULL,				/* la_get_symbol_name_cmp */
1016a45ae5f8SJohn Marino   iterate_over_symbols,
10175796c8dcSSimon Schubert   LANG_MAGIC
10185796c8dcSSimon Schubert };
10195796c8dcSSimon Schubert 
10205796c8dcSSimon Schubert /* The following language_defn does not represent a real language.
10215796c8dcSSimon Schubert    It just provides a minimal support a-la-C that should allow users
10225796c8dcSSimon Schubert    to do some simple operations when debugging applications that use
10235796c8dcSSimon Schubert    a language currently not supported by GDB.  */
10245796c8dcSSimon Schubert 
10255796c8dcSSimon Schubert const struct language_defn minimal_language_defn =
10265796c8dcSSimon Schubert {
10275796c8dcSSimon Schubert   "minimal",			/* Language name */
10285796c8dcSSimon Schubert   language_minimal,
10295796c8dcSSimon Schubert   range_check_off,
10305796c8dcSSimon Schubert   case_sensitive_on,
10315796c8dcSSimon Schubert   array_row_major,
10325796c8dcSSimon Schubert   macro_expansion_c,
10335796c8dcSSimon Schubert   &exp_descriptor_c,
10345796c8dcSSimon Schubert   c_parse,
10355796c8dcSSimon Schubert   c_error,
10365796c8dcSSimon Schubert   null_post_parser,
10375796c8dcSSimon Schubert   c_printchar,			/* Print a character constant */
10385796c8dcSSimon Schubert   c_printstr,			/* Function to print string constant */
10395796c8dcSSimon Schubert   c_emit_char,			/* Print a single char */
10405796c8dcSSimon Schubert   c_print_type,			/* Print a type using appropriate syntax */
10415796c8dcSSimon Schubert   c_print_typedef,		/* Print a typedef using appropriate syntax */
10425796c8dcSSimon Schubert   c_val_print,			/* Print a value using appropriate syntax */
10435796c8dcSSimon Schubert   c_value_print,		/* Print a top-level value */
1044*ef5ccd6cSJohn Marino   default_read_var_value,	/* la_read_var_value */
10455796c8dcSSimon Schubert   NULL,				/* Language specific skip_trampoline */
10465796c8dcSSimon Schubert   NULL,				/* name_of_this */
10475796c8dcSSimon Schubert   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
10485796c8dcSSimon Schubert   basic_lookup_transparent_type,/* lookup_transparent_type */
10495796c8dcSSimon Schubert   NULL,				/* Language specific symbol demangler */
1050c50c785cSJohn Marino   NULL,				/* Language specific
1051c50c785cSJohn Marino 				   class_name_from_physname */
10525796c8dcSSimon Schubert   c_op_print_tab,		/* expression operators for printing */
10535796c8dcSSimon Schubert   1,				/* c-style arrays */
10545796c8dcSSimon Schubert   0,				/* String lower bound */
10555796c8dcSSimon Schubert   default_word_break_characters,
10565796c8dcSSimon Schubert   default_make_symbol_completion_list,
10575796c8dcSSimon Schubert   c_language_arch_info,
10585796c8dcSSimon Schubert   default_print_array_index,
10595796c8dcSSimon Schubert   default_pass_by_reference,
10605796c8dcSSimon Schubert   c_get_string,
1061*ef5ccd6cSJohn Marino   NULL,				/* la_get_symbol_name_cmp */
1062a45ae5f8SJohn Marino   iterate_over_symbols,
10635796c8dcSSimon Schubert   LANG_MAGIC
10645796c8dcSSimon Schubert };
10655796c8dcSSimon Schubert 
10665796c8dcSSimon Schubert void
_initialize_c_language(void)10675796c8dcSSimon Schubert _initialize_c_language (void)
10685796c8dcSSimon Schubert {
10695796c8dcSSimon Schubert   add_language (&c_language_defn);
10705796c8dcSSimon Schubert   add_language (&cplus_language_defn);
10715796c8dcSSimon Schubert   add_language (&asm_language_defn);
10725796c8dcSSimon Schubert   add_language (&minimal_language_defn);
10735796c8dcSSimon Schubert }
1074