* c-valprint.c (print_function_pointer_address): New function
[deliverable/binutils-gdb.git] / gdb / language.h
CommitLineData
c906108c 1/* Source-language-related definitions for GDB.
d9fcf2fb 2 Copyright 1991, 1992, 2000 Free Software Foundation, Inc.
c906108c
SS
3 Contributed by the Department of Computer Science at the State University
4 of New York at Buffalo.
5
c5aa993b 6 This file is part of GDB.
c906108c 7
c5aa993b
JM
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
c906108c 12
c5aa993b
JM
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
c906108c 17
c5aa993b
JM
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
c906108c
SS
22
23#if !defined (LANGUAGE_H)
24#define LANGUAGE_H 1
25
104c1213 26/* Forward decls for prototypes */
c906108c
SS
27struct value;
28struct objfile;
29struct expression;
c5aa993b 30/* enum exp_opcode; ANSI's `wisdom' didn't include forward enum decls. */
c906108c
SS
31
32/* This used to be included to configure GDB for one or more specific
7e73cedf 33 languages. Now it is left out to configure for all of them. FIXME. */
c906108c
SS
34/* #include "lang_def.h" */
35#define _LANG_c
36#define _LANG_m2
37#define _LANG_chill
750ba382
PM
38#define _LANG_fortran
39#define _LANG_pascal
c906108c 40
c5aa993b 41#define MAX_FORTRAN_DIMS 7 /* Maximum number of F77 array dims */
c906108c
SS
42
43/* range_mode ==
44 range_mode_auto: range_check set automatically to default of language.
45 range_mode_manual: range_check set manually by user. */
46
c5aa993b
JM
47extern enum range_mode
48 {
49 range_mode_auto, range_mode_manual
50 }
51range_mode;
c906108c
SS
52
53/* range_check ==
54 range_check_on: Ranges are checked in GDB expressions, producing errors.
55 range_check_warn: Ranges are checked, producing warnings.
56 range_check_off: Ranges are not checked in GDB expressions. */
57
58extern enum range_check
c5aa993b
JM
59 {
60 range_check_off, range_check_warn, range_check_on
61 }
62range_check;
c906108c
SS
63
64/* type_mode ==
65 type_mode_auto: type_check set automatically to default of language
66 type_mode_manual: type_check set manually by user. */
67
c5aa993b
JM
68extern enum type_mode
69 {
70 type_mode_auto, type_mode_manual
71 }
72type_mode;
c906108c
SS
73
74/* type_check ==
75 type_check_on: Types are checked in GDB expressions, producing errors.
76 type_check_warn: Types are checked, producing warnings.
77 type_check_off: Types are not checked in GDB expressions. */
78
79extern enum type_check
c5aa993b
JM
80 {
81 type_check_off, type_check_warn, type_check_on
82 }
83type_check;
63872f9d
JG
84
85/* case_mode ==
86 case_mode_auto: case_sensitivity set upon selection of scope
87 case_mode_manual: case_sensitivity set only by user. */
88
89extern enum case_mode
90 {
91 case_mode_auto, case_mode_manual
92 }
93case_mode;
94
95/* case_sensitivity ==
96 case_sensitive_on: Case sensitivity in name matching is used
97 case_sensitive_off: Case sensitivity in name matching is not used */
98
99extern enum case_sensitivity
100 {
101 case_sensitive_on, case_sensitive_off
102 }
103case_sensitivity;
c906108c
SS
104\f
105/* Information for doing language dependent formatting of printed values. */
106
107struct language_format_info
c5aa993b
JM
108 {
109 /* The format that can be passed directly to standard C printf functions
110 to generate a completely formatted value in the format appropriate for
111 the language. */
c906108c 112
c5aa993b 113 char *la_format;
c906108c 114
c5aa993b
JM
115 /* The prefix to be used when directly printing a value, or constructing
116 a standard C printf format. This generally is everything up to the
117 conversion specification (the part introduced by the '%' character
118 and terminated by the conversion specifier character). */
c906108c 119
c5aa993b 120 char *la_format_prefix;
c906108c 121
c5aa993b
JM
122 /* The conversion specifier. This is generally everything after the
123 field width and precision, typically only a single character such
124 as 'o' for octal format or 'x' for hexadecimal format. */
c906108c 125
c5aa993b 126 char *la_format_specifier;
c906108c 127
c5aa993b
JM
128 /* The suffix to be used when directly printing a value, or constructing
129 a standard C printf format. This generally is everything after the
130 conversion specification (the part introduced by the '%' character
131 and terminated by the conversion specifier character). */
c906108c 132
c5aa993b
JM
133 char *la_format_suffix; /* Suffix for custom format string */
134 };
c906108c
SS
135
136/* Structure tying together assorted information about a language. */
137
138struct language_defn
c5aa993b
JM
139 {
140 /* Name of the language */
c906108c 141
c5aa993b 142 char *la_name;
c906108c 143
c5aa993b 144 /* its symtab language-enum (defs.h) */
c906108c 145
c5aa993b 146 enum language la_language;
c906108c 147
c5aa993b
JM
148 /* Its builtin types. This is a vector ended by a NULL pointer. These
149 types can be specified by name in parsing types in expressions,
150 regardless of whether the program being debugged actually defines
151 such a type. */
c906108c 152
c5aa993b 153 struct type **const *la_builtin_type_vector;
c906108c 154
c5aa993b 155 /* Default range checking */
c906108c 156
c5aa993b 157 enum range_check la_range_check;
c906108c 158
c5aa993b 159 /* Default type checking */
c906108c 160
c5aa993b 161 enum type_check la_type_check;
c906108c 162
63872f9d
JG
163 /* Default case sensitivity */
164 enum case_sensitivity la_case_sensitivity;
165
c5aa993b 166 /* Parser function. */
c906108c 167
507f3c78 168 int (*la_parser) (void);
c906108c 169
c5aa993b 170 /* Parser error function */
c906108c 171
507f3c78 172 void (*la_error) (char *);
c906108c 173
c5aa993b 174 /* Evaluate an expression. */
507f3c78
KB
175 struct value *(*evaluate_exp) (struct type *, struct expression *,
176 int *, enum noside);
c906108c 177
d9fcf2fb 178 void (*la_printchar) (int ch, struct ui_file * stream);
c906108c 179
d9fcf2fb
JM
180 void (*la_printstr) (struct ui_file * stream, char *string,
181 unsigned int length, int width,
182 int force_ellipses);
c906108c 183
d9fcf2fb 184 void (*la_emitchar) (int ch, struct ui_file * stream, int quoter);
c906108c 185
507f3c78 186 struct type *(*la_fund_type) (struct objfile *, int);
c906108c 187
c5aa993b 188 /* Print a type using syntax appropriate for this language. */
c906108c 189
d9fcf2fb
JM
190 void (*la_print_type) (struct type *, char *, struct ui_file *, int,
191 int);
c906108c 192
c5aa993b 193 /* Print a value using syntax appropriate for this language. */
c906108c 194
d9fcf2fb
JM
195 int (*la_val_print) (struct type *, char *, int, CORE_ADDR,
196 struct ui_file *, int, int, int,
197 enum val_prettyprint);
c906108c 198
c5aa993b 199 /* Print a top-level value using syntax appropriate for this language. */
c906108c 200
d9fcf2fb
JM
201 int (*la_value_print) (struct value *, struct ui_file *,
202 int, enum val_prettyprint);
c906108c 203
c5aa993b 204 /* Base 2 (binary) formats. */
c906108c 205
c5aa993b 206 struct language_format_info la_binary_format;
c906108c 207
c5aa993b 208 /* Base 8 (octal) formats. */
c906108c 209
c5aa993b 210 struct language_format_info la_octal_format;
c906108c 211
c5aa993b 212 /* Base 10 (decimal) formats */
c906108c 213
c5aa993b 214 struct language_format_info la_decimal_format;
c906108c 215
c5aa993b 216 /* Base 16 (hexadecimal) formats */
c906108c 217
c5aa993b 218 struct language_format_info la_hex_format;
c906108c 219
c5aa993b 220 /* Table for printing expressions */
c906108c 221
c5aa993b 222 const struct op_print *la_op_print_tab;
c906108c 223
c5aa993b
JM
224 /* Zero if the language has first-class arrays. True if there are no
225 array values, and array objects decay to pointers, as in C. */
c906108c 226
c5aa993b 227 char c_style_arrays;
c906108c 228
c5aa993b
JM
229 /* Index to use for extracting the first element of a string. */
230 char string_lower_bound;
c906108c 231
c5aa993b
JM
232 /* Type of elements of strings. */
233 struct type **string_char_type;
c906108c 234
c5aa993b
JM
235 /* Add fields above this point, so the magic number is always last. */
236 /* Magic number for compat checking */
237
238 long la_magic;
239
240 };
c906108c
SS
241
242#define LANG_MAGIC 910823L
243
244/* Pointer to the language_defn for our current language. This pointer
245 always points to *some* valid struct; it can be used without checking
246 it for validity.
247
248 The current language affects expression parsing and evaluation
249 (FIXME: it might be cleaner to make the evaluation-related stuff
250 separate exp_opcodes for each different set of semantics. We
251 should at least think this through more clearly with respect to
252 what happens if the language is changed between parsing and
253 evaluation) and printing of things like types and arrays. It does
254 *not* affect symbol-reading-- each source file in a symbol-file has
255 its own language and we should keep track of that regardless of the
256 language when symbols are read. If we want some manual setting for
257 the language of symbol files (e.g. detecting when ".c" files are
7e73cedf 258 C++), it should be a separate setting from the current_language. */
c906108c
SS
259
260extern const struct language_defn *current_language;
261
262/* Pointer to the language_defn expected by the user, e.g. the language
263 of main(), or the language we last mentioned in a message, or C. */
264
265extern const struct language_defn *expected_language;
266
267/* language_mode ==
268 language_mode_auto: current_language automatically set upon selection
c5aa993b 269 of scope (e.g. stack frame)
c906108c
SS
270 language_mode_manual: current_language set only by user. */
271
272extern enum language_mode
c5aa993b
JM
273 {
274 language_mode_auto, language_mode_manual
275 }
276language_mode;
c906108c
SS
277\f
278/* These macros define the behaviour of the expression
279 evaluator. */
280
281/* Should we strictly type check expressions? */
282#define STRICT_TYPE (type_check != type_check_off)
283
284/* Should we range check values against the domain of their type? */
285#define RANGE_CHECK (range_check != range_check_off)
286
287/* "cast" really means conversion */
288/* FIXME -- should be a setting in language_defn */
289#define CAST_IS_CONVERSION (current_language->la_language == language_c || \
290 current_language->la_language == language_cplus)
291
a14ed312 292extern void language_info (int);
c906108c 293
a14ed312 294extern enum language set_language (enum language);
c906108c 295\f
c5aa993b 296
c906108c
SS
297/* This page contains functions that return things that are
298 specific to languages. Each of these functions is based on
299 the current setting of working_lang, which the user sets
300 with the "set language" command. */
301
302#define create_fundamental_type(objfile,typeid) \
303 (current_language->la_fund_type(objfile, typeid))
304
305#define LA_PRINT_TYPE(type,varstring,stream,show,level) \
306 (current_language->la_print_type(type,varstring,stream,show,level))
307
308#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,fmt,deref,recurse,pretty) \
309 (current_language->la_val_print(type,valaddr,offset,addr,stream,fmt,deref, \
310 recurse,pretty))
311#define LA_VALUE_PRINT(val,stream,fmt,pretty) \
312 (current_language->la_value_print(val,stream,fmt,pretty))
313
314/* Return a format string for printf that will print a number in one of
315 the local (language-specific) formats. Result is static and is
316 overwritten by the next call. Takes printf options like "08" or "l"
317 (to produce e.g. %08x or %lx). */
318
319#define local_binary_format() \
320 (current_language->la_binary_format.la_format)
321#define local_binary_format_prefix() \
322 (current_language->la_binary_format.la_format_prefix)
323#define local_binary_format_specifier() \
324 (current_language->la_binary_format.la_format_specifier)
325#define local_binary_format_suffix() \
326 (current_language->la_binary_format.la_format_suffix)
327
328#define local_octal_format() \
329 (current_language->la_octal_format.la_format)
330#define local_octal_format_prefix() \
331 (current_language->la_octal_format.la_format_prefix)
332#define local_octal_format_specifier() \
333 (current_language->la_octal_format.la_format_specifier)
334#define local_octal_format_suffix() \
335 (current_language->la_octal_format.la_format_suffix)
336
337#define local_decimal_format() \
338 (current_language->la_decimal_format.la_format)
339#define local_decimal_format_prefix() \
340 (current_language->la_decimal_format.la_format_prefix)
341#define local_decimal_format_specifier() \
342 (current_language->la_decimal_format.la_format_specifier)
343#define local_decimal_format_suffix() \
344 (current_language->la_decimal_format.la_format_suffix)
345
346#define local_hex_format() \
347 (current_language->la_hex_format.la_format)
348#define local_hex_format_prefix() \
349 (current_language->la_hex_format.la_format_prefix)
350#define local_hex_format_specifier() \
351 (current_language->la_hex_format.la_format_specifier)
352#define local_hex_format_suffix() \
353 (current_language->la_hex_format.la_format_suffix)
354
355#define LA_PRINT_CHAR(ch, stream) \
356 (current_language->la_printchar(ch, stream))
357#define LA_PRINT_STRING(stream, string, length, width, force_ellipses) \
358 (current_language->la_printstr(stream, string, length, width, force_ellipses))
359#define LA_EMIT_CHAR(ch, stream, quoter) \
360 (current_language->la_emitchar(ch, stream, quoter))
361
362/* Test a character to decide whether it can be printed in literal form
363 or needs to be printed in another representation. For example,
364 in C the literal form of the character with octal value 141 is 'a'
365 and the "other representation" is '\141'. The "other representation"
366 is program language dependent. */
367
368#define PRINT_LITERAL_FORM(c) \
369 ((c) >= 0x20 \
370 && ((c) < 0x7F || (c) >= 0xA0) \
371 && (!sevenbit_strings || (c) < 0x80))
372
373/* Return a format string for printf that will print a number in one of
374 the local (language-specific) formats. Result is static and is
375 overwritten by the next call. Takes printf options like "08" or "l"
376 (to produce e.g. %08x or %lx). */
377
a14ed312 378extern char *local_decimal_format_custom (char *); /* language.c */
c906108c 379
a14ed312 380extern char *local_octal_format_custom (char *); /* language.c */
c906108c 381
a14ed312 382extern char *local_hex_format_custom (char *); /* language.c */
c906108c 383
7acb79c8
AC
384#if 0
385/* FIXME: cagney/2000-03-04: This function does not appear to be used.
386 It can be deleted once 5.0 has been released. */
c4093a6a
JM
387/* Return a string that contains the hex digits of the number. No preceeding
388 "0x" */
389
a14ed312 390extern char *longest_raw_hex_string (LONGEST);
7acb79c8 391#endif
c4093a6a 392
c906108c
SS
393/* Return a string that contains a number formatted in one of the local
394 (language-specific) formats. Result is static and is overwritten by
c4093a6a 395 the next call. Takes printf options like "08l" or "l". */
c906108c 396
a14ed312 397extern char *local_hex_string (unsigned long); /* language.c */
c906108c 398
a14ed312 399extern char *longest_local_hex_string (LONGEST); /* language.c */
c4093a6a 400
a14ed312 401extern char *local_hex_string_custom (unsigned long, char *); /* language.c */
c906108c 402
a14ed312 403extern char *longest_local_hex_string_custom (LONGEST, char *); /* language.c */
c4093a6a 404
c906108c
SS
405/* Type predicates */
406
a14ed312 407extern int simple_type (struct type *);
c906108c 408
a14ed312 409extern int ordered_type (struct type *);
c906108c 410
a14ed312 411extern int same_type (struct type *, struct type *);
c906108c 412
a14ed312 413extern int integral_type (struct type *);
c906108c 414
a14ed312 415extern int numeric_type (struct type *);
c906108c 416
a14ed312 417extern int character_type (struct type *);
c906108c 418
a14ed312 419extern int boolean_type (struct type *);
c906108c 420
a14ed312 421extern int float_type (struct type *);
c906108c 422
a14ed312 423extern int pointer_type (struct type *);
c906108c 424
a14ed312 425extern int structured_type (struct type *);
c906108c
SS
426
427/* Checks Binary and Unary operations for semantic type correctness */
428/* FIXME: Does not appear to be used */
429#define unop_type_check(v,o) binop_type_check((v),NULL,(o))
430
a14ed312 431extern void binop_type_check (struct value *, struct value *, int);
c906108c
SS
432
433/* Error messages */
434
a14ed312 435extern void op_error (char *fmt, enum exp_opcode, int);
c906108c
SS
436
437#define type_op_error(f,o) \
438 op_error((f),(o),type_check==type_check_on ? 1 : 0)
439#define range_op_error(f,o) \
440 op_error((f),(o),range_check==range_check_on ? 1 : 0)
441
a14ed312 442extern void type_error (char *, ...) ATTR_FORMAT (printf, 1, 2);
c906108c 443
a14ed312
KB
444void
445range_error (char *, ...)
446ATTR_FORMAT (printf, 1, 2);
c906108c
SS
447
448/* Data: Does this value represent "truth" to the current language? */
449
a14ed312 450extern int value_true (struct value *);
c906108c 451
a14ed312 452extern struct type *lang_bool_type (void);
c906108c
SS
453
454/* The type used for Boolean values in the current language. */
455#define LA_BOOL_TYPE lang_bool_type ()
456
457/* Misc: The string representing a particular enum language. */
458
a14ed312 459extern enum language language_enum (char *str);
c906108c 460
a14ed312 461extern const struct language_defn *language_def (enum language);
7a292a7a 462
a14ed312 463extern char *language_str (enum language);
c906108c
SS
464
465/* Add a language to the set known by GDB (at initialization time). */
466
a14ed312 467extern void add_language (const struct language_defn *);
c906108c 468
a14ed312 469extern enum language get_frame_language (void); /* In stack.c */
c906108c 470
c5aa993b 471#endif /* defined (LANGUAGE_H) */
This page took 0.095175 seconds and 4 git commands to generate.