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