* Makefile.am: Use a temporary file to build chew.
[deliverable/binutils-gdb.git] / gdb / c-lang.c
CommitLineData
c906108c 1/* C language support routines for GDB, the GNU debugger.
ce27fb25
AC
2
3 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002,
4 2003, 2004, 2005 Free Software Foundation, Inc.
c906108c 5
c5aa993b 6 This file is part of GDB.
c906108c 7
c5aa993b
JM
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.
c906108c 12
c5aa993b
JM
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.
c906108c 17
c5aa993b
JM
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., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
c906108c
SS
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"
745b8ca0 30#include "valprint.h"
84f0252a
JB
31#include "macroscope.h"
32#include "gdb_assert.h"
234b45d4 33#include "charset.h"
a15ef5f5 34#include "gdb_string.h"
9a3d7dfd 35#include "demangle.h"
1fcb5155 36#include "cp-support.h"
c906108c 37
a14ed312 38extern void _initialize_c_language (void);
d9fcf2fb 39static void c_emit_char (int c, struct ui_file * stream, int quoter);
c906108c
SS
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
45static void
f86f5ca3 46c_emit_char (int c, struct ui_file *stream, int quoter)
c906108c 47{
234b45d4
KB
48 const char *escape;
49 int host_char;
50
c906108c
SS
51 c &= 0xFF; /* Avoid sign bit follies */
52
234b45d4
KB
53 escape = c_target_char_has_backslash_escape (c);
54 if (escape)
c906108c 55 {
234b45d4
KB
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);
c906108c 62 }
234b45d4
KB
63 else if (target_char_to_host (c, &host_char)
64 && host_char_print_literally (host_char))
c906108c 65 {
234b45d4
KB
66 if (host_char == '\\' || host_char == quoter)
67 fputs_filtered ("\\", stream);
68 fprintf_filtered (stream, "%c", host_char);
c906108c 69 }
234b45d4
KB
70 else
71 fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
c906108c
SS
72}
73
74void
fba45db2 75c_printchar (int c, struct ui_file *stream)
c906108c
SS
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
88void
ce27fb25
AC
89c_printstr (struct ui_file *stream, const bfd_byte *string,
90 unsigned int length, int width, int force_ellipses)
c906108c 91{
f86f5ca3 92 unsigned int i;
c906108c
SS
93 unsigned int things_printed = 0;
94 int in_quotes = 0;
95 int need_comma = 0;
c906108c
SS
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
78a51202
JB
102 && (extract_unsigned_integer (string + (length - 1) * width, width)
103 == '\0'))
c906108c
SS
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
c5aa993b 115 to see whether it is repeated. */
c906108c
SS
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)
c5aa993b 135 == current_char)
c906108c
SS
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);
3d263c1d 152 fprintf_filtered (stream, _(" <repeats %u times>"), reps);
c906108c
SS
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
8470e927 205 starts taking its fundamental type information directly from the
c906108c
SS
206 debugging information supplied by the compiler. fnf@cygnus.com */
207
208struct type *
fba45db2 209c_create_fundamental_type (struct objfile *objfile, int typeid)
c906108c 210{
f86f5ca3 211 struct type *type = NULL;
c906108c
SS
212
213 switch (typeid)
214 {
c5aa993b
JM
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);
3d263c1d 223 warning (_("internal error: no C/C++ fundamental type %d"), typeid);
c5aa993b
JM
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);
c5aa993b
JM
234 break;
235 case FT_CHAR:
236 type = init_type (TYPE_CODE_INT,
237 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
6edc140f 238 TYPE_FLAG_NOSIGN, "char", objfile);
c5aa993b
JM
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;
f65ca430
DJ
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;
c5aa993b
JM
349 case FT_TEMPLATE_ARG:
350 type = init_type (TYPE_CODE_TEMPLATE_ARG,
351 0,
352 0, "<template arg>", objfile);
c5aa993b
JM
353 break;
354 }
c906108c
SS
355 return (type);
356}
c906108c 357\f
84f0252a 358/* Preprocessing and parsing C and C++ expressions. */
c5aa993b 359
84f0252a
JB
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. */
378static char *macro_original_text;
379static char *macro_expanded_text;
380
381
382void
383scan_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
399int
5ae5f592 400scanning_macro_expansion (void)
84f0252a
JB
401{
402 return macro_original_text != 0;
403}
404
405
406void
5ae5f592 407finished_macro_expansion (void)
84f0252a
JB
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
424static void
425scan_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. */
434macro_lookup_ftype *expression_macro_lookup_func;
435void *expression_macro_lookup_baton;
436
437
438static struct macro_definition *
439null_macro_lookup (const char *name, void *baton)
440{
441 return 0;
442}
443
444
445static int
5ae5f592 446c_preprocess_and_parse (void)
84f0252a
JB
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
c906108c
SS
480/* Table mapping opcodes into strings for printing operators
481 and precedences of the operators. */
482
483const struct op_print c_op_print_tab[] =
c5aa993b
JM
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},
c5aa993b 514 {NULL, 0, 0, 0}
c906108c
SS
515};
516\f
685419e2
AC
517enum 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
e9667a65 538void
685419e2
AC
539c_language_arch_info (struct gdbarch *gdbarch,
540 struct language_arch_info *lai)
541{
542 const struct builtin_type *builtin = builtin_type (gdbarch);
e9667a65 543 lai->string_char_type = builtin->builtin_char;
685419e2
AC
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
c5aa993b
JM
566const struct language_defn c_language_defn =
567{
c906108c
SS
568 "c", /* Language name */
569 language_c,
685419e2 570 NULL,
c906108c
SS
571 range_check_off,
572 type_check_off,
63872f9d 573 case_sensitive_on,
7ca2d3a3 574 array_row_major,
5f9769d1 575 &exp_descriptor_standard,
84f0252a 576 c_preprocess_and_parse,
c906108c 577 c_error,
e85c3284 578 null_post_parser,
c906108c
SS
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 */
f636b87d 586 NULL, /* Language specific skip_trampoline */
5f9a71c3
DC
587 NULL, /* value_of_this */
588 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
b368761e 589 basic_lookup_transparent_type,/* lookup_transparent_type */
9a3d7dfd 590 NULL, /* Language specific symbol demangler */
31c27f77 591 NULL, /* Language specific class_name_from_physname */
c906108c
SS
592 c_op_print_tab, /* expression operators for printing */
593 1, /* c-style arrays */
594 0, /* String lower bound */
685419e2 595 NULL,
6084f43a 596 default_word_break_characters,
685419e2 597 c_language_arch_info,
c906108c
SS
598 LANG_MAGIC
599};
600
c5aa993b 601struct type **const (cplus_builtin_types[]) =
c906108c
SS
602{
603 &builtin_type_int,
78a51202
JB
604 &builtin_type_long,
605 &builtin_type_short,
606 &builtin_type_char,
607 &builtin_type_float,
608 &builtin_type_double,
609 &builtin_type_void,
610 &builtin_type_long_long,
611 &builtin_type_signed_char,
612 &builtin_type_unsigned_char,
613 &builtin_type_unsigned_short,
614 &builtin_type_unsigned_int,
615 &builtin_type_unsigned_long,
616 &builtin_type_unsigned_long_long,
617 &builtin_type_long_double,
618 &builtin_type_complex,
619 &builtin_type_double_complex,
620 &builtin_type_bool,
621 0
c906108c
SS
622};
623
c5aa993b
JM
624const struct language_defn cplus_language_defn =
625{
626 "c++", /* Language name */
c906108c
SS
627 language_cplus,
628 cplus_builtin_types,
629 range_check_off,
630 type_check_off,
63872f9d 631 case_sensitive_on,
7ca2d3a3 632 array_row_major,
5f9769d1 633 &exp_descriptor_standard,
84f0252a 634 c_preprocess_and_parse,
c906108c 635 c_error,
e85c3284 636 null_post_parser,
c906108c
SS
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 */
f636b87d 644 NULL, /* Language specific skip_trampoline */
5f9a71c3 645 value_of_this, /* value_of_this */
1fcb5155 646 cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
b368761e 647 cp_lookup_transparent_type, /* lookup_transparent_type */
9a3d7dfd 648 cplus_demangle, /* Language specific symbol demangler */
31c27f77 649 cp_class_name_from_physname, /* Language specific class_name_from_physname */
c906108c
SS
650 c_op_print_tab, /* expression operators for printing */
651 1, /* c-style arrays */
652 0, /* String lower bound */
c5aa993b 653 &builtin_type_char, /* Type of string elements */
6084f43a 654 default_word_break_characters,
f290d38e 655 NULL, /* FIXME: la_language_arch_info. */
c906108c
SS
656 LANG_MAGIC
657};
658
c5aa993b
JM
659const struct language_defn asm_language_defn =
660{
c906108c
SS
661 "asm", /* Language name */
662 language_asm,
e9667a65 663 NULL,
c906108c
SS
664 range_check_off,
665 type_check_off,
63872f9d 666 case_sensitive_on,
7ca2d3a3 667 array_row_major,
5f9769d1 668 &exp_descriptor_standard,
84f0252a 669 c_preprocess_and_parse,
c906108c 670 c_error,
e85c3284 671 null_post_parser,
c906108c
SS
672 c_printchar, /* Print a character constant */
673 c_printstr, /* Function to print string constant */
674 c_emit_char, /* Print a single char */
675 c_create_fundamental_type, /* Create fundamental type in this language */
676 c_print_type, /* Print a type using appropriate syntax */
677 c_val_print, /* Print a value using appropriate syntax */
678 c_value_print, /* Print a top-level value */
f636b87d 679 NULL, /* Language specific skip_trampoline */
5f9a71c3
DC
680 NULL, /* value_of_this */
681 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
b368761e 682 basic_lookup_transparent_type,/* lookup_transparent_type */
9a3d7dfd 683 NULL, /* Language specific symbol demangler */
31c27f77 684 NULL, /* Language specific class_name_from_physname */
c906108c
SS
685 c_op_print_tab, /* expression operators for printing */
686 1, /* c-style arrays */
687 0, /* String lower bound */
e9667a65 688 NULL,
6084f43a 689 default_word_break_characters,
e9667a65 690 c_language_arch_info, /* FIXME: la_language_arch_info. */
c906108c
SS
691 LANG_MAGIC
692};
693
20a0e81d
JB
694/* The following language_defn does not represent a real language.
695 It just provides a minimal support a-la-C that should allow users
696 to do some simple operations when debugging applications that use
697 a language currently not supported by GDB. */
698
699const struct language_defn minimal_language_defn =
700{
701 "minimal", /* Language name */
702 language_minimal,
e9667a65 703 NULL,
20a0e81d
JB
704 range_check_off,
705 type_check_off,
706 case_sensitive_on,
7ca2d3a3 707 array_row_major,
5f9769d1 708 &exp_descriptor_standard,
20a0e81d
JB
709 c_preprocess_and_parse,
710 c_error,
e85c3284 711 null_post_parser,
20a0e81d
JB
712 c_printchar, /* Print a character constant */
713 c_printstr, /* Function to print string constant */
714 c_emit_char, /* Print a single char */
715 c_create_fundamental_type, /* Create fundamental type in this language */
716 c_print_type, /* Print a type using appropriate syntax */
717 c_val_print, /* Print a value using appropriate syntax */
718 c_value_print, /* Print a top-level value */
719 NULL, /* Language specific skip_trampoline */
5f9a71c3
DC
720 NULL, /* value_of_this */
721 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
b368761e 722 basic_lookup_transparent_type,/* lookup_transparent_type */
20a0e81d 723 NULL, /* Language specific symbol demangler */
31c27f77 724 NULL, /* Language specific class_name_from_physname */
20a0e81d
JB
725 c_op_print_tab, /* expression operators for printing */
726 1, /* c-style arrays */
727 0, /* String lower bound */
e9667a65 728 NULL,
6084f43a 729 default_word_break_characters,
e9667a65 730 c_language_arch_info,
20a0e81d
JB
731 LANG_MAGIC
732};
733
c906108c 734void
fba45db2 735_initialize_c_language (void)
c906108c
SS
736{
737 add_language (&c_language_defn);
738 add_language (&cplus_language_defn);
739 add_language (&asm_language_defn);
20a0e81d 740 add_language (&minimal_language_defn);
c906108c 741}
This page took 0.390664 seconds and 4 git commands to generate.