Commit | Line | Data |
---|---|---|
c906108c | 1 | /* C language support routines for GDB, the GNU debugger. |
ce27fb25 | 2 | |
28e7fd62 | 3 | Copyright (C) 1992-2013 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 | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 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 | 17 | You should have received a copy of the GNU General Public License |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c SS |
19 | |
20 | #include "defs.h" | |
21 | #include "symtab.h" | |
22 | #include "gdbtypes.h" | |
23 | #include "expression.h" | |
24 | #include "parser-defs.h" | |
25 | #include "language.h" | |
26 | #include "c-lang.h" | |
745b8ca0 | 27 | #include "valprint.h" |
84f0252a JB |
28 | #include "macroscope.h" |
29 | #include "gdb_assert.h" | |
234b45d4 | 30 | #include "charset.h" |
a15ef5f5 | 31 | #include "gdb_string.h" |
9a3d7dfd | 32 | #include "demangle.h" |
b18be20d | 33 | #include "cp-abi.h" |
1fcb5155 | 34 | #include "cp-support.h" |
6c7a06a3 TT |
35 | #include "gdb_obstack.h" |
36 | #include <ctype.h> | |
621c8364 | 37 | #include "exceptions.h" |
578d3588 | 38 | #include "gdbcore.h" |
c906108c | 39 | |
a14ed312 | 40 | extern void _initialize_c_language (void); |
6c7a06a3 TT |
41 | |
42 | /* Given a C string type, STR_TYPE, return the corresponding target | |
43 | character set name. */ | |
44 | ||
45 | static const char * | |
e17a4113 | 46 | charset_for_string_type (enum c_string_type str_type, |
f870a310 | 47 | struct gdbarch *gdbarch) |
6c7a06a3 TT |
48 | { |
49 | switch (str_type & ~C_CHAR) | |
50 | { | |
51 | case C_STRING: | |
f870a310 | 52 | return target_charset (gdbarch); |
6c7a06a3 | 53 | case C_WIDE_STRING: |
f870a310 | 54 | return target_wide_charset (gdbarch); |
6c7a06a3 | 55 | case C_STRING_16: |
b8899f2b | 56 | /* FIXME: UTF-16 is not always correct. */ |
f870a310 | 57 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) |
b8899f2b | 58 | return "UTF-16BE"; |
6c7a06a3 | 59 | else |
b8899f2b | 60 | return "UTF-16LE"; |
6c7a06a3 | 61 | case C_STRING_32: |
b8899f2b | 62 | /* FIXME: UTF-32 is not always correct. */ |
f870a310 | 63 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) |
b8899f2b | 64 | return "UTF-32BE"; |
6c7a06a3 | 65 | else |
b8899f2b | 66 | return "UTF-32LE"; |
6c7a06a3 | 67 | } |
9b20d036 | 68 | internal_error (__FILE__, __LINE__, _("unhandled c_string_type")); |
6c7a06a3 TT |
69 | } |
70 | ||
71 | /* Classify ELTTYPE according to what kind of character it is. Return | |
72 | the enum constant representing the character type. Also set | |
73 | *ENCODING to the name of the character set to use when converting | |
aff410f1 MS |
74 | characters of this type in target BYTE_ORDER to the host character |
75 | set. */ | |
6c7a06a3 TT |
76 | |
77 | static enum c_string_type | |
f870a310 | 78 | classify_type (struct type *elttype, struct gdbarch *gdbarch, |
e17a4113 | 79 | const char **encoding) |
6c7a06a3 | 80 | { |
6c7a06a3 TT |
81 | enum c_string_type result; |
82 | ||
85e306ed TT |
83 | /* We loop because ELTTYPE may be a typedef, and we want to |
84 | successively peel each typedef until we reach a type we | |
85 | understand. We don't use CHECK_TYPEDEF because that will strip | |
86 | all typedefs at once -- but in C, wchar_t is itself a typedef, so | |
87 | that would do the wrong thing. */ | |
88 | while (elttype) | |
6c7a06a3 | 89 | { |
0d5cff50 | 90 | const char *name = TYPE_NAME (elttype); |
6c7a06a3 TT |
91 | |
92 | if (TYPE_CODE (elttype) == TYPE_CODE_CHAR || !name) | |
93 | { | |
94 | result = C_CHAR; | |
95 | goto done; | |
96 | } | |
97 | ||
98 | if (!strcmp (name, "wchar_t")) | |
99 | { | |
100 | result = C_WIDE_CHAR; | |
101 | goto done; | |
102 | } | |
103 | ||
104 | if (!strcmp (name, "char16_t")) | |
105 | { | |
106 | result = C_CHAR_16; | |
107 | goto done; | |
108 | } | |
109 | ||
110 | if (!strcmp (name, "char32_t")) | |
111 | { | |
112 | result = C_CHAR_32; | |
113 | goto done; | |
114 | } | |
115 | ||
85e306ed TT |
116 | if (TYPE_CODE (elttype) != TYPE_CODE_TYPEDEF) |
117 | break; | |
118 | ||
119 | /* Call for side effects. */ | |
120 | check_typedef (elttype); | |
121 | ||
122 | if (TYPE_TARGET_TYPE (elttype)) | |
123 | elttype = TYPE_TARGET_TYPE (elttype); | |
124 | else | |
125 | { | |
126 | /* Perhaps check_typedef did not update the target type. In | |
127 | this case, force the lookup again and hope it works out. | |
128 | It never will for C, but it might for C++. */ | |
129 | CHECK_TYPEDEF (elttype); | |
130 | } | |
6c7a06a3 | 131 | } |
6c7a06a3 TT |
132 | |
133 | /* Punt. */ | |
134 | result = C_CHAR; | |
135 | ||
136 | done: | |
e17a4113 | 137 | if (encoding) |
f870a310 | 138 | *encoding = charset_for_string_type (result, gdbarch); |
e17a4113 | 139 | |
6c7a06a3 TT |
140 | return result; |
141 | } | |
142 | ||
aff410f1 MS |
143 | /* Print the character C on STREAM as part of the contents of a |
144 | literal string whose delimiter is QUOTER. Note that that format | |
145 | for printing characters and strings is language specific. */ | |
c906108c | 146 | |
6aecb9c2 JB |
147 | void |
148 | c_emit_char (int c, struct type *type, | |
149 | struct ui_file *stream, int quoter) | |
c906108c | 150 | { |
6c7a06a3 | 151 | const char *encoding; |
234b45d4 | 152 | |
f870a310 | 153 | classify_type (type, get_type_arch (type), &encoding); |
3b2b8fea | 154 | generic_emit_char (c, type, stream, quoter, encoding); |
c906108c SS |
155 | } |
156 | ||
157 | void | |
6c7a06a3 | 158 | c_printchar (int c, struct type *type, struct ui_file *stream) |
c906108c | 159 | { |
6c7a06a3 | 160 | enum c_string_type str_type; |
6c7a06a3 | 161 | |
f870a310 | 162 | str_type = classify_type (type, get_type_arch (type), NULL); |
6c7a06a3 TT |
163 | switch (str_type) |
164 | { | |
165 | case C_CHAR: | |
166 | break; | |
167 | case C_WIDE_CHAR: | |
168 | fputc_filtered ('L', stream); | |
169 | break; | |
170 | case C_CHAR_16: | |
171 | fputc_filtered ('u', stream); | |
172 | break; | |
173 | case C_CHAR_32: | |
174 | fputc_filtered ('U', stream); | |
175 | break; | |
176 | } | |
177 | ||
c906108c | 178 | fputc_filtered ('\'', stream); |
6c7a06a3 | 179 | LA_EMIT_CHAR (c, type, stream, '\''); |
c906108c SS |
180 | fputc_filtered ('\'', stream); |
181 | } | |
182 | ||
aff410f1 MS |
183 | /* Print the character string STRING, printing at most LENGTH |
184 | characters. LENGTH is -1 if the string is nul terminated. Each | |
185 | character is WIDTH bytes long. Printing stops early if the number | |
186 | hits print_max; repeat counts are printed as appropriate. Print | |
187 | ellipses at the end if we had to stop before printing LENGTH | |
188 | characters, or if FORCE_ELLIPSES. */ | |
c906108c SS |
189 | |
190 | void | |
aff410f1 MS |
191 | c_printstr (struct ui_file *stream, struct type *type, |
192 | const gdb_byte *string, unsigned int length, | |
193 | const char *user_encoding, int force_ellipses, | |
79a45b7d | 194 | const struct value_print_options *options) |
c906108c | 195 | { |
3b2b8fea TT |
196 | enum c_string_type str_type; |
197 | const char *type_encoding; | |
198 | const char *encoding; | |
199 | ||
f870a310 TT |
200 | str_type = (classify_type (type, get_type_arch (type), &type_encoding) |
201 | & ~C_CHAR); | |
6c7a06a3 TT |
202 | switch (str_type) |
203 | { | |
204 | case C_STRING: | |
205 | break; | |
206 | case C_WIDE_STRING: | |
207 | fputs_filtered ("L", stream); | |
208 | break; | |
209 | case C_STRING_16: | |
210 | fputs_filtered ("u", stream); | |
211 | break; | |
212 | case C_STRING_32: | |
213 | fputs_filtered ("U", stream); | |
214 | break; | |
215 | } | |
216 | ||
3b2b8fea | 217 | encoding = (user_encoding && *user_encoding) ? user_encoding : type_encoding; |
6c7a06a3 | 218 | |
3b2b8fea TT |
219 | generic_printstr (stream, type, string, length, encoding, force_ellipses, |
220 | '"', 1, options); | |
c906108c | 221 | } |
ae6a3a4c TJB |
222 | |
223 | /* Obtain a C string from the inferior storing it in a newly allocated | |
aff410f1 MS |
224 | buffer in BUFFER, which should be freed by the caller. If the in- |
225 | and out-parameter *LENGTH is specified at -1, the string is read | |
fbb8f299 | 226 | until a null character of the appropriate width is found, otherwise |
aff410f1 MS |
227 | the string is read to the length of characters specified. The size |
228 | of a character is determined by the length of the target type of | |
229 | the pointer or array. If VALUE is an array with a known length, | |
230 | the function will not read past the end of the array. On | |
231 | completion, *LENGTH will be set to the size of the string read in | |
fbb8f299 PM |
232 | characters. (If a length of -1 is specified, the length returned |
233 | will not include the null character). CHARSET is always set to the | |
234 | target charset. */ | |
ae6a3a4c TJB |
235 | |
236 | void | |
aff410f1 MS |
237 | c_get_string (struct value *value, gdb_byte **buffer, |
238 | int *length, struct type **char_type, | |
239 | const char **charset) | |
ae6a3a4c TJB |
240 | { |
241 | int err, width; | |
242 | unsigned int fetchlimit; | |
243 | struct type *type = check_typedef (value_type (value)); | |
244 | struct type *element_type = TYPE_TARGET_TYPE (type); | |
fbb8f299 | 245 | int req_length = *length; |
aff410f1 MS |
246 | enum bfd_endian byte_order |
247 | = gdbarch_byte_order (get_type_arch (type)); | |
ae6a3a4c TJB |
248 | |
249 | if (element_type == NULL) | |
250 | goto error; | |
251 | ||
252 | if (TYPE_CODE (type) == TYPE_CODE_ARRAY) | |
253 | { | |
aff410f1 MS |
254 | /* If we know the size of the array, we can use it as a limit on |
255 | the number of characters to be fetched. */ | |
ae6a3a4c TJB |
256 | if (TYPE_NFIELDS (type) == 1 |
257 | && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_RANGE) | |
258 | { | |
259 | LONGEST low_bound, high_bound; | |
260 | ||
261 | get_discrete_bounds (TYPE_FIELD_TYPE (type, 0), | |
262 | &low_bound, &high_bound); | |
263 | fetchlimit = high_bound - low_bound + 1; | |
264 | } | |
265 | else | |
266 | fetchlimit = UINT_MAX; | |
267 | } | |
268 | else if (TYPE_CODE (type) == TYPE_CODE_PTR) | |
269 | fetchlimit = UINT_MAX; | |
270 | else | |
271 | /* We work only with arrays and pointers. */ | |
272 | goto error; | |
273 | ||
96c07c5b | 274 | if (! c_textual_element_type (element_type, 0)) |
ae6a3a4c | 275 | goto error; |
df54f8eb | 276 | classify_type (element_type, get_type_arch (element_type), charset); |
ae6a3a4c TJB |
277 | width = TYPE_LENGTH (element_type); |
278 | ||
aff410f1 MS |
279 | /* If the string lives in GDB's memory instead of the inferior's, |
280 | then we just need to copy it to BUFFER. Also, since such strings | |
281 | are arrays with known size, FETCHLIMIT will hold the size of the | |
282 | array. */ | |
ae6a3a4c TJB |
283 | if ((VALUE_LVAL (value) == not_lval |
284 | || VALUE_LVAL (value) == lval_internalvar) | |
285 | && fetchlimit != UINT_MAX) | |
286 | { | |
287 | int i; | |
288 | const gdb_byte *contents = value_contents (value); | |
289 | ||
fbb8f299 PM |
290 | /* If a length is specified, use that. */ |
291 | if (*length >= 0) | |
292 | i = *length; | |
293 | else | |
294 | /* Otherwise, look for a null character. */ | |
295 | for (i = 0; i < fetchlimit; i++) | |
aff410f1 MS |
296 | if (extract_unsigned_integer (contents + i * width, |
297 | width, byte_order) == 0) | |
fbb8f299 PM |
298 | break; |
299 | ||
300 | /* I is now either a user-defined length, the number of non-null | |
301 | characters, or FETCHLIMIT. */ | |
ae6a3a4c TJB |
302 | *length = i * width; |
303 | *buffer = xmalloc (*length); | |
304 | memcpy (*buffer, contents, *length); | |
305 | err = 0; | |
306 | } | |
307 | else | |
308 | { | |
621c8364 TT |
309 | CORE_ADDR addr = value_as_address (value); |
310 | ||
311 | err = read_string (addr, *length, width, fetchlimit, | |
312 | byte_order, buffer, length); | |
ae6a3a4c TJB |
313 | if (err) |
314 | { | |
8ea5dfdf | 315 | xfree (*buffer); |
578d3588 | 316 | memory_error (err, addr); |
ae6a3a4c TJB |
317 | } |
318 | } | |
319 | ||
fbb8f299 PM |
320 | /* If the LENGTH is specified at -1, we want to return the string |
321 | length up to the terminating null character. If an actual length | |
322 | was specified, we want to return the length of exactly what was | |
323 | read. */ | |
324 | if (req_length == -1) | |
325 | /* If the last character is null, subtract it from LENGTH. */ | |
326 | if (*length > 0 | |
aff410f1 MS |
327 | && extract_unsigned_integer (*buffer + *length - width, |
328 | width, byte_order) == 0) | |
fbb8f299 PM |
329 | *length -= width; |
330 | ||
331 | /* The read_string function will return the number of bytes read. | |
332 | If length returned from read_string was > 0, return the number of | |
333 | characters read by dividing the number of bytes by width. */ | |
334 | if (*length != 0) | |
335 | *length = *length / width; | |
ae6a3a4c | 336 | |
96c07c5b | 337 | *char_type = element_type; |
ae6a3a4c TJB |
338 | |
339 | return; | |
340 | ||
341 | error: | |
342 | { | |
343 | char *type_str; | |
344 | ||
345 | type_str = type_to_string (type); | |
346 | if (type_str) | |
347 | { | |
348 | make_cleanup (xfree, type_str); | |
349 | error (_("Trying to read string with inappropriate type `%s'."), | |
350 | type_str); | |
351 | } | |
352 | else | |
353 | error (_("Trying to read string with inappropriate type.")); | |
354 | } | |
355 | } | |
356 | ||
c906108c | 357 | \f |
6c7a06a3 TT |
358 | /* Evaluating C and C++ expressions. */ |
359 | ||
360 | /* Convert a UCN. The digits of the UCN start at P and extend no | |
361 | farther than LIMIT. DEST_CHARSET is the name of the character set | |
362 | into which the UCN should be converted. The results are written to | |
363 | OUTPUT. LENGTH is the maximum length of the UCN, either 4 or 8. | |
364 | Returns a pointer to just after the final digit of the UCN. */ | |
365 | ||
366 | static char * | |
367 | convert_ucn (char *p, char *limit, const char *dest_charset, | |
368 | struct obstack *output, int length) | |
369 | { | |
370 | unsigned long result = 0; | |
371 | gdb_byte data[4]; | |
372 | int i; | |
373 | ||
374 | for (i = 0; i < length && p < limit && isxdigit (*p); ++i, ++p) | |
375 | result = (result << 4) + host_hex_value (*p); | |
376 | ||
377 | for (i = 3; i >= 0; --i) | |
378 | { | |
379 | data[i] = result & 0xff; | |
380 | result >>= 8; | |
381 | } | |
382 | ||
aff410f1 MS |
383 | convert_between_encodings ("UTF-32BE", dest_charset, data, |
384 | 4, 4, output, translit_none); | |
6c7a06a3 TT |
385 | |
386 | return p; | |
387 | } | |
388 | ||
389 | /* Emit a character, VALUE, which was specified numerically, to | |
390 | OUTPUT. TYPE is the target character type. */ | |
391 | ||
392 | static void | |
393 | emit_numeric_character (struct type *type, unsigned long value, | |
394 | struct obstack *output) | |
395 | { | |
396 | gdb_byte *buffer; | |
397 | ||
398 | buffer = alloca (TYPE_LENGTH (type)); | |
399 | pack_long (buffer, type, value); | |
400 | obstack_grow (output, buffer, TYPE_LENGTH (type)); | |
401 | } | |
402 | ||
403 | /* Convert an octal escape sequence. TYPE is the target character | |
404 | type. The digits of the escape sequence begin at P and extend no | |
405 | farther than LIMIT. The result is written to OUTPUT. Returns a | |
406 | pointer to just after the final digit of the escape sequence. */ | |
407 | ||
408 | static char * | |
aff410f1 MS |
409 | convert_octal (struct type *type, char *p, |
410 | char *limit, struct obstack *output) | |
6c7a06a3 | 411 | { |
30b66ecc | 412 | int i; |
6c7a06a3 TT |
413 | unsigned long value = 0; |
414 | ||
30b66ecc TT |
415 | for (i = 0; |
416 | i < 3 && p < limit && isdigit (*p) && *p != '8' && *p != '9'; | |
417 | ++i) | |
6c7a06a3 TT |
418 | { |
419 | value = 8 * value + host_hex_value (*p); | |
420 | ++p; | |
421 | } | |
422 | ||
423 | emit_numeric_character (type, value, output); | |
424 | ||
425 | return p; | |
426 | } | |
427 | ||
428 | /* Convert a hex escape sequence. TYPE is the target character type. | |
429 | The digits of the escape sequence begin at P and extend no farther | |
430 | than LIMIT. The result is written to OUTPUT. Returns a pointer to | |
431 | just after the final digit of the escape sequence. */ | |
432 | ||
433 | static char * | |
aff410f1 MS |
434 | convert_hex (struct type *type, char *p, |
435 | char *limit, struct obstack *output) | |
6c7a06a3 TT |
436 | { |
437 | unsigned long value = 0; | |
438 | ||
439 | while (p < limit && isxdigit (*p)) | |
440 | { | |
441 | value = 16 * value + host_hex_value (*p); | |
442 | ++p; | |
443 | } | |
444 | ||
445 | emit_numeric_character (type, value, output); | |
446 | ||
447 | return p; | |
448 | } | |
449 | ||
450 | #define ADVANCE \ | |
451 | do { \ | |
452 | ++p; \ | |
453 | if (p == limit) \ | |
454 | error (_("Malformed escape sequence")); \ | |
455 | } while (0) | |
456 | ||
457 | /* Convert an escape sequence to a target format. TYPE is the target | |
458 | character type to use, and DEST_CHARSET is the name of the target | |
459 | character set. The backslash of the escape sequence is at *P, and | |
460 | the escape sequence will not extend past LIMIT. The results are | |
461 | written to OUTPUT. Returns a pointer to just past the final | |
462 | character of the escape sequence. */ | |
463 | ||
464 | static char * | |
465 | convert_escape (struct type *type, const char *dest_charset, | |
466 | char *p, char *limit, struct obstack *output) | |
467 | { | |
468 | /* Skip the backslash. */ | |
469 | ADVANCE; | |
470 | ||
471 | switch (*p) | |
472 | { | |
473 | case '\\': | |
474 | obstack_1grow (output, '\\'); | |
475 | ++p; | |
476 | break; | |
477 | ||
478 | case 'x': | |
479 | ADVANCE; | |
480 | if (!isxdigit (*p)) | |
481 | error (_("\\x used with no following hex digits.")); | |
482 | p = convert_hex (type, p, limit, output); | |
483 | break; | |
484 | ||
485 | case '0': | |
486 | case '1': | |
487 | case '2': | |
488 | case '3': | |
489 | case '4': | |
490 | case '5': | |
491 | case '6': | |
492 | case '7': | |
493 | p = convert_octal (type, p, limit, output); | |
494 | break; | |
495 | ||
496 | case 'u': | |
497 | case 'U': | |
498 | { | |
499 | int length = *p == 'u' ? 4 : 8; | |
c5504eaf | 500 | |
6c7a06a3 TT |
501 | ADVANCE; |
502 | if (!isxdigit (*p)) | |
503 | error (_("\\u used with no following hex digits")); | |
504 | p = convert_ucn (p, limit, dest_charset, output, length); | |
505 | } | |
506 | } | |
507 | ||
508 | return p; | |
509 | } | |
510 | ||
511 | /* Given a single string from a (C-specific) OP_STRING list, convert | |
512 | it to a target string, handling escape sequences specially. The | |
513 | output is written to OUTPUT. DATA is the input string, which has | |
514 | length LEN. DEST_CHARSET is the name of the target character set, | |
515 | and TYPE is the type of target character to use. */ | |
516 | ||
517 | static void | |
518 | parse_one_string (struct obstack *output, char *data, int len, | |
519 | const char *dest_charset, struct type *type) | |
520 | { | |
521 | char *limit; | |
522 | ||
523 | limit = data + len; | |
524 | ||
525 | while (data < limit) | |
526 | { | |
527 | char *p = data; | |
c5504eaf | 528 | |
6c7a06a3 TT |
529 | /* Look for next escape, or the end of the input. */ |
530 | while (p < limit && *p != '\\') | |
531 | ++p; | |
532 | /* If we saw a run of characters, convert them all. */ | |
533 | if (p > data) | |
534 | convert_between_encodings (host_charset (), dest_charset, | |
ac91cd70 | 535 | (gdb_byte *) data, p - data, 1, |
aff410f1 | 536 | output, translit_none); |
6c7a06a3 TT |
537 | /* If we saw an escape, convert it. */ |
538 | if (p < limit) | |
539 | p = convert_escape (type, dest_charset, p, limit, output); | |
540 | data = p; | |
541 | } | |
542 | } | |
543 | ||
544 | /* Expression evaluator for the C language family. Most operations | |
545 | are delegated to evaluate_subexp_standard; see that function for a | |
546 | description of the arguments. */ | |
547 | ||
f4b8a18d | 548 | struct value * |
6c7a06a3 TT |
549 | evaluate_subexp_c (struct type *expect_type, struct expression *exp, |
550 | int *pos, enum noside noside) | |
551 | { | |
552 | enum exp_opcode op = exp->elts[*pos].opcode; | |
553 | ||
554 | switch (op) | |
555 | { | |
556 | case OP_STRING: | |
557 | { | |
558 | int oplen, limit; | |
559 | struct type *type; | |
560 | struct obstack output; | |
561 | struct cleanup *cleanup; | |
562 | struct value *result; | |
563 | enum c_string_type dest_type; | |
564 | const char *dest_charset; | |
c50491a7 | 565 | int satisfy_expected = 0; |
6c7a06a3 TT |
566 | |
567 | obstack_init (&output); | |
568 | cleanup = make_cleanup_obstack_free (&output); | |
569 | ||
570 | ++*pos; | |
571 | oplen = longest_to_int (exp->elts[*pos].longconst); | |
572 | ||
573 | ++*pos; | |
574 | limit = *pos + BYTES_TO_EXP_ELEM (oplen + 1); | |
575 | dest_type | |
576 | = (enum c_string_type) longest_to_int (exp->elts[*pos].longconst); | |
577 | switch (dest_type & ~C_CHAR) | |
578 | { | |
579 | case C_STRING: | |
d80b854b UW |
580 | type = language_string_char_type (exp->language_defn, |
581 | exp->gdbarch); | |
6c7a06a3 TT |
582 | break; |
583 | case C_WIDE_STRING: | |
e6c014f2 UW |
584 | type = lookup_typename (exp->language_defn, exp->gdbarch, |
585 | "wchar_t", NULL, 0); | |
6c7a06a3 TT |
586 | break; |
587 | case C_STRING_16: | |
e6c014f2 UW |
588 | type = lookup_typename (exp->language_defn, exp->gdbarch, |
589 | "char16_t", NULL, 0); | |
6c7a06a3 TT |
590 | break; |
591 | case C_STRING_32: | |
e6c014f2 UW |
592 | type = lookup_typename (exp->language_defn, exp->gdbarch, |
593 | "char32_t", NULL, 0); | |
6c7a06a3 TT |
594 | break; |
595 | default: | |
9b20d036 | 596 | internal_error (__FILE__, __LINE__, _("unhandled c_string_type")); |
6c7a06a3 | 597 | } |
546e879e TT |
598 | |
599 | /* Ensure TYPE_LENGTH is valid for TYPE. */ | |
600 | check_typedef (type); | |
601 | ||
c50491a7 TT |
602 | /* If the caller expects an array of some integral type, |
603 | satisfy them. If something odder is expected, rely on the | |
604 | caller to cast. */ | |
605 | if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_ARRAY) | |
606 | { | |
607 | struct type *element_type | |
608 | = check_typedef (TYPE_TARGET_TYPE (expect_type)); | |
609 | ||
610 | if (TYPE_CODE (element_type) == TYPE_CODE_INT | |
611 | || TYPE_CODE (element_type) == TYPE_CODE_CHAR) | |
612 | { | |
613 | type = element_type; | |
614 | satisfy_expected = 1; | |
615 | } | |
616 | } | |
617 | ||
f870a310 | 618 | dest_charset = charset_for_string_type (dest_type, exp->gdbarch); |
6c7a06a3 TT |
619 | |
620 | ++*pos; | |
621 | while (*pos < limit) | |
622 | { | |
623 | int len; | |
624 | ||
625 | len = longest_to_int (exp->elts[*pos].longconst); | |
626 | ||
627 | ++*pos; | |
628 | if (noside != EVAL_SKIP) | |
629 | parse_one_string (&output, &exp->elts[*pos].string, len, | |
630 | dest_charset, type); | |
631 | *pos += BYTES_TO_EXP_ELEM (len); | |
632 | } | |
633 | ||
634 | /* Skip the trailing length and opcode. */ | |
635 | *pos += 2; | |
636 | ||
637 | if (noside == EVAL_SKIP) | |
334cc82d TT |
638 | { |
639 | /* Return a dummy value of the appropriate type. */ | |
c50491a7 TT |
640 | if (expect_type != NULL) |
641 | result = allocate_value (expect_type); | |
642 | else if ((dest_type & C_CHAR) != 0) | |
334cc82d TT |
643 | result = allocate_value (type); |
644 | else | |
3b7538c0 | 645 | result = value_cstring ("", 0, type); |
334cc82d TT |
646 | do_cleanups (cleanup); |
647 | return result; | |
648 | } | |
6c7a06a3 TT |
649 | |
650 | if ((dest_type & C_CHAR) != 0) | |
651 | { | |
652 | LONGEST value; | |
653 | ||
654 | if (obstack_object_size (&output) != TYPE_LENGTH (type)) | |
3e43a32a MS |
655 | error (_("Could not convert character " |
656 | "constant to target character set")); | |
51a5cd90 | 657 | value = unpack_long (type, (gdb_byte *) obstack_base (&output)); |
6c7a06a3 TT |
658 | result = value_from_longest (type, value); |
659 | } | |
660 | else | |
661 | { | |
662 | int i; | |
c5504eaf | 663 | |
6c7a06a3 TT |
664 | /* Write the terminating character. */ |
665 | for (i = 0; i < TYPE_LENGTH (type); ++i) | |
666 | obstack_1grow (&output, 0); | |
c50491a7 TT |
667 | |
668 | if (satisfy_expected) | |
669 | { | |
670 | LONGEST low_bound, high_bound; | |
671 | int element_size = TYPE_LENGTH (type); | |
672 | ||
673 | if (get_discrete_bounds (TYPE_INDEX_TYPE (expect_type), | |
674 | &low_bound, &high_bound) < 0) | |
675 | { | |
676 | low_bound = 0; | |
677 | high_bound = (TYPE_LENGTH (expect_type) / element_size) - 1; | |
678 | } | |
679 | if (obstack_object_size (&output) / element_size | |
680 | > (high_bound - low_bound + 1)) | |
681 | error (_("Too many array elements")); | |
682 | ||
683 | result = allocate_value (expect_type); | |
684 | memcpy (value_contents_raw (result), obstack_base (&output), | |
685 | obstack_object_size (&output)); | |
686 | } | |
687 | else | |
688 | result = value_cstring (obstack_base (&output), | |
689 | obstack_object_size (&output), | |
690 | type); | |
6c7a06a3 TT |
691 | } |
692 | do_cleanups (cleanup); | |
693 | return result; | |
694 | } | |
695 | break; | |
696 | ||
697 | default: | |
698 | break; | |
699 | } | |
700 | return evaluate_subexp_standard (expect_type, exp, pos, noside); | |
701 | } | |
c5aa993b | 702 | |
84f0252a | 703 | |
84f0252a | 704 | \f |
c906108c SS |
705 | /* Table mapping opcodes into strings for printing operators |
706 | and precedences of the operators. */ | |
707 | ||
708 | const struct op_print c_op_print_tab[] = | |
c5aa993b JM |
709 | { |
710 | {",", BINOP_COMMA, PREC_COMMA, 0}, | |
711 | {"=", BINOP_ASSIGN, PREC_ASSIGN, 1}, | |
712 | {"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0}, | |
713 | {"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0}, | |
714 | {"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0}, | |
715 | {"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0}, | |
716 | {"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0}, | |
717 | {"==", BINOP_EQUAL, PREC_EQUAL, 0}, | |
718 | {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0}, | |
719 | {"<=", BINOP_LEQ, PREC_ORDER, 0}, | |
720 | {">=", BINOP_GEQ, PREC_ORDER, 0}, | |
721 | {">", BINOP_GTR, PREC_ORDER, 0}, | |
722 | {"<", BINOP_LESS, PREC_ORDER, 0}, | |
723 | {">>", BINOP_RSH, PREC_SHIFT, 0}, | |
724 | {"<<", BINOP_LSH, PREC_SHIFT, 0}, | |
725 | {"+", BINOP_ADD, PREC_ADD, 0}, | |
726 | {"-", BINOP_SUB, PREC_ADD, 0}, | |
727 | {"*", BINOP_MUL, PREC_MUL, 0}, | |
728 | {"/", BINOP_DIV, PREC_MUL, 0}, | |
729 | {"%", BINOP_REM, PREC_MUL, 0}, | |
730 | {"@", BINOP_REPEAT, PREC_REPEAT, 0}, | |
a016fc87 | 731 | {"+", UNOP_PLUS, PREC_PREFIX, 0}, |
c5aa993b JM |
732 | {"-", UNOP_NEG, PREC_PREFIX, 0}, |
733 | {"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0}, | |
734 | {"~", UNOP_COMPLEMENT, PREC_PREFIX, 0}, | |
735 | {"*", UNOP_IND, PREC_PREFIX, 0}, | |
736 | {"&", UNOP_ADDR, PREC_PREFIX, 0}, | |
737 | {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0}, | |
738 | {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0}, | |
739 | {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0}, | |
c5aa993b | 740 | {NULL, 0, 0, 0} |
c906108c SS |
741 | }; |
742 | \f | |
685419e2 AC |
743 | enum c_primitive_types { |
744 | c_primitive_type_int, | |
745 | c_primitive_type_long, | |
746 | c_primitive_type_short, | |
747 | c_primitive_type_char, | |
748 | c_primitive_type_float, | |
749 | c_primitive_type_double, | |
750 | c_primitive_type_void, | |
751 | c_primitive_type_long_long, | |
752 | c_primitive_type_signed_char, | |
753 | c_primitive_type_unsigned_char, | |
754 | c_primitive_type_unsigned_short, | |
755 | c_primitive_type_unsigned_int, | |
756 | c_primitive_type_unsigned_long, | |
757 | c_primitive_type_unsigned_long_long, | |
758 | c_primitive_type_long_double, | |
759 | c_primitive_type_complex, | |
760 | c_primitive_type_double_complex, | |
213e4dc2 TJB |
761 | c_primitive_type_decfloat, |
762 | c_primitive_type_decdouble, | |
763 | c_primitive_type_declong, | |
685419e2 AC |
764 | nr_c_primitive_types |
765 | }; | |
766 | ||
e9667a65 | 767 | void |
685419e2 AC |
768 | c_language_arch_info (struct gdbarch *gdbarch, |
769 | struct language_arch_info *lai) | |
770 | { | |
771 | const struct builtin_type *builtin = builtin_type (gdbarch); | |
c5504eaf | 772 | |
e9667a65 | 773 | lai->string_char_type = builtin->builtin_char; |
685419e2 AC |
774 | lai->primitive_type_vector |
775 | = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_c_primitive_types + 1, | |
776 | struct type *); | |
777 | lai->primitive_type_vector [c_primitive_type_int] = builtin->builtin_int; | |
778 | lai->primitive_type_vector [c_primitive_type_long] = builtin->builtin_long; | |
779 | lai->primitive_type_vector [c_primitive_type_short] = builtin->builtin_short; | |
780 | lai->primitive_type_vector [c_primitive_type_char] = builtin->builtin_char; | |
781 | lai->primitive_type_vector [c_primitive_type_float] = builtin->builtin_float; | |
782 | lai->primitive_type_vector [c_primitive_type_double] = builtin->builtin_double; | |
783 | lai->primitive_type_vector [c_primitive_type_void] = builtin->builtin_void; | |
784 | lai->primitive_type_vector [c_primitive_type_long_long] = builtin->builtin_long_long; | |
785 | lai->primitive_type_vector [c_primitive_type_signed_char] = builtin->builtin_signed_char; | |
786 | lai->primitive_type_vector [c_primitive_type_unsigned_char] = builtin->builtin_unsigned_char; | |
787 | lai->primitive_type_vector [c_primitive_type_unsigned_short] = builtin->builtin_unsigned_short; | |
788 | lai->primitive_type_vector [c_primitive_type_unsigned_int] = builtin->builtin_unsigned_int; | |
789 | lai->primitive_type_vector [c_primitive_type_unsigned_long] = builtin->builtin_unsigned_long; | |
790 | lai->primitive_type_vector [c_primitive_type_unsigned_long_long] = builtin->builtin_unsigned_long_long; | |
791 | lai->primitive_type_vector [c_primitive_type_long_double] = builtin->builtin_long_double; | |
792 | lai->primitive_type_vector [c_primitive_type_complex] = builtin->builtin_complex; | |
793 | lai->primitive_type_vector [c_primitive_type_double_complex] = builtin->builtin_double_complex; | |
213e4dc2 TJB |
794 | lai->primitive_type_vector [c_primitive_type_decfloat] = builtin->builtin_decfloat; |
795 | lai->primitive_type_vector [c_primitive_type_decdouble] = builtin->builtin_decdouble; | |
796 | lai->primitive_type_vector [c_primitive_type_declong] = builtin->builtin_declong; | |
fbb06eb1 UW |
797 | |
798 | lai->bool_type_default = builtin->builtin_int; | |
cad351d1 | 799 | } |
685419e2 | 800 | |
6aecb9c2 | 801 | const struct exp_descriptor exp_descriptor_c = |
6c7a06a3 TT |
802 | { |
803 | print_subexp_standard, | |
804 | operator_length_standard, | |
c0201579 | 805 | operator_check_standard, |
6c7a06a3 TT |
806 | op_name_standard, |
807 | dump_subexp_body_standard, | |
808 | evaluate_subexp_c | |
809 | }; | |
810 | ||
c5aa993b JM |
811 | const struct language_defn c_language_defn = |
812 | { | |
c906108c SS |
813 | "c", /* Language name */ |
814 | language_c, | |
c906108c | 815 | range_check_off, |
63872f9d | 816 | case_sensitive_on, |
7ca2d3a3 | 817 | array_row_major, |
9a044a89 | 818 | macro_expansion_c, |
6c7a06a3 | 819 | &exp_descriptor_c, |
7c8adf68 | 820 | c_parse, |
c906108c | 821 | c_error, |
e85c3284 | 822 | null_post_parser, |
c906108c SS |
823 | c_printchar, /* Print a character constant */ |
824 | c_printstr, /* Function to print string constant */ | |
825 | c_emit_char, /* Print a single char */ | |
c906108c | 826 | c_print_type, /* Print a type using appropriate syntax */ |
5c6ce71d | 827 | c_print_typedef, /* Print a typedef using appropriate syntax */ |
c906108c SS |
828 | c_val_print, /* Print a value using appropriate syntax */ |
829 | c_value_print, /* Print a top-level value */ | |
a5ee536b | 830 | default_read_var_value, /* la_read_var_value */ |
f636b87d | 831 | NULL, /* Language specific skip_trampoline */ |
2b2d9e11 | 832 | NULL, /* name_of_this */ |
5f9a71c3 | 833 | basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ |
b368761e | 834 | basic_lookup_transparent_type,/* lookup_transparent_type */ |
9a3d7dfd | 835 | NULL, /* Language specific symbol demangler */ |
aff410f1 MS |
836 | NULL, /* Language specific |
837 | class_name_from_physname */ | |
c906108c SS |
838 | c_op_print_tab, /* expression operators for printing */ |
839 | 1, /* c-style arrays */ | |
840 | 0, /* String lower bound */ | |
6084f43a | 841 | default_word_break_characters, |
41d27058 | 842 | default_make_symbol_completion_list, |
685419e2 | 843 | c_language_arch_info, |
e79af960 | 844 | default_print_array_index, |
41f1b697 | 845 | default_pass_by_reference, |
ae6a3a4c | 846 | c_get_string, |
1a119f36 | 847 | NULL, /* la_get_symbol_name_cmp */ |
f8eba3c6 | 848 | iterate_over_symbols, |
c906108c SS |
849 | LANG_MAGIC |
850 | }; | |
851 | ||
cad351d1 UW |
852 | enum cplus_primitive_types { |
853 | cplus_primitive_type_int, | |
854 | cplus_primitive_type_long, | |
855 | cplus_primitive_type_short, | |
856 | cplus_primitive_type_char, | |
857 | cplus_primitive_type_float, | |
858 | cplus_primitive_type_double, | |
859 | cplus_primitive_type_void, | |
860 | cplus_primitive_type_long_long, | |
861 | cplus_primitive_type_signed_char, | |
862 | cplus_primitive_type_unsigned_char, | |
863 | cplus_primitive_type_unsigned_short, | |
864 | cplus_primitive_type_unsigned_int, | |
865 | cplus_primitive_type_unsigned_long, | |
866 | cplus_primitive_type_unsigned_long_long, | |
867 | cplus_primitive_type_long_double, | |
868 | cplus_primitive_type_complex, | |
869 | cplus_primitive_type_double_complex, | |
870 | cplus_primitive_type_bool, | |
213e4dc2 TJB |
871 | cplus_primitive_type_decfloat, |
872 | cplus_primitive_type_decdouble, | |
873 | cplus_primitive_type_declong, | |
cad351d1 | 874 | nr_cplus_primitive_types |
c906108c SS |
875 | }; |
876 | ||
cad351d1 UW |
877 | static void |
878 | cplus_language_arch_info (struct gdbarch *gdbarch, | |
879 | struct language_arch_info *lai) | |
880 | { | |
881 | const struct builtin_type *builtin = builtin_type (gdbarch); | |
c5504eaf | 882 | |
cad351d1 UW |
883 | lai->string_char_type = builtin->builtin_char; |
884 | lai->primitive_type_vector | |
885 | = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_cplus_primitive_types + 1, | |
886 | struct type *); | |
887 | lai->primitive_type_vector [cplus_primitive_type_int] | |
888 | = builtin->builtin_int; | |
889 | lai->primitive_type_vector [cplus_primitive_type_long] | |
890 | = builtin->builtin_long; | |
891 | lai->primitive_type_vector [cplus_primitive_type_short] | |
892 | = builtin->builtin_short; | |
893 | lai->primitive_type_vector [cplus_primitive_type_char] | |
894 | = builtin->builtin_char; | |
895 | lai->primitive_type_vector [cplus_primitive_type_float] | |
896 | = builtin->builtin_float; | |
897 | lai->primitive_type_vector [cplus_primitive_type_double] | |
898 | = builtin->builtin_double; | |
899 | lai->primitive_type_vector [cplus_primitive_type_void] | |
900 | = builtin->builtin_void; | |
901 | lai->primitive_type_vector [cplus_primitive_type_long_long] | |
902 | = builtin->builtin_long_long; | |
903 | lai->primitive_type_vector [cplus_primitive_type_signed_char] | |
904 | = builtin->builtin_signed_char; | |
905 | lai->primitive_type_vector [cplus_primitive_type_unsigned_char] | |
906 | = builtin->builtin_unsigned_char; | |
907 | lai->primitive_type_vector [cplus_primitive_type_unsigned_short] | |
908 | = builtin->builtin_unsigned_short; | |
909 | lai->primitive_type_vector [cplus_primitive_type_unsigned_int] | |
910 | = builtin->builtin_unsigned_int; | |
911 | lai->primitive_type_vector [cplus_primitive_type_unsigned_long] | |
912 | = builtin->builtin_unsigned_long; | |
913 | lai->primitive_type_vector [cplus_primitive_type_unsigned_long_long] | |
914 | = builtin->builtin_unsigned_long_long; | |
915 | lai->primitive_type_vector [cplus_primitive_type_long_double] | |
916 | = builtin->builtin_long_double; | |
917 | lai->primitive_type_vector [cplus_primitive_type_complex] | |
918 | = builtin->builtin_complex; | |
919 | lai->primitive_type_vector [cplus_primitive_type_double_complex] | |
920 | = builtin->builtin_double_complex; | |
921 | lai->primitive_type_vector [cplus_primitive_type_bool] | |
922 | = builtin->builtin_bool; | |
213e4dc2 TJB |
923 | lai->primitive_type_vector [cplus_primitive_type_decfloat] |
924 | = builtin->builtin_decfloat; | |
925 | lai->primitive_type_vector [cplus_primitive_type_decdouble] | |
926 | = builtin->builtin_decdouble; | |
927 | lai->primitive_type_vector [cplus_primitive_type_declong] | |
928 | = builtin->builtin_declong; | |
fbb06eb1 UW |
929 | |
930 | lai->bool_type_symbol = "bool"; | |
931 | lai->bool_type_default = builtin->builtin_bool; | |
cad351d1 UW |
932 | } |
933 | ||
c5aa993b JM |
934 | const struct language_defn cplus_language_defn = |
935 | { | |
936 | "c++", /* Language name */ | |
c906108c | 937 | language_cplus, |
c906108c | 938 | range_check_off, |
63872f9d | 939 | case_sensitive_on, |
7ca2d3a3 | 940 | array_row_major, |
9a044a89 | 941 | macro_expansion_c, |
6c7a06a3 | 942 | &exp_descriptor_c, |
7c8adf68 | 943 | c_parse, |
c906108c | 944 | c_error, |
e85c3284 | 945 | null_post_parser, |
c906108c SS |
946 | c_printchar, /* Print a character constant */ |
947 | c_printstr, /* Function to print string constant */ | |
948 | c_emit_char, /* Print a single char */ | |
c906108c | 949 | c_print_type, /* Print a type using appropriate syntax */ |
5c6ce71d | 950 | c_print_typedef, /* Print a typedef using appropriate syntax */ |
c906108c SS |
951 | c_val_print, /* Print a value using appropriate syntax */ |
952 | c_value_print, /* Print a top-level value */ | |
a5ee536b | 953 | default_read_var_value, /* la_read_var_value */ |
b18be20d | 954 | cplus_skip_trampoline, /* Language specific skip_trampoline */ |
2b2d9e11 | 955 | "this", /* name_of_this */ |
1fcb5155 | 956 | cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ |
b368761e | 957 | cp_lookup_transparent_type, /* lookup_transparent_type */ |
8de20a37 | 958 | gdb_demangle, /* Language specific symbol demangler */ |
aff410f1 MS |
959 | cp_class_name_from_physname, /* Language specific |
960 | class_name_from_physname */ | |
c906108c SS |
961 | c_op_print_tab, /* expression operators for printing */ |
962 | 1, /* c-style arrays */ | |
963 | 0, /* String lower bound */ | |
6084f43a | 964 | default_word_break_characters, |
41d27058 | 965 | default_make_symbol_completion_list, |
cad351d1 | 966 | cplus_language_arch_info, |
e79af960 | 967 | default_print_array_index, |
41f1b697 | 968 | cp_pass_by_reference, |
ae6a3a4c | 969 | c_get_string, |
1a119f36 | 970 | NULL, /* la_get_symbol_name_cmp */ |
f8eba3c6 | 971 | iterate_over_symbols, |
c906108c SS |
972 | LANG_MAGIC |
973 | }; | |
974 | ||
c5aa993b JM |
975 | const struct language_defn asm_language_defn = |
976 | { | |
c906108c SS |
977 | "asm", /* Language name */ |
978 | language_asm, | |
c906108c | 979 | range_check_off, |
63872f9d | 980 | case_sensitive_on, |
7ca2d3a3 | 981 | array_row_major, |
9a044a89 | 982 | macro_expansion_c, |
6c7a06a3 | 983 | &exp_descriptor_c, |
7c8adf68 | 984 | c_parse, |
c906108c | 985 | c_error, |
e85c3284 | 986 | null_post_parser, |
c906108c SS |
987 | c_printchar, /* Print a character constant */ |
988 | c_printstr, /* Function to print string constant */ | |
989 | c_emit_char, /* Print a single char */ | |
c906108c | 990 | c_print_type, /* Print a type using appropriate syntax */ |
5c6ce71d | 991 | c_print_typedef, /* Print a typedef using appropriate syntax */ |
c906108c SS |
992 | c_val_print, /* Print a value using appropriate syntax */ |
993 | c_value_print, /* Print a top-level value */ | |
a5ee536b | 994 | default_read_var_value, /* la_read_var_value */ |
f636b87d | 995 | NULL, /* Language specific skip_trampoline */ |
2b2d9e11 | 996 | NULL, /* name_of_this */ |
5f9a71c3 | 997 | basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ |
b368761e | 998 | basic_lookup_transparent_type,/* lookup_transparent_type */ |
9a3d7dfd | 999 | NULL, /* Language specific symbol demangler */ |
aff410f1 MS |
1000 | NULL, /* Language specific |
1001 | class_name_from_physname */ | |
c906108c SS |
1002 | c_op_print_tab, /* expression operators for printing */ |
1003 | 1, /* c-style arrays */ | |
1004 | 0, /* String lower bound */ | |
6084f43a | 1005 | default_word_break_characters, |
41d27058 | 1006 | default_make_symbol_completion_list, |
aff410f1 | 1007 | c_language_arch_info, /* FIXME: la_language_arch_info. */ |
e79af960 | 1008 | default_print_array_index, |
41f1b697 | 1009 | default_pass_by_reference, |
ae6a3a4c | 1010 | c_get_string, |
1a119f36 | 1011 | NULL, /* la_get_symbol_name_cmp */ |
f8eba3c6 | 1012 | iterate_over_symbols, |
c906108c SS |
1013 | LANG_MAGIC |
1014 | }; | |
1015 | ||
20a0e81d JB |
1016 | /* The following language_defn does not represent a real language. |
1017 | It just provides a minimal support a-la-C that should allow users | |
1018 | to do some simple operations when debugging applications that use | |
1019 | a language currently not supported by GDB. */ | |
1020 | ||
1021 | const struct language_defn minimal_language_defn = | |
1022 | { | |
1023 | "minimal", /* Language name */ | |
1024 | language_minimal, | |
20a0e81d | 1025 | range_check_off, |
20a0e81d | 1026 | case_sensitive_on, |
7ca2d3a3 | 1027 | array_row_major, |
9a044a89 | 1028 | macro_expansion_c, |
6c7a06a3 | 1029 | &exp_descriptor_c, |
7c8adf68 | 1030 | c_parse, |
20a0e81d | 1031 | c_error, |
e85c3284 | 1032 | null_post_parser, |
20a0e81d JB |
1033 | c_printchar, /* Print a character constant */ |
1034 | c_printstr, /* Function to print string constant */ | |
1035 | c_emit_char, /* Print a single char */ | |
20a0e81d | 1036 | c_print_type, /* Print a type using appropriate syntax */ |
5c6ce71d | 1037 | c_print_typedef, /* Print a typedef using appropriate syntax */ |
20a0e81d JB |
1038 | c_val_print, /* Print a value using appropriate syntax */ |
1039 | c_value_print, /* Print a top-level value */ | |
a5ee536b | 1040 | default_read_var_value, /* la_read_var_value */ |
20a0e81d | 1041 | NULL, /* Language specific skip_trampoline */ |
2b2d9e11 | 1042 | NULL, /* name_of_this */ |
5f9a71c3 | 1043 | basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ |
b368761e | 1044 | basic_lookup_transparent_type,/* lookup_transparent_type */ |
20a0e81d | 1045 | NULL, /* Language specific symbol demangler */ |
aff410f1 MS |
1046 | NULL, /* Language specific |
1047 | class_name_from_physname */ | |
20a0e81d JB |
1048 | c_op_print_tab, /* expression operators for printing */ |
1049 | 1, /* c-style arrays */ | |
1050 | 0, /* String lower bound */ | |
6084f43a | 1051 | default_word_break_characters, |
41d27058 | 1052 | default_make_symbol_completion_list, |
e9667a65 | 1053 | c_language_arch_info, |
e79af960 | 1054 | default_print_array_index, |
41f1b697 | 1055 | default_pass_by_reference, |
ae6a3a4c | 1056 | c_get_string, |
1a119f36 | 1057 | NULL, /* la_get_symbol_name_cmp */ |
f8eba3c6 | 1058 | iterate_over_symbols, |
20a0e81d JB |
1059 | LANG_MAGIC |
1060 | }; | |
1061 | ||
c906108c | 1062 | void |
fba45db2 | 1063 | _initialize_c_language (void) |
c906108c SS |
1064 | { |
1065 | add_language (&c_language_defn); | |
1066 | add_language (&cplus_language_defn); | |
1067 | add_language (&asm_language_defn); | |
20a0e81d | 1068 | add_language (&minimal_language_defn); |
c906108c | 1069 | } |