OSDN Git Service

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