* sim/cris/hw/rv-n-cris/irq6.ms: New test.
[platform/upstream/binutils.git] / gdb / c-lang.c
1 /* C language support routines for GDB, the GNU debugger.
2
3    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002,
4    2003, 2004, 2005 Free Software Foundation, Inc.
5
6    This file is part of GDB.
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    Boston, MA 02110-1301, USA.  */
22
23 #include "defs.h"
24 #include "symtab.h"
25 #include "gdbtypes.h"
26 #include "expression.h"
27 #include "parser-defs.h"
28 #include "language.h"
29 #include "c-lang.h"
30 #include "valprint.h"
31 #include "macroscope.h"
32 #include "gdb_assert.h"
33 #include "charset.h"
34 #include "gdb_string.h"
35 #include "demangle.h"
36 #include "cp-support.h"
37
38 extern void _initialize_c_language (void);
39 static void c_emit_char (int c, struct ui_file * stream, int quoter);
40
41 /* Print the character C on STREAM as part of the contents of a literal
42    string whose delimiter is QUOTER.  Note that that format for printing
43    characters and strings is language specific. */
44
45 static void
46 c_emit_char (int c, struct ui_file *stream, int quoter)
47 {
48   const char *escape;
49   int host_char;
50
51   c &= 0xFF;                    /* Avoid sign bit follies */
52
53   escape = c_target_char_has_backslash_escape (c);
54   if (escape)
55     {
56       if (quoter == '"' && strcmp (escape, "0") == 0)
57         /* Print nulls embedded in double quoted strings as \000 to
58            prevent ambiguity.  */
59         fprintf_filtered (stream, "\\000");
60       else
61         fprintf_filtered (stream, "\\%s", escape);
62     }
63   else if (target_char_to_host (c, &host_char)
64            && host_char_print_literally (host_char))
65     {
66       if (host_char == '\\' || host_char == quoter)
67         fputs_filtered ("\\", stream);
68       fprintf_filtered (stream, "%c", host_char);
69     }
70   else
71     fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
72 }
73
74 void
75 c_printchar (int c, struct ui_file *stream)
76 {
77   fputc_filtered ('\'', stream);
78   LA_EMIT_CHAR (c, stream, '\'');
79   fputc_filtered ('\'', stream);
80 }
81
82 /* Print the character string STRING, printing at most LENGTH characters.
83    LENGTH is -1 if the string is nul terminated.  Each character is WIDTH bytes
84    long.  Printing stops early if the number hits print_max; repeat counts are
85    printed as appropriate.  Print ellipses at the end if we had to stop before
86    printing LENGTH characters, or if FORCE_ELLIPSES.  */
87
88 void
89 c_printstr (struct ui_file *stream, const gdb_byte *string,
90             unsigned int length, int width, int force_ellipses)
91 {
92   unsigned int i;
93   unsigned int things_printed = 0;
94   int in_quotes = 0;
95   int need_comma = 0;
96
97   /* If the string was not truncated due to `set print elements', and
98      the last byte of it is a null, we don't print that, in traditional C
99      style.  */
100   if (!force_ellipses
101       && length > 0
102       && (extract_unsigned_integer (string + (length - 1) * width, width)
103           == '\0'))
104     length--;
105
106   if (length == 0)
107     {
108       fputs_filtered ("\"\"", stream);
109       return;
110     }
111
112   for (i = 0; i < length && things_printed < print_max; ++i)
113     {
114       /* Position of the character we are examining
115          to see whether it is repeated.  */
116       unsigned int rep1;
117       /* Number of repetitions we have detected so far.  */
118       unsigned int reps;
119       unsigned long current_char;
120
121       QUIT;
122
123       if (need_comma)
124         {
125           fputs_filtered (", ", stream);
126           need_comma = 0;
127         }
128
129       current_char = extract_unsigned_integer (string + i * width, width);
130
131       rep1 = i + 1;
132       reps = 1;
133       while (rep1 < length
134              && extract_unsigned_integer (string + rep1 * width, width)
135              == current_char)
136         {
137           ++rep1;
138           ++reps;
139         }
140
141       if (reps > repeat_count_threshold)
142         {
143           if (in_quotes)
144             {
145               if (inspect_it)
146                 fputs_filtered ("\\\", ", stream);
147               else
148                 fputs_filtered ("\", ", stream);
149               in_quotes = 0;
150             }
151           LA_PRINT_CHAR (current_char, stream);
152           fprintf_filtered (stream, _(" <repeats %u times>"), reps);
153           i = rep1 - 1;
154           things_printed += repeat_count_threshold;
155           need_comma = 1;
156         }
157       else
158         {
159           if (!in_quotes)
160             {
161               if (inspect_it)
162                 fputs_filtered ("\\\"", stream);
163               else
164                 fputs_filtered ("\"", stream);
165               in_quotes = 1;
166             }
167           LA_EMIT_CHAR (current_char, stream, '"');
168           ++things_printed;
169         }
170     }
171
172   /* Terminate the quotes if necessary.  */
173   if (in_quotes)
174     {
175       if (inspect_it)
176         fputs_filtered ("\\\"", stream);
177       else
178         fputs_filtered ("\"", stream);
179     }
180
181   if (force_ellipses || i < length)
182     fputs_filtered ("...", stream);
183 }
184
185 /* Create a fundamental C type using default reasonable for the current
186    target machine.
187
188    Some object/debugging file formats (DWARF version 1, COFF, etc) do not
189    define fundamental types such as "int" or "double".  Others (stabs or
190    DWARF version 2, etc) do define fundamental types.  For the formats which
191    don't provide fundamental types, gdb can create such types using this
192    function.
193
194    FIXME:  Some compilers distinguish explicitly signed integral types
195    (signed short, signed int, signed long) from "regular" integral types
196    (short, int, long) in the debugging information.  There is some dis-
197    agreement as to how useful this feature is.  In particular, gcc does
198    not support this.  Also, only some debugging formats allow the
199    distinction to be passed on to a debugger.  For now, we always just
200    use "short", "int", or "long" as the type name, for both the implicit
201    and explicitly signed types.  This also makes life easier for the
202    gdb test suite since we don't have to account for the differences
203    in output depending upon what the compiler and debugging format
204    support.  We will probably have to re-examine the issue when gdb
205    starts taking its fundamental type information directly from the
206    debugging information supplied by the compiler.  fnf@cygnus.com */
207
208 struct type *
209 c_create_fundamental_type (struct objfile *objfile, int typeid)
210 {
211   struct type *type = NULL;
212
213   switch (typeid)
214     {
215     default:
216       /* FIXME:  For now, if we are asked to produce a type not in this
217          language, create the equivalent of a C integer type with the
218          name "<?type?>".  When all the dust settles from the type
219          reconstruction work, this should probably become an error. */
220       type = init_type (TYPE_CODE_INT,
221                         TARGET_INT_BIT / TARGET_CHAR_BIT,
222                         0, "<?type?>", objfile);
223       warning (_("internal error: no C/C++ fundamental type %d"), typeid);
224       break;
225     case FT_VOID:
226       type = init_type (TYPE_CODE_VOID,
227                         TARGET_CHAR_BIT / TARGET_CHAR_BIT,
228                         0, "void", objfile);
229       break;
230     case FT_BOOLEAN:
231       type = init_type (TYPE_CODE_BOOL,
232                         TARGET_CHAR_BIT / TARGET_CHAR_BIT,
233                         0, "bool", objfile);
234       break;
235     case FT_CHAR:
236       type = init_type (TYPE_CODE_INT,
237                         TARGET_CHAR_BIT / TARGET_CHAR_BIT,
238                         TYPE_FLAG_NOSIGN, "char", objfile);
239       break;
240     case FT_SIGNED_CHAR:
241       type = init_type (TYPE_CODE_INT,
242                         TARGET_CHAR_BIT / TARGET_CHAR_BIT,
243                         0, "signed char", objfile);
244       break;
245     case FT_UNSIGNED_CHAR:
246       type = init_type (TYPE_CODE_INT,
247                         TARGET_CHAR_BIT / TARGET_CHAR_BIT,
248                         TYPE_FLAG_UNSIGNED, "unsigned char", objfile);
249       break;
250     case FT_SHORT:
251       type = init_type (TYPE_CODE_INT,
252                         TARGET_SHORT_BIT / TARGET_CHAR_BIT,
253                         0, "short", objfile);
254       break;
255     case FT_SIGNED_SHORT:
256       type = init_type (TYPE_CODE_INT,
257                         TARGET_SHORT_BIT / TARGET_CHAR_BIT,
258                         0, "short", objfile);   /* FIXME-fnf */
259       break;
260     case FT_UNSIGNED_SHORT:
261       type = init_type (TYPE_CODE_INT,
262                         TARGET_SHORT_BIT / TARGET_CHAR_BIT,
263                         TYPE_FLAG_UNSIGNED, "unsigned short", objfile);
264       break;
265     case FT_INTEGER:
266       type = init_type (TYPE_CODE_INT,
267                         TARGET_INT_BIT / TARGET_CHAR_BIT,
268                         0, "int", objfile);
269       break;
270     case FT_SIGNED_INTEGER:
271       type = init_type (TYPE_CODE_INT,
272                         TARGET_INT_BIT / TARGET_CHAR_BIT,
273                         0, "int", objfile);     /* FIXME -fnf */
274       break;
275     case FT_UNSIGNED_INTEGER:
276       type = init_type (TYPE_CODE_INT,
277                         TARGET_INT_BIT / TARGET_CHAR_BIT,
278                         TYPE_FLAG_UNSIGNED, "unsigned int", objfile);
279       break;
280     case FT_LONG:
281       type = init_type (TYPE_CODE_INT,
282                         TARGET_LONG_BIT / TARGET_CHAR_BIT,
283                         0, "long", objfile);
284       break;
285     case FT_SIGNED_LONG:
286       type = init_type (TYPE_CODE_INT,
287                         TARGET_LONG_BIT / TARGET_CHAR_BIT,
288                         0, "long", objfile);    /* FIXME -fnf */
289       break;
290     case FT_UNSIGNED_LONG:
291       type = init_type (TYPE_CODE_INT,
292                         TARGET_LONG_BIT / TARGET_CHAR_BIT,
293                         TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
294       break;
295     case FT_LONG_LONG:
296       type = init_type (TYPE_CODE_INT,
297                         TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
298                         0, "long long", objfile);
299       break;
300     case FT_SIGNED_LONG_LONG:
301       type = init_type (TYPE_CODE_INT,
302                         TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
303                         0, "signed long long", objfile);
304       break;
305     case FT_UNSIGNED_LONG_LONG:
306       type = init_type (TYPE_CODE_INT,
307                         TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
308                         TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
309       break;
310     case FT_FLOAT:
311       type = init_type (TYPE_CODE_FLT,
312                         TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
313                         0, "float", objfile);
314       break;
315     case FT_DBL_PREC_FLOAT:
316       type = init_type (TYPE_CODE_FLT,
317                         TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
318                         0, "double", objfile);
319       break;
320     case FT_EXT_PREC_FLOAT:
321       type = init_type (TYPE_CODE_FLT,
322                         TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
323                         0, "long double", objfile);
324       break;
325     case FT_COMPLEX:
326       type = init_type (TYPE_CODE_FLT,
327                         2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
328                         0, "complex float", objfile);
329       TYPE_TARGET_TYPE (type)
330         = init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
331                      0, "float", objfile);
332       break;
333     case FT_DBL_PREC_COMPLEX:
334       type = init_type (TYPE_CODE_FLT,
335                         2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
336                         0, "complex double", objfile);
337       TYPE_TARGET_TYPE (type)
338         = init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
339                      0, "double", objfile);
340       break;
341     case FT_EXT_PREC_COMPLEX:
342       type = init_type (TYPE_CODE_FLT,
343                         2 * TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
344                         0, "complex long double", objfile);
345       TYPE_TARGET_TYPE (type)
346         = init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
347                      0, "long double", objfile);
348       break;
349     case FT_TEMPLATE_ARG:
350       type = init_type (TYPE_CODE_TEMPLATE_ARG,
351                         0,
352                         0, "<template arg>", objfile);
353       break;
354     }
355   return (type);
356 }
357 \f
358 /* Preprocessing and parsing C and C++ expressions.  */
359
360
361 /* When we find that lexptr (the global var defined in parse.c) is
362    pointing at a macro invocation, we expand the invocation, and call
363    scan_macro_expansion to save the old lexptr here and point lexptr
364    into the expanded text.  When we reach the end of that, we call
365    end_macro_expansion to pop back to the value we saved here.  The
366    macro expansion code promises to return only fully-expanded text,
367    so we don't need to "push" more than one level.
368
369    This is disgusting, of course.  It would be cleaner to do all macro
370    expansion beforehand, and then hand that to lexptr.  But we don't
371    really know where the expression ends.  Remember, in a command like
372
373      (gdb) break *ADDRESS if CONDITION
374
375    we evaluate ADDRESS in the scope of the current frame, but we
376    evaluate CONDITION in the scope of the breakpoint's location.  So
377    it's simply wrong to try to macro-expand the whole thing at once.  */
378 static char *macro_original_text;
379 static char *macro_expanded_text;
380
381
382 void
383 scan_macro_expansion (char *expansion)
384 {
385   /* We'd better not be trying to push the stack twice.  */
386   gdb_assert (! macro_original_text);
387   gdb_assert (! macro_expanded_text);
388
389   /* Save the old lexptr value, so we can return to it when we're done
390      parsing the expanded text.  */
391   macro_original_text = lexptr;
392   lexptr = expansion;
393
394   /* Save the expanded text, so we can free it when we're finished.  */
395   macro_expanded_text = expansion;
396 }
397
398
399 int
400 scanning_macro_expansion (void)
401 {
402   return macro_original_text != 0;
403 }
404
405
406 void 
407 finished_macro_expansion (void)
408 {
409   /* There'd better be something to pop back to, and we better have
410      saved a pointer to the start of the expanded text.  */
411   gdb_assert (macro_original_text);
412   gdb_assert (macro_expanded_text);
413
414   /* Pop back to the original text.  */
415   lexptr = macro_original_text;
416   macro_original_text = 0;
417
418   /* Free the expanded text.  */
419   xfree (macro_expanded_text);
420   macro_expanded_text = 0;
421 }
422
423
424 static void
425 scan_macro_cleanup (void *dummy)
426 {
427   if (macro_original_text)
428     finished_macro_expansion ();
429 }
430
431
432 /* We set these global variables before calling c_parse, to tell it
433    how it to find macro definitions for the expression at hand.  */
434 macro_lookup_ftype *expression_macro_lookup_func;
435 void *expression_macro_lookup_baton;
436
437
438 static struct macro_definition *
439 null_macro_lookup (const char *name, void *baton)
440 {
441   return 0;
442 }
443
444
445 static int
446 c_preprocess_and_parse (void)
447 {
448   /* Set up a lookup function for the macro expander.  */
449   struct macro_scope *scope = 0;
450   struct cleanup *back_to = make_cleanup (free_current_contents, &scope);
451
452   if (expression_context_block)
453     scope = sal_macro_scope (find_pc_line (expression_context_pc, 0));
454   else
455     scope = default_macro_scope ();
456
457   if (scope)
458     {
459       expression_macro_lookup_func = standard_macro_lookup;
460       expression_macro_lookup_baton = (void *) scope;
461     }
462   else
463     {
464       expression_macro_lookup_func = null_macro_lookup;
465       expression_macro_lookup_baton = 0;      
466     }
467
468   gdb_assert (! macro_original_text);
469   make_cleanup (scan_macro_cleanup, 0);
470
471   {
472     int result = c_parse ();
473     do_cleanups (back_to);
474     return result;
475   }
476 }
477
478
479 \f
480 /* Table mapping opcodes into strings for printing operators
481    and precedences of the operators.  */
482
483 const struct op_print c_op_print_tab[] =
484 {
485   {",", BINOP_COMMA, PREC_COMMA, 0},
486   {"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
487   {"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
488   {"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
489   {"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
490   {"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
491   {"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
492   {"==", BINOP_EQUAL, PREC_EQUAL, 0},
493   {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
494   {"<=", BINOP_LEQ, PREC_ORDER, 0},
495   {">=", BINOP_GEQ, PREC_ORDER, 0},
496   {">", BINOP_GTR, PREC_ORDER, 0},
497   {"<", BINOP_LESS, PREC_ORDER, 0},
498   {">>", BINOP_RSH, PREC_SHIFT, 0},
499   {"<<", BINOP_LSH, PREC_SHIFT, 0},
500   {"+", BINOP_ADD, PREC_ADD, 0},
501   {"-", BINOP_SUB, PREC_ADD, 0},
502   {"*", BINOP_MUL, PREC_MUL, 0},
503   {"/", BINOP_DIV, PREC_MUL, 0},
504   {"%", BINOP_REM, PREC_MUL, 0},
505   {"@", BINOP_REPEAT, PREC_REPEAT, 0},
506   {"-", UNOP_NEG, PREC_PREFIX, 0},
507   {"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
508   {"~", UNOP_COMPLEMENT, PREC_PREFIX, 0},
509   {"*", UNOP_IND, PREC_PREFIX, 0},
510   {"&", UNOP_ADDR, PREC_PREFIX, 0},
511   {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
512   {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
513   {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
514   {NULL, 0, 0, 0}
515 };
516 \f
517 enum c_primitive_types {
518   c_primitive_type_int,
519   c_primitive_type_long,
520   c_primitive_type_short,
521   c_primitive_type_char,
522   c_primitive_type_float,
523   c_primitive_type_double,
524   c_primitive_type_void,
525   c_primitive_type_long_long,
526   c_primitive_type_signed_char,
527   c_primitive_type_unsigned_char,
528   c_primitive_type_unsigned_short,
529   c_primitive_type_unsigned_int,
530   c_primitive_type_unsigned_long,
531   c_primitive_type_unsigned_long_long,
532   c_primitive_type_long_double,
533   c_primitive_type_complex,
534   c_primitive_type_double_complex,
535   nr_c_primitive_types
536 };
537
538 void
539 c_language_arch_info (struct gdbarch *gdbarch,
540                       struct language_arch_info *lai)
541 {
542   const struct builtin_type *builtin = builtin_type (gdbarch);
543   lai->string_char_type = builtin->builtin_char;
544   lai->primitive_type_vector
545     = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_c_primitive_types + 1,
546                               struct type *);
547   lai->primitive_type_vector [c_primitive_type_int] = builtin->builtin_int;
548   lai->primitive_type_vector [c_primitive_type_long] = builtin->builtin_long;
549   lai->primitive_type_vector [c_primitive_type_short] = builtin->builtin_short;
550   lai->primitive_type_vector [c_primitive_type_char] = builtin->builtin_char;
551   lai->primitive_type_vector [c_primitive_type_float] = builtin->builtin_float;
552   lai->primitive_type_vector [c_primitive_type_double] = builtin->builtin_double;
553   lai->primitive_type_vector [c_primitive_type_void] = builtin->builtin_void;
554   lai->primitive_type_vector [c_primitive_type_long_long] = builtin->builtin_long_long;
555   lai->primitive_type_vector [c_primitive_type_signed_char] = builtin->builtin_signed_char;
556   lai->primitive_type_vector [c_primitive_type_unsigned_char] = builtin->builtin_unsigned_char;
557   lai->primitive_type_vector [c_primitive_type_unsigned_short] = builtin->builtin_unsigned_short;
558   lai->primitive_type_vector [c_primitive_type_unsigned_int] = builtin->builtin_unsigned_int;
559   lai->primitive_type_vector [c_primitive_type_unsigned_long] = builtin->builtin_unsigned_long;
560   lai->primitive_type_vector [c_primitive_type_unsigned_long_long] = builtin->builtin_unsigned_long_long;
561   lai->primitive_type_vector [c_primitive_type_long_double] = builtin->builtin_long_double;
562   lai->primitive_type_vector [c_primitive_type_complex] = builtin->builtin_complex;
563   lai->primitive_type_vector [c_primitive_type_double_complex] = builtin->builtin_double_complex;
564 };
565
566 const struct language_defn c_language_defn =
567 {
568   "c",                          /* Language name */
569   language_c,
570   NULL,
571   range_check_off,
572   type_check_off,
573   case_sensitive_on,
574   array_row_major,
575   &exp_descriptor_standard,
576   c_preprocess_and_parse,
577   c_error,
578   null_post_parser,
579   c_printchar,                  /* Print a character constant */
580   c_printstr,                   /* Function to print string constant */
581   c_emit_char,                  /* Print a single char */
582   c_create_fundamental_type,    /* Create fundamental type in this language */
583   c_print_type,                 /* Print a type using appropriate syntax */
584   c_val_print,                  /* Print a value using appropriate syntax */
585   c_value_print,                /* Print a top-level value */
586   NULL,                         /* Language specific skip_trampoline */
587   NULL,                         /* value_of_this */
588   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
589   basic_lookup_transparent_type,/* lookup_transparent_type */
590   NULL,                         /* Language specific symbol demangler */
591   NULL,                         /* Language specific class_name_from_physname */
592   c_op_print_tab,               /* expression operators for printing */
593   1,                            /* c-style arrays */
594   0,                            /* String lower bound */
595   NULL,
596   default_word_break_characters,
597   c_language_arch_info,
598   default_print_array_index,
599   LANG_MAGIC
600 };
601
602 struct type **const (cplus_builtin_types[]) =
603 {
604   &builtin_type_int,
605   &builtin_type_long,
606   &builtin_type_short,
607   &builtin_type_char,
608   &builtin_type_float,
609   &builtin_type_double,
610   &builtin_type_void,
611   &builtin_type_long_long,
612   &builtin_type_signed_char,
613   &builtin_type_unsigned_char,
614   &builtin_type_unsigned_short,
615   &builtin_type_unsigned_int,
616   &builtin_type_unsigned_long,
617   &builtin_type_unsigned_long_long,
618   &builtin_type_long_double,
619   &builtin_type_complex,
620   &builtin_type_double_complex,
621   &builtin_type_bool,
622   0
623 };
624
625 const struct language_defn cplus_language_defn =
626 {
627   "c++",                        /* Language name */
628   language_cplus,
629   cplus_builtin_types,
630   range_check_off,
631   type_check_off,
632   case_sensitive_on,
633   array_row_major,
634   &exp_descriptor_standard,
635   c_preprocess_and_parse,
636   c_error,
637   null_post_parser,
638   c_printchar,                  /* Print a character constant */
639   c_printstr,                   /* Function to print string constant */
640   c_emit_char,                  /* Print a single char */
641   c_create_fundamental_type,    /* Create fundamental type in this language */
642   c_print_type,                 /* Print a type using appropriate syntax */
643   c_val_print,                  /* Print a value using appropriate syntax */
644   c_value_print,                /* Print a top-level value */
645   NULL,                         /* Language specific skip_trampoline */
646   value_of_this,                /* value_of_this */
647   cp_lookup_symbol_nonlocal,    /* lookup_symbol_nonlocal */
648   cp_lookup_transparent_type,   /* lookup_transparent_type */
649   cplus_demangle,               /* Language specific symbol demangler */
650   cp_class_name_from_physname,  /* Language specific class_name_from_physname */
651   c_op_print_tab,               /* expression operators for printing */
652   1,                            /* c-style arrays */
653   0,                            /* String lower bound */
654   &builtin_type_char,           /* Type of string elements */
655   default_word_break_characters,
656   NULL, /* FIXME: la_language_arch_info.  */
657   default_print_array_index,
658   LANG_MAGIC
659 };
660
661 const struct language_defn asm_language_defn =
662 {
663   "asm",                        /* Language name */
664   language_asm,
665   NULL,
666   range_check_off,
667   type_check_off,
668   case_sensitive_on,
669   array_row_major,
670   &exp_descriptor_standard,
671   c_preprocess_and_parse,
672   c_error,
673   null_post_parser,
674   c_printchar,                  /* Print a character constant */
675   c_printstr,                   /* Function to print string constant */
676   c_emit_char,                  /* Print a single char */
677   c_create_fundamental_type,    /* Create fundamental type in this language */
678   c_print_type,                 /* Print a type using appropriate syntax */
679   c_val_print,                  /* Print a value using appropriate syntax */
680   c_value_print,                /* Print a top-level value */
681   NULL,                         /* Language specific skip_trampoline */
682   NULL,                         /* value_of_this */
683   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
684   basic_lookup_transparent_type,/* lookup_transparent_type */
685   NULL,                         /* Language specific symbol demangler */
686   NULL,                         /* Language specific class_name_from_physname */
687   c_op_print_tab,               /* expression operators for printing */
688   1,                            /* c-style arrays */
689   0,                            /* String lower bound */
690   NULL,
691   default_word_break_characters,
692   c_language_arch_info, /* FIXME: la_language_arch_info.  */
693   default_print_array_index,
694   LANG_MAGIC
695 };
696
697 /* The following language_defn does not represent a real language.
698    It just provides a minimal support a-la-C that should allow users
699    to do some simple operations when debugging applications that use
700    a language currently not supported by GDB.  */
701
702 const struct language_defn minimal_language_defn =
703 {
704   "minimal",                    /* Language name */
705   language_minimal,
706   NULL,
707   range_check_off,
708   type_check_off,
709   case_sensitive_on,
710   array_row_major,
711   &exp_descriptor_standard,
712   c_preprocess_and_parse,
713   c_error,
714   null_post_parser,
715   c_printchar,                  /* Print a character constant */
716   c_printstr,                   /* Function to print string constant */
717   c_emit_char,                  /* Print a single char */
718   c_create_fundamental_type,    /* Create fundamental type in this language */
719   c_print_type,                 /* Print a type using appropriate syntax */
720   c_val_print,                  /* Print a value using appropriate syntax */
721   c_value_print,                /* Print a top-level value */
722   NULL,                         /* Language specific skip_trampoline */
723   NULL,                         /* value_of_this */
724   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
725   basic_lookup_transparent_type,/* lookup_transparent_type */
726   NULL,                         /* Language specific symbol demangler */
727   NULL,                         /* Language specific class_name_from_physname */
728   c_op_print_tab,               /* expression operators for printing */
729   1,                            /* c-style arrays */
730   0,                            /* String lower bound */
731   NULL,
732   default_word_break_characters,
733   c_language_arch_info,
734   default_print_array_index,
735   LANG_MAGIC
736 };
737
738 void
739 _initialize_c_language (void)
740 {
741   add_language (&c_language_defn);
742   add_language (&cplus_language_defn);
743   add_language (&asm_language_defn);
744   add_language (&minimal_language_defn);
745 }