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