15796c8dcSSimon Schubert /* Source-language-related definitions for GDB. 25796c8dcSSimon Schubert 35796c8dcSSimon Schubert Copyright (C) 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2003, 2004, 4*cf7f2e2dSJohn Marino 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 55796c8dcSSimon Schubert 65796c8dcSSimon Schubert Contributed by the Department of Computer Science at the State University 75796c8dcSSimon Schubert of New York at Buffalo. 85796c8dcSSimon Schubert 95796c8dcSSimon Schubert This file is part of GDB. 105796c8dcSSimon Schubert 115796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 125796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 135796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 145796c8dcSSimon Schubert (at your option) any later version. 155796c8dcSSimon Schubert 165796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 175796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 185796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 195796c8dcSSimon Schubert GNU General Public License for more details. 205796c8dcSSimon Schubert 215796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 225796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 235796c8dcSSimon Schubert 245796c8dcSSimon Schubert #if !defined (LANGUAGE_H) 255796c8dcSSimon Schubert #define LANGUAGE_H 1 265796c8dcSSimon Schubert 275796c8dcSSimon Schubert /* Forward decls for prototypes */ 285796c8dcSSimon Schubert struct value; 295796c8dcSSimon Schubert struct objfile; 305796c8dcSSimon Schubert struct frame_info; 315796c8dcSSimon Schubert struct expression; 325796c8dcSSimon Schubert struct ui_file; 335796c8dcSSimon Schubert struct value_print_options; 345796c8dcSSimon Schubert 355796c8dcSSimon Schubert #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 /* type_mode == 595796c8dcSSimon Schubert type_mode_auto: type_check set automatically to default of language 605796c8dcSSimon Schubert type_mode_manual: type_check set manually by user. */ 615796c8dcSSimon Schubert 625796c8dcSSimon Schubert extern enum type_mode 635796c8dcSSimon Schubert { 645796c8dcSSimon Schubert type_mode_auto, type_mode_manual 655796c8dcSSimon Schubert } 665796c8dcSSimon Schubert type_mode; 675796c8dcSSimon Schubert 685796c8dcSSimon Schubert /* type_check == 695796c8dcSSimon Schubert type_check_on: Types are checked in GDB expressions, producing errors. 705796c8dcSSimon Schubert type_check_warn: Types are checked, producing warnings. 715796c8dcSSimon Schubert type_check_off: Types are not checked in GDB expressions. */ 725796c8dcSSimon Schubert 735796c8dcSSimon Schubert extern enum type_check 745796c8dcSSimon Schubert { 755796c8dcSSimon Schubert type_check_off, type_check_warn, type_check_on 765796c8dcSSimon Schubert } 775796c8dcSSimon Schubert type_check; 785796c8dcSSimon Schubert 795796c8dcSSimon Schubert /* case_mode == 805796c8dcSSimon Schubert case_mode_auto: case_sensitivity set upon selection of scope 815796c8dcSSimon Schubert case_mode_manual: case_sensitivity set only by user. */ 825796c8dcSSimon Schubert 835796c8dcSSimon Schubert extern enum case_mode 845796c8dcSSimon Schubert { 855796c8dcSSimon Schubert case_mode_auto, case_mode_manual 865796c8dcSSimon Schubert } 875796c8dcSSimon Schubert case_mode; 885796c8dcSSimon Schubert 895796c8dcSSimon Schubert /* array_ordering == 905796c8dcSSimon Schubert array_row_major: Arrays are in row major order 915796c8dcSSimon Schubert array_column_major: Arrays are in column major order.*/ 925796c8dcSSimon Schubert 935796c8dcSSimon Schubert extern enum array_ordering 945796c8dcSSimon Schubert { 955796c8dcSSimon Schubert array_row_major, array_column_major 965796c8dcSSimon Schubert } 975796c8dcSSimon Schubert array_ordering; 985796c8dcSSimon Schubert 995796c8dcSSimon Schubert 1005796c8dcSSimon Schubert /* case_sensitivity == 1015796c8dcSSimon Schubert case_sensitive_on: Case sensitivity in name matching is used 1025796c8dcSSimon Schubert case_sensitive_off: Case sensitivity in name matching is not used */ 1035796c8dcSSimon Schubert 1045796c8dcSSimon Schubert extern enum case_sensitivity 1055796c8dcSSimon Schubert { 1065796c8dcSSimon Schubert case_sensitive_on, case_sensitive_off 1075796c8dcSSimon Schubert } 1085796c8dcSSimon Schubert case_sensitivity; 1095796c8dcSSimon Schubert 1105796c8dcSSimon Schubert 1115796c8dcSSimon Schubert /* macro_expansion == 1125796c8dcSSimon Schubert macro_expansion_no: No macro expansion is available 1135796c8dcSSimon Schubert macro_expansion_c: C-like macro expansion is available */ 1145796c8dcSSimon Schubert 1155796c8dcSSimon Schubert enum macro_expansion 1165796c8dcSSimon Schubert { 1175796c8dcSSimon Schubert macro_expansion_no, macro_expansion_c 1185796c8dcSSimon Schubert }; 1195796c8dcSSimon Schubert 1205796c8dcSSimon Schubert 1215796c8dcSSimon Schubert /* Per architecture (OS/ABI) language information. */ 1225796c8dcSSimon Schubert 1235796c8dcSSimon Schubert struct language_arch_info 1245796c8dcSSimon Schubert { 1255796c8dcSSimon Schubert /* Its primitive types. This is a vector ended by a NULL pointer. 1265796c8dcSSimon Schubert These types can be specified by name in parsing types in 1275796c8dcSSimon Schubert expressions, regardless of whether the program being debugged 1285796c8dcSSimon Schubert actually defines such a type. */ 1295796c8dcSSimon Schubert struct type **primitive_type_vector; 1305796c8dcSSimon Schubert /* Type of elements of strings. */ 1315796c8dcSSimon Schubert struct type *string_char_type; 1325796c8dcSSimon Schubert 1335796c8dcSSimon Schubert /* Symbol name of type to use as boolean type, if defined. */ 1345796c8dcSSimon Schubert const char *bool_type_symbol; 1355796c8dcSSimon Schubert /* Otherwise, this is the default boolean builtin type. */ 1365796c8dcSSimon Schubert struct type *bool_type_default; 1375796c8dcSSimon Schubert }; 1385796c8dcSSimon Schubert 1395796c8dcSSimon Schubert /* Structure tying together assorted information about a language. */ 1405796c8dcSSimon Schubert 1415796c8dcSSimon Schubert struct language_defn 1425796c8dcSSimon Schubert { 1435796c8dcSSimon Schubert /* Name of the language */ 1445796c8dcSSimon Schubert 1455796c8dcSSimon Schubert char *la_name; 1465796c8dcSSimon Schubert 1475796c8dcSSimon Schubert /* its symtab language-enum (defs.h) */ 1485796c8dcSSimon Schubert 1495796c8dcSSimon Schubert enum language la_language; 1505796c8dcSSimon Schubert 1515796c8dcSSimon Schubert /* Default range checking */ 1525796c8dcSSimon Schubert 1535796c8dcSSimon Schubert enum range_check la_range_check; 1545796c8dcSSimon Schubert 1555796c8dcSSimon Schubert /* Default type checking */ 1565796c8dcSSimon Schubert 1575796c8dcSSimon Schubert enum type_check la_type_check; 1585796c8dcSSimon Schubert 1595796c8dcSSimon Schubert /* Default case sensitivity */ 1605796c8dcSSimon Schubert enum case_sensitivity la_case_sensitivity; 1615796c8dcSSimon Schubert 1625796c8dcSSimon Schubert /* Multi-dimensional array ordering */ 1635796c8dcSSimon Schubert enum array_ordering la_array_ordering; 1645796c8dcSSimon Schubert 1655796c8dcSSimon Schubert /* Style of macro expansion, if any, supported by this language. */ 1665796c8dcSSimon Schubert enum macro_expansion la_macro_expansion; 1675796c8dcSSimon Schubert 1685796c8dcSSimon Schubert /* Definitions related to expression printing, prefixifying, and 1695796c8dcSSimon Schubert dumping */ 1705796c8dcSSimon Schubert 1715796c8dcSSimon Schubert const struct exp_descriptor *la_exp_desc; 1725796c8dcSSimon Schubert 1735796c8dcSSimon Schubert /* Parser function. */ 1745796c8dcSSimon Schubert 1755796c8dcSSimon Schubert int (*la_parser) (void); 1765796c8dcSSimon Schubert 1775796c8dcSSimon Schubert /* Parser error function */ 1785796c8dcSSimon Schubert 1795796c8dcSSimon Schubert void (*la_error) (char *); 1805796c8dcSSimon Schubert 1815796c8dcSSimon Schubert /* Given an expression *EXPP created by prefixifying the result of 1825796c8dcSSimon Schubert la_parser, perform any remaining processing necessary to complete 1835796c8dcSSimon Schubert its translation. *EXPP may change; la_post_parser is responsible 1845796c8dcSSimon Schubert for releasing its previous contents, if necessary. If 1855796c8dcSSimon Schubert VOID_CONTEXT_P, then no value is expected from the expression. */ 1865796c8dcSSimon Schubert 1875796c8dcSSimon Schubert void (*la_post_parser) (struct expression ** expp, int void_context_p); 1885796c8dcSSimon Schubert 1895796c8dcSSimon Schubert void (*la_printchar) (int ch, struct type *chtype, struct ui_file * stream); 1905796c8dcSSimon Schubert 1915796c8dcSSimon Schubert void (*la_printstr) (struct ui_file * stream, struct type *elttype, 1925796c8dcSSimon Schubert const gdb_byte *string, unsigned int length, 193*cf7f2e2dSJohn Marino const char *encoding, int force_ellipses, 1945796c8dcSSimon Schubert const struct value_print_options *); 1955796c8dcSSimon Schubert 1965796c8dcSSimon Schubert void (*la_emitchar) (int ch, struct type *chtype, 1975796c8dcSSimon Schubert struct ui_file * stream, int quoter); 1985796c8dcSSimon Schubert 1995796c8dcSSimon Schubert /* Print a type using syntax appropriate for this language. */ 2005796c8dcSSimon Schubert 201*cf7f2e2dSJohn Marino void (*la_print_type) (struct type *, const char *, struct ui_file *, int, 2025796c8dcSSimon Schubert int); 2035796c8dcSSimon Schubert 2045796c8dcSSimon Schubert /* Print a typedef using syntax appropriate for this language. 2055796c8dcSSimon Schubert TYPE is the underlying type. NEW_SYMBOL is the symbol naming 2065796c8dcSSimon Schubert the type. STREAM is the output stream on which to print. */ 2075796c8dcSSimon Schubert 2085796c8dcSSimon Schubert void (*la_print_typedef) (struct type *type, struct symbol *new_symbol, 2095796c8dcSSimon Schubert struct ui_file *stream); 2105796c8dcSSimon Schubert 211*cf7f2e2dSJohn Marino /* Print a value using syntax appropriate for this language. 2125796c8dcSSimon Schubert 213*cf7f2e2dSJohn Marino TYPE is the type of the sub-object to be printed. 214*cf7f2e2dSJohn Marino 215*cf7f2e2dSJohn Marino CONTENTS holds the bits of the value. This holds the entire 216*cf7f2e2dSJohn Marino enclosing object. 217*cf7f2e2dSJohn Marino 218*cf7f2e2dSJohn Marino EMBEDDED_OFFSET is the offset into the outermost object of the 219*cf7f2e2dSJohn Marino sub-object represented by TYPE. This is the object which this 220*cf7f2e2dSJohn Marino call should print. Note that the enclosing type is not 221*cf7f2e2dSJohn Marino available. 222*cf7f2e2dSJohn Marino 223*cf7f2e2dSJohn Marino ADDRESS is the address in the inferior of the enclosing object. 224*cf7f2e2dSJohn Marino 225*cf7f2e2dSJohn Marino STREAM is the stream on which the value is to be printed. 226*cf7f2e2dSJohn Marino 227*cf7f2e2dSJohn Marino RECURSE is the recursion depth. It is zero-based. 228*cf7f2e2dSJohn Marino 229*cf7f2e2dSJohn Marino OPTIONS are the formatting options to be used when 230*cf7f2e2dSJohn Marino printing. */ 231*cf7f2e2dSJohn Marino 232*cf7f2e2dSJohn Marino int (*la_val_print) (struct type *type, 233*cf7f2e2dSJohn Marino const gdb_byte *contents, 234*cf7f2e2dSJohn Marino int embedded_offset, CORE_ADDR address, 235*cf7f2e2dSJohn Marino struct ui_file *stream, int recurse, 236*cf7f2e2dSJohn Marino const struct value *val, 237*cf7f2e2dSJohn Marino const struct value_print_options *options); 2385796c8dcSSimon Schubert 2395796c8dcSSimon Schubert /* Print a top-level value using syntax appropriate for this language. */ 2405796c8dcSSimon Schubert 2415796c8dcSSimon Schubert int (*la_value_print) (struct value *, struct ui_file *, 2425796c8dcSSimon Schubert const struct value_print_options *); 2435796c8dcSSimon Schubert 2445796c8dcSSimon Schubert /* PC is possibly an unknown languages trampoline. 2455796c8dcSSimon Schubert If that PC falls in a trampoline belonging to this language, 2465796c8dcSSimon Schubert return the address of the first pc in the real function, or 0 2475796c8dcSSimon Schubert if it isn't a language tramp for this language. */ 2485796c8dcSSimon Schubert CORE_ADDR (*skip_trampoline) (struct frame_info *, CORE_ADDR); 2495796c8dcSSimon Schubert 2505796c8dcSSimon Schubert /* Now come some hooks for lookup_symbol. */ 2515796c8dcSSimon Schubert 2525796c8dcSSimon Schubert /* If this is non-NULL, specifies the name that of the implicit 2535796c8dcSSimon Schubert local variable that refers to the current object instance. */ 2545796c8dcSSimon Schubert 2555796c8dcSSimon Schubert char *la_name_of_this; 2565796c8dcSSimon Schubert 2575796c8dcSSimon Schubert /* This is a function that lookup_symbol will call when it gets to 2585796c8dcSSimon Schubert the part of symbol lookup where C looks up static and global 2595796c8dcSSimon Schubert variables. */ 2605796c8dcSSimon Schubert 2615796c8dcSSimon Schubert struct symbol *(*la_lookup_symbol_nonlocal) (const char *, 2625796c8dcSSimon Schubert const struct block *, 2635796c8dcSSimon Schubert const domain_enum); 2645796c8dcSSimon Schubert 2655796c8dcSSimon Schubert /* Find the definition of the type with the given name. */ 2665796c8dcSSimon Schubert struct type *(*la_lookup_transparent_type) (const char *); 2675796c8dcSSimon Schubert 2685796c8dcSSimon Schubert /* Return demangled language symbol, or NULL. */ 2695796c8dcSSimon Schubert char *(*la_demangle) (const char *mangled, int options); 2705796c8dcSSimon Schubert 2715796c8dcSSimon Schubert /* Return class name of a mangled method name or NULL. */ 2725796c8dcSSimon Schubert char *(*la_class_name_from_physname) (const char *physname); 2735796c8dcSSimon Schubert 2745796c8dcSSimon Schubert /* Table for printing expressions */ 2755796c8dcSSimon Schubert 2765796c8dcSSimon Schubert const struct op_print *la_op_print_tab; 2775796c8dcSSimon Schubert 2785796c8dcSSimon Schubert /* Zero if the language has first-class arrays. True if there are no 2795796c8dcSSimon Schubert array values, and array objects decay to pointers, as in C. */ 2805796c8dcSSimon Schubert 2815796c8dcSSimon Schubert char c_style_arrays; 2825796c8dcSSimon Schubert 2835796c8dcSSimon Schubert /* Index to use for extracting the first element of a string. */ 2845796c8dcSSimon Schubert char string_lower_bound; 2855796c8dcSSimon Schubert 2865796c8dcSSimon Schubert /* The list of characters forming word boundaries. */ 2875796c8dcSSimon Schubert char *(*la_word_break_characters) (void); 2885796c8dcSSimon Schubert 2895796c8dcSSimon Schubert /* Should return a NULL terminated array of all symbols which 2905796c8dcSSimon Schubert are possible completions for TEXT. WORD is the entire command 2915796c8dcSSimon Schubert on which the completion is being made. */ 2925796c8dcSSimon Schubert char **(*la_make_symbol_completion_list) (char *text, char *word); 2935796c8dcSSimon Schubert 2945796c8dcSSimon Schubert /* The per-architecture (OS/ABI) language information. */ 2955796c8dcSSimon Schubert void (*la_language_arch_info) (struct gdbarch *, 2965796c8dcSSimon Schubert struct language_arch_info *); 2975796c8dcSSimon Schubert 2985796c8dcSSimon Schubert /* Print the index of an element of an array. */ 2995796c8dcSSimon Schubert void (*la_print_array_index) (struct value *index_value, 3005796c8dcSSimon Schubert struct ui_file *stream, 3015796c8dcSSimon Schubert const struct value_print_options *options); 3025796c8dcSSimon Schubert 3035796c8dcSSimon Schubert /* Return non-zero if TYPE should be passed (and returned) by 3045796c8dcSSimon Schubert reference at the language level. */ 3055796c8dcSSimon Schubert int (*la_pass_by_reference) (struct type *type); 3065796c8dcSSimon Schubert 3075796c8dcSSimon Schubert /* Obtain a string from the inferior, storing it in a newly allocated 3085796c8dcSSimon Schubert buffer in BUFFER, which should be freed by the caller. If the 3095796c8dcSSimon Schubert in- and out-parameter *LENGTH is specified at -1, the string is 3105796c8dcSSimon Schubert read until a null character of the appropriate width is found - 3115796c8dcSSimon Schubert otherwise the string is read to the length of characters specified. 3125796c8dcSSimon Schubert On completion, *LENGTH will hold the size of the string in characters. 3135796c8dcSSimon Schubert If a *LENGTH of -1 was specified it will count only actual 3145796c8dcSSimon Schubert characters, excluding any eventual terminating null character. 3155796c8dcSSimon Schubert Otherwise *LENGTH will include all characters - including any nulls. 3165796c8dcSSimon Schubert CHARSET will hold the encoding used in the string. */ 3175796c8dcSSimon Schubert void (*la_get_string) (struct value *value, gdb_byte **buffer, int *length, 318*cf7f2e2dSJohn Marino struct type **chartype, const char **charset); 3195796c8dcSSimon Schubert 3205796c8dcSSimon Schubert /* Add fields above this point, so the magic number is always last. */ 3215796c8dcSSimon Schubert /* Magic number for compat checking */ 3225796c8dcSSimon Schubert 3235796c8dcSSimon Schubert long la_magic; 3245796c8dcSSimon Schubert 3255796c8dcSSimon Schubert }; 3265796c8dcSSimon Schubert 3275796c8dcSSimon Schubert #define LANG_MAGIC 910823L 3285796c8dcSSimon Schubert 3295796c8dcSSimon Schubert /* Pointer to the language_defn for our current language. This pointer 3305796c8dcSSimon Schubert always points to *some* valid struct; it can be used without checking 3315796c8dcSSimon Schubert it for validity. 3325796c8dcSSimon Schubert 3335796c8dcSSimon Schubert The current language affects expression parsing and evaluation 3345796c8dcSSimon Schubert (FIXME: it might be cleaner to make the evaluation-related stuff 3355796c8dcSSimon Schubert separate exp_opcodes for each different set of semantics. We 3365796c8dcSSimon Schubert should at least think this through more clearly with respect to 3375796c8dcSSimon Schubert what happens if the language is changed between parsing and 3385796c8dcSSimon Schubert evaluation) and printing of things like types and arrays. It does 3395796c8dcSSimon Schubert *not* affect symbol-reading-- each source file in a symbol-file has 3405796c8dcSSimon Schubert its own language and we should keep track of that regardless of the 3415796c8dcSSimon Schubert language when symbols are read. If we want some manual setting for 3425796c8dcSSimon Schubert the language of symbol files (e.g. detecting when ".c" files are 3435796c8dcSSimon Schubert C++), it should be a separate setting from the current_language. */ 3445796c8dcSSimon Schubert 3455796c8dcSSimon Schubert extern const struct language_defn *current_language; 3465796c8dcSSimon Schubert 3475796c8dcSSimon Schubert /* Pointer to the language_defn expected by the user, e.g. the language 3485796c8dcSSimon Schubert of main(), or the language we last mentioned in a message, or C. */ 3495796c8dcSSimon Schubert 3505796c8dcSSimon Schubert extern const struct language_defn *expected_language; 3515796c8dcSSimon Schubert 3525796c8dcSSimon Schubert /* language_mode == 3535796c8dcSSimon Schubert language_mode_auto: current_language automatically set upon selection 3545796c8dcSSimon Schubert of scope (e.g. stack frame) 3555796c8dcSSimon Schubert language_mode_manual: current_language set only by user. */ 3565796c8dcSSimon Schubert 3575796c8dcSSimon Schubert extern enum language_mode 3585796c8dcSSimon Schubert { 3595796c8dcSSimon Schubert language_mode_auto, language_mode_manual 3605796c8dcSSimon Schubert } 3615796c8dcSSimon Schubert language_mode; 3625796c8dcSSimon Schubert 3635796c8dcSSimon Schubert struct type *language_bool_type (const struct language_defn *l, 3645796c8dcSSimon Schubert struct gdbarch *gdbarch); 3655796c8dcSSimon Schubert 3665796c8dcSSimon Schubert struct type *language_string_char_type (const struct language_defn *l, 3675796c8dcSSimon Schubert struct gdbarch *gdbarch); 3685796c8dcSSimon Schubert 3695796c8dcSSimon Schubert struct type *language_lookup_primitive_type_by_name (const struct language_defn *l, 3705796c8dcSSimon Schubert struct gdbarch *gdbarch, 3715796c8dcSSimon Schubert const char *name); 3725796c8dcSSimon Schubert 3735796c8dcSSimon Schubert 3745796c8dcSSimon Schubert /* These macros define the behaviour of the expression 3755796c8dcSSimon Schubert evaluator. */ 3765796c8dcSSimon Schubert 3775796c8dcSSimon Schubert /* Should we strictly type check expressions? */ 3785796c8dcSSimon Schubert #define STRICT_TYPE (type_check != type_check_off) 3795796c8dcSSimon Schubert 3805796c8dcSSimon Schubert /* Should we range check values against the domain of their type? */ 3815796c8dcSSimon Schubert #define RANGE_CHECK (range_check != range_check_off) 3825796c8dcSSimon Schubert 3835796c8dcSSimon Schubert /* "cast" really means conversion */ 3845796c8dcSSimon Schubert /* FIXME -- should be a setting in language_defn */ 385*cf7f2e2dSJohn Marino #define CAST_IS_CONVERSION(LANG) ((LANG)->la_language == language_c || \ 386*cf7f2e2dSJohn Marino (LANG)->la_language == language_cplus || \ 387*cf7f2e2dSJohn Marino (LANG)->la_language == language_objc) 3885796c8dcSSimon Schubert 3895796c8dcSSimon Schubert extern void language_info (int); 3905796c8dcSSimon Schubert 3915796c8dcSSimon Schubert extern enum language set_language (enum language); 3925796c8dcSSimon Schubert 3935796c8dcSSimon Schubert 3945796c8dcSSimon Schubert /* This page contains functions that return things that are 3955796c8dcSSimon Schubert specific to languages. Each of these functions is based on 3965796c8dcSSimon Schubert the current setting of working_lang, which the user sets 3975796c8dcSSimon Schubert with the "set language" command. */ 3985796c8dcSSimon Schubert 3995796c8dcSSimon Schubert #define LA_PRINT_TYPE(type,varstring,stream,show,level) \ 4005796c8dcSSimon Schubert (current_language->la_print_type(type,varstring,stream,show,level)) 4015796c8dcSSimon Schubert 4025796c8dcSSimon Schubert #define LA_PRINT_TYPEDEF(type,new_symbol,stream) \ 4035796c8dcSSimon Schubert (current_language->la_print_typedef(type,new_symbol,stream)) 4045796c8dcSSimon Schubert 405*cf7f2e2dSJohn Marino #define LA_VAL_PRINT(type,valaddr,offset,addr,stream,val,recurse,options) \ 4065796c8dcSSimon Schubert (current_language->la_val_print(type,valaddr,offset,addr,stream, \ 407*cf7f2e2dSJohn Marino val,recurse,options)) 4085796c8dcSSimon Schubert #define LA_VALUE_PRINT(val,stream,options) \ 4095796c8dcSSimon Schubert (current_language->la_value_print(val,stream,options)) 4105796c8dcSSimon Schubert 4115796c8dcSSimon Schubert #define LA_PRINT_CHAR(ch, type, stream) \ 4125796c8dcSSimon Schubert (current_language->la_printchar(ch, type, stream)) 413*cf7f2e2dSJohn Marino #define LA_PRINT_STRING(stream, elttype, string, length, encoding, force_ellipses,options) \ 4145796c8dcSSimon Schubert (current_language->la_printstr(stream, elttype, string, length, \ 415*cf7f2e2dSJohn Marino encoding, force_ellipses,options)) 4165796c8dcSSimon Schubert #define LA_EMIT_CHAR(ch, type, stream, quoter) \ 4175796c8dcSSimon Schubert (current_language->la_emitchar(ch, type, stream, quoter)) 418*cf7f2e2dSJohn Marino #define LA_GET_STRING(value, buffer, length, chartype, encoding) \ 419*cf7f2e2dSJohn Marino (current_language->la_get_string(value, buffer, length, chartype, encoding)) 4205796c8dcSSimon Schubert 4215796c8dcSSimon Schubert #define LA_PRINT_ARRAY_INDEX(index_value, stream, optins) \ 4225796c8dcSSimon Schubert (current_language->la_print_array_index(index_value, stream, options)) 4235796c8dcSSimon Schubert 4245796c8dcSSimon Schubert /* Test a character to decide whether it can be printed in literal form 4255796c8dcSSimon Schubert or needs to be printed in another representation. For example, 4265796c8dcSSimon Schubert in C the literal form of the character with octal value 141 is 'a' 4275796c8dcSSimon Schubert and the "other representation" is '\141'. The "other representation" 4285796c8dcSSimon Schubert is program language dependent. */ 4295796c8dcSSimon Schubert 4305796c8dcSSimon Schubert #define PRINT_LITERAL_FORM(c) \ 4315796c8dcSSimon Schubert ((c) >= 0x20 \ 4325796c8dcSSimon Schubert && ((c) < 0x7F || (c) >= 0xA0) \ 4335796c8dcSSimon Schubert && (!sevenbit_strings || (c) < 0x80)) 4345796c8dcSSimon Schubert 4355796c8dcSSimon Schubert /* Type predicates */ 4365796c8dcSSimon Schubert 4375796c8dcSSimon Schubert extern int simple_type (struct type *); 4385796c8dcSSimon Schubert 4395796c8dcSSimon Schubert extern int ordered_type (struct type *); 4405796c8dcSSimon Schubert 4415796c8dcSSimon Schubert extern int same_type (struct type *, struct type *); 4425796c8dcSSimon Schubert 4435796c8dcSSimon Schubert extern int integral_type (struct type *); 4445796c8dcSSimon Schubert 4455796c8dcSSimon Schubert extern int numeric_type (struct type *); 4465796c8dcSSimon Schubert 4475796c8dcSSimon Schubert extern int character_type (struct type *); 4485796c8dcSSimon Schubert 4495796c8dcSSimon Schubert extern int boolean_type (struct type *); 4505796c8dcSSimon Schubert 4515796c8dcSSimon Schubert extern int float_type (struct type *); 4525796c8dcSSimon Schubert 4535796c8dcSSimon Schubert extern int pointer_type (struct type *); 4545796c8dcSSimon Schubert 4555796c8dcSSimon Schubert extern int structured_type (struct type *); 4565796c8dcSSimon Schubert 4575796c8dcSSimon Schubert /* Checks Binary and Unary operations for semantic type correctness */ 4585796c8dcSSimon Schubert /* FIXME: Does not appear to be used */ 4595796c8dcSSimon Schubert #define unop_type_check(v,o) binop_type_check((v),NULL,(o)) 4605796c8dcSSimon Schubert 4615796c8dcSSimon Schubert extern void binop_type_check (struct value *, struct value *, int); 4625796c8dcSSimon Schubert 4635796c8dcSSimon Schubert /* Error messages */ 4645796c8dcSSimon Schubert 465*cf7f2e2dSJohn Marino extern void type_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2); 4665796c8dcSSimon Schubert 467*cf7f2e2dSJohn Marino extern void range_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2); 4685796c8dcSSimon Schubert 4695796c8dcSSimon Schubert /* Data: Does this value represent "truth" to the current language? */ 4705796c8dcSSimon Schubert 4715796c8dcSSimon Schubert extern int value_true (struct value *); 4725796c8dcSSimon Schubert 4735796c8dcSSimon Schubert /* Misc: The string representing a particular enum language. */ 4745796c8dcSSimon Schubert 4755796c8dcSSimon Schubert extern enum language language_enum (char *str); 4765796c8dcSSimon Schubert 4775796c8dcSSimon Schubert extern const struct language_defn *language_def (enum language); 4785796c8dcSSimon Schubert 4795796c8dcSSimon Schubert extern char *language_str (enum language); 4805796c8dcSSimon Schubert 4815796c8dcSSimon Schubert /* Add a language to the set known by GDB (at initialization time). */ 4825796c8dcSSimon Schubert 4835796c8dcSSimon Schubert extern void add_language (const struct language_defn *); 4845796c8dcSSimon Schubert 4855796c8dcSSimon Schubert extern enum language get_frame_language (void); /* In stack.c */ 4865796c8dcSSimon Schubert 4875796c8dcSSimon Schubert /* Check for a language-specific trampoline. */ 4885796c8dcSSimon Schubert 4895796c8dcSSimon Schubert extern CORE_ADDR skip_language_trampoline (struct frame_info *, CORE_ADDR pc); 4905796c8dcSSimon Schubert 4915796c8dcSSimon Schubert /* Return demangled language symbol, or NULL. */ 4925796c8dcSSimon Schubert extern char *language_demangle (const struct language_defn *current_language, 4935796c8dcSSimon Schubert const char *mangled, int options); 4945796c8dcSSimon Schubert 4955796c8dcSSimon Schubert /* Return class name from physname, or NULL. */ 4965796c8dcSSimon Schubert extern char *language_class_name_from_physname (const struct language_defn *, 4975796c8dcSSimon Schubert const char *physname); 4985796c8dcSSimon Schubert 4995796c8dcSSimon Schubert /* Splitting strings into words. */ 5005796c8dcSSimon Schubert extern char *default_word_break_characters (void); 5015796c8dcSSimon Schubert 5025796c8dcSSimon Schubert /* Print the index of an array element using the C99 syntax. */ 5035796c8dcSSimon Schubert extern void default_print_array_index (struct value *index_value, 5045796c8dcSSimon Schubert struct ui_file *stream, 5055796c8dcSSimon Schubert const struct value_print_options *options); 5065796c8dcSSimon Schubert 5075796c8dcSSimon Schubert /* Return non-zero if TYPE should be passed (and returned) by 5085796c8dcSSimon Schubert reference at the language level. */ 5095796c8dcSSimon Schubert int language_pass_by_reference (struct type *type); 5105796c8dcSSimon Schubert 5115796c8dcSSimon Schubert /* Return zero; by default, types are passed by value at the language 5125796c8dcSSimon Schubert level. The target ABI may pass or return some structs by reference 5135796c8dcSSimon Schubert independent of this. */ 5145796c8dcSSimon Schubert int default_pass_by_reference (struct type *type); 5155796c8dcSSimon Schubert 5165796c8dcSSimon Schubert /* The default implementation of la_print_typedef. */ 5175796c8dcSSimon Schubert void default_print_typedef (struct type *type, struct symbol *new_symbol, 5185796c8dcSSimon Schubert struct ui_file *stream); 5195796c8dcSSimon Schubert 5205796c8dcSSimon Schubert void default_get_string (struct value *value, gdb_byte **buffer, int *length, 521*cf7f2e2dSJohn Marino struct type **char_type, const char **charset); 5225796c8dcSSimon Schubert 5235796c8dcSSimon Schubert void c_get_string (struct value *value, gdb_byte **buffer, int *length, 524*cf7f2e2dSJohn Marino struct type **char_type, const char **charset); 5255796c8dcSSimon Schubert 5265796c8dcSSimon Schubert #endif /* defined (LANGUAGE_H) */ 527