Commit | Line | Data |
---|---|---|
c8023e66 | 1 | /* Multiple source language support for GDB. |
7ed0f002 | 2 | Copyright 1991, 1992 Free Software Foundation, Inc. |
c8023e66 JG |
3 | Contributed by the Department of Computer Science at the State University |
4 | of New York at Buffalo. | |
5 | ||
6 | This file is part of GDB. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
21 | ||
22 | /* This file contains functions that return things that are specific | |
23 | to languages. Each function should examine current_language if necessary, | |
24 | and return the appropriate result. */ | |
25 | ||
26 | /* FIXME: Most of these would be better organized as macros which | |
27 | return data out of a "language-specific" struct pointer that is set | |
28 | whenever the working language changes. That would be a lot faster. */ | |
29 | ||
d747e0af | 30 | #include "defs.h" |
c8023e66 JG |
31 | #include <string.h> |
32 | #include <varargs.h> | |
33 | ||
c8023e66 | 34 | #include "symtab.h" |
1ab3bf1b | 35 | #include "gdbtypes.h" |
c8023e66 JG |
36 | #include "value.h" |
37 | #include "gdbcmd.h" | |
38 | #include "frame.h" | |
c8023e66 | 39 | #include "expression.h" |
7ed0f002 | 40 | #include "language.h" |
c8023e66 JG |
41 | #include "target.h" |
42 | #include "parser-defs.h" | |
43 | ||
7ed0f002 JG |
44 | static void |
45 | show_language_command PARAMS ((char *, int)); | |
46 | ||
47 | static void | |
48 | set_language_command PARAMS ((char *, int)); | |
49 | ||
50 | static void | |
51 | show_type_command PARAMS ((char *, int)); | |
c4668207 | 52 | |
7ed0f002 JG |
53 | static void |
54 | set_type_command PARAMS ((char *, int)); | |
55 | ||
56 | static void | |
57 | show_range_command PARAMS ((char *, int)); | |
58 | ||
59 | static void | |
60 | set_range_command PARAMS ((char *, int)); | |
61 | ||
62 | static void | |
63 | set_range_str PARAMS ((void)); | |
64 | ||
65 | static void | |
66 | set_type_str PARAMS ((void)); | |
67 | ||
68 | static void | |
69 | set_lang_str PARAMS ((void)); | |
70 | ||
71 | static void | |
72 | unk_lang_error PARAMS ((char *)); | |
73 | ||
74 | static int | |
75 | unk_lang_parser PARAMS ((void)); | |
76 | ||
77 | static void | |
78 | show_check PARAMS ((char *, int)); | |
79 | ||
80 | static void | |
81 | set_check PARAMS ((char *, int)); | |
82 | ||
83 | static void | |
84 | set_type_range PARAMS ((void)); | |
c8023e66 JG |
85 | |
86 | /* Forward declaration */ | |
0c6efbcc | 87 | extern const struct language_defn unknown_language_defn; |
318bf84f | 88 | extern char *warning_pre_print; |
7ed0f002 | 89 | |
c8023e66 JG |
90 | /* The current (default at startup) state of type and range checking. |
91 | (If the modes are set to "auto", though, these are changed based | |
92 | on the default language at startup, and then again based on the | |
93 | language of the first source file. */ | |
94 | ||
95 | enum range_mode range_mode = range_mode_auto; | |
96 | enum range_check range_check = range_check_off; | |
97 | enum type_mode type_mode = type_mode_auto; | |
98 | enum type_check type_check = type_check_off; | |
99 | ||
100 | /* The current language and language_mode (see language.h) */ | |
101 | ||
0c6efbcc | 102 | const struct language_defn *current_language = &unknown_language_defn; |
c8023e66 JG |
103 | enum language_mode language_mode = language_mode_auto; |
104 | ||
b5af69c3 JG |
105 | /* The language that the user expects to be typing in (the language |
106 | of main(), or the last language we notified them about, or C). */ | |
107 | ||
108 | const struct language_defn *expected_language; | |
109 | ||
c8023e66 JG |
110 | /* The list of supported languages. The list itself is malloc'd. */ |
111 | ||
7ed0f002 | 112 | static const struct language_defn **languages; |
c8023e66 JG |
113 | static unsigned languages_size; |
114 | static unsigned languages_allocsize; | |
e58de8a2 | 115 | #define DEFAULT_ALLOCSIZE 4 |
c8023e66 JG |
116 | |
117 | /* The "set language/type/range" commands all put stuff in these | |
118 | buffers. This is to make them work as set/show commands. The | |
119 | user's string is copied here, then the set_* commands look at | |
120 | them and update them to something that looks nice when it is | |
121 | printed out. */ | |
122 | ||
123 | static char *language; | |
124 | static char *type; | |
125 | static char *range; | |
126 | ||
127 | /* Warning issued when current_language and the language of the current | |
128 | frame do not match. */ | |
129 | char lang_frame_mismatch_warn[] = | |
130 | "Warning: the current language does not match this frame."; | |
131 | ||
c8023e66 JG |
132 | \f |
133 | /* This page contains the functions corresponding to GDB commands | |
134 | and their helpers. */ | |
135 | ||
136 | /* Show command. Display a warning if the language set | |
137 | does not match the frame. */ | |
7ed0f002 | 138 | static void |
d8ce1326 JG |
139 | show_language_command (ignore, from_tty) |
140 | char *ignore; | |
c8023e66 JG |
141 | int from_tty; |
142 | { | |
143 | enum language flang; /* The language of the current frame */ | |
144 | ||
145 | flang = get_frame_language(); | |
146 | if (flang != language_unknown && | |
147 | language_mode == language_mode_manual && | |
148 | current_language->la_language != flang) | |
149 | printf_filtered("%s\n",lang_frame_mismatch_warn); | |
150 | } | |
151 | ||
152 | /* Set command. Change the current working language. */ | |
7ed0f002 | 153 | static void |
d8ce1326 JG |
154 | set_language_command (ignore, from_tty) |
155 | char *ignore; | |
c8023e66 JG |
156 | int from_tty; |
157 | { | |
158 | int i; | |
159 | enum language flang; | |
5f3d478e | 160 | char *err_lang; |
c8023e66 JG |
161 | |
162 | /* FIXME -- do this from the list, with HELP. */ | |
163 | if (!language || !language[0]) { | |
19cfe25d FF |
164 | printf("The currently understood settings are:\n\n"); |
165 | printf ("local or auto Automatic setting based on source file\n"); | |
166 | printf ("c Use the C language\n"); | |
167 | printf ("c++ Use the C++ language\n"); | |
168 | /* start-sanitize-chill */ | |
169 | printf ("chill Use the Chill language\n"); | |
170 | /* end-sanitize-chill */ | |
171 | printf ("modula-2 Use the Modula-2 language\n"); | |
0b798409 JG |
172 | /* Restore the silly string. */ |
173 | set_language(current_language->la_language); | |
c8023e66 JG |
174 | return; |
175 | } | |
176 | ||
177 | /* Search the list of languages for a match. */ | |
178 | for (i = 0; i < languages_size; i++) { | |
179 | if (!strcmp (languages[i]->la_name, language)) { | |
180 | /* Found it! Go into manual mode, and use this language. */ | |
181 | if (languages[i]->la_language == language_auto) { | |
182 | /* Enter auto mode. Set to the current frame's language, if known. */ | |
183 | language_mode = language_mode_auto; | |
184 | flang = get_frame_language(); | |
185 | if (flang!=language_unknown) | |
186 | set_language(flang); | |
b5af69c3 | 187 | expected_language = current_language; |
c8023e66 JG |
188 | return; |
189 | } else { | |
190 | /* Enter manual mode. Set the specified language. */ | |
191 | language_mode = language_mode_manual; | |
192 | current_language = languages[i]; | |
193 | set_type_range (); | |
194 | set_lang_str(); | |
b5af69c3 | 195 | expected_language = current_language; |
c8023e66 JG |
196 | return; |
197 | } | |
198 | } | |
199 | } | |
200 | ||
5f3d478e JG |
201 | /* Reset the language (esp. the global string "language") to the |
202 | correct values. */ | |
203 | err_lang=savestring(language,strlen(language)); | |
204 | make_cleanup (free, err_lang); /* Free it after error */ | |
205 | set_language(current_language->la_language); | |
206 | error ("Unknown language `%s'.",err_lang); | |
c8023e66 JG |
207 | } |
208 | ||
209 | /* Show command. Display a warning if the type setting does | |
210 | not match the current language. */ | |
7ed0f002 | 211 | static void |
d8ce1326 JG |
212 | show_type_command(ignore, from_tty) |
213 | char *ignore; | |
c8023e66 JG |
214 | int from_tty; |
215 | { | |
216 | if (type_check != current_language->la_type_check) | |
597dc86b | 217 | printf( |
c8023e66 JG |
218 | "Warning: the current type check setting does not match the language.\n"); |
219 | } | |
220 | ||
221 | /* Set command. Change the setting for type checking. */ | |
7ed0f002 | 222 | static void |
d8ce1326 JG |
223 | set_type_command(ignore, from_tty) |
224 | char *ignore; | |
c8023e66 JG |
225 | int from_tty; |
226 | { | |
227 | if (!strcmp(type,"on")) | |
228 | { | |
229 | type_check = type_check_on; | |
230 | type_mode = type_mode_manual; | |
231 | } | |
232 | else if (!strcmp(type,"warn")) | |
233 | { | |
234 | type_check = type_check_warn; | |
235 | type_mode = type_mode_manual; | |
236 | } | |
237 | else if (!strcmp(type,"off")) | |
238 | { | |
239 | type_check = type_check_off; | |
240 | type_mode = type_mode_manual; | |
241 | } | |
242 | else if (!strcmp(type,"auto")) | |
243 | { | |
244 | type_mode = type_mode_auto; | |
245 | set_type_range(); | |
246 | /* Avoid hitting the set_type_str call below. We | |
247 | did it in set_type_range. */ | |
248 | return; | |
249 | } | |
250 | set_type_str(); | |
d8ce1326 | 251 | show_type_command((char *)NULL, from_tty); |
c8023e66 JG |
252 | } |
253 | ||
254 | /* Show command. Display a warning if the range setting does | |
255 | not match the current language. */ | |
7ed0f002 | 256 | static void |
d8ce1326 JG |
257 | show_range_command(ignore, from_tty) |
258 | char *ignore; | |
c8023e66 JG |
259 | int from_tty; |
260 | { | |
261 | ||
262 | if (range_check != current_language->la_range_check) | |
597dc86b | 263 | printf( |
c8023e66 JG |
264 | "Warning: the current range check setting does not match the language.\n"); |
265 | } | |
266 | ||
267 | /* Set command. Change the setting for range checking. */ | |
7ed0f002 | 268 | static void |
d8ce1326 JG |
269 | set_range_command(ignore, from_tty) |
270 | char *ignore; | |
c8023e66 JG |
271 | int from_tty; |
272 | { | |
273 | if (!strcmp(range,"on")) | |
274 | { | |
275 | range_check = range_check_on; | |
276 | range_mode = range_mode_manual; | |
277 | } | |
278 | else if (!strcmp(range,"warn")) | |
279 | { | |
280 | range_check = range_check_warn; | |
281 | range_mode = range_mode_manual; | |
282 | } | |
283 | else if (!strcmp(range,"off")) | |
284 | { | |
285 | range_check = range_check_off; | |
286 | range_mode = range_mode_manual; | |
287 | } | |
288 | else if (!strcmp(range,"auto")) | |
289 | { | |
290 | range_mode = range_mode_auto; | |
291 | set_type_range(); | |
292 | /* Avoid hitting the set_range_str call below. We | |
293 | did it in set_type_range. */ | |
294 | return; | |
295 | } | |
296 | set_range_str(); | |
d8ce1326 | 297 | show_range_command((char *)0, from_tty); |
c8023e66 JG |
298 | } |
299 | ||
300 | /* Set the status of range and type checking based on | |
301 | the current modes and the current language. | |
302 | If SHOW is non-zero, then print out the current language, | |
303 | type and range checking status. */ | |
304 | static void | |
305 | set_type_range() | |
306 | { | |
c8023e66 JG |
307 | |
308 | if (range_mode == range_mode_auto) | |
309 | range_check = current_language->la_range_check; | |
310 | ||
311 | if (type_mode == type_mode_auto) | |
312 | type_check = current_language->la_type_check; | |
313 | ||
314 | set_type_str(); | |
315 | set_range_str(); | |
316 | } | |
317 | ||
318 | /* Set current language to (enum language) LANG. */ | |
319 | ||
320 | void | |
321 | set_language(lang) | |
322 | enum language lang; | |
323 | { | |
324 | int i; | |
325 | ||
326 | for (i = 0; i < languages_size; i++) { | |
327 | if (languages[i]->la_language == lang) { | |
328 | current_language = languages[i]; | |
329 | set_type_range (); | |
330 | set_lang_str(); | |
545af6ce | 331 | break; |
c8023e66 JG |
332 | } |
333 | } | |
334 | } | |
335 | \f | |
336 | /* This page contains functions that update the global vars | |
337 | language, type and range. */ | |
7ed0f002 | 338 | static void |
c8023e66 JG |
339 | set_lang_str() |
340 | { | |
d8ce1326 | 341 | char *prefix = ""; |
c8023e66 JG |
342 | |
343 | free (language); | |
344 | if (language_mode == language_mode_auto) | |
345 | prefix = "auto; currently "; | |
346 | ||
58ae87f6 | 347 | language = concat(prefix, current_language->la_name, NULL); |
c8023e66 JG |
348 | } |
349 | ||
7ed0f002 | 350 | static void |
c8023e66 JG |
351 | set_type_str() |
352 | { | |
353 | char *tmp, *prefix = ""; | |
354 | ||
355 | free (type); | |
356 | if (type_mode==type_mode_auto) | |
357 | prefix = "auto; currently "; | |
358 | ||
359 | switch(type_check) | |
360 | { | |
361 | case type_check_on: | |
362 | tmp = "on"; | |
363 | break; | |
364 | case type_check_off: | |
365 | tmp = "off"; | |
366 | break; | |
367 | case type_check_warn: | |
368 | tmp = "warn"; | |
369 | break; | |
370 | default: | |
371 | error ("Unrecognized type check setting."); | |
372 | } | |
373 | ||
58ae87f6 | 374 | type = concat(prefix,tmp,NULL); |
c8023e66 JG |
375 | } |
376 | ||
7ed0f002 | 377 | static void |
c8023e66 JG |
378 | set_range_str() |
379 | { | |
380 | char *tmp, *pref = ""; | |
381 | ||
382 | free (range); | |
383 | if (range_mode==range_mode_auto) | |
384 | pref = "auto; currently "; | |
385 | ||
386 | switch(range_check) | |
387 | { | |
388 | case range_check_on: | |
389 | tmp = "on"; | |
390 | break; | |
391 | case range_check_off: | |
392 | tmp = "off"; | |
393 | break; | |
394 | case range_check_warn: | |
395 | tmp = "warn"; | |
396 | break; | |
397 | default: | |
398 | error ("Unrecognized range check setting."); | |
399 | } | |
400 | ||
58ae87f6 | 401 | range = concat(pref,tmp,NULL); |
c8023e66 JG |
402 | } |
403 | ||
404 | ||
405 | /* Print out the current language settings: language, range and | |
7ed0f002 | 406 | type checking. If QUIETLY, print only what has changed. */ |
b5af69c3 | 407 | |
c8023e66 | 408 | void |
7ed0f002 JG |
409 | language_info (quietly) |
410 | int quietly; | |
c8023e66 | 411 | { |
b5af69c3 JG |
412 | if (quietly && expected_language == current_language) |
413 | return; | |
414 | ||
415 | expected_language = current_language; | |
416 | printf("Current language: %s\n",language); | |
417 | show_language_command((char *)0, 1); | |
418 | ||
419 | if (!quietly) | |
420 | { | |
421 | printf("Type checking: %s\n",type); | |
422 | show_type_command((char *)0, 1); | |
423 | printf("Range checking: %s\n",range); | |
424 | show_range_command((char *)0, 1); | |
425 | } | |
c8023e66 JG |
426 | } |
427 | \f | |
428 | /* Return the result of a binary operation. */ | |
7ed0f002 JG |
429 | |
430 | #if 0 /* Currently unused */ | |
431 | ||
c8023e66 JG |
432 | struct type * |
433 | binop_result_type(v1,v2) | |
434 | value v1,v2; | |
435 | { | |
436 | int l1,l2,size,uns; | |
437 | ||
d8ce1326 JG |
438 | l1 = TYPE_LENGTH(VALUE_TYPE(v1)); |
439 | l2 = TYPE_LENGTH(VALUE_TYPE(v2)); | |
c8023e66 JG |
440 | |
441 | switch(current_language->la_language) | |
442 | { | |
443 | case language_c: | |
545af6ce | 444 | case language_cplus: |
c8023e66 JG |
445 | if (TYPE_CODE(VALUE_TYPE(v1))==TYPE_CODE_FLT) |
446 | return TYPE_CODE(VALUE_TYPE(v2)) == TYPE_CODE_FLT && l2 > l1 ? | |
447 | VALUE_TYPE(v2) : VALUE_TYPE(v1); | |
448 | else if (TYPE_CODE(VALUE_TYPE(v2))==TYPE_CODE_FLT) | |
449 | return TYPE_CODE(VALUE_TYPE(v1)) == TYPE_CODE_FLT && l1 > l2 ? | |
450 | VALUE_TYPE(v1) : VALUE_TYPE(v2); | |
451 | else if (TYPE_UNSIGNED(VALUE_TYPE(v1)) && l1 > l2) | |
452 | return VALUE_TYPE(v1); | |
453 | else if (TYPE_UNSIGNED(VALUE_TYPE(v2)) && l2 > l1) | |
454 | return VALUE_TYPE(v2); | |
455 | else /* Both are signed. Result is the longer type */ | |
456 | return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2); | |
457 | break; | |
458 | case language_m2: | |
459 | /* If we are doing type-checking, l1 should equal l2, so this is | |
460 | not needed. */ | |
461 | return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2); | |
462 | break; | |
19cfe25d | 463 | /* start-sanitize-chill */ |
e58de8a2 FF |
464 | case language_chill: |
465 | error ("Missing Chill support in function binop_result_check.");/*FIXME*/ | |
19cfe25d | 466 | /* end-sanitize-chill */ |
c8023e66 | 467 | } |
d8ce1326 JG |
468 | abort(); |
469 | return (struct type *)0; /* For lint */ | |
c8023e66 | 470 | } |
7ed0f002 JG |
471 | |
472 | #endif /* 0 */ | |
473 | ||
c8023e66 JG |
474 | \f |
475 | /* This page contains functions that return format strings for | |
476 | printf for printing out numbers in different formats */ | |
477 | ||
478 | /* Returns the appropriate printf format for hexadecimal | |
479 | numbers. */ | |
480 | char * | |
481 | local_hex_format_custom(pre) | |
482 | char *pre; | |
483 | { | |
484 | static char form[50]; | |
485 | ||
486 | strcpy (form, current_language->la_hex_format_pre); | |
487 | strcat (form, pre); | |
488 | strcat (form, current_language->la_hex_format_suf); | |
489 | return form; | |
490 | } | |
491 | ||
492 | /* Converts a number to hexadecimal and stores it in a static | |
493 | string. Returns a pointer to this string. */ | |
494 | char * | |
495 | local_hex_string (num) | |
496 | int num; | |
497 | { | |
498 | static char res[50]; | |
499 | ||
500 | sprintf (res, current_language->la_hex_format, num); | |
501 | return res; | |
502 | } | |
503 | ||
504 | /* Converts a number to custom hexadecimal and stores it in a static | |
505 | string. Returns a pointer to this string. */ | |
506 | char * | |
507 | local_hex_string_custom(num,pre) | |
508 | int num; | |
509 | char *pre; | |
510 | { | |
511 | static char res[50]; | |
512 | ||
513 | sprintf (res, local_hex_format_custom(pre), num); | |
514 | return res; | |
515 | } | |
516 | ||
517 | /* Returns the appropriate printf format for octal | |
518 | numbers. */ | |
519 | char * | |
520 | local_octal_format_custom(pre) | |
521 | char *pre; | |
522 | { | |
523 | static char form[50]; | |
524 | ||
525 | strcpy (form, current_language->la_octal_format_pre); | |
526 | strcat (form, pre); | |
527 | strcat (form, current_language->la_octal_format_suf); | |
528 | return form; | |
529 | } | |
530 | \f | |
531 | /* This page contains functions that are used in type/range checking. | |
532 | They all return zero if the type/range check fails. | |
533 | ||
534 | It is hoped that these will make extending GDB to parse different | |
535 | languages a little easier. These are primarily used in eval.c when | |
536 | evaluating expressions and making sure that their types are correct. | |
537 | Instead of having a mess of conjucted/disjuncted expressions in an "if", | |
538 | the ideas of type can be wrapped up in the following functions. | |
539 | ||
540 | Note that some of them are not currently dependent upon which language | |
541 | is currently being parsed. For example, floats are the same in | |
542 | C and Modula-2 (ie. the only floating point type has TYPE_CODE of | |
543 | TYPE_CODE_FLT), while booleans are different. */ | |
544 | ||
545 | /* Returns non-zero if its argument is a simple type. This is the same for | |
546 | both Modula-2 and for C. In the C case, TYPE_CODE_CHAR will never occur, | |
547 | and thus will never cause the failure of the test. */ | |
548 | int | |
549 | simple_type(type) | |
550 | struct type *type; | |
551 | { | |
552 | switch (TYPE_CODE (type)) { | |
553 | case TYPE_CODE_INT: | |
554 | case TYPE_CODE_CHAR: | |
555 | case TYPE_CODE_ENUM: | |
556 | case TYPE_CODE_FLT: | |
557 | case TYPE_CODE_RANGE: | |
558 | case TYPE_CODE_BOOL: | |
559 | return 1; | |
560 | ||
561 | default: | |
562 | return 0; | |
563 | } | |
564 | } | |
565 | ||
566 | /* Returns non-zero if its argument is of an ordered type. */ | |
567 | int | |
568 | ordered_type (type) | |
569 | struct type *type; | |
570 | { | |
571 | switch (TYPE_CODE (type)) { | |
572 | case TYPE_CODE_INT: | |
573 | case TYPE_CODE_CHAR: | |
574 | case TYPE_CODE_ENUM: | |
575 | case TYPE_CODE_FLT: | |
576 | case TYPE_CODE_RANGE: | |
577 | return 1; | |
578 | ||
579 | default: | |
580 | return 0; | |
581 | } | |
582 | } | |
583 | ||
584 | /* Returns non-zero if the two types are the same */ | |
585 | int | |
586 | same_type (arg1, arg2) | |
587 | struct type *arg1, *arg2; | |
588 | { | |
589 | if (structured_type(arg1) ? !structured_type(arg2) : structured_type(arg2)) | |
590 | /* One is structured and one isn't */ | |
591 | return 0; | |
592 | else if (structured_type(arg1) && structured_type(arg2)) | |
593 | return arg1 == arg2; | |
594 | else if (numeric_type(arg1) && numeric_type(arg2)) | |
595 | return (TYPE_CODE(arg2) == TYPE_CODE(arg1)) && | |
596 | (TYPE_UNSIGNED(arg1) == TYPE_UNSIGNED(arg2)) | |
597 | ? 1 : 0; | |
598 | else | |
599 | return arg1==arg2; | |
600 | } | |
601 | ||
602 | /* Returns non-zero if the type is integral */ | |
603 | int | |
604 | integral_type (type) | |
605 | struct type *type; | |
606 | { | |
607 | switch(current_language->la_language) | |
608 | { | |
609 | case language_c: | |
545af6ce | 610 | case language_cplus: |
c8023e66 JG |
611 | return (TYPE_CODE(type) != TYPE_CODE_INT) && |
612 | (TYPE_CODE(type) != TYPE_CODE_ENUM) ? 0 : 1; | |
613 | case language_m2: | |
614 | return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1; | |
19cfe25d | 615 | /* start-sanitize-chill */ |
e58de8a2 FF |
616 | case language_chill: |
617 | error ("Missing Chill support in function integral_type."); /*FIXME*/ | |
19cfe25d | 618 | /* end-sanitize-chill */ |
c8023e66 JG |
619 | default: |
620 | error ("Language not supported."); | |
621 | } | |
622 | } | |
623 | ||
624 | /* Returns non-zero if the value is numeric */ | |
625 | int | |
626 | numeric_type (type) | |
627 | struct type *type; | |
628 | { | |
629 | switch (TYPE_CODE (type)) { | |
630 | case TYPE_CODE_INT: | |
631 | case TYPE_CODE_FLT: | |
632 | return 1; | |
633 | ||
634 | default: | |
635 | return 0; | |
636 | } | |
637 | } | |
638 | ||
639 | /* Returns non-zero if the value is a character type */ | |
640 | int | |
641 | character_type (type) | |
642 | struct type *type; | |
643 | { | |
644 | switch(current_language->la_language) | |
645 | { | |
646 | case language_m2: | |
647 | return TYPE_CODE(type) != TYPE_CODE_CHAR ? 0 : 1; | |
648 | ||
649 | case language_c: | |
545af6ce | 650 | case language_cplus: |
c8023e66 JG |
651 | return (TYPE_CODE(type) == TYPE_CODE_INT) && |
652 | TYPE_LENGTH(type) == sizeof(char) | |
653 | ? 1 : 0; | |
19cfe25d | 654 | /* start-sanitize-chill */ |
e58de8a2 FF |
655 | case language_chill: |
656 | error ("Missing Chill support in function character_type."); /*FIXME*/ | |
19cfe25d | 657 | /* end-sanitize-chill */ |
51b57ded FF |
658 | default: |
659 | return (0); | |
c8023e66 JG |
660 | } |
661 | } | |
662 | ||
663 | /* Returns non-zero if the value is a boolean type */ | |
664 | int | |
665 | boolean_type (type) | |
666 | struct type *type; | |
667 | { | |
668 | switch(current_language->la_language) | |
669 | { | |
19cfe25d | 670 | /* start-sanitize-chill */ |
e58de8a2 | 671 | case language_chill: |
19cfe25d | 672 | /* end-sanitize-chill */ |
c8023e66 JG |
673 | case language_m2: |
674 | return TYPE_CODE(type) != TYPE_CODE_BOOL ? 0 : 1; | |
675 | ||
676 | case language_c: | |
545af6ce | 677 | case language_cplus: |
c8023e66 | 678 | return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1; |
51b57ded FF |
679 | default: |
680 | return (0); | |
c8023e66 JG |
681 | } |
682 | } | |
683 | ||
684 | /* Returns non-zero if the value is a floating-point type */ | |
685 | int | |
686 | float_type (type) | |
687 | struct type *type; | |
688 | { | |
689 | return TYPE_CODE(type) == TYPE_CODE_FLT; | |
690 | } | |
691 | ||
692 | /* Returns non-zero if the value is a pointer type */ | |
693 | int | |
694 | pointer_type(type) | |
695 | struct type *type; | |
696 | { | |
697 | return TYPE_CODE(type) == TYPE_CODE_PTR || | |
698 | TYPE_CODE(type) == TYPE_CODE_REF; | |
699 | } | |
700 | ||
701 | /* Returns non-zero if the value is a structured type */ | |
702 | int | |
703 | structured_type(type) | |
704 | struct type *type; | |
705 | { | |
706 | switch(current_language->la_language) | |
707 | { | |
708 | case language_c: | |
545af6ce | 709 | case language_cplus: |
c8023e66 JG |
710 | return (TYPE_CODE(type) == TYPE_CODE_STRUCT) || |
711 | (TYPE_CODE(type) == TYPE_CODE_UNION) || | |
712 | (TYPE_CODE(type) == TYPE_CODE_ARRAY); | |
713 | case language_m2: | |
714 | return (TYPE_CODE(type) == TYPE_CODE_STRUCT) || | |
715 | (TYPE_CODE(type) == TYPE_CODE_SET) || | |
716 | (TYPE_CODE(type) == TYPE_CODE_ARRAY); | |
19cfe25d | 717 | /* start-sanitize-chill */ |
e58de8a2 FF |
718 | case language_chill: |
719 | error ("Missing Chill support in function structured_type."); /*FIXME*/ | |
19cfe25d | 720 | /* end-sanitize-chill */ |
51b57ded FF |
721 | default: |
722 | return (0); | |
c8023e66 JG |
723 | } |
724 | } | |
725 | \f | |
726 | /* This page contains functions that return info about | |
727 | (struct value) values used in GDB. */ | |
728 | ||
729 | /* Returns non-zero if the value VAL represents a true value. */ | |
730 | int | |
731 | value_true(val) | |
732 | value val; | |
733 | { | |
734 | int len, i; | |
735 | struct type *type; | |
736 | LONGEST v; | |
737 | ||
738 | switch (current_language->la_language) { | |
739 | ||
740 | case language_c: | |
545af6ce | 741 | case language_cplus: |
e58de8a2 | 742 | return !value_logical_not (val); |
c8023e66 JG |
743 | |
744 | case language_m2: | |
745 | type = VALUE_TYPE(val); | |
746 | if (TYPE_CODE (type) != TYPE_CODE_BOOL) | |
747 | return 0; /* Not a BOOLEAN at all */ | |
748 | /* Search the fields for one that matches the current value. */ | |
749 | len = TYPE_NFIELDS (type); | |
750 | v = value_as_long (val); | |
751 | for (i = 0; i < len; i++) | |
752 | { | |
753 | QUIT; | |
754 | if (v == TYPE_FIELD_BITPOS (type, i)) | |
755 | break; | |
756 | } | |
757 | if (i >= len) | |
758 | return 0; /* Not a valid BOOLEAN value */ | |
759 | if (!strcmp ("TRUE", TYPE_FIELD_NAME(VALUE_TYPE(val), i))) | |
760 | return 1; /* BOOLEAN with value TRUE */ | |
761 | else | |
762 | return 0; /* BOOLEAN with value FALSE */ | |
763 | break; | |
764 | ||
19cfe25d | 765 | /* start-sanitize-chill */ |
e58de8a2 FF |
766 | case language_chill: |
767 | error ("Missing Chill support in function value_type."); /*FIXME*/ | |
19cfe25d | 768 | /* end-sanitize-chill */ |
e58de8a2 | 769 | |
c8023e66 JG |
770 | default: |
771 | error ("Language not supported."); | |
772 | } | |
773 | } | |
774 | \f | |
775 | /* Returns non-zero if the operator OP is defined on | |
776 | the values ARG1 and ARG2. */ | |
7ed0f002 JG |
777 | |
778 | #if 0 /* Currently unused */ | |
779 | ||
c8023e66 JG |
780 | void |
781 | binop_type_check(arg1,arg2,op) | |
782 | value arg1,arg2; | |
783 | int op; | |
784 | { | |
785 | struct type *t1, *t2; | |
786 | ||
787 | /* If we're not checking types, always return success. */ | |
788 | if (!STRICT_TYPE) | |
789 | return; | |
790 | ||
791 | t1=VALUE_TYPE(arg1); | |
792 | if (arg2!=(value)NULL) | |
793 | t2=VALUE_TYPE(arg2); | |
794 | else | |
795 | t2=NULL; | |
796 | ||
797 | switch(op) | |
798 | { | |
799 | case BINOP_ADD: | |
800 | case BINOP_SUB: | |
801 | if ((numeric_type(t1) && pointer_type(t2)) || | |
802 | (pointer_type(t1) && numeric_type(t2))) | |
803 | { | |
318bf84f | 804 | warning ("combining pointer and integer.\n"); |
c8023e66 JG |
805 | break; |
806 | } | |
807 | case BINOP_MUL: | |
808 | case BINOP_LSH: | |
809 | case BINOP_RSH: | |
810 | if (!numeric_type(t1) || !numeric_type(t2)) | |
811 | type_op_error ("Arguments to %s must be numbers.",op); | |
812 | else if (!same_type(t1,t2)) | |
813 | type_op_error ("Arguments to %s must be of the same type.",op); | |
814 | break; | |
815 | ||
e58de8a2 FF |
816 | case BINOP_LOGICAL_AND: |
817 | case BINOP_LOGICAL_OR: | |
c8023e66 JG |
818 | if (!boolean_type(t1) || !boolean_type(t2)) |
819 | type_op_error ("Arguments to %s must be of boolean type.",op); | |
820 | break; | |
821 | ||
822 | case BINOP_EQUAL: | |
823 | if ((pointer_type(t1) && !(pointer_type(t2) || integral_type(t2))) || | |
824 | (pointer_type(t2) && !(pointer_type(t1) || integral_type(t1)))) | |
825 | type_op_error ("A pointer can only be compared to an integer or pointer.",op); | |
826 | else if ((pointer_type(t1) && integral_type(t2)) || | |
827 | (integral_type(t1) && pointer_type(t2))) | |
828 | { | |
318bf84f | 829 | warning ("combining integer and pointer.\n"); |
c8023e66 JG |
830 | break; |
831 | } | |
832 | else if (!simple_type(t1) || !simple_type(t2)) | |
833 | type_op_error ("Arguments to %s must be of simple type.",op); | |
834 | else if (!same_type(t1,t2)) | |
835 | type_op_error ("Arguments to %s must be of the same type.",op); | |
836 | break; | |
837 | ||
838 | case BINOP_REM: | |
839 | if (!integral_type(t1) || !integral_type(t2)) | |
840 | type_op_error ("Arguments to %s must be of integral type.",op); | |
841 | break; | |
842 | ||
843 | case BINOP_LESS: | |
844 | case BINOP_GTR: | |
845 | case BINOP_LEQ: | |
846 | case BINOP_GEQ: | |
847 | if (!ordered_type(t1) || !ordered_type(t2)) | |
848 | type_op_error ("Arguments to %s must be of ordered type.",op); | |
849 | else if (!same_type(t1,t2)) | |
850 | type_op_error ("Arguments to %s must be of the same type.",op); | |
851 | break; | |
852 | ||
853 | case BINOP_ASSIGN: | |
854 | if (pointer_type(t1) && !integral_type(t2)) | |
855 | type_op_error ("A pointer can only be assigned an integer.",op); | |
856 | else if (pointer_type(t1) && integral_type(t2)) | |
857 | { | |
318bf84f | 858 | warning ("combining integer and pointer."); |
c8023e66 JG |
859 | break; |
860 | } | |
861 | else if (!simple_type(t1) || !simple_type(t2)) | |
862 | type_op_error ("Arguments to %s must be of simple type.",op); | |
863 | else if (!same_type(t1,t2)) | |
864 | type_op_error ("Arguments to %s must be of the same type.",op); | |
865 | break; | |
866 | ||
867 | /* Unary checks -- arg2 is null */ | |
868 | ||
e58de8a2 | 869 | case UNOP_LOGICAL_NOT: |
c8023e66 JG |
870 | if (!boolean_type(t1)) |
871 | type_op_error ("Argument to %s must be of boolean type.",op); | |
872 | break; | |
873 | ||
874 | case UNOP_PLUS: | |
875 | case UNOP_NEG: | |
876 | if (!numeric_type(t1)) | |
877 | type_op_error ("Argument to %s must be of numeric type.",op); | |
878 | break; | |
879 | ||
880 | case UNOP_IND: | |
881 | if (integral_type(t1)) | |
882 | { | |
318bf84f | 883 | warning ("combining pointer and integer.\n"); |
c8023e66 JG |
884 | break; |
885 | } | |
886 | else if (!pointer_type(t1)) | |
887 | type_op_error ("Argument to %s must be a pointer.",op); | |
888 | break; | |
889 | ||
890 | case UNOP_PREINCREMENT: | |
891 | case UNOP_POSTINCREMENT: | |
892 | case UNOP_PREDECREMENT: | |
893 | case UNOP_POSTDECREMENT: | |
894 | if (!ordered_type(t1)) | |
895 | type_op_error ("Argument to %s must be of an ordered type.",op); | |
896 | break; | |
897 | ||
898 | default: | |
899 | /* Ok. The following operators have different meanings in | |
900 | different languages. */ | |
901 | switch(current_language->la_language) | |
902 | { | |
903 | #ifdef _LANG_c | |
904 | case language_c: | |
545af6ce | 905 | case language_cplus: |
c8023e66 JG |
906 | switch(op) |
907 | { | |
908 | case BINOP_DIV: | |
909 | if (!numeric_type(t1) || !numeric_type(t2)) | |
910 | type_op_error ("Arguments to %s must be numbers.",op); | |
911 | break; | |
912 | } | |
913 | break; | |
914 | #endif | |
915 | ||
916 | #ifdef _LANG_m2 | |
917 | case language_m2: | |
918 | switch(op) | |
919 | { | |
920 | case BINOP_DIV: | |
921 | if (!float_type(t1) || !float_type(t2)) | |
922 | type_op_error ("Arguments to %s must be floating point numbers.",op); | |
923 | break; | |
924 | case BINOP_INTDIV: | |
925 | if (!integral_type(t1) || !integral_type(t2)) | |
926 | type_op_error ("Arguments to %s must be of integral type.",op); | |
927 | break; | |
928 | } | |
929 | #endif | |
e58de8a2 | 930 | |
19cfe25d | 931 | /* start-sanitize-chill */ |
e58de8a2 FF |
932 | #ifdef _LANG_chill |
933 | case language_chill: | |
934 | error ("Missing Chill support in function binop_type_check.");/*FIXME*/ | |
935 | #endif | |
19cfe25d | 936 | /* end-sanitize-chill */ |
e58de8a2 | 937 | |
c8023e66 JG |
938 | } |
939 | } | |
940 | } | |
7ed0f002 JG |
941 | |
942 | #endif /* 0 */ | |
943 | ||
c8023e66 JG |
944 | \f |
945 | /* This page contains functions for the printing out of | |
946 | error messages that occur during type- and range- | |
947 | checking. */ | |
948 | ||
949 | /* Prints the format string FMT with the operator as a string | |
950 | corresponding to the opcode OP. If FATAL is non-zero, then | |
951 | this is an error and error () is called. Otherwise, it is | |
952 | a warning and printf() is called. */ | |
953 | void | |
954 | op_error (fmt,op,fatal) | |
955 | char *fmt; | |
956 | enum exp_opcode op; | |
957 | int fatal; | |
958 | { | |
959 | if (fatal) | |
960 | error (fmt,op_string(op)); | |
961 | else | |
962 | { | |
318bf84f | 963 | warning (fmt,op_string(op)); |
c8023e66 JG |
964 | } |
965 | } | |
966 | ||
967 | /* These are called when a language fails a type- or range-check. | |
968 | The first argument should be a printf()-style format string, and | |
969 | the rest of the arguments should be its arguments. If | |
970 | [type|range]_check is [type|range]_check_on, then return_to_top_level() | |
971 | is called in the style of error (). Otherwise, the message is prefixed | |
318bf84f | 972 | by the value of warning_pre_print and we do not return to the top level. */ |
7ed0f002 | 973 | |
c8023e66 JG |
974 | void |
975 | type_error (va_alist) | |
7ed0f002 | 976 | va_dcl |
c8023e66 JG |
977 | { |
978 | va_list args; | |
979 | char *string; | |
980 | ||
981 | if (type_check==type_check_warn) | |
597dc86b | 982 | fprintf(stderr,warning_pre_print); |
c8023e66 JG |
983 | else |
984 | target_terminal_ours(); | |
985 | ||
986 | va_start (args); | |
987 | string = va_arg (args, char *); | |
597dc86b SG |
988 | vfprintf (stderr, string, args); |
989 | fprintf (stderr, "\n"); | |
c8023e66 JG |
990 | va_end (args); |
991 | if (type_check==type_check_on) | |
992 | return_to_top_level(); | |
993 | } | |
994 | ||
995 | void | |
996 | range_error (va_alist) | |
7ed0f002 | 997 | va_dcl |
c8023e66 JG |
998 | { |
999 | va_list args; | |
1000 | char *string; | |
1001 | ||
1002 | if (range_check==range_check_warn) | |
597dc86b | 1003 | fprintf(stderr,warning_pre_print); |
c8023e66 JG |
1004 | else |
1005 | target_terminal_ours(); | |
1006 | ||
1007 | va_start (args); | |
1008 | string = va_arg (args, char *); | |
597dc86b SG |
1009 | vfprintf (stderr, string, args); |
1010 | fprintf (stderr, "\n"); | |
c8023e66 JG |
1011 | va_end (args); |
1012 | if (range_check==range_check_on) | |
1013 | return_to_top_level(); | |
1014 | } | |
1015 | ||
1016 | \f | |
1017 | /* This page contains miscellaneous functions */ | |
1018 | ||
1019 | /* Return the language as a string */ | |
1020 | char * | |
1021 | language_str(lang) | |
1022 | enum language lang; | |
1023 | { | |
1024 | int i; | |
1025 | ||
1026 | for (i = 0; i < languages_size; i++) { | |
1027 | if (languages[i]->la_language == lang) { | |
1028 | return languages[i]->la_name; | |
1029 | } | |
1030 | } | |
1031 | return "Unknown"; | |
1032 | } | |
1033 | ||
c8023e66 | 1034 | static void |
d8ce1326 JG |
1035 | set_check (ignore, from_tty) |
1036 | char *ignore; | |
c8023e66 JG |
1037 | int from_tty; |
1038 | { | |
597dc86b | 1039 | printf( |
c8023e66 JG |
1040 | "\"set check\" must be followed by the name of a check subcommand.\n"); |
1041 | help_list(setchecklist, "set check ", -1, stdout); | |
1042 | } | |
1043 | ||
1044 | static void | |
be772100 JG |
1045 | show_check (ignore, from_tty) |
1046 | char *ignore; | |
c8023e66 JG |
1047 | int from_tty; |
1048 | { | |
1049 | cmd_show_list(showchecklist, from_tty, ""); | |
1050 | } | |
1051 | \f | |
1052 | /* Add a language to the set of known languages. */ | |
1053 | ||
1054 | void | |
1055 | add_language (lang) | |
7ed0f002 | 1056 | const struct language_defn *lang; |
c8023e66 JG |
1057 | { |
1058 | if (lang->la_magic != LANG_MAGIC) | |
1059 | { | |
597dc86b | 1060 | fprintf(stderr, "Magic number of %s language struct wrong\n", |
c8023e66 JG |
1061 | lang->la_name); |
1062 | abort(); | |
1063 | } | |
1064 | ||
1065 | if (!languages) | |
1066 | { | |
1067 | languages_allocsize = DEFAULT_ALLOCSIZE; | |
7ed0f002 | 1068 | languages = (const struct language_defn **) xmalloc |
c8023e66 JG |
1069 | (languages_allocsize * sizeof (*languages)); |
1070 | } | |
1071 | if (languages_size >= languages_allocsize) | |
1072 | { | |
1073 | languages_allocsize *= 2; | |
7ed0f002 | 1074 | languages = (const struct language_defn **) xrealloc ((char *) languages, |
c8023e66 JG |
1075 | languages_allocsize * sizeof (*languages)); |
1076 | } | |
1077 | languages[languages_size++] = lang; | |
c8023e66 JG |
1078 | } |
1079 | ||
1080 | /* Define the language that is no language. */ | |
1081 | ||
7ed0f002 | 1082 | static int |
c8023e66 JG |
1083 | unk_lang_parser () |
1084 | { | |
1085 | return 1; | |
1086 | } | |
1087 | ||
7ed0f002 JG |
1088 | static void |
1089 | unk_lang_error (msg) | |
1090 | char *msg; | |
c8023e66 JG |
1091 | { |
1092 | error ("Attempted to parse an expression with unknown language"); | |
1093 | } | |
1094 | ||
1095 | static struct type ** const (unknown_builtin_types[]) = { 0 }; | |
1096 | static const struct op_print unk_op_print_tab[] = { 0 }; | |
1097 | ||
1098 | const struct language_defn unknown_language_defn = { | |
1099 | "unknown", | |
1100 | language_unknown, | |
1101 | &unknown_builtin_types[0], | |
1102 | range_check_off, | |
1103 | type_check_off, | |
1104 | unk_lang_parser, | |
1105 | unk_lang_error, | |
1106 | &builtin_type_error, /* longest signed integral type */ | |
1107 | &builtin_type_error, /* longest unsigned integral type */ | |
1108 | &builtin_type_error, /* longest floating point type */ | |
1109 | "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ | |
1110 | "0%o", "0%", "o", /* Octal format, prefix, suffix */ | |
1111 | unk_op_print_tab, /* expression operators for printing */ | |
1112 | LANG_MAGIC | |
1113 | }; | |
1114 | ||
1115 | /* These two structs define fake entries for the "local" and "auto" options. */ | |
1116 | const struct language_defn auto_language_defn = { | |
1117 | "auto", | |
1118 | language_auto, | |
1119 | &unknown_builtin_types[0], | |
1120 | range_check_off, | |
1121 | type_check_off, | |
1122 | unk_lang_parser, | |
1123 | unk_lang_error, | |
1124 | &builtin_type_error, /* longest signed integral type */ | |
1125 | &builtin_type_error, /* longest unsigned integral type */ | |
1126 | &builtin_type_error, /* longest floating point type */ | |
1127 | "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ | |
1128 | "0%o", "0%", "o", /* Octal format, prefix, suffix */ | |
1129 | unk_op_print_tab, /* expression operators for printing */ | |
1130 | LANG_MAGIC | |
1131 | }; | |
1132 | ||
1133 | const struct language_defn local_language_defn = { | |
1134 | "local", | |
1135 | language_auto, | |
1136 | &unknown_builtin_types[0], | |
1137 | range_check_off, | |
1138 | type_check_off, | |
1139 | unk_lang_parser, | |
1140 | unk_lang_error, | |
1141 | &builtin_type_error, /* longest signed integral type */ | |
1142 | &builtin_type_error, /* longest unsigned integral type */ | |
1143 | &builtin_type_error, /* longest floating point type */ | |
1144 | "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ | |
1145 | "0%o", "0%", "o", /* Octal format, prefix, suffix */ | |
1146 | unk_op_print_tab, /* expression operators for printing */ | |
1147 | LANG_MAGIC | |
1148 | }; | |
1149 | \f | |
1150 | /* Initialize the language routines */ | |
1151 | ||
1152 | void | |
1153 | _initialize_language() | |
1154 | { | |
1155 | struct cmd_list_element *set, *show; | |
1156 | ||
1157 | /* GDB commands for language specific stuff */ | |
1158 | ||
1159 | set = add_set_cmd ("language", class_support, var_string_noescape, | |
1160 | (char *)&language, | |
0b798409 | 1161 | "Set the current source language.", |
c8023e66 JG |
1162 | &setlist); |
1163 | show = add_show_from_set (set, &showlist); | |
1ab3bf1b JG |
1164 | set->function.cfunc = set_language_command; |
1165 | show->function.cfunc = show_language_command; | |
c8023e66 JG |
1166 | |
1167 | add_prefix_cmd ("check", no_class, set_check, | |
1168 | "Set the status of the type/range checker", | |
1169 | &setchecklist, "set check ", 0, &setlist); | |
1170 | add_alias_cmd ("c", "check", no_class, 1, &setlist); | |
1171 | add_alias_cmd ("ch", "check", no_class, 1, &setlist); | |
1172 | ||
1173 | add_prefix_cmd ("check", no_class, show_check, | |
1174 | "Show the status of the type/range checker", | |
7cb83757 | 1175 | &showchecklist, "show check ", 0, &showlist); |
c8023e66 JG |
1176 | add_alias_cmd ("c", "check", no_class, 1, &showlist); |
1177 | add_alias_cmd ("ch", "check", no_class, 1, &showlist); | |
1178 | ||
1179 | set = add_set_cmd ("type", class_support, var_string_noescape, | |
1180 | (char *)&type, | |
7cb83757 | 1181 | "Set type checking. (on/warn/off/auto)", |
c8023e66 JG |
1182 | &setchecklist); |
1183 | show = add_show_from_set (set, &showchecklist); | |
1ab3bf1b JG |
1184 | set->function.cfunc = set_type_command; |
1185 | show->function.cfunc = show_type_command; | |
c8023e66 JG |
1186 | |
1187 | set = add_set_cmd ("range", class_support, var_string_noescape, | |
1188 | (char *)&range, | |
7cb83757 | 1189 | "Set range checking. (on/warn/off/auto)", |
c8023e66 JG |
1190 | &setchecklist); |
1191 | show = add_show_from_set (set, &showchecklist); | |
1ab3bf1b JG |
1192 | set->function.cfunc = set_range_command; |
1193 | show->function.cfunc = show_range_command; | |
c8023e66 JG |
1194 | |
1195 | add_language (&unknown_language_defn); | |
1196 | add_language (&local_language_defn); | |
1197 | add_language (&auto_language_defn); | |
1198 | ||
1199 | language = savestring ("auto",strlen("auto")); | |
1200 | range = savestring ("auto",strlen("auto")); | |
1201 | type = savestring ("auto",strlen("auto")); | |
1202 | ||
1203 | /* Have the above take effect */ | |
1204 | ||
5f3d478e | 1205 | set_language_command (language, 0); |
c8023e66 JG |
1206 | set_type_command (NULL, 0); |
1207 | set_range_command (NULL, 0); | |
1208 | } |