xref: /dragonfly/contrib/gdb-7/gdb/language.h (revision ef5ccd6c)
15796c8dcSSimon Schubert /* Source-language-related definitions for GDB.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 1991-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    Contributed by the Department of Computer Science at the State University
65796c8dcSSimon Schubert    of New York at Buffalo.
75796c8dcSSimon Schubert 
85796c8dcSSimon Schubert    This file is part of GDB.
95796c8dcSSimon Schubert 
105796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
115796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
125796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
135796c8dcSSimon Schubert    (at your option) any later version.
145796c8dcSSimon Schubert 
155796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
165796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
175796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
185796c8dcSSimon Schubert    GNU General Public License for more details.
195796c8dcSSimon Schubert 
205796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
215796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
225796c8dcSSimon Schubert 
235796c8dcSSimon Schubert #if !defined (LANGUAGE_H)
245796c8dcSSimon Schubert #define LANGUAGE_H 1
255796c8dcSSimon Schubert 
26c50c785cSJohn Marino /* Forward decls for prototypes.  */
275796c8dcSSimon Schubert struct value;
285796c8dcSSimon Schubert struct objfile;
295796c8dcSSimon Schubert struct frame_info;
305796c8dcSSimon Schubert struct expression;
315796c8dcSSimon Schubert struct ui_file;
325796c8dcSSimon Schubert struct value_print_options;
33*ef5ccd6cSJohn Marino struct type_print_options;
345796c8dcSSimon Schubert 
35c50c785cSJohn Marino #define MAX_FORTRAN_DIMS  7	/* Maximum number of F77 array dims.  */
365796c8dcSSimon Schubert 
375796c8dcSSimon Schubert /* range_mode ==
385796c8dcSSimon Schubert    range_mode_auto:   range_check set automatically to default of language.
395796c8dcSSimon Schubert    range_mode_manual: range_check set manually by user.  */
405796c8dcSSimon Schubert 
415796c8dcSSimon Schubert extern enum range_mode
425796c8dcSSimon Schubert   {
435796c8dcSSimon Schubert     range_mode_auto, range_mode_manual
445796c8dcSSimon Schubert   }
455796c8dcSSimon Schubert range_mode;
465796c8dcSSimon Schubert 
475796c8dcSSimon Schubert /* range_check ==
485796c8dcSSimon Schubert    range_check_on:    Ranges are checked in GDB expressions, producing errors.
495796c8dcSSimon Schubert    range_check_warn:  Ranges are checked, producing warnings.
505796c8dcSSimon Schubert    range_check_off:   Ranges are not checked in GDB expressions.  */
515796c8dcSSimon Schubert 
525796c8dcSSimon Schubert extern enum range_check
535796c8dcSSimon Schubert   {
545796c8dcSSimon Schubert     range_check_off, range_check_warn, range_check_on
555796c8dcSSimon Schubert   }
565796c8dcSSimon Schubert range_check;
575796c8dcSSimon Schubert 
585796c8dcSSimon Schubert /* case_mode ==
59c50c785cSJohn Marino    case_mode_auto:   case_sensitivity set upon selection of scope.
605796c8dcSSimon Schubert    case_mode_manual: case_sensitivity set only by user.  */
615796c8dcSSimon Schubert 
625796c8dcSSimon Schubert extern enum case_mode
635796c8dcSSimon Schubert   {
645796c8dcSSimon Schubert     case_mode_auto, case_mode_manual
655796c8dcSSimon Schubert   }
665796c8dcSSimon Schubert case_mode;
675796c8dcSSimon Schubert 
685796c8dcSSimon Schubert /* array_ordering ==
69c50c785cSJohn Marino    array_row_major:     Arrays are in row major order.
705796c8dcSSimon Schubert    array_column_major:  Arrays are in column major order.  */
715796c8dcSSimon Schubert 
725796c8dcSSimon Schubert extern enum array_ordering
735796c8dcSSimon Schubert   {
745796c8dcSSimon Schubert     array_row_major, array_column_major
755796c8dcSSimon Schubert   }
765796c8dcSSimon Schubert array_ordering;
775796c8dcSSimon Schubert 
785796c8dcSSimon Schubert 
795796c8dcSSimon Schubert /* case_sensitivity ==
80c50c785cSJohn Marino    case_sensitive_on:   Case sensitivity in name matching is used.
81c50c785cSJohn Marino    case_sensitive_off:  Case sensitivity in name matching is not used.  */
825796c8dcSSimon Schubert 
835796c8dcSSimon Schubert extern enum case_sensitivity
845796c8dcSSimon Schubert   {
855796c8dcSSimon Schubert     case_sensitive_on, case_sensitive_off
865796c8dcSSimon Schubert   }
875796c8dcSSimon Schubert case_sensitivity;
885796c8dcSSimon Schubert 
895796c8dcSSimon Schubert 
905796c8dcSSimon Schubert /* macro_expansion ==
91c50c785cSJohn Marino    macro_expansion_no:  No macro expansion is available.
92c50c785cSJohn Marino    macro_expansion_c:   C-like macro expansion is available.  */
935796c8dcSSimon Schubert 
945796c8dcSSimon Schubert enum macro_expansion
955796c8dcSSimon Schubert   {
965796c8dcSSimon Schubert     macro_expansion_no, macro_expansion_c
975796c8dcSSimon Schubert   };
985796c8dcSSimon Schubert 
995796c8dcSSimon Schubert 
1005796c8dcSSimon Schubert /* Per architecture (OS/ABI) language information.  */
1015796c8dcSSimon Schubert 
1025796c8dcSSimon Schubert struct language_arch_info
1035796c8dcSSimon Schubert {
1045796c8dcSSimon Schubert   /* Its primitive types.  This is a vector ended by a NULL pointer.
1055796c8dcSSimon Schubert      These types can be specified by name in parsing types in
1065796c8dcSSimon Schubert      expressions, regardless of whether the program being debugged
1075796c8dcSSimon Schubert      actually defines such a type.  */
1085796c8dcSSimon Schubert   struct type **primitive_type_vector;
1095796c8dcSSimon Schubert   /* Type of elements of strings.  */
1105796c8dcSSimon Schubert   struct type *string_char_type;
1115796c8dcSSimon Schubert 
1125796c8dcSSimon Schubert   /* Symbol name of type to use as boolean type, if defined.  */
1135796c8dcSSimon Schubert   const char *bool_type_symbol;
1145796c8dcSSimon Schubert   /* Otherwise, this is the default boolean builtin type.  */
1155796c8dcSSimon Schubert   struct type *bool_type_default;
1165796c8dcSSimon Schubert };
1175796c8dcSSimon Schubert 
118*ef5ccd6cSJohn Marino /* A pointer to a function expected to return nonzero if
119*ef5ccd6cSJohn Marino    SYMBOL_SEARCH_NAME matches the given LOOKUP_NAME.
120*ef5ccd6cSJohn Marino 
121*ef5ccd6cSJohn Marino    SYMBOL_SEARCH_NAME should be a symbol's "search" name.
122*ef5ccd6cSJohn Marino    LOOKUP_NAME should be the name of an entity after it has been
123*ef5ccd6cSJohn Marino    transformed for lookup.  */
124*ef5ccd6cSJohn Marino 
125*ef5ccd6cSJohn Marino typedef int (*symbol_name_cmp_ftype) (const char *symbol_search_name,
126*ef5ccd6cSJohn Marino 					  const char *lookup_name);
127*ef5ccd6cSJohn Marino 
1285796c8dcSSimon Schubert /* Structure tying together assorted information about a language.  */
1295796c8dcSSimon Schubert 
1305796c8dcSSimon Schubert struct language_defn
1315796c8dcSSimon Schubert   {
132c50c785cSJohn Marino     /* Name of the language.  */
1335796c8dcSSimon Schubert 
1345796c8dcSSimon Schubert     char *la_name;
1355796c8dcSSimon Schubert 
136c50c785cSJohn Marino     /* its symtab language-enum (defs.h).  */
1375796c8dcSSimon Schubert 
1385796c8dcSSimon Schubert     enum language la_language;
1395796c8dcSSimon Schubert 
140c50c785cSJohn Marino     /* Default range checking.  */
1415796c8dcSSimon Schubert 
1425796c8dcSSimon Schubert     enum range_check la_range_check;
1435796c8dcSSimon Schubert 
144c50c785cSJohn Marino     /* Default case sensitivity.  */
1455796c8dcSSimon Schubert     enum case_sensitivity la_case_sensitivity;
1465796c8dcSSimon Schubert 
147c50c785cSJohn Marino     /* Multi-dimensional array ordering.  */
1485796c8dcSSimon Schubert     enum array_ordering la_array_ordering;
1495796c8dcSSimon Schubert 
1505796c8dcSSimon Schubert     /* Style of macro expansion, if any, supported by this language.  */
1515796c8dcSSimon Schubert     enum macro_expansion la_macro_expansion;
1525796c8dcSSimon Schubert 
1535796c8dcSSimon Schubert     /* Definitions related to expression printing, prefixifying, and
154c50c785cSJohn Marino        dumping.  */
1555796c8dcSSimon Schubert 
1565796c8dcSSimon Schubert     const struct exp_descriptor *la_exp_desc;
1575796c8dcSSimon Schubert 
1585796c8dcSSimon Schubert     /* Parser function.  */
1595796c8dcSSimon Schubert 
1605796c8dcSSimon Schubert     int (*la_parser) (void);
1615796c8dcSSimon Schubert 
162c50c785cSJohn Marino     /* Parser error function.  */
1635796c8dcSSimon Schubert 
1645796c8dcSSimon Schubert     void (*la_error) (char *);
1655796c8dcSSimon Schubert 
1665796c8dcSSimon Schubert     /* Given an expression *EXPP created by prefixifying the result of
1675796c8dcSSimon Schubert        la_parser, perform any remaining processing necessary to complete
1685796c8dcSSimon Schubert        its translation.  *EXPP may change; la_post_parser is responsible
1695796c8dcSSimon Schubert        for releasing its previous contents, if necessary.  If
1705796c8dcSSimon Schubert        VOID_CONTEXT_P, then no value is expected from the expression.  */
1715796c8dcSSimon Schubert 
1725796c8dcSSimon Schubert     void (*la_post_parser) (struct expression ** expp, int void_context_p);
1735796c8dcSSimon Schubert 
174c50c785cSJohn Marino     void (*la_printchar) (int ch, struct type *chtype,
175c50c785cSJohn Marino 			  struct ui_file * stream);
1765796c8dcSSimon Schubert 
1775796c8dcSSimon Schubert     void (*la_printstr) (struct ui_file * stream, struct type *elttype,
1785796c8dcSSimon Schubert 			 const gdb_byte *string, unsigned int length,
179cf7f2e2dSJohn Marino 			 const char *encoding, int force_ellipses,
1805796c8dcSSimon Schubert 			 const struct value_print_options *);
1815796c8dcSSimon Schubert 
1825796c8dcSSimon Schubert     void (*la_emitchar) (int ch, struct type *chtype,
1835796c8dcSSimon Schubert 			 struct ui_file * stream, int quoter);
1845796c8dcSSimon Schubert 
1855796c8dcSSimon Schubert     /* Print a type using syntax appropriate for this language.  */
1865796c8dcSSimon Schubert 
187cf7f2e2dSJohn Marino     void (*la_print_type) (struct type *, const char *, struct ui_file *, int,
188*ef5ccd6cSJohn Marino 			   int, const struct type_print_options *);
1895796c8dcSSimon Schubert 
1905796c8dcSSimon Schubert     /* Print a typedef using syntax appropriate for this language.
1915796c8dcSSimon Schubert        TYPE is the underlying type.  NEW_SYMBOL is the symbol naming
1925796c8dcSSimon Schubert        the type.  STREAM is the output stream on which to print.  */
1935796c8dcSSimon Schubert 
1945796c8dcSSimon Schubert     void (*la_print_typedef) (struct type *type, struct symbol *new_symbol,
1955796c8dcSSimon Schubert 			      struct ui_file *stream);
1965796c8dcSSimon Schubert 
197cf7f2e2dSJohn Marino     /* Print a value using syntax appropriate for this language.
1985796c8dcSSimon Schubert 
199cf7f2e2dSJohn Marino        TYPE is the type of the sub-object to be printed.
200cf7f2e2dSJohn Marino 
201cf7f2e2dSJohn Marino        CONTENTS holds the bits of the value.  This holds the entire
202cf7f2e2dSJohn Marino        enclosing object.
203cf7f2e2dSJohn Marino 
204cf7f2e2dSJohn Marino        EMBEDDED_OFFSET is the offset into the outermost object of the
205cf7f2e2dSJohn Marino        sub-object represented by TYPE.  This is the object which this
206cf7f2e2dSJohn Marino        call should print.  Note that the enclosing type is not
207cf7f2e2dSJohn Marino        available.
208cf7f2e2dSJohn Marino 
209cf7f2e2dSJohn Marino        ADDRESS is the address in the inferior of the enclosing object.
210cf7f2e2dSJohn Marino 
211cf7f2e2dSJohn Marino        STREAM is the stream on which the value is to be printed.
212cf7f2e2dSJohn Marino 
213cf7f2e2dSJohn Marino        RECURSE is the recursion depth.  It is zero-based.
214cf7f2e2dSJohn Marino 
215cf7f2e2dSJohn Marino        OPTIONS are the formatting options to be used when
216cf7f2e2dSJohn Marino        printing.  */
217cf7f2e2dSJohn Marino 
218*ef5ccd6cSJohn Marino     void (*la_val_print) (struct type *type,
219cf7f2e2dSJohn Marino 			  const gdb_byte *contents,
220cf7f2e2dSJohn Marino 			  int embedded_offset, CORE_ADDR address,
221cf7f2e2dSJohn Marino 			  struct ui_file *stream, int recurse,
222cf7f2e2dSJohn Marino 			  const struct value *val,
223cf7f2e2dSJohn Marino 			  const struct value_print_options *options);
2245796c8dcSSimon Schubert 
2255796c8dcSSimon Schubert     /* Print a top-level value using syntax appropriate for this language.  */
2265796c8dcSSimon Schubert 
227*ef5ccd6cSJohn Marino     void (*la_value_print) (struct value *, struct ui_file *,
2285796c8dcSSimon Schubert 			    const struct value_print_options *);
2295796c8dcSSimon Schubert 
230*ef5ccd6cSJohn Marino     /* Given a symbol VAR, and a stack frame id FRAME, read the value
231*ef5ccd6cSJohn Marino        of the variable an return (pointer to a) struct value containing
232*ef5ccd6cSJohn Marino        the value.
233*ef5ccd6cSJohn Marino 
234*ef5ccd6cSJohn Marino        Throw an error if the variable cannot be found.  */
235*ef5ccd6cSJohn Marino 
236*ef5ccd6cSJohn Marino     struct value *(*la_read_var_value) (struct symbol *var,
237*ef5ccd6cSJohn Marino 					struct frame_info *frame);
238*ef5ccd6cSJohn Marino 
2395796c8dcSSimon Schubert     /* PC is possibly an unknown languages trampoline.
2405796c8dcSSimon Schubert        If that PC falls in a trampoline belonging to this language,
2415796c8dcSSimon Schubert        return the address of the first pc in the real function, or 0
2425796c8dcSSimon Schubert        if it isn't a language tramp for this language.  */
2435796c8dcSSimon Schubert     CORE_ADDR (*skip_trampoline) (struct frame_info *, CORE_ADDR);
2445796c8dcSSimon Schubert 
2455796c8dcSSimon Schubert     /* Now come some hooks for lookup_symbol.  */
2465796c8dcSSimon Schubert 
2475796c8dcSSimon Schubert     /* If this is non-NULL, specifies the name that of the implicit
2485796c8dcSSimon Schubert        local variable that refers to the current object instance.  */
2495796c8dcSSimon Schubert 
2505796c8dcSSimon Schubert     char *la_name_of_this;
2515796c8dcSSimon Schubert 
2525796c8dcSSimon Schubert     /* This is a function that lookup_symbol will call when it gets to
2535796c8dcSSimon Schubert        the part of symbol lookup where C looks up static and global
2545796c8dcSSimon Schubert        variables.  */
2555796c8dcSSimon Schubert 
2565796c8dcSSimon Schubert     struct symbol *(*la_lookup_symbol_nonlocal) (const char *,
2575796c8dcSSimon Schubert 						 const struct block *,
2585796c8dcSSimon Schubert 						 const domain_enum);
2595796c8dcSSimon Schubert 
2605796c8dcSSimon Schubert     /* Find the definition of the type with the given name.  */
2615796c8dcSSimon Schubert     struct type *(*la_lookup_transparent_type) (const char *);
2625796c8dcSSimon Schubert 
2635796c8dcSSimon Schubert     /* Return demangled language symbol, or NULL.  */
2645796c8dcSSimon Schubert     char *(*la_demangle) (const char *mangled, int options);
2655796c8dcSSimon Schubert 
2665796c8dcSSimon Schubert     /* Return class name of a mangled method name or NULL.  */
2675796c8dcSSimon Schubert     char *(*la_class_name_from_physname) (const char *physname);
2685796c8dcSSimon Schubert 
269c50c785cSJohn Marino     /* Table for printing expressions.  */
2705796c8dcSSimon Schubert 
2715796c8dcSSimon Schubert     const struct op_print *la_op_print_tab;
2725796c8dcSSimon Schubert 
2735796c8dcSSimon Schubert     /* Zero if the language has first-class arrays.  True if there are no
2745796c8dcSSimon Schubert        array values, and array objects decay to pointers, as in C.  */
2755796c8dcSSimon Schubert 
2765796c8dcSSimon Schubert     char c_style_arrays;
2775796c8dcSSimon Schubert 
2785796c8dcSSimon Schubert     /* Index to use for extracting the first element of a string.  */
2795796c8dcSSimon Schubert     char string_lower_bound;
2805796c8dcSSimon Schubert 
2815796c8dcSSimon Schubert     /* The list of characters forming word boundaries.  */
2825796c8dcSSimon Schubert     char *(*la_word_break_characters) (void);
2835796c8dcSSimon Schubert 
284*ef5ccd6cSJohn Marino     /* Should return a vector of all symbols which are possible
285*ef5ccd6cSJohn Marino        completions for TEXT.  WORD is the entire command on which the
286*ef5ccd6cSJohn Marino        completion is being made.  If CODE is TYPE_CODE_UNDEF, then all
287*ef5ccd6cSJohn Marino        symbols should be examined; otherwise, only STRUCT_DOMAIN
288*ef5ccd6cSJohn Marino        symbols whose type has a code of CODE should be matched.  */
289*ef5ccd6cSJohn Marino     VEC (char_ptr) *(*la_make_symbol_completion_list) (char *text, char *word,
290*ef5ccd6cSJohn Marino 						       enum type_code code);
2915796c8dcSSimon Schubert 
2925796c8dcSSimon Schubert     /* The per-architecture (OS/ABI) language information.  */
2935796c8dcSSimon Schubert     void (*la_language_arch_info) (struct gdbarch *,
2945796c8dcSSimon Schubert 				   struct language_arch_info *);
2955796c8dcSSimon Schubert 
2965796c8dcSSimon Schubert     /* Print the index of an element of an array.  */
2975796c8dcSSimon Schubert     void (*la_print_array_index) (struct value *index_value,
2985796c8dcSSimon Schubert                                   struct ui_file *stream,
2995796c8dcSSimon Schubert                                   const struct value_print_options *options);
3005796c8dcSSimon Schubert 
3015796c8dcSSimon Schubert     /* Return non-zero if TYPE should be passed (and returned) by
3025796c8dcSSimon Schubert        reference at the language level.  */
3035796c8dcSSimon Schubert     int (*la_pass_by_reference) (struct type *type);
3045796c8dcSSimon Schubert 
3055796c8dcSSimon Schubert     /* Obtain a string from the inferior, storing it in a newly allocated
3065796c8dcSSimon Schubert        buffer in BUFFER, which should be freed by the caller.  If the
3075796c8dcSSimon Schubert        in- and out-parameter *LENGTH is specified at -1, the string is
3085796c8dcSSimon Schubert        read until a null character of the appropriate width is found -
3095796c8dcSSimon Schubert        otherwise the string is read to the length of characters specified.
3105796c8dcSSimon Schubert        On completion, *LENGTH will hold the size of the string in characters.
3115796c8dcSSimon Schubert        If a *LENGTH of -1 was specified it will count only actual
3125796c8dcSSimon Schubert        characters, excluding any eventual terminating null character.
3135796c8dcSSimon Schubert        Otherwise *LENGTH will include all characters - including any nulls.
3145796c8dcSSimon Schubert        CHARSET will hold the encoding used in the string.  */
3155796c8dcSSimon Schubert     void (*la_get_string) (struct value *value, gdb_byte **buffer, int *length,
316cf7f2e2dSJohn Marino 			   struct type **chartype, const char **charset);
3175796c8dcSSimon Schubert 
318*ef5ccd6cSJohn Marino     /* Return a pointer to the function that should be used to match
319*ef5ccd6cSJohn Marino        a symbol name against LOOKUP_NAME. This is mostly for languages
320*ef5ccd6cSJohn Marino        such as Ada where the matching algorithm depends on LOOKUP_NAME.
321a45ae5f8SJohn Marino 
322*ef5ccd6cSJohn Marino        This field may be NULL, in which case strcmp_iw will be used
323*ef5ccd6cSJohn Marino        to perform the matching.  */
324*ef5ccd6cSJohn Marino     symbol_name_cmp_ftype (*la_get_symbol_name_cmp) (const char *lookup_name);
325a45ae5f8SJohn Marino 
326a45ae5f8SJohn Marino     /* Find all symbols in the current program space matching NAME in
327a45ae5f8SJohn Marino        DOMAIN, according to this language's rules.
328a45ae5f8SJohn Marino 
329*ef5ccd6cSJohn Marino        The search is done in BLOCK only.
330*ef5ccd6cSJohn Marino        The caller is responsible for iterating up through superblocks
331*ef5ccd6cSJohn Marino        if desired.
332a45ae5f8SJohn Marino 
333a45ae5f8SJohn Marino        For each one, call CALLBACK with the symbol and the DATA
334a45ae5f8SJohn Marino        argument.  If CALLBACK returns zero, the iteration ends at that
335a45ae5f8SJohn Marino        point.
336a45ae5f8SJohn Marino 
337*ef5ccd6cSJohn Marino        This field may not be NULL.  If the language does not need any
338*ef5ccd6cSJohn Marino        special processing here, 'iterate_over_symbols' should be
339*ef5ccd6cSJohn Marino        used as the definition.  */
340a45ae5f8SJohn Marino     void (*la_iterate_over_symbols) (const struct block *block,
341a45ae5f8SJohn Marino 				     const char *name,
342a45ae5f8SJohn Marino 				     domain_enum domain,
343*ef5ccd6cSJohn Marino 				     symbol_found_callback_ftype *callback,
344a45ae5f8SJohn Marino 				     void *data);
345a45ae5f8SJohn Marino 
3465796c8dcSSimon Schubert     /* Add fields above this point, so the magic number is always last.  */
347c50c785cSJohn Marino     /* Magic number for compat checking.  */
3485796c8dcSSimon Schubert 
3495796c8dcSSimon Schubert     long la_magic;
3505796c8dcSSimon Schubert 
3515796c8dcSSimon Schubert   };
3525796c8dcSSimon Schubert 
3535796c8dcSSimon Schubert #define LANG_MAGIC	910823L
3545796c8dcSSimon Schubert 
3555796c8dcSSimon Schubert /* Pointer to the language_defn for our current language.  This pointer
3565796c8dcSSimon Schubert    always points to *some* valid struct; it can be used without checking
3575796c8dcSSimon Schubert    it for validity.
3585796c8dcSSimon Schubert 
3595796c8dcSSimon Schubert    The current language affects expression parsing and evaluation
3605796c8dcSSimon Schubert    (FIXME: it might be cleaner to make the evaluation-related stuff
3615796c8dcSSimon Schubert    separate exp_opcodes for each different set of semantics.  We
3625796c8dcSSimon Schubert    should at least think this through more clearly with respect to
3635796c8dcSSimon Schubert    what happens if the language is changed between parsing and
3645796c8dcSSimon Schubert    evaluation) and printing of things like types and arrays.  It does
3655796c8dcSSimon Schubert    *not* affect symbol-reading-- each source file in a symbol-file has
3665796c8dcSSimon Schubert    its own language and we should keep track of that regardless of the
3675796c8dcSSimon Schubert    language when symbols are read.  If we want some manual setting for
3685796c8dcSSimon Schubert    the language of symbol files (e.g. detecting when ".c" files are
3695796c8dcSSimon Schubert    C++), it should be a separate setting from the current_language.  */
3705796c8dcSSimon Schubert 
3715796c8dcSSimon Schubert extern const struct language_defn *current_language;
3725796c8dcSSimon Schubert 
3735796c8dcSSimon Schubert /* Pointer to the language_defn expected by the user, e.g. the language
3745796c8dcSSimon Schubert    of main(), or the language we last mentioned in a message, or C.  */
3755796c8dcSSimon Schubert 
3765796c8dcSSimon Schubert extern const struct language_defn *expected_language;
3775796c8dcSSimon Schubert 
3785796c8dcSSimon Schubert /* language_mode ==
3795796c8dcSSimon Schubert    language_mode_auto:   current_language automatically set upon selection
3805796c8dcSSimon Schubert    of scope (e.g. stack frame)
3815796c8dcSSimon Schubert    language_mode_manual: current_language set only by user.  */
3825796c8dcSSimon Schubert 
3835796c8dcSSimon Schubert extern enum language_mode
3845796c8dcSSimon Schubert   {
3855796c8dcSSimon Schubert     language_mode_auto, language_mode_manual
3865796c8dcSSimon Schubert   }
3875796c8dcSSimon Schubert language_mode;
3885796c8dcSSimon Schubert 
3895796c8dcSSimon Schubert struct type *language_bool_type (const struct language_defn *l,
3905796c8dcSSimon Schubert 				 struct gdbarch *gdbarch);
3915796c8dcSSimon Schubert 
3925796c8dcSSimon Schubert struct type *language_string_char_type (const struct language_defn *l,
3935796c8dcSSimon Schubert 					struct gdbarch *gdbarch);
3945796c8dcSSimon Schubert 
3955796c8dcSSimon Schubert struct type *language_lookup_primitive_type_by_name (const struct language_defn *l,
3965796c8dcSSimon Schubert 						     struct gdbarch *gdbarch,
3975796c8dcSSimon Schubert 						     const char *name);
3985796c8dcSSimon Schubert 
3995796c8dcSSimon Schubert 
4005796c8dcSSimon Schubert /* These macros define the behaviour of the expression
4015796c8dcSSimon Schubert    evaluator.  */
4025796c8dcSSimon Schubert 
4035796c8dcSSimon Schubert /* Should we range check values against the domain of their type?  */
4045796c8dcSSimon Schubert #define RANGE_CHECK (range_check != range_check_off)
4055796c8dcSSimon Schubert 
406c50c785cSJohn Marino /* "cast" really means conversion.  */
407c50c785cSJohn Marino /* FIXME -- should be a setting in language_defn.  */
408cf7f2e2dSJohn Marino #define CAST_IS_CONVERSION(LANG) ((LANG)->la_language == language_c  || \
409cf7f2e2dSJohn Marino 				  (LANG)->la_language == language_cplus || \
410cf7f2e2dSJohn Marino 				  (LANG)->la_language == language_objc)
4115796c8dcSSimon Schubert 
4125796c8dcSSimon Schubert extern void language_info (int);
4135796c8dcSSimon Schubert 
4145796c8dcSSimon Schubert extern enum language set_language (enum language);
4155796c8dcSSimon Schubert 
4165796c8dcSSimon Schubert 
4175796c8dcSSimon Schubert /* This page contains functions that return things that are
4185796c8dcSSimon Schubert    specific to languages.  Each of these functions is based on
4195796c8dcSSimon Schubert    the current setting of working_lang, which the user sets
4205796c8dcSSimon Schubert    with the "set language" command.  */
4215796c8dcSSimon Schubert 
422*ef5ccd6cSJohn Marino #define LA_PRINT_TYPE(type,varstring,stream,show,level,flags)		\
423*ef5ccd6cSJohn Marino   (current_language->la_print_type(type,varstring,stream,show,level,flags))
4245796c8dcSSimon Schubert 
4255796c8dcSSimon Schubert #define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
4265796c8dcSSimon Schubert   (current_language->la_print_typedef(type,new_symbol,stream))
4275796c8dcSSimon Schubert 
428cf7f2e2dSJohn Marino #define LA_VAL_PRINT(type,valaddr,offset,addr,stream,val,recurse,options) \
4295796c8dcSSimon Schubert   (current_language->la_val_print(type,valaddr,offset,addr,stream, \
430cf7f2e2dSJohn Marino 				  val,recurse,options))
4315796c8dcSSimon Schubert #define LA_VALUE_PRINT(val,stream,options) \
4325796c8dcSSimon Schubert   (current_language->la_value_print(val,stream,options))
4335796c8dcSSimon Schubert 
4345796c8dcSSimon Schubert #define LA_PRINT_CHAR(ch, type, stream) \
4355796c8dcSSimon Schubert   (current_language->la_printchar(ch, type, stream))
436cf7f2e2dSJohn Marino #define LA_PRINT_STRING(stream, elttype, string, length, encoding, force_ellipses, options) \
4375796c8dcSSimon Schubert   (current_language->la_printstr(stream, elttype, string, length, \
438cf7f2e2dSJohn Marino 				 encoding, force_ellipses,options))
4395796c8dcSSimon Schubert #define LA_EMIT_CHAR(ch, type, stream, quoter) \
4405796c8dcSSimon Schubert   (current_language->la_emitchar(ch, type, stream, quoter))
441cf7f2e2dSJohn Marino #define LA_GET_STRING(value, buffer, length, chartype, encoding) \
442cf7f2e2dSJohn Marino   (current_language->la_get_string(value, buffer, length, chartype, encoding))
4435796c8dcSSimon Schubert 
444c50c785cSJohn Marino #define LA_PRINT_ARRAY_INDEX(index_value, stream, options) \
4455796c8dcSSimon Schubert   (current_language->la_print_array_index(index_value, stream, options))
4465796c8dcSSimon Schubert 
447a45ae5f8SJohn Marino #define LA_ITERATE_OVER_SYMBOLS(BLOCK, NAME, DOMAIN, CALLBACK, DATA) \
448a45ae5f8SJohn Marino   (current_language->la_iterate_over_symbols (BLOCK, NAME, DOMAIN, CALLBACK, \
449a45ae5f8SJohn Marino 					      DATA))
450a45ae5f8SJohn Marino 
4515796c8dcSSimon Schubert /* Test a character to decide whether it can be printed in literal form
4525796c8dcSSimon Schubert    or needs to be printed in another representation.  For example,
4535796c8dcSSimon Schubert    in C the literal form of the character with octal value 141 is 'a'
4545796c8dcSSimon Schubert    and the "other representation" is '\141'.  The "other representation"
4555796c8dcSSimon Schubert    is program language dependent.  */
4565796c8dcSSimon Schubert 
4575796c8dcSSimon Schubert #define PRINT_LITERAL_FORM(c)		\
4585796c8dcSSimon Schubert   ((c) >= 0x20				\
4595796c8dcSSimon Schubert    && ((c) < 0x7F || (c) >= 0xA0)	\
4605796c8dcSSimon Schubert    && (!sevenbit_strings || (c) < 0x80))
4615796c8dcSSimon Schubert 
4625796c8dcSSimon Schubert /* Type predicates */
4635796c8dcSSimon Schubert 
4645796c8dcSSimon Schubert extern int pointer_type (struct type *);
4655796c8dcSSimon Schubert 
466c50c785cSJohn Marino /* Checks Binary and Unary operations for semantic type correctness.  */
467c50c785cSJohn Marino /* FIXME:  Does not appear to be used.  */
4685796c8dcSSimon Schubert #define unop_type_check(v,o) binop_type_check((v),NULL,(o))
4695796c8dcSSimon Schubert 
4705796c8dcSSimon Schubert extern void binop_type_check (struct value *, struct value *, int);
4715796c8dcSSimon Schubert 
4725796c8dcSSimon Schubert /* Error messages */
4735796c8dcSSimon Schubert 
474cf7f2e2dSJohn Marino extern void range_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
4755796c8dcSSimon Schubert 
4765796c8dcSSimon Schubert /* Data:  Does this value represent "truth" to the current language?  */
4775796c8dcSSimon Schubert 
4785796c8dcSSimon Schubert extern int value_true (struct value *);
4795796c8dcSSimon Schubert 
4805796c8dcSSimon Schubert /* Misc:  The string representing a particular enum language.  */
4815796c8dcSSimon Schubert 
4825796c8dcSSimon Schubert extern enum language language_enum (char *str);
4835796c8dcSSimon Schubert 
4845796c8dcSSimon Schubert extern const struct language_defn *language_def (enum language);
4855796c8dcSSimon Schubert 
4865796c8dcSSimon Schubert extern char *language_str (enum language);
4875796c8dcSSimon Schubert 
4885796c8dcSSimon Schubert /* Add a language to the set known by GDB (at initialization time).  */
4895796c8dcSSimon Schubert 
4905796c8dcSSimon Schubert extern void add_language (const struct language_defn *);
4915796c8dcSSimon Schubert 
4925796c8dcSSimon Schubert extern enum language get_frame_language (void);	/* In stack.c */
4935796c8dcSSimon Schubert 
4945796c8dcSSimon Schubert /* Check for a language-specific trampoline.  */
4955796c8dcSSimon Schubert 
4965796c8dcSSimon Schubert extern CORE_ADDR skip_language_trampoline (struct frame_info *, CORE_ADDR pc);
4975796c8dcSSimon Schubert 
4985796c8dcSSimon Schubert /* Return demangled language symbol, or NULL.  */
4995796c8dcSSimon Schubert extern char *language_demangle (const struct language_defn *current_language,
5005796c8dcSSimon Schubert 				const char *mangled, int options);
5015796c8dcSSimon Schubert 
5025796c8dcSSimon Schubert /* Return class name from physname, or NULL.  */
5035796c8dcSSimon Schubert extern char *language_class_name_from_physname (const struct language_defn *,
5045796c8dcSSimon Schubert 					        const char *physname);
5055796c8dcSSimon Schubert 
5065796c8dcSSimon Schubert /* Splitting strings into words.  */
5075796c8dcSSimon Schubert extern char *default_word_break_characters (void);
5085796c8dcSSimon Schubert 
5095796c8dcSSimon Schubert /* Print the index of an array element using the C99 syntax.  */
5105796c8dcSSimon Schubert extern void default_print_array_index (struct value *index_value,
5115796c8dcSSimon Schubert                                        struct ui_file *stream,
5125796c8dcSSimon Schubert 				       const struct value_print_options *options);
5135796c8dcSSimon Schubert 
5145796c8dcSSimon Schubert /* Return non-zero if TYPE should be passed (and returned) by
5155796c8dcSSimon Schubert    reference at the language level.  */
5165796c8dcSSimon Schubert int language_pass_by_reference (struct type *type);
5175796c8dcSSimon Schubert 
5185796c8dcSSimon Schubert /* Return zero; by default, types are passed by value at the language
5195796c8dcSSimon Schubert    level.  The target ABI may pass or return some structs by reference
5205796c8dcSSimon Schubert    independent of this.  */
5215796c8dcSSimon Schubert int default_pass_by_reference (struct type *type);
5225796c8dcSSimon Schubert 
5235796c8dcSSimon Schubert /* The default implementation of la_print_typedef.  */
5245796c8dcSSimon Schubert void default_print_typedef (struct type *type, struct symbol *new_symbol,
5255796c8dcSSimon Schubert 			    struct ui_file *stream);
5265796c8dcSSimon Schubert 
5275796c8dcSSimon Schubert void default_get_string (struct value *value, gdb_byte **buffer, int *length,
528cf7f2e2dSJohn Marino 			 struct type **char_type, const char **charset);
5295796c8dcSSimon Schubert 
5305796c8dcSSimon Schubert void c_get_string (struct value *value, gdb_byte **buffer, int *length,
531cf7f2e2dSJohn Marino 		   struct type **char_type, const char **charset);
5325796c8dcSSimon Schubert 
5335796c8dcSSimon Schubert #endif /* defined (LANGUAGE_H) */
534