1 |
578 |
markom |
/* Multiple source language support for GDB.
|
2 |
|
|
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
|
3 |
|
|
Free Software Foundation, Inc.
|
4 |
|
|
Contributed by the Department of Computer Science at the State University
|
5 |
|
|
of New York at Buffalo.
|
6 |
|
|
|
7 |
|
|
This file is part of GDB.
|
8 |
|
|
|
9 |
|
|
This program is free software; you can redistribute it and/or modify
|
10 |
|
|
it under the terms of the GNU General Public License as published by
|
11 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
12 |
|
|
(at your option) any later version.
|
13 |
|
|
|
14 |
|
|
This program is distributed in the hope that it will be useful,
|
15 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
|
|
GNU General Public License for more details.
|
18 |
|
|
|
19 |
|
|
You should have received a copy of the GNU General Public License
|
20 |
|
|
along with this program; if not, write to the Free Software
|
21 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
22 |
|
|
Boston, MA 02111-1307, USA. */
|
23 |
|
|
|
24 |
|
|
/* This file contains functions that return things that are specific
|
25 |
|
|
to languages. Each function should examine current_language if necessary,
|
26 |
|
|
and return the appropriate result. */
|
27 |
|
|
|
28 |
|
|
/* FIXME: Most of these would be better organized as macros which
|
29 |
|
|
return data out of a "language-specific" struct pointer that is set
|
30 |
|
|
whenever the working language changes. That would be a lot faster. */
|
31 |
|
|
|
32 |
|
|
#include "defs.h"
|
33 |
|
|
#include <ctype.h>
|
34 |
|
|
#include "gdb_string.h"
|
35 |
|
|
|
36 |
|
|
#include "symtab.h"
|
37 |
|
|
#include "gdbtypes.h"
|
38 |
|
|
#include "value.h"
|
39 |
|
|
#include "gdbcmd.h"
|
40 |
|
|
#include "expression.h"
|
41 |
|
|
#include "language.h"
|
42 |
|
|
#include "target.h"
|
43 |
|
|
#include "parser-defs.h"
|
44 |
|
|
#include "jv-lang.h"
|
45 |
|
|
|
46 |
|
|
extern void _initialize_language (void);
|
47 |
|
|
|
48 |
|
|
static void show_language_command (char *, int);
|
49 |
|
|
|
50 |
|
|
static void set_language_command (char *, int);
|
51 |
|
|
|
52 |
|
|
static void show_type_command (char *, int);
|
53 |
|
|
|
54 |
|
|
static void set_type_command (char *, int);
|
55 |
|
|
|
56 |
|
|
static void show_range_command (char *, int);
|
57 |
|
|
|
58 |
|
|
static void set_range_command (char *, int);
|
59 |
|
|
|
60 |
|
|
static void show_case_command (char *, int);
|
61 |
|
|
|
62 |
|
|
static void set_case_command (char *, int);
|
63 |
|
|
|
64 |
|
|
static void set_case_str (void);
|
65 |
|
|
|
66 |
|
|
static void set_range_str (void);
|
67 |
|
|
|
68 |
|
|
static void set_type_str (void);
|
69 |
|
|
|
70 |
|
|
static void set_lang_str (void);
|
71 |
|
|
|
72 |
|
|
static void unk_lang_error (char *);
|
73 |
|
|
|
74 |
|
|
static int unk_lang_parser (void);
|
75 |
|
|
|
76 |
|
|
static void show_check (char *, int);
|
77 |
|
|
|
78 |
|
|
static void set_check (char *, int);
|
79 |
|
|
|
80 |
|
|
static void set_type_range_case (void);
|
81 |
|
|
|
82 |
|
|
static void unk_lang_emit_char (int c, struct ui_file *stream, int quoter);
|
83 |
|
|
|
84 |
|
|
static void unk_lang_printchar (int c, struct ui_file *stream);
|
85 |
|
|
|
86 |
|
|
static void unk_lang_printstr (struct ui_file * stream, char *string,
|
87 |
|
|
unsigned int length, int width,
|
88 |
|
|
int force_ellipses);
|
89 |
|
|
|
90 |
|
|
static struct type *unk_lang_create_fundamental_type (struct objfile *, int);
|
91 |
|
|
|
92 |
|
|
static void unk_lang_print_type (struct type *, char *, struct ui_file *,
|
93 |
|
|
int, int);
|
94 |
|
|
|
95 |
|
|
static int unk_lang_val_print (struct type *, char *, int, CORE_ADDR,
|
96 |
|
|
struct ui_file *, int, int, int,
|
97 |
|
|
enum val_prettyprint);
|
98 |
|
|
|
99 |
|
|
static int unk_lang_value_print (value_ptr, struct ui_file *, int, enum val_prettyprint);
|
100 |
|
|
|
101 |
|
|
/* Forward declaration */
|
102 |
|
|
extern const struct language_defn unknown_language_defn;
|
103 |
|
|
extern char *warning_pre_print;
|
104 |
|
|
|
105 |
|
|
/* The current (default at startup) state of type and range checking.
|
106 |
|
|
(If the modes are set to "auto", though, these are changed based
|
107 |
|
|
on the default language at startup, and then again based on the
|
108 |
|
|
language of the first source file. */
|
109 |
|
|
|
110 |
|
|
enum range_mode range_mode = range_mode_auto;
|
111 |
|
|
enum range_check range_check = range_check_off;
|
112 |
|
|
enum type_mode type_mode = type_mode_auto;
|
113 |
|
|
enum type_check type_check = type_check_off;
|
114 |
|
|
enum case_mode case_mode = case_mode_auto;
|
115 |
|
|
enum case_sensitivity case_sensitivity = case_sensitive_on;
|
116 |
|
|
|
117 |
|
|
/* The current language and language_mode (see language.h) */
|
118 |
|
|
|
119 |
|
|
const struct language_defn *current_language = &unknown_language_defn;
|
120 |
|
|
enum language_mode language_mode = language_mode_auto;
|
121 |
|
|
|
122 |
|
|
/* The language that the user expects to be typing in (the language
|
123 |
|
|
of main(), or the last language we notified them about, or C). */
|
124 |
|
|
|
125 |
|
|
const struct language_defn *expected_language;
|
126 |
|
|
|
127 |
|
|
/* The list of supported languages. The list itself is malloc'd. */
|
128 |
|
|
|
129 |
|
|
static const struct language_defn **languages;
|
130 |
|
|
static unsigned languages_size;
|
131 |
|
|
static unsigned languages_allocsize;
|
132 |
|
|
#define DEFAULT_ALLOCSIZE 4
|
133 |
|
|
|
134 |
|
|
/* The "set language/type/range" commands all put stuff in these
|
135 |
|
|
buffers. This is to make them work as set/show commands. The
|
136 |
|
|
user's string is copied here, then the set_* commands look at
|
137 |
|
|
them and update them to something that looks nice when it is
|
138 |
|
|
printed out. */
|
139 |
|
|
|
140 |
|
|
static char *language;
|
141 |
|
|
static char *type;
|
142 |
|
|
static char *range;
|
143 |
|
|
static char *case_sensitive;
|
144 |
|
|
|
145 |
|
|
/* Warning issued when current_language and the language of the current
|
146 |
|
|
frame do not match. */
|
147 |
|
|
char lang_frame_mismatch_warn[] =
|
148 |
|
|
"Warning: the current language does not match this frame.";
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
/* This page contains the functions corresponding to GDB commands
|
152 |
|
|
and their helpers. */
|
153 |
|
|
|
154 |
|
|
/* Show command. Display a warning if the language set
|
155 |
|
|
does not match the frame. */
|
156 |
|
|
static void
|
157 |
|
|
show_language_command (char *ignore, int from_tty)
|
158 |
|
|
{
|
159 |
|
|
enum language flang; /* The language of the current frame */
|
160 |
|
|
|
161 |
|
|
flang = get_frame_language ();
|
162 |
|
|
if (flang != language_unknown &&
|
163 |
|
|
language_mode == language_mode_manual &&
|
164 |
|
|
current_language->la_language != flang)
|
165 |
|
|
printf_filtered ("%s\n", lang_frame_mismatch_warn);
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
/* Set command. Change the current working language. */
|
169 |
|
|
static void
|
170 |
|
|
set_language_command (char *ignore, int from_tty)
|
171 |
|
|
{
|
172 |
|
|
int i;
|
173 |
|
|
enum language flang;
|
174 |
|
|
char *err_lang;
|
175 |
|
|
|
176 |
|
|
if (!language || !language[0])
|
177 |
|
|
{
|
178 |
|
|
printf_unfiltered ("The currently understood settings are:\n\n");
|
179 |
|
|
printf_unfiltered ("local or auto Automatic setting based on source file\n");
|
180 |
|
|
|
181 |
|
|
for (i = 0; i < languages_size; ++i)
|
182 |
|
|
{
|
183 |
|
|
/* Already dealt with these above. */
|
184 |
|
|
if (languages[i]->la_language == language_unknown
|
185 |
|
|
|| languages[i]->la_language == language_auto)
|
186 |
|
|
continue;
|
187 |
|
|
|
188 |
|
|
/* FIXME for now assume that the human-readable name is just
|
189 |
|
|
a capitalization of the internal name. */
|
190 |
|
|
printf_unfiltered ("%-16s Use the %c%s language\n",
|
191 |
|
|
languages[i]->la_name,
|
192 |
|
|
/* Capitalize first letter of language
|
193 |
|
|
name. */
|
194 |
|
|
toupper (languages[i]->la_name[0]),
|
195 |
|
|
languages[i]->la_name + 1);
|
196 |
|
|
}
|
197 |
|
|
/* Restore the silly string. */
|
198 |
|
|
set_language (current_language->la_language);
|
199 |
|
|
return;
|
200 |
|
|
}
|
201 |
|
|
|
202 |
|
|
/* Search the list of languages for a match. */
|
203 |
|
|
for (i = 0; i < languages_size; i++)
|
204 |
|
|
{
|
205 |
|
|
if (STREQ (languages[i]->la_name, language))
|
206 |
|
|
{
|
207 |
|
|
/* Found it! Go into manual mode, and use this language. */
|
208 |
|
|
if (languages[i]->la_language == language_auto)
|
209 |
|
|
{
|
210 |
|
|
/* Enter auto mode. Set to the current frame's language, if known. */
|
211 |
|
|
language_mode = language_mode_auto;
|
212 |
|
|
flang = get_frame_language ();
|
213 |
|
|
if (flang != language_unknown)
|
214 |
|
|
set_language (flang);
|
215 |
|
|
expected_language = current_language;
|
216 |
|
|
return;
|
217 |
|
|
}
|
218 |
|
|
else
|
219 |
|
|
{
|
220 |
|
|
/* Enter manual mode. Set the specified language. */
|
221 |
|
|
language_mode = language_mode_manual;
|
222 |
|
|
current_language = languages[i];
|
223 |
|
|
set_type_range_case ();
|
224 |
|
|
set_lang_str ();
|
225 |
|
|
expected_language = current_language;
|
226 |
|
|
return;
|
227 |
|
|
}
|
228 |
|
|
}
|
229 |
|
|
}
|
230 |
|
|
|
231 |
|
|
/* Reset the language (esp. the global string "language") to the
|
232 |
|
|
correct values. */
|
233 |
|
|
err_lang = savestring (language, strlen (language));
|
234 |
|
|
make_cleanup (xfree, err_lang); /* Free it after error */
|
235 |
|
|
set_language (current_language->la_language);
|
236 |
|
|
error ("Unknown language `%s'.", err_lang);
|
237 |
|
|
}
|
238 |
|
|
|
239 |
|
|
/* Show command. Display a warning if the type setting does
|
240 |
|
|
not match the current language. */
|
241 |
|
|
static void
|
242 |
|
|
show_type_command (char *ignore, int from_tty)
|
243 |
|
|
{
|
244 |
|
|
if (type_check != current_language->la_type_check)
|
245 |
|
|
printf_unfiltered (
|
246 |
|
|
"Warning: the current type check setting does not match the language.\n");
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
/* Set command. Change the setting for type checking. */
|
250 |
|
|
static void
|
251 |
|
|
set_type_command (char *ignore, int from_tty)
|
252 |
|
|
{
|
253 |
|
|
if (STREQ (type, "on"))
|
254 |
|
|
{
|
255 |
|
|
type_check = type_check_on;
|
256 |
|
|
type_mode = type_mode_manual;
|
257 |
|
|
}
|
258 |
|
|
else if (STREQ (type, "warn"))
|
259 |
|
|
{
|
260 |
|
|
type_check = type_check_warn;
|
261 |
|
|
type_mode = type_mode_manual;
|
262 |
|
|
}
|
263 |
|
|
else if (STREQ (type, "off"))
|
264 |
|
|
{
|
265 |
|
|
type_check = type_check_off;
|
266 |
|
|
type_mode = type_mode_manual;
|
267 |
|
|
}
|
268 |
|
|
else if (STREQ (type, "auto"))
|
269 |
|
|
{
|
270 |
|
|
type_mode = type_mode_auto;
|
271 |
|
|
set_type_range_case ();
|
272 |
|
|
/* Avoid hitting the set_type_str call below. We
|
273 |
|
|
did it in set_type_range_case. */
|
274 |
|
|
return;
|
275 |
|
|
}
|
276 |
|
|
else
|
277 |
|
|
{
|
278 |
|
|
warning ("Unrecognized type check setting: \"%s\"", type);
|
279 |
|
|
}
|
280 |
|
|
set_type_str ();
|
281 |
|
|
show_type_command ((char *) NULL, from_tty);
|
282 |
|
|
}
|
283 |
|
|
|
284 |
|
|
/* Show command. Display a warning if the range setting does
|
285 |
|
|
not match the current language. */
|
286 |
|
|
static void
|
287 |
|
|
show_range_command (char *ignore, int from_tty)
|
288 |
|
|
{
|
289 |
|
|
|
290 |
|
|
if (range_check != current_language->la_range_check)
|
291 |
|
|
printf_unfiltered (
|
292 |
|
|
"Warning: the current range check setting does not match the language.\n");
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
/* Set command. Change the setting for range checking. */
|
296 |
|
|
static void
|
297 |
|
|
set_range_command (char *ignore, int from_tty)
|
298 |
|
|
{
|
299 |
|
|
if (STREQ (range, "on"))
|
300 |
|
|
{
|
301 |
|
|
range_check = range_check_on;
|
302 |
|
|
range_mode = range_mode_manual;
|
303 |
|
|
}
|
304 |
|
|
else if (STREQ (range, "warn"))
|
305 |
|
|
{
|
306 |
|
|
range_check = range_check_warn;
|
307 |
|
|
range_mode = range_mode_manual;
|
308 |
|
|
}
|
309 |
|
|
else if (STREQ (range, "off"))
|
310 |
|
|
{
|
311 |
|
|
range_check = range_check_off;
|
312 |
|
|
range_mode = range_mode_manual;
|
313 |
|
|
}
|
314 |
|
|
else if (STREQ (range, "auto"))
|
315 |
|
|
{
|
316 |
|
|
range_mode = range_mode_auto;
|
317 |
|
|
set_type_range_case ();
|
318 |
|
|
/* Avoid hitting the set_range_str call below. We
|
319 |
|
|
did it in set_type_range_case. */
|
320 |
|
|
return;
|
321 |
|
|
}
|
322 |
|
|
else
|
323 |
|
|
{
|
324 |
|
|
warning ("Unrecognized range check setting: \"%s\"", range);
|
325 |
|
|
}
|
326 |
|
|
set_range_str ();
|
327 |
|
|
show_range_command ((char *) 0, from_tty);
|
328 |
|
|
}
|
329 |
|
|
|
330 |
|
|
/* Show command. Display a warning if the case sensitivity setting does
|
331 |
|
|
not match the current language. */
|
332 |
|
|
static void
|
333 |
|
|
show_case_command (char *ignore, int from_tty)
|
334 |
|
|
{
|
335 |
|
|
if (case_sensitivity != current_language->la_case_sensitivity)
|
336 |
|
|
printf_unfiltered(
|
337 |
|
|
"Warning: the current case sensitivity setting does not match the language.\n");
|
338 |
|
|
}
|
339 |
|
|
|
340 |
|
|
/* Set command. Change the setting for case sensitivity. */
|
341 |
|
|
static void
|
342 |
|
|
set_case_command (char *ignore, int from_tty)
|
343 |
|
|
{
|
344 |
|
|
if (STREQ (case_sensitive, "on"))
|
345 |
|
|
{
|
346 |
|
|
case_sensitivity = case_sensitive_on;
|
347 |
|
|
case_mode = case_mode_manual;
|
348 |
|
|
}
|
349 |
|
|
else if (STREQ (case_sensitive, "off"))
|
350 |
|
|
{
|
351 |
|
|
case_sensitivity = case_sensitive_off;
|
352 |
|
|
case_mode = case_mode_manual;
|
353 |
|
|
}
|
354 |
|
|
else if (STREQ (case_sensitive, "auto"))
|
355 |
|
|
{
|
356 |
|
|
case_mode = case_mode_auto;
|
357 |
|
|
set_type_range_case ();
|
358 |
|
|
/* Avoid hitting the set_case_str call below. We
|
359 |
|
|
did it in set_type_range_case. */
|
360 |
|
|
return;
|
361 |
|
|
}
|
362 |
|
|
else
|
363 |
|
|
{
|
364 |
|
|
warning ("Unrecognized case-sensitive setting: \"%s\"", case_sensitive);
|
365 |
|
|
}
|
366 |
|
|
set_case_str();
|
367 |
|
|
show_case_command ((char *) NULL, from_tty);
|
368 |
|
|
}
|
369 |
|
|
|
370 |
|
|
/* Set the status of range and type checking and case sensitivity based on
|
371 |
|
|
the current modes and the current language.
|
372 |
|
|
If SHOW is non-zero, then print out the current language,
|
373 |
|
|
type and range checking status. */
|
374 |
|
|
static void
|
375 |
|
|
set_type_range_case (void)
|
376 |
|
|
{
|
377 |
|
|
|
378 |
|
|
if (range_mode == range_mode_auto)
|
379 |
|
|
range_check = current_language->la_range_check;
|
380 |
|
|
|
381 |
|
|
if (type_mode == type_mode_auto)
|
382 |
|
|
type_check = current_language->la_type_check;
|
383 |
|
|
|
384 |
|
|
if (case_mode == case_mode_auto)
|
385 |
|
|
case_sensitivity = current_language->la_case_sensitivity;
|
386 |
|
|
|
387 |
|
|
set_type_str ();
|
388 |
|
|
set_range_str ();
|
389 |
|
|
set_case_str ();
|
390 |
|
|
}
|
391 |
|
|
|
392 |
|
|
/* Set current language to (enum language) LANG. Returns previous language. */
|
393 |
|
|
|
394 |
|
|
enum language
|
395 |
|
|
set_language (enum language lang)
|
396 |
|
|
{
|
397 |
|
|
int i;
|
398 |
|
|
enum language prev_language;
|
399 |
|
|
|
400 |
|
|
prev_language = current_language->la_language;
|
401 |
|
|
|
402 |
|
|
for (i = 0; i < languages_size; i++)
|
403 |
|
|
{
|
404 |
|
|
if (languages[i]->la_language == lang)
|
405 |
|
|
{
|
406 |
|
|
current_language = languages[i];
|
407 |
|
|
set_type_range_case ();
|
408 |
|
|
set_lang_str ();
|
409 |
|
|
break;
|
410 |
|
|
}
|
411 |
|
|
}
|
412 |
|
|
|
413 |
|
|
return prev_language;
|
414 |
|
|
}
|
415 |
|
|
|
416 |
|
|
/* This page contains functions that update the global vars
|
417 |
|
|
language, type and range. */
|
418 |
|
|
static void
|
419 |
|
|
set_lang_str (void)
|
420 |
|
|
{
|
421 |
|
|
char *prefix = "";
|
422 |
|
|
|
423 |
|
|
if (language)
|
424 |
|
|
xfree (language);
|
425 |
|
|
if (language_mode == language_mode_auto)
|
426 |
|
|
prefix = "auto; currently ";
|
427 |
|
|
|
428 |
|
|
language = concat (prefix, current_language->la_name, NULL);
|
429 |
|
|
}
|
430 |
|
|
|
431 |
|
|
static void
|
432 |
|
|
set_type_str (void)
|
433 |
|
|
{
|
434 |
|
|
char *tmp = NULL, *prefix = "";
|
435 |
|
|
|
436 |
|
|
if (type)
|
437 |
|
|
xfree (type);
|
438 |
|
|
if (type_mode == type_mode_auto)
|
439 |
|
|
prefix = "auto; currently ";
|
440 |
|
|
|
441 |
|
|
switch (type_check)
|
442 |
|
|
{
|
443 |
|
|
case type_check_on:
|
444 |
|
|
tmp = "on";
|
445 |
|
|
break;
|
446 |
|
|
case type_check_off:
|
447 |
|
|
tmp = "off";
|
448 |
|
|
break;
|
449 |
|
|
case type_check_warn:
|
450 |
|
|
tmp = "warn";
|
451 |
|
|
break;
|
452 |
|
|
default:
|
453 |
|
|
error ("Unrecognized type check setting.");
|
454 |
|
|
}
|
455 |
|
|
|
456 |
|
|
type = concat (prefix, tmp, NULL);
|
457 |
|
|
}
|
458 |
|
|
|
459 |
|
|
static void
|
460 |
|
|
set_range_str (void)
|
461 |
|
|
{
|
462 |
|
|
char *tmp, *pref = "";
|
463 |
|
|
|
464 |
|
|
if (range_mode == range_mode_auto)
|
465 |
|
|
pref = "auto; currently ";
|
466 |
|
|
|
467 |
|
|
switch (range_check)
|
468 |
|
|
{
|
469 |
|
|
case range_check_on:
|
470 |
|
|
tmp = "on";
|
471 |
|
|
break;
|
472 |
|
|
case range_check_off:
|
473 |
|
|
tmp = "off";
|
474 |
|
|
break;
|
475 |
|
|
case range_check_warn:
|
476 |
|
|
tmp = "warn";
|
477 |
|
|
break;
|
478 |
|
|
default:
|
479 |
|
|
error ("Unrecognized range check setting.");
|
480 |
|
|
}
|
481 |
|
|
|
482 |
|
|
if (range)
|
483 |
|
|
xfree (range);
|
484 |
|
|
range = concat (pref, tmp, NULL);
|
485 |
|
|
}
|
486 |
|
|
|
487 |
|
|
static void
|
488 |
|
|
set_case_str()
|
489 |
|
|
{
|
490 |
|
|
char *tmp = NULL, *prefix = "";
|
491 |
|
|
|
492 |
|
|
if (case_mode==case_mode_auto)
|
493 |
|
|
prefix = "auto; currently ";
|
494 |
|
|
|
495 |
|
|
switch (case_sensitivity)
|
496 |
|
|
{
|
497 |
|
|
case case_sensitive_on:
|
498 |
|
|
tmp = "on";
|
499 |
|
|
break;
|
500 |
|
|
case case_sensitive_off:
|
501 |
|
|
tmp = "off";
|
502 |
|
|
break;
|
503 |
|
|
default:
|
504 |
|
|
error ("Unrecognized case-sensitive setting.");
|
505 |
|
|
}
|
506 |
|
|
|
507 |
|
|
xfree (case_sensitive);
|
508 |
|
|
case_sensitive = concat (prefix, tmp, NULL);
|
509 |
|
|
}
|
510 |
|
|
|
511 |
|
|
/* Print out the current language settings: language, range and
|
512 |
|
|
type checking. If QUIETLY, print only what has changed. */
|
513 |
|
|
|
514 |
|
|
void
|
515 |
|
|
language_info (int quietly)
|
516 |
|
|
{
|
517 |
|
|
if (quietly && expected_language == current_language)
|
518 |
|
|
return;
|
519 |
|
|
|
520 |
|
|
expected_language = current_language;
|
521 |
|
|
printf_unfiltered ("Current language: %s\n", language);
|
522 |
|
|
show_language_command ((char *) 0, 1);
|
523 |
|
|
|
524 |
|
|
if (!quietly)
|
525 |
|
|
{
|
526 |
|
|
printf_unfiltered ("Type checking: %s\n", type);
|
527 |
|
|
show_type_command ((char *) 0, 1);
|
528 |
|
|
printf_unfiltered ("Range checking: %s\n", range);
|
529 |
|
|
show_range_command ((char *) 0, 1);
|
530 |
|
|
printf_unfiltered ("Case sensitivity: %s\n", case_sensitive);
|
531 |
|
|
show_case_command ((char *) 0, 1);
|
532 |
|
|
}
|
533 |
|
|
}
|
534 |
|
|
|
535 |
|
|
/* Return the result of a binary operation. */
|
536 |
|
|
|
537 |
|
|
#if 0 /* Currently unused */
|
538 |
|
|
|
539 |
|
|
struct type *
|
540 |
|
|
binop_result_type (value_ptr v1, value_ptr v2)
|
541 |
|
|
{
|
542 |
|
|
int size, uns;
|
543 |
|
|
struct type *t1 = check_typedef (VALUE_TYPE (v1));
|
544 |
|
|
struct type *t2 = check_typedef (VALUE_TYPE (v2));
|
545 |
|
|
|
546 |
|
|
int l1 = TYPE_LENGTH (t1);
|
547 |
|
|
int l2 = TYPE_LENGTH (t2);
|
548 |
|
|
|
549 |
|
|
switch (current_language->la_language)
|
550 |
|
|
{
|
551 |
|
|
case language_c:
|
552 |
|
|
case language_cplus:
|
553 |
|
|
if (TYPE_CODE (t1) == TYPE_CODE_FLT)
|
554 |
|
|
return TYPE_CODE (t2) == TYPE_CODE_FLT && l2 > l1 ?
|
555 |
|
|
VALUE_TYPE (v2) : VALUE_TYPE (v1);
|
556 |
|
|
else if (TYPE_CODE (t2) == TYPE_CODE_FLT)
|
557 |
|
|
return TYPE_CODE (t1) == TYPE_CODE_FLT && l1 > l2 ?
|
558 |
|
|
VALUE_TYPE (v1) : VALUE_TYPE (v2);
|
559 |
|
|
else if (TYPE_UNSIGNED (t1) && l1 > l2)
|
560 |
|
|
return VALUE_TYPE (v1);
|
561 |
|
|
else if (TYPE_UNSIGNED (t2) && l2 > l1)
|
562 |
|
|
return VALUE_TYPE (v2);
|
563 |
|
|
else /* Both are signed. Result is the longer type */
|
564 |
|
|
return l1 > l2 ? VALUE_TYPE (v1) : VALUE_TYPE (v2);
|
565 |
|
|
break;
|
566 |
|
|
case language_m2:
|
567 |
|
|
/* If we are doing type-checking, l1 should equal l2, so this is
|
568 |
|
|
not needed. */
|
569 |
|
|
return l1 > l2 ? VALUE_TYPE (v1) : VALUE_TYPE (v2);
|
570 |
|
|
break;
|
571 |
|
|
case language_chill:
|
572 |
|
|
error ("Missing Chill support in function binop_result_check."); /*FIXME */
|
573 |
|
|
}
|
574 |
|
|
internal_error (__FILE__, __LINE__, "failed internal consistency check");
|
575 |
|
|
return (struct type *) 0; /* For lint */
|
576 |
|
|
}
|
577 |
|
|
|
578 |
|
|
#endif /* 0 */
|
579 |
|
|
|
580 |
|
|
|
581 |
|
|
/* This page contains functions that return format strings for
|
582 |
|
|
printf for printing out numbers in different formats */
|
583 |
|
|
|
584 |
|
|
/* Returns the appropriate printf format for hexadecimal
|
585 |
|
|
numbers. */
|
586 |
|
|
char *
|
587 |
|
|
local_hex_format_custom (char *pre)
|
588 |
|
|
{
|
589 |
|
|
static char form[50];
|
590 |
|
|
|
591 |
|
|
strcpy (form, local_hex_format_prefix ());
|
592 |
|
|
strcat (form, "%");
|
593 |
|
|
strcat (form, pre);
|
594 |
|
|
strcat (form, local_hex_format_specifier ());
|
595 |
|
|
strcat (form, local_hex_format_suffix ());
|
596 |
|
|
return form;
|
597 |
|
|
}
|
598 |
|
|
|
599 |
|
|
#if 0
|
600 |
|
|
/* FIXME: cagney/2000-03-04: This function does not appear to be used.
|
601 |
|
|
It can be deleted once 5.0 has been released. */
|
602 |
|
|
/* FIXME: cagney/2000-03-04: This code assumes that the compiler
|
603 |
|
|
supports ``long long''. */
|
604 |
|
|
/* Converts a number to hexadecimal (without leading "0x") and stores it in a
|
605 |
|
|
static string. Returns a pointer to this string. */
|
606 |
|
|
|
607 |
|
|
char *
|
608 |
|
|
longest_raw_hex_string (LONGEST num)
|
609 |
|
|
{
|
610 |
|
|
static char res_longest_raw_hex_string[50];
|
611 |
|
|
long long ll = num; /* MERGEBUG ?? see below */
|
612 |
|
|
res_longest_raw_hex_string[0] = 0;
|
613 |
|
|
/* MERGEBUG ?? As a quick fix I am replacing this with sprintf
|
614 |
|
|
strcat_address_numeric (num, 0, res_longest_raw_hex_string, 50);
|
615 |
|
|
*/
|
616 |
|
|
|
617 |
|
|
sprintf (res_longest_raw_hex_string, "%llx", ll);
|
618 |
|
|
return res_longest_raw_hex_string;
|
619 |
|
|
}
|
620 |
|
|
#endif
|
621 |
|
|
|
622 |
|
|
/* Converts a number to hexadecimal and stores it in a static
|
623 |
|
|
string. Returns a pointer to this string. */
|
624 |
|
|
char *
|
625 |
|
|
local_hex_string (unsigned long num)
|
626 |
|
|
{
|
627 |
|
|
static char res[50];
|
628 |
|
|
|
629 |
|
|
sprintf (res, local_hex_format (), num);
|
630 |
|
|
return res;
|
631 |
|
|
}
|
632 |
|
|
|
633 |
|
|
/* Converts a LONGEST number to hexadecimal and stores it in a static
|
634 |
|
|
string. Returns a pointer to this string. */
|
635 |
|
|
char *
|
636 |
|
|
longest_local_hex_string (LONGEST num)
|
637 |
|
|
{
|
638 |
|
|
return longest_local_hex_string_custom (num, "l");
|
639 |
|
|
}
|
640 |
|
|
|
641 |
|
|
/* Converts a number to custom hexadecimal and stores it in a static
|
642 |
|
|
string. Returns a pointer to this string. */
|
643 |
|
|
char *
|
644 |
|
|
local_hex_string_custom (unsigned long num, char *pre)
|
645 |
|
|
{
|
646 |
|
|
static char res[50];
|
647 |
|
|
|
648 |
|
|
sprintf (res, local_hex_format_custom (pre), num);
|
649 |
|
|
return res;
|
650 |
|
|
}
|
651 |
|
|
|
652 |
|
|
/* Converts a LONGEST number to custom hexadecimal and stores it in a static
|
653 |
|
|
string. Returns a pointer to this string. Note that the width parameter
|
654 |
|
|
should end with "l", e.g. "08l" as with calls to local_hex_string_custom */
|
655 |
|
|
|
656 |
|
|
char *
|
657 |
|
|
longest_local_hex_string_custom (LONGEST num, char *width)
|
658 |
|
|
{
|
659 |
|
|
#define RESULT_BUF_LEN 50
|
660 |
|
|
static char res2[RESULT_BUF_LEN];
|
661 |
|
|
char format[RESULT_BUF_LEN];
|
662 |
|
|
#if !defined (PRINTF_HAS_LONG_LONG)
|
663 |
|
|
int field_width;
|
664 |
|
|
int num_len;
|
665 |
|
|
int num_pad_chars;
|
666 |
|
|
char *pad_char; /* string with one character */
|
667 |
|
|
int pad_on_left;
|
668 |
|
|
char *parse_ptr;
|
669 |
|
|
char temp_nbr_buf[RESULT_BUF_LEN];
|
670 |
|
|
#endif
|
671 |
|
|
|
672 |
|
|
#ifndef CC_HAS_LONG_LONG
|
673 |
|
|
/* If there is no long long, then LONGEST should be just long and we
|
674 |
|
|
can use local_hex_string_custom
|
675 |
|
|
*/
|
676 |
|
|
return local_hex_string_custom ((unsigned long) num, width);
|
677 |
|
|
#elif defined (PRINTF_HAS_LONG_LONG)
|
678 |
|
|
/* Just use printf. */
|
679 |
|
|
strcpy (format, local_hex_format_prefix ()); /* 0x */
|
680 |
|
|
strcat (format, "%");
|
681 |
|
|
strcat (format, width); /* e.g. "08l" */
|
682 |
|
|
strcat (format, "l"); /* need "ll" for long long */
|
683 |
|
|
strcat (format, local_hex_format_specifier ()); /* "x" */
|
684 |
|
|
strcat (format, local_hex_format_suffix ()); /* "" */
|
685 |
|
|
sprintf (res2, format, num);
|
686 |
|
|
return res2;
|
687 |
|
|
#else /* !defined (PRINTF_HAS_LONG_LONG) */
|
688 |
|
|
/* Use strcat_address_numeric to print the number into a string, then
|
689 |
|
|
build the result string from local_hex_format_prefix, padding and
|
690 |
|
|
the hex representation as indicated by "width". */
|
691 |
|
|
|
692 |
|
|
temp_nbr_buf[0] = 0;
|
693 |
|
|
/* With use_local == 0, we don't get the leading "0x" prefix. */
|
694 |
|
|
/* MERGEBUG ?? As a quick fix I am replacing this call to
|
695 |
|
|
strcat_address_numeric with sprintf
|
696 |
|
|
strcat_address_numeric(num, 0, temp_nbr_buf, RESULT_BUF_LEN);
|
697 |
|
|
*/
|
698 |
|
|
|
699 |
|
|
{
|
700 |
|
|
long long ll = num;
|
701 |
|
|
sprintf (temp_nbr_buf, "%llx", ll);
|
702 |
|
|
}
|
703 |
|
|
/* parse width */
|
704 |
|
|
parse_ptr = width;
|
705 |
|
|
pad_on_left = 1;
|
706 |
|
|
pad_char = " ";
|
707 |
|
|
if (*parse_ptr == '-')
|
708 |
|
|
{
|
709 |
|
|
parse_ptr++;
|
710 |
|
|
pad_on_left = 0;
|
711 |
|
|
}
|
712 |
|
|
if (*parse_ptr == '0')
|
713 |
|
|
{
|
714 |
|
|
parse_ptr++;
|
715 |
|
|
if (pad_on_left)
|
716 |
|
|
pad_char = "0"; /* If padding is on the right, it is blank */
|
717 |
|
|
}
|
718 |
|
|
field_width = atoi (parse_ptr);
|
719 |
|
|
num_len = strlen (temp_nbr_buf);
|
720 |
|
|
num_pad_chars = field_width - strlen (temp_nbr_buf); /* possibly negative */
|
721 |
|
|
|
722 |
|
|
if (strlen (local_hex_format_prefix ()) + num_len + num_pad_chars
|
723 |
|
|
>= RESULT_BUF_LEN) /* paranoia */
|
724 |
|
|
internal_error (__FILE__, __LINE__,
|
725 |
|
|
"longest_local_hex_string_custom: insufficient space to store result");
|
726 |
|
|
|
727 |
|
|
strcpy (res2, local_hex_format_prefix ());
|
728 |
|
|
if (pad_on_left)
|
729 |
|
|
{
|
730 |
|
|
while (num_pad_chars > 0)
|
731 |
|
|
{
|
732 |
|
|
strcat (res2, pad_char);
|
733 |
|
|
num_pad_chars--;
|
734 |
|
|
}
|
735 |
|
|
}
|
736 |
|
|
strcat (res2, temp_nbr_buf);
|
737 |
|
|
if (!pad_on_left)
|
738 |
|
|
{
|
739 |
|
|
while (num_pad_chars > 0)
|
740 |
|
|
{
|
741 |
|
|
strcat (res2, pad_char);
|
742 |
|
|
num_pad_chars--;
|
743 |
|
|
}
|
744 |
|
|
}
|
745 |
|
|
return res2;
|
746 |
|
|
#endif
|
747 |
|
|
|
748 |
|
|
} /* longest_local_hex_string_custom */
|
749 |
|
|
|
750 |
|
|
/* Returns the appropriate printf format for octal
|
751 |
|
|
numbers. */
|
752 |
|
|
char *
|
753 |
|
|
local_octal_format_custom (char *pre)
|
754 |
|
|
{
|
755 |
|
|
static char form[50];
|
756 |
|
|
|
757 |
|
|
strcpy (form, local_octal_format_prefix ());
|
758 |
|
|
strcat (form, "%");
|
759 |
|
|
strcat (form, pre);
|
760 |
|
|
strcat (form, local_octal_format_specifier ());
|
761 |
|
|
strcat (form, local_octal_format_suffix ());
|
762 |
|
|
return form;
|
763 |
|
|
}
|
764 |
|
|
|
765 |
|
|
/* Returns the appropriate printf format for decimal numbers. */
|
766 |
|
|
char *
|
767 |
|
|
local_decimal_format_custom (char *pre)
|
768 |
|
|
{
|
769 |
|
|
static char form[50];
|
770 |
|
|
|
771 |
|
|
strcpy (form, local_decimal_format_prefix ());
|
772 |
|
|
strcat (form, "%");
|
773 |
|
|
strcat (form, pre);
|
774 |
|
|
strcat (form, local_decimal_format_specifier ());
|
775 |
|
|
strcat (form, local_decimal_format_suffix ());
|
776 |
|
|
return form;
|
777 |
|
|
}
|
778 |
|
|
|
779 |
|
|
#if 0
|
780 |
|
|
/* This page contains functions that are used in type/range checking.
|
781 |
|
|
They all return zero if the type/range check fails.
|
782 |
|
|
|
783 |
|
|
It is hoped that these will make extending GDB to parse different
|
784 |
|
|
languages a little easier. These are primarily used in eval.c when
|
785 |
|
|
evaluating expressions and making sure that their types are correct.
|
786 |
|
|
Instead of having a mess of conjucted/disjuncted expressions in an "if",
|
787 |
|
|
the ideas of type can be wrapped up in the following functions.
|
788 |
|
|
|
789 |
|
|
Note that some of them are not currently dependent upon which language
|
790 |
|
|
is currently being parsed. For example, floats are the same in
|
791 |
|
|
C and Modula-2 (ie. the only floating point type has TYPE_CODE of
|
792 |
|
|
TYPE_CODE_FLT), while booleans are different. */
|
793 |
|
|
|
794 |
|
|
/* Returns non-zero if its argument is a simple type. This is the same for
|
795 |
|
|
both Modula-2 and for C. In the C case, TYPE_CODE_CHAR will never occur,
|
796 |
|
|
and thus will never cause the failure of the test. */
|
797 |
|
|
int
|
798 |
|
|
simple_type (struct type *type)
|
799 |
|
|
{
|
800 |
|
|
CHECK_TYPEDEF (type);
|
801 |
|
|
switch (TYPE_CODE (type))
|
802 |
|
|
{
|
803 |
|
|
case TYPE_CODE_INT:
|
804 |
|
|
case TYPE_CODE_CHAR:
|
805 |
|
|
case TYPE_CODE_ENUM:
|
806 |
|
|
case TYPE_CODE_FLT:
|
807 |
|
|
case TYPE_CODE_RANGE:
|
808 |
|
|
case TYPE_CODE_BOOL:
|
809 |
|
|
return 1;
|
810 |
|
|
|
811 |
|
|
default:
|
812 |
|
|
return 0;
|
813 |
|
|
}
|
814 |
|
|
}
|
815 |
|
|
|
816 |
|
|
/* Returns non-zero if its argument is of an ordered type.
|
817 |
|
|
An ordered type is one in which the elements can be tested for the
|
818 |
|
|
properties of "greater than", "less than", etc, or for which the
|
819 |
|
|
operations "increment" or "decrement" make sense. */
|
820 |
|
|
int
|
821 |
|
|
ordered_type (struct type *type)
|
822 |
|
|
{
|
823 |
|
|
CHECK_TYPEDEF (type);
|
824 |
|
|
switch (TYPE_CODE (type))
|
825 |
|
|
{
|
826 |
|
|
case TYPE_CODE_INT:
|
827 |
|
|
case TYPE_CODE_CHAR:
|
828 |
|
|
case TYPE_CODE_ENUM:
|
829 |
|
|
case TYPE_CODE_FLT:
|
830 |
|
|
case TYPE_CODE_RANGE:
|
831 |
|
|
return 1;
|
832 |
|
|
|
833 |
|
|
default:
|
834 |
|
|
return 0;
|
835 |
|
|
}
|
836 |
|
|
}
|
837 |
|
|
|
838 |
|
|
/* Returns non-zero if the two types are the same */
|
839 |
|
|
int
|
840 |
|
|
same_type (struct type *arg1, struct type *arg2)
|
841 |
|
|
{
|
842 |
|
|
CHECK_TYPEDEF (type);
|
843 |
|
|
if (structured_type (arg1) ? !structured_type (arg2) : structured_type (arg2))
|
844 |
|
|
/* One is structured and one isn't */
|
845 |
|
|
return 0;
|
846 |
|
|
else if (structured_type (arg1) && structured_type (arg2))
|
847 |
|
|
return arg1 == arg2;
|
848 |
|
|
else if (numeric_type (arg1) && numeric_type (arg2))
|
849 |
|
|
return (TYPE_CODE (arg2) == TYPE_CODE (arg1)) &&
|
850 |
|
|
(TYPE_UNSIGNED (arg1) == TYPE_UNSIGNED (arg2))
|
851 |
|
|
? 1 : 0;
|
852 |
|
|
else
|
853 |
|
|
return arg1 == arg2;
|
854 |
|
|
}
|
855 |
|
|
|
856 |
|
|
/* Returns non-zero if the type is integral */
|
857 |
|
|
int
|
858 |
|
|
integral_type (struct type *type)
|
859 |
|
|
{
|
860 |
|
|
CHECK_TYPEDEF (type);
|
861 |
|
|
switch (current_language->la_language)
|
862 |
|
|
{
|
863 |
|
|
case language_c:
|
864 |
|
|
case language_cplus:
|
865 |
|
|
return (TYPE_CODE (type) != TYPE_CODE_INT) &&
|
866 |
|
|
(TYPE_CODE (type) != TYPE_CODE_ENUM) ? 0 : 1;
|
867 |
|
|
case language_m2:
|
868 |
|
|
case language_pascal:
|
869 |
|
|
return TYPE_CODE (type) != TYPE_CODE_INT ? 0 : 1;
|
870 |
|
|
case language_chill:
|
871 |
|
|
error ("Missing Chill support in function integral_type."); /*FIXME */
|
872 |
|
|
default:
|
873 |
|
|
error ("Language not supported.");
|
874 |
|
|
}
|
875 |
|
|
}
|
876 |
|
|
|
877 |
|
|
/* Returns non-zero if the value is numeric */
|
878 |
|
|
int
|
879 |
|
|
numeric_type (struct type *type)
|
880 |
|
|
{
|
881 |
|
|
CHECK_TYPEDEF (type);
|
882 |
|
|
switch (TYPE_CODE (type))
|
883 |
|
|
{
|
884 |
|
|
case TYPE_CODE_INT:
|
885 |
|
|
case TYPE_CODE_FLT:
|
886 |
|
|
return 1;
|
887 |
|
|
|
888 |
|
|
default:
|
889 |
|
|
return 0;
|
890 |
|
|
}
|
891 |
|
|
}
|
892 |
|
|
|
893 |
|
|
/* Returns non-zero if the value is a character type */
|
894 |
|
|
int
|
895 |
|
|
character_type (struct type *type)
|
896 |
|
|
{
|
897 |
|
|
CHECK_TYPEDEF (type);
|
898 |
|
|
switch (current_language->la_language)
|
899 |
|
|
{
|
900 |
|
|
case language_chill:
|
901 |
|
|
case language_m2:
|
902 |
|
|
case language_pascal:
|
903 |
|
|
return TYPE_CODE (type) != TYPE_CODE_CHAR ? 0 : 1;
|
904 |
|
|
|
905 |
|
|
case language_c:
|
906 |
|
|
case language_cplus:
|
907 |
|
|
return (TYPE_CODE (type) == TYPE_CODE_INT) &&
|
908 |
|
|
TYPE_LENGTH (type) == sizeof (char)
|
909 |
|
|
? 1 : 0;
|
910 |
|
|
default:
|
911 |
|
|
return (0);
|
912 |
|
|
}
|
913 |
|
|
}
|
914 |
|
|
|
915 |
|
|
/* Returns non-zero if the value is a string type */
|
916 |
|
|
int
|
917 |
|
|
string_type (struct type *type)
|
918 |
|
|
{
|
919 |
|
|
CHECK_TYPEDEF (type);
|
920 |
|
|
switch (current_language->la_language)
|
921 |
|
|
{
|
922 |
|
|
case language_chill:
|
923 |
|
|
case language_m2:
|
924 |
|
|
case language_pascal:
|
925 |
|
|
return TYPE_CODE (type) != TYPE_CODE_STRING ? 0 : 1;
|
926 |
|
|
|
927 |
|
|
case language_c:
|
928 |
|
|
case language_cplus:
|
929 |
|
|
/* C does not have distinct string type. */
|
930 |
|
|
return (0);
|
931 |
|
|
default:
|
932 |
|
|
return (0);
|
933 |
|
|
}
|
934 |
|
|
}
|
935 |
|
|
|
936 |
|
|
/* Returns non-zero if the value is a boolean type */
|
937 |
|
|
int
|
938 |
|
|
boolean_type (struct type *type)
|
939 |
|
|
{
|
940 |
|
|
CHECK_TYPEDEF (type);
|
941 |
|
|
if (TYPE_CODE (type) == TYPE_CODE_BOOL)
|
942 |
|
|
return 1;
|
943 |
|
|
switch (current_language->la_language)
|
944 |
|
|
{
|
945 |
|
|
case language_c:
|
946 |
|
|
case language_cplus:
|
947 |
|
|
/* Might be more cleanly handled by having a TYPE_CODE_INT_NOT_BOOL
|
948 |
|
|
for CHILL and such languages, or a TYPE_CODE_INT_OR_BOOL for C. */
|
949 |
|
|
if (TYPE_CODE (type) == TYPE_CODE_INT)
|
950 |
|
|
return 1;
|
951 |
|
|
default:
|
952 |
|
|
break;
|
953 |
|
|
}
|
954 |
|
|
return 0;
|
955 |
|
|
}
|
956 |
|
|
|
957 |
|
|
/* Returns non-zero if the value is a floating-point type */
|
958 |
|
|
int
|
959 |
|
|
float_type (struct type *type)
|
960 |
|
|
{
|
961 |
|
|
CHECK_TYPEDEF (type);
|
962 |
|
|
return TYPE_CODE (type) == TYPE_CODE_FLT;
|
963 |
|
|
}
|
964 |
|
|
|
965 |
|
|
/* Returns non-zero if the value is a pointer type */
|
966 |
|
|
int
|
967 |
|
|
pointer_type (struct type *type)
|
968 |
|
|
{
|
969 |
|
|
return TYPE_CODE (type) == TYPE_CODE_PTR ||
|
970 |
|
|
TYPE_CODE (type) == TYPE_CODE_REF;
|
971 |
|
|
}
|
972 |
|
|
|
973 |
|
|
/* Returns non-zero if the value is a structured type */
|
974 |
|
|
int
|
975 |
|
|
structured_type (struct type *type)
|
976 |
|
|
{
|
977 |
|
|
CHECK_TYPEDEF (type);
|
978 |
|
|
switch (current_language->la_language)
|
979 |
|
|
{
|
980 |
|
|
case language_c:
|
981 |
|
|
case language_cplus:
|
982 |
|
|
return (TYPE_CODE (type) == TYPE_CODE_STRUCT) ||
|
983 |
|
|
(TYPE_CODE (type) == TYPE_CODE_UNION) ||
|
984 |
|
|
(TYPE_CODE (type) == TYPE_CODE_ARRAY);
|
985 |
|
|
case language_pascal:
|
986 |
|
|
return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
|
987 |
|
|
(TYPE_CODE(type) == TYPE_CODE_UNION) ||
|
988 |
|
|
(TYPE_CODE(type) == TYPE_CODE_SET) ||
|
989 |
|
|
(TYPE_CODE(type) == TYPE_CODE_ARRAY);
|
990 |
|
|
case language_m2:
|
991 |
|
|
return (TYPE_CODE (type) == TYPE_CODE_STRUCT) ||
|
992 |
|
|
(TYPE_CODE (type) == TYPE_CODE_SET) ||
|
993 |
|
|
(TYPE_CODE (type) == TYPE_CODE_ARRAY);
|
994 |
|
|
case language_chill:
|
995 |
|
|
error ("Missing Chill support in function structured_type."); /*FIXME */
|
996 |
|
|
default:
|
997 |
|
|
return (0);
|
998 |
|
|
}
|
999 |
|
|
}
|
1000 |
|
|
#endif
|
1001 |
|
|
|
1002 |
|
|
struct type *
|
1003 |
|
|
lang_bool_type (void)
|
1004 |
|
|
{
|
1005 |
|
|
struct symbol *sym;
|
1006 |
|
|
struct type *type;
|
1007 |
|
|
switch (current_language->la_language)
|
1008 |
|
|
{
|
1009 |
|
|
case language_chill:
|
1010 |
|
|
return builtin_type_chill_bool;
|
1011 |
|
|
case language_fortran:
|
1012 |
|
|
sym = lookup_symbol ("logical", NULL, VAR_NAMESPACE, NULL, NULL);
|
1013 |
|
|
if (sym)
|
1014 |
|
|
{
|
1015 |
|
|
type = SYMBOL_TYPE (sym);
|
1016 |
|
|
if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
|
1017 |
|
|
return type;
|
1018 |
|
|
}
|
1019 |
|
|
return builtin_type_f_logical_s2;
|
1020 |
|
|
case language_cplus:
|
1021 |
|
|
case language_pascal:
|
1022 |
|
|
if (current_language->la_language==language_cplus)
|
1023 |
|
|
{sym = lookup_symbol ("bool", NULL, VAR_NAMESPACE, NULL, NULL);}
|
1024 |
|
|
else
|
1025 |
|
|
{sym = lookup_symbol ("boolean", NULL, VAR_NAMESPACE, NULL, NULL);}
|
1026 |
|
|
if (sym)
|
1027 |
|
|
{
|
1028 |
|
|
type = SYMBOL_TYPE (sym);
|
1029 |
|
|
if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
|
1030 |
|
|
return type;
|
1031 |
|
|
}
|
1032 |
|
|
return builtin_type_bool;
|
1033 |
|
|
case language_java:
|
1034 |
|
|
sym = lookup_symbol ("boolean", NULL, VAR_NAMESPACE, NULL, NULL);
|
1035 |
|
|
if (sym)
|
1036 |
|
|
{
|
1037 |
|
|
type = SYMBOL_TYPE (sym);
|
1038 |
|
|
if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
|
1039 |
|
|
return type;
|
1040 |
|
|
}
|
1041 |
|
|
return java_boolean_type;
|
1042 |
|
|
default:
|
1043 |
|
|
return builtin_type_int;
|
1044 |
|
|
}
|
1045 |
|
|
}
|
1046 |
|
|
|
1047 |
|
|
/* This page contains functions that return info about
|
1048 |
|
|
(struct value) values used in GDB. */
|
1049 |
|
|
|
1050 |
|
|
/* Returns non-zero if the value VAL represents a true value. */
|
1051 |
|
|
int
|
1052 |
|
|
value_true (value_ptr val)
|
1053 |
|
|
{
|
1054 |
|
|
/* It is possible that we should have some sort of error if a non-boolean
|
1055 |
|
|
value is used in this context. Possibly dependent on some kind of
|
1056 |
|
|
"boolean-checking" option like range checking. But it should probably
|
1057 |
|
|
not depend on the language except insofar as is necessary to identify
|
1058 |
|
|
a "boolean" value (i.e. in C using a float, pointer, etc., as a boolean
|
1059 |
|
|
should be an error, probably). */
|
1060 |
|
|
return !value_logical_not (val);
|
1061 |
|
|
}
|
1062 |
|
|
|
1063 |
|
|
/* Returns non-zero if the operator OP is defined on
|
1064 |
|
|
the values ARG1 and ARG2. */
|
1065 |
|
|
|
1066 |
|
|
#if 0 /* Currently unused */
|
1067 |
|
|
|
1068 |
|
|
void
|
1069 |
|
|
binop_type_check (value_ptr arg1, value_ptr arg2, int op)
|
1070 |
|
|
{
|
1071 |
|
|
struct type *t1, *t2;
|
1072 |
|
|
|
1073 |
|
|
/* If we're not checking types, always return success. */
|
1074 |
|
|
if (!STRICT_TYPE)
|
1075 |
|
|
return;
|
1076 |
|
|
|
1077 |
|
|
t1 = VALUE_TYPE (arg1);
|
1078 |
|
|
if (arg2 != NULL)
|
1079 |
|
|
t2 = VALUE_TYPE (arg2);
|
1080 |
|
|
else
|
1081 |
|
|
t2 = NULL;
|
1082 |
|
|
|
1083 |
|
|
switch (op)
|
1084 |
|
|
{
|
1085 |
|
|
case BINOP_ADD:
|
1086 |
|
|
case BINOP_SUB:
|
1087 |
|
|
if ((numeric_type (t1) && pointer_type (t2)) ||
|
1088 |
|
|
(pointer_type (t1) && numeric_type (t2)))
|
1089 |
|
|
{
|
1090 |
|
|
warning ("combining pointer and integer.\n");
|
1091 |
|
|
break;
|
1092 |
|
|
}
|
1093 |
|
|
case BINOP_MUL:
|
1094 |
|
|
case BINOP_LSH:
|
1095 |
|
|
case BINOP_RSH:
|
1096 |
|
|
if (!numeric_type (t1) || !numeric_type (t2))
|
1097 |
|
|
type_op_error ("Arguments to %s must be numbers.", op);
|
1098 |
|
|
else if (!same_type (t1, t2))
|
1099 |
|
|
type_op_error ("Arguments to %s must be of the same type.", op);
|
1100 |
|
|
break;
|
1101 |
|
|
|
1102 |
|
|
case BINOP_LOGICAL_AND:
|
1103 |
|
|
case BINOP_LOGICAL_OR:
|
1104 |
|
|
if (!boolean_type (t1) || !boolean_type (t2))
|
1105 |
|
|
type_op_error ("Arguments to %s must be of boolean type.", op);
|
1106 |
|
|
break;
|
1107 |
|
|
|
1108 |
|
|
case BINOP_EQUAL:
|
1109 |
|
|
if ((pointer_type (t1) && !(pointer_type (t2) || integral_type (t2))) ||
|
1110 |
|
|
(pointer_type (t2) && !(pointer_type (t1) || integral_type (t1))))
|
1111 |
|
|
type_op_error ("A pointer can only be compared to an integer or pointer.", op);
|
1112 |
|
|
else if ((pointer_type (t1) && integral_type (t2)) ||
|
1113 |
|
|
(integral_type (t1) && pointer_type (t2)))
|
1114 |
|
|
{
|
1115 |
|
|
warning ("combining integer and pointer.\n");
|
1116 |
|
|
break;
|
1117 |
|
|
}
|
1118 |
|
|
else if (!simple_type (t1) || !simple_type (t2))
|
1119 |
|
|
type_op_error ("Arguments to %s must be of simple type.", op);
|
1120 |
|
|
else if (!same_type (t1, t2))
|
1121 |
|
|
type_op_error ("Arguments to %s must be of the same type.", op);
|
1122 |
|
|
break;
|
1123 |
|
|
|
1124 |
|
|
case BINOP_REM:
|
1125 |
|
|
case BINOP_MOD:
|
1126 |
|
|
if (!integral_type (t1) || !integral_type (t2))
|
1127 |
|
|
type_op_error ("Arguments to %s must be of integral type.", op);
|
1128 |
|
|
break;
|
1129 |
|
|
|
1130 |
|
|
case BINOP_LESS:
|
1131 |
|
|
case BINOP_GTR:
|
1132 |
|
|
case BINOP_LEQ:
|
1133 |
|
|
case BINOP_GEQ:
|
1134 |
|
|
if (!ordered_type (t1) || !ordered_type (t2))
|
1135 |
|
|
type_op_error ("Arguments to %s must be of ordered type.", op);
|
1136 |
|
|
else if (!same_type (t1, t2))
|
1137 |
|
|
type_op_error ("Arguments to %s must be of the same type.", op);
|
1138 |
|
|
break;
|
1139 |
|
|
|
1140 |
|
|
case BINOP_ASSIGN:
|
1141 |
|
|
if (pointer_type (t1) && !integral_type (t2))
|
1142 |
|
|
type_op_error ("A pointer can only be assigned an integer.", op);
|
1143 |
|
|
else if (pointer_type (t1) && integral_type (t2))
|
1144 |
|
|
{
|
1145 |
|
|
warning ("combining integer and pointer.");
|
1146 |
|
|
break;
|
1147 |
|
|
}
|
1148 |
|
|
else if (!simple_type (t1) || !simple_type (t2))
|
1149 |
|
|
type_op_error ("Arguments to %s must be of simple type.", op);
|
1150 |
|
|
else if (!same_type (t1, t2))
|
1151 |
|
|
type_op_error ("Arguments to %s must be of the same type.", op);
|
1152 |
|
|
break;
|
1153 |
|
|
|
1154 |
|
|
case BINOP_CONCAT:
|
1155 |
|
|
/* FIXME: Needs to handle bitstrings as well. */
|
1156 |
|
|
if (!(string_type (t1) || character_type (t1) || integral_type (t1))
|
1157 |
|
|
|| !(string_type (t2) || character_type (t2) || integral_type (t2)))
|
1158 |
|
|
type_op_error ("Arguments to %s must be strings or characters.", op);
|
1159 |
|
|
break;
|
1160 |
|
|
|
1161 |
|
|
/* Unary checks -- arg2 is null */
|
1162 |
|
|
|
1163 |
|
|
case UNOP_LOGICAL_NOT:
|
1164 |
|
|
if (!boolean_type (t1))
|
1165 |
|
|
type_op_error ("Argument to %s must be of boolean type.", op);
|
1166 |
|
|
break;
|
1167 |
|
|
|
1168 |
|
|
case UNOP_PLUS:
|
1169 |
|
|
case UNOP_NEG:
|
1170 |
|
|
if (!numeric_type (t1))
|
1171 |
|
|
type_op_error ("Argument to %s must be of numeric type.", op);
|
1172 |
|
|
break;
|
1173 |
|
|
|
1174 |
|
|
case UNOP_IND:
|
1175 |
|
|
if (integral_type (t1))
|
1176 |
|
|
{
|
1177 |
|
|
warning ("combining pointer and integer.\n");
|
1178 |
|
|
break;
|
1179 |
|
|
}
|
1180 |
|
|
else if (!pointer_type (t1))
|
1181 |
|
|
type_op_error ("Argument to %s must be a pointer.", op);
|
1182 |
|
|
break;
|
1183 |
|
|
|
1184 |
|
|
case UNOP_PREINCREMENT:
|
1185 |
|
|
case UNOP_POSTINCREMENT:
|
1186 |
|
|
case UNOP_PREDECREMENT:
|
1187 |
|
|
case UNOP_POSTDECREMENT:
|
1188 |
|
|
if (!ordered_type (t1))
|
1189 |
|
|
type_op_error ("Argument to %s must be of an ordered type.", op);
|
1190 |
|
|
break;
|
1191 |
|
|
|
1192 |
|
|
default:
|
1193 |
|
|
/* Ok. The following operators have different meanings in
|
1194 |
|
|
different languages. */
|
1195 |
|
|
switch (current_language->la_language)
|
1196 |
|
|
{
|
1197 |
|
|
#ifdef _LANG_c
|
1198 |
|
|
case language_c:
|
1199 |
|
|
case language_cplus:
|
1200 |
|
|
switch (op)
|
1201 |
|
|
{
|
1202 |
|
|
case BINOP_DIV:
|
1203 |
|
|
if (!numeric_type (t1) || !numeric_type (t2))
|
1204 |
|
|
type_op_error ("Arguments to %s must be numbers.", op);
|
1205 |
|
|
break;
|
1206 |
|
|
}
|
1207 |
|
|
break;
|
1208 |
|
|
#endif
|
1209 |
|
|
|
1210 |
|
|
#ifdef _LANG_m2
|
1211 |
|
|
case language_m2:
|
1212 |
|
|
switch (op)
|
1213 |
|
|
{
|
1214 |
|
|
case BINOP_DIV:
|
1215 |
|
|
if (!float_type (t1) || !float_type (t2))
|
1216 |
|
|
type_op_error ("Arguments to %s must be floating point numbers.", op);
|
1217 |
|
|
break;
|
1218 |
|
|
case BINOP_INTDIV:
|
1219 |
|
|
if (!integral_type (t1) || !integral_type (t2))
|
1220 |
|
|
type_op_error ("Arguments to %s must be of integral type.", op);
|
1221 |
|
|
break;
|
1222 |
|
|
}
|
1223 |
|
|
#endif
|
1224 |
|
|
|
1225 |
|
|
#ifdef _LANG_pascal
|
1226 |
|
|
case language_pascal:
|
1227 |
|
|
switch(op)
|
1228 |
|
|
{
|
1229 |
|
|
case BINOP_DIV:
|
1230 |
|
|
if (!float_type(t1) && !float_type(t2))
|
1231 |
|
|
type_op_error ("Arguments to %s must be floating point numbers.",op);
|
1232 |
|
|
break;
|
1233 |
|
|
case BINOP_INTDIV:
|
1234 |
|
|
if (!integral_type(t1) || !integral_type(t2))
|
1235 |
|
|
type_op_error ("Arguments to %s must be of integral type.",op);
|
1236 |
|
|
break;
|
1237 |
|
|
}
|
1238 |
|
|
#endif
|
1239 |
|
|
|
1240 |
|
|
#ifdef _LANG_chill
|
1241 |
|
|
case language_chill:
|
1242 |
|
|
error ("Missing Chill support in function binop_type_check."); /*FIXME */
|
1243 |
|
|
#endif
|
1244 |
|
|
|
1245 |
|
|
}
|
1246 |
|
|
}
|
1247 |
|
|
}
|
1248 |
|
|
|
1249 |
|
|
#endif /* 0 */
|
1250 |
|
|
|
1251 |
|
|
|
1252 |
|
|
/* This page contains functions for the printing out of
|
1253 |
|
|
error messages that occur during type- and range-
|
1254 |
|
|
checking. */
|
1255 |
|
|
|
1256 |
|
|
/* Prints the format string FMT with the operator as a string
|
1257 |
|
|
corresponding to the opcode OP. If FATAL is non-zero, then
|
1258 |
|
|
this is an error and error () is called. Otherwise, it is
|
1259 |
|
|
a warning and printf() is called. */
|
1260 |
|
|
void
|
1261 |
|
|
op_error (char *fmt, enum exp_opcode op, int fatal)
|
1262 |
|
|
{
|
1263 |
|
|
if (fatal)
|
1264 |
|
|
error (fmt, op_string (op));
|
1265 |
|
|
else
|
1266 |
|
|
{
|
1267 |
|
|
warning (fmt, op_string (op));
|
1268 |
|
|
}
|
1269 |
|
|
}
|
1270 |
|
|
|
1271 |
|
|
/* These are called when a language fails a type- or range-check.
|
1272 |
|
|
The first argument should be a printf()-style format string, and
|
1273 |
|
|
the rest of the arguments should be its arguments. If
|
1274 |
|
|
[type|range]_check is [type|range]_check_on, then return_to_top_level()
|
1275 |
|
|
is called in the style of error (). Otherwise, the message is prefixed
|
1276 |
|
|
by the value of warning_pre_print and we do not return to the top level. */
|
1277 |
|
|
|
1278 |
|
|
void
|
1279 |
|
|
type_error (char *string,...)
|
1280 |
|
|
{
|
1281 |
|
|
va_list args;
|
1282 |
|
|
va_start (args, string);
|
1283 |
|
|
|
1284 |
|
|
if (type_check == type_check_warn)
|
1285 |
|
|
fprintf_filtered (gdb_stderr, warning_pre_print);
|
1286 |
|
|
else
|
1287 |
|
|
error_begin ();
|
1288 |
|
|
|
1289 |
|
|
vfprintf_filtered (gdb_stderr, string, args);
|
1290 |
|
|
fprintf_filtered (gdb_stderr, "\n");
|
1291 |
|
|
va_end (args);
|
1292 |
|
|
if (type_check == type_check_on)
|
1293 |
|
|
return_to_top_level (RETURN_ERROR);
|
1294 |
|
|
}
|
1295 |
|
|
|
1296 |
|
|
void
|
1297 |
|
|
range_error (char *string,...)
|
1298 |
|
|
{
|
1299 |
|
|
va_list args;
|
1300 |
|
|
va_start (args, string);
|
1301 |
|
|
|
1302 |
|
|
if (range_check == range_check_warn)
|
1303 |
|
|
fprintf_filtered (gdb_stderr, warning_pre_print);
|
1304 |
|
|
else
|
1305 |
|
|
error_begin ();
|
1306 |
|
|
|
1307 |
|
|
vfprintf_filtered (gdb_stderr, string, args);
|
1308 |
|
|
fprintf_filtered (gdb_stderr, "\n");
|
1309 |
|
|
va_end (args);
|
1310 |
|
|
if (range_check == range_check_on)
|
1311 |
|
|
return_to_top_level (RETURN_ERROR);
|
1312 |
|
|
}
|
1313 |
|
|
|
1314 |
|
|
|
1315 |
|
|
/* This page contains miscellaneous functions */
|
1316 |
|
|
|
1317 |
|
|
/* Return the language enum for a given language string. */
|
1318 |
|
|
|
1319 |
|
|
enum language
|
1320 |
|
|
language_enum (char *str)
|
1321 |
|
|
{
|
1322 |
|
|
int i;
|
1323 |
|
|
|
1324 |
|
|
for (i = 0; i < languages_size; i++)
|
1325 |
|
|
if (STREQ (languages[i]->la_name, str))
|
1326 |
|
|
return languages[i]->la_language;
|
1327 |
|
|
|
1328 |
|
|
return language_unknown;
|
1329 |
|
|
}
|
1330 |
|
|
|
1331 |
|
|
/* Return the language struct for a given language enum. */
|
1332 |
|
|
|
1333 |
|
|
const struct language_defn *
|
1334 |
|
|
language_def (enum language lang)
|
1335 |
|
|
{
|
1336 |
|
|
int i;
|
1337 |
|
|
|
1338 |
|
|
for (i = 0; i < languages_size; i++)
|
1339 |
|
|
{
|
1340 |
|
|
if (languages[i]->la_language == lang)
|
1341 |
|
|
{
|
1342 |
|
|
return languages[i];
|
1343 |
|
|
}
|
1344 |
|
|
}
|
1345 |
|
|
return NULL;
|
1346 |
|
|
}
|
1347 |
|
|
|
1348 |
|
|
/* Return the language as a string */
|
1349 |
|
|
char *
|
1350 |
|
|
language_str (enum language lang)
|
1351 |
|
|
{
|
1352 |
|
|
int i;
|
1353 |
|
|
|
1354 |
|
|
for (i = 0; i < languages_size; i++)
|
1355 |
|
|
{
|
1356 |
|
|
if (languages[i]->la_language == lang)
|
1357 |
|
|
{
|
1358 |
|
|
return languages[i]->la_name;
|
1359 |
|
|
}
|
1360 |
|
|
}
|
1361 |
|
|
return "Unknown";
|
1362 |
|
|
}
|
1363 |
|
|
|
1364 |
|
|
static void
|
1365 |
|
|
set_check (char *ignore, int from_tty)
|
1366 |
|
|
{
|
1367 |
|
|
printf_unfiltered (
|
1368 |
|
|
"\"set check\" must be followed by the name of a check subcommand.\n");
|
1369 |
|
|
help_list (setchecklist, "set check ", -1, gdb_stdout);
|
1370 |
|
|
}
|
1371 |
|
|
|
1372 |
|
|
static void
|
1373 |
|
|
show_check (char *ignore, int from_tty)
|
1374 |
|
|
{
|
1375 |
|
|
cmd_show_list (showchecklist, from_tty, "");
|
1376 |
|
|
}
|
1377 |
|
|
|
1378 |
|
|
/* Add a language to the set of known languages. */
|
1379 |
|
|
|
1380 |
|
|
void
|
1381 |
|
|
add_language (const struct language_defn *lang)
|
1382 |
|
|
{
|
1383 |
|
|
if (lang->la_magic != LANG_MAGIC)
|
1384 |
|
|
{
|
1385 |
|
|
fprintf_unfiltered (gdb_stderr, "Magic number of %s language struct wrong\n",
|
1386 |
|
|
lang->la_name);
|
1387 |
|
|
internal_error (__FILE__, __LINE__, "failed internal consistency check");
|
1388 |
|
|
}
|
1389 |
|
|
|
1390 |
|
|
if (!languages)
|
1391 |
|
|
{
|
1392 |
|
|
languages_allocsize = DEFAULT_ALLOCSIZE;
|
1393 |
|
|
languages = (const struct language_defn **) xmalloc
|
1394 |
|
|
(languages_allocsize * sizeof (*languages));
|
1395 |
|
|
}
|
1396 |
|
|
if (languages_size >= languages_allocsize)
|
1397 |
|
|
{
|
1398 |
|
|
languages_allocsize *= 2;
|
1399 |
|
|
languages = (const struct language_defn **) xrealloc ((char *) languages,
|
1400 |
|
|
languages_allocsize * sizeof (*languages));
|
1401 |
|
|
}
|
1402 |
|
|
languages[languages_size++] = lang;
|
1403 |
|
|
}
|
1404 |
|
|
|
1405 |
|
|
/* Define the language that is no language. */
|
1406 |
|
|
|
1407 |
|
|
static int
|
1408 |
|
|
unk_lang_parser (void)
|
1409 |
|
|
{
|
1410 |
|
|
return 1;
|
1411 |
|
|
}
|
1412 |
|
|
|
1413 |
|
|
static void
|
1414 |
|
|
unk_lang_error (char *msg)
|
1415 |
|
|
{
|
1416 |
|
|
error ("Attempted to parse an expression with unknown language");
|
1417 |
|
|
}
|
1418 |
|
|
|
1419 |
|
|
static void
|
1420 |
|
|
unk_lang_emit_char (register int c, struct ui_file *stream, int quoter)
|
1421 |
|
|
{
|
1422 |
|
|
error ("internal error - unimplemented function unk_lang_emit_char called.");
|
1423 |
|
|
}
|
1424 |
|
|
|
1425 |
|
|
static void
|
1426 |
|
|
unk_lang_printchar (register int c, struct ui_file *stream)
|
1427 |
|
|
{
|
1428 |
|
|
error ("internal error - unimplemented function unk_lang_printchar called.");
|
1429 |
|
|
}
|
1430 |
|
|
|
1431 |
|
|
static void
|
1432 |
|
|
unk_lang_printstr (struct ui_file *stream, char *string, unsigned int length,
|
1433 |
|
|
int width, int force_ellipses)
|
1434 |
|
|
{
|
1435 |
|
|
error ("internal error - unimplemented function unk_lang_printstr called.");
|
1436 |
|
|
}
|
1437 |
|
|
|
1438 |
|
|
static struct type *
|
1439 |
|
|
unk_lang_create_fundamental_type (struct objfile *objfile, int typeid)
|
1440 |
|
|
{
|
1441 |
|
|
error ("internal error - unimplemented function unk_lang_create_fundamental_type called.");
|
1442 |
|
|
}
|
1443 |
|
|
|
1444 |
|
|
static void
|
1445 |
|
|
unk_lang_print_type (struct type *type, char *varstring, struct ui_file *stream,
|
1446 |
|
|
int show, int level)
|
1447 |
|
|
{
|
1448 |
|
|
error ("internal error - unimplemented function unk_lang_print_type called.");
|
1449 |
|
|
}
|
1450 |
|
|
|
1451 |
|
|
static int
|
1452 |
|
|
unk_lang_val_print (struct type *type, char *valaddr, int embedded_offset,
|
1453 |
|
|
CORE_ADDR address, struct ui_file *stream, int format,
|
1454 |
|
|
int deref_ref, int recurse, enum val_prettyprint pretty)
|
1455 |
|
|
{
|
1456 |
|
|
error ("internal error - unimplemented function unk_lang_val_print called.");
|
1457 |
|
|
}
|
1458 |
|
|
|
1459 |
|
|
static int
|
1460 |
|
|
unk_lang_value_print (value_ptr val, struct ui_file *stream, int format,
|
1461 |
|
|
enum val_prettyprint pretty)
|
1462 |
|
|
{
|
1463 |
|
|
error ("internal error - unimplemented function unk_lang_value_print called.");
|
1464 |
|
|
}
|
1465 |
|
|
|
1466 |
|
|
static struct type **CONST_PTR (unknown_builtin_types[]) =
|
1467 |
|
|
{
|
1468 |
|
|
|
1469 |
|
|
};
|
1470 |
|
|
static const struct op_print unk_op_print_tab[] =
|
1471 |
|
|
{
|
1472 |
|
|
{NULL, OP_NULL, PREC_NULL, 0}
|
1473 |
|
|
};
|
1474 |
|
|
|
1475 |
|
|
const struct language_defn unknown_language_defn =
|
1476 |
|
|
{
|
1477 |
|
|
"unknown",
|
1478 |
|
|
language_unknown,
|
1479 |
|
|
&unknown_builtin_types[0],
|
1480 |
|
|
range_check_off,
|
1481 |
|
|
type_check_off,
|
1482 |
|
|
case_sensitive_on,
|
1483 |
|
|
unk_lang_parser,
|
1484 |
|
|
unk_lang_error,
|
1485 |
|
|
evaluate_subexp_standard,
|
1486 |
|
|
unk_lang_printchar, /* Print character constant */
|
1487 |
|
|
unk_lang_printstr,
|
1488 |
|
|
unk_lang_emit_char,
|
1489 |
|
|
unk_lang_create_fundamental_type,
|
1490 |
|
|
unk_lang_print_type, /* Print a type using appropriate syntax */
|
1491 |
|
|
unk_lang_val_print, /* Print a value using appropriate syntax */
|
1492 |
|
|
unk_lang_value_print, /* Print a top-level value */
|
1493 |
|
|
{"", "", "", ""}, /* Binary format info */
|
1494 |
|
|
{"0%lo", "0", "o", ""}, /* Octal format info */
|
1495 |
|
|
{"%ld", "", "d", ""}, /* Decimal format info */
|
1496 |
|
|
{"0x%lx", "0x", "x", ""}, /* Hex format info */
|
1497 |
|
|
unk_op_print_tab, /* expression operators for printing */
|
1498 |
|
|
1, /* c-style arrays */
|
1499 |
|
|
0, /* String lower bound */
|
1500 |
|
|
&builtin_type_char, /* Type of string elements */
|
1501 |
|
|
LANG_MAGIC
|
1502 |
|
|
};
|
1503 |
|
|
|
1504 |
|
|
/* These two structs define fake entries for the "local" and "auto" options. */
|
1505 |
|
|
const struct language_defn auto_language_defn =
|
1506 |
|
|
{
|
1507 |
|
|
"auto",
|
1508 |
|
|
language_auto,
|
1509 |
|
|
&unknown_builtin_types[0],
|
1510 |
|
|
range_check_off,
|
1511 |
|
|
type_check_off,
|
1512 |
|
|
case_sensitive_on,
|
1513 |
|
|
unk_lang_parser,
|
1514 |
|
|
unk_lang_error,
|
1515 |
|
|
evaluate_subexp_standard,
|
1516 |
|
|
unk_lang_printchar, /* Print character constant */
|
1517 |
|
|
unk_lang_printstr,
|
1518 |
|
|
unk_lang_emit_char,
|
1519 |
|
|
unk_lang_create_fundamental_type,
|
1520 |
|
|
unk_lang_print_type, /* Print a type using appropriate syntax */
|
1521 |
|
|
unk_lang_val_print, /* Print a value using appropriate syntax */
|
1522 |
|
|
unk_lang_value_print, /* Print a top-level value */
|
1523 |
|
|
{"", "", "", ""}, /* Binary format info */
|
1524 |
|
|
{"0%lo", "0", "o", ""}, /* Octal format info */
|
1525 |
|
|
{"%ld", "", "d", ""}, /* Decimal format info */
|
1526 |
|
|
{"0x%lx", "0x", "x", ""}, /* Hex format info */
|
1527 |
|
|
unk_op_print_tab, /* expression operators for printing */
|
1528 |
|
|
1, /* c-style arrays */
|
1529 |
|
|
0, /* String lower bound */
|
1530 |
|
|
&builtin_type_char, /* Type of string elements */
|
1531 |
|
|
LANG_MAGIC
|
1532 |
|
|
};
|
1533 |
|
|
|
1534 |
|
|
const struct language_defn local_language_defn =
|
1535 |
|
|
{
|
1536 |
|
|
"local",
|
1537 |
|
|
language_auto,
|
1538 |
|
|
&unknown_builtin_types[0],
|
1539 |
|
|
range_check_off,
|
1540 |
|
|
type_check_off,
|
1541 |
|
|
case_sensitive_on,
|
1542 |
|
|
unk_lang_parser,
|
1543 |
|
|
unk_lang_error,
|
1544 |
|
|
evaluate_subexp_standard,
|
1545 |
|
|
unk_lang_printchar, /* Print character constant */
|
1546 |
|
|
unk_lang_printstr,
|
1547 |
|
|
unk_lang_emit_char,
|
1548 |
|
|
unk_lang_create_fundamental_type,
|
1549 |
|
|
unk_lang_print_type, /* Print a type using appropriate syntax */
|
1550 |
|
|
unk_lang_val_print, /* Print a value using appropriate syntax */
|
1551 |
|
|
unk_lang_value_print, /* Print a top-level value */
|
1552 |
|
|
{"", "", "", ""}, /* Binary format info */
|
1553 |
|
|
{"0%lo", "0", "o", ""}, /* Octal format info */
|
1554 |
|
|
{"%ld", "", "d", ""}, /* Decimal format info */
|
1555 |
|
|
{"0x%lx", "0x", "x", ""}, /* Hex format info */
|
1556 |
|
|
unk_op_print_tab, /* expression operators for printing */
|
1557 |
|
|
1, /* c-style arrays */
|
1558 |
|
|
0, /* String lower bound */
|
1559 |
|
|
&builtin_type_char, /* Type of string elements */
|
1560 |
|
|
LANG_MAGIC
|
1561 |
|
|
};
|
1562 |
|
|
|
1563 |
|
|
/* Initialize the language routines */
|
1564 |
|
|
|
1565 |
|
|
void
|
1566 |
|
|
_initialize_language (void)
|
1567 |
|
|
{
|
1568 |
|
|
struct cmd_list_element *set, *show;
|
1569 |
|
|
|
1570 |
|
|
/* GDB commands for language specific stuff */
|
1571 |
|
|
|
1572 |
|
|
set = add_set_cmd ("language", class_support, var_string_noescape,
|
1573 |
|
|
(char *) &language,
|
1574 |
|
|
"Set the current source language.",
|
1575 |
|
|
&setlist);
|
1576 |
|
|
show = add_show_from_set (set, &showlist);
|
1577 |
|
|
set->function.cfunc = set_language_command;
|
1578 |
|
|
show->function.cfunc = show_language_command;
|
1579 |
|
|
|
1580 |
|
|
add_prefix_cmd ("check", no_class, set_check,
|
1581 |
|
|
"Set the status of the type/range checker",
|
1582 |
|
|
&setchecklist, "set check ", 0, &setlist);
|
1583 |
|
|
add_alias_cmd ("c", "check", no_class, 1, &setlist);
|
1584 |
|
|
add_alias_cmd ("ch", "check", no_class, 1, &setlist);
|
1585 |
|
|
|
1586 |
|
|
add_prefix_cmd ("check", no_class, show_check,
|
1587 |
|
|
"Show the status of the type/range checker",
|
1588 |
|
|
&showchecklist, "show check ", 0, &showlist);
|
1589 |
|
|
add_alias_cmd ("c", "check", no_class, 1, &showlist);
|
1590 |
|
|
add_alias_cmd ("ch", "check", no_class, 1, &showlist);
|
1591 |
|
|
|
1592 |
|
|
set = add_set_cmd ("type", class_support, var_string_noescape,
|
1593 |
|
|
(char *) &type,
|
1594 |
|
|
"Set type checking. (on/warn/off/auto)",
|
1595 |
|
|
&setchecklist);
|
1596 |
|
|
show = add_show_from_set (set, &showchecklist);
|
1597 |
|
|
set->function.cfunc = set_type_command;
|
1598 |
|
|
show->function.cfunc = show_type_command;
|
1599 |
|
|
|
1600 |
|
|
set = add_set_cmd ("range", class_support, var_string_noescape,
|
1601 |
|
|
(char *) &range,
|
1602 |
|
|
"Set range checking. (on/warn/off/auto)",
|
1603 |
|
|
&setchecklist);
|
1604 |
|
|
show = add_show_from_set (set, &showchecklist);
|
1605 |
|
|
set->function.cfunc = set_range_command;
|
1606 |
|
|
show->function.cfunc = show_range_command;
|
1607 |
|
|
|
1608 |
|
|
set = add_set_cmd ("case-sensitive", class_support, var_string_noescape,
|
1609 |
|
|
(char *) &case_sensitive,
|
1610 |
|
|
"Set case sensitivity in name search. (on/off/auto)\n\
|
1611 |
|
|
For Fortran the default is off; for other languages the default is on.",
|
1612 |
|
|
&setlist);
|
1613 |
|
|
show = add_show_from_set (set, &showlist);
|
1614 |
|
|
set->function.cfunc = set_case_command;
|
1615 |
|
|
show->function.cfunc = show_case_command;
|
1616 |
|
|
|
1617 |
|
|
add_language (&unknown_language_defn);
|
1618 |
|
|
add_language (&local_language_defn);
|
1619 |
|
|
add_language (&auto_language_defn);
|
1620 |
|
|
|
1621 |
|
|
language = savestring ("auto", strlen ("auto"));
|
1622 |
|
|
type = savestring ("auto", strlen ("auto"));
|
1623 |
|
|
range = savestring ("auto", strlen ("auto"));
|
1624 |
|
|
case_sensitive = savestring ("auto",strlen ("auto"));
|
1625 |
|
|
|
1626 |
|
|
/* Have the above take effect */
|
1627 |
|
|
set_language (language_auto);
|
1628 |
|
|
}
|