15796c8dcSSimon Schubert /* Source-language-related definitions for GDB. 25796c8dcSSimon Schubert 3*a45ae5f8SJohn Marino Copyright (C) 1991-1995, 1998-2000, 2003-2004, 2007-2012 Free 4*a45ae5f8SJohn Marino 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 27c50c785cSJohn Marino /* 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 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 /* type_mode == 59c50c785cSJohn Marino 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 == 80c50c785cSJohn Marino 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 == 90c50c785cSJohn Marino 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 == 101c50c785cSJohn Marino case_sensitive_on: Case sensitivity in name matching is used. 102c50c785cSJohn Marino 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 == 112c50c785cSJohn Marino macro_expansion_no: No macro expansion is available. 113c50c785cSJohn Marino 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 { 143c50c785cSJohn Marino /* Name of the language. */ 1445796c8dcSSimon Schubert 1455796c8dcSSimon Schubert char *la_name; 1465796c8dcSSimon Schubert 147c50c785cSJohn Marino /* its symtab language-enum (defs.h). */ 1485796c8dcSSimon Schubert 1495796c8dcSSimon Schubert enum language la_language; 1505796c8dcSSimon Schubert 151c50c785cSJohn Marino /* Default range checking. */ 1525796c8dcSSimon Schubert 1535796c8dcSSimon Schubert enum range_check la_range_check; 1545796c8dcSSimon Schubert 155c50c785cSJohn Marino /* Default type checking. */ 1565796c8dcSSimon Schubert 1575796c8dcSSimon Schubert enum type_check la_type_check; 1585796c8dcSSimon Schubert 159c50c785cSJohn Marino /* Default case sensitivity. */ 1605796c8dcSSimon Schubert enum case_sensitivity la_case_sensitivity; 1615796c8dcSSimon Schubert 162c50c785cSJohn Marino /* 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 169c50c785cSJohn Marino 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 177c50c785cSJohn Marino /* 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 189c50c785cSJohn Marino void (*la_printchar) (int ch, struct type *chtype, 190c50c785cSJohn Marino struct ui_file * stream); 1915796c8dcSSimon Schubert 1925796c8dcSSimon Schubert void (*la_printstr) (struct ui_file * stream, struct type *elttype, 1935796c8dcSSimon Schubert const gdb_byte *string, unsigned int length, 194cf7f2e2dSJohn Marino const char *encoding, int force_ellipses, 1955796c8dcSSimon Schubert const struct value_print_options *); 1965796c8dcSSimon Schubert 1975796c8dcSSimon Schubert void (*la_emitchar) (int ch, struct type *chtype, 1985796c8dcSSimon Schubert struct ui_file * stream, int quoter); 1995796c8dcSSimon Schubert 2005796c8dcSSimon Schubert /* Print a type using syntax appropriate for this language. */ 2015796c8dcSSimon Schubert 202cf7f2e2dSJohn Marino void (*la_print_type) (struct type *, const char *, struct ui_file *, int, 2035796c8dcSSimon Schubert int); 2045796c8dcSSimon Schubert 2055796c8dcSSimon Schubert /* Print a typedef using syntax appropriate for this language. 2065796c8dcSSimon Schubert TYPE is the underlying type. NEW_SYMBOL is the symbol naming 2075796c8dcSSimon Schubert the type. STREAM is the output stream on which to print. */ 2085796c8dcSSimon Schubert 2095796c8dcSSimon Schubert void (*la_print_typedef) (struct type *type, struct symbol *new_symbol, 2105796c8dcSSimon Schubert struct ui_file *stream); 2115796c8dcSSimon Schubert 212cf7f2e2dSJohn Marino /* Print a value using syntax appropriate for this language. 2135796c8dcSSimon Schubert 214cf7f2e2dSJohn Marino TYPE is the type of the sub-object to be printed. 215cf7f2e2dSJohn Marino 216cf7f2e2dSJohn Marino CONTENTS holds the bits of the value. This holds the entire 217cf7f2e2dSJohn Marino enclosing object. 218cf7f2e2dSJohn Marino 219cf7f2e2dSJohn Marino EMBEDDED_OFFSET is the offset into the outermost object of the 220cf7f2e2dSJohn Marino sub-object represented by TYPE. This is the object which this 221cf7f2e2dSJohn Marino call should print. Note that the enclosing type is not 222cf7f2e2dSJohn Marino available. 223cf7f2e2dSJohn Marino 224cf7f2e2dSJohn Marino ADDRESS is the address in the inferior of the enclosing object. 225cf7f2e2dSJohn Marino 226cf7f2e2dSJohn Marino STREAM is the stream on which the value is to be printed. 227cf7f2e2dSJohn Marino 228cf7f2e2dSJohn Marino RECURSE is the recursion depth. It is zero-based. 229cf7f2e2dSJohn Marino 230cf7f2e2dSJohn Marino OPTIONS are the formatting options to be used when 231cf7f2e2dSJohn Marino printing. */ 232cf7f2e2dSJohn Marino 233cf7f2e2dSJohn Marino int (*la_val_print) (struct type *type, 234cf7f2e2dSJohn Marino const gdb_byte *contents, 235cf7f2e2dSJohn Marino int embedded_offset, CORE_ADDR address, 236cf7f2e2dSJohn Marino struct ui_file *stream, int recurse, 237cf7f2e2dSJohn Marino const struct value *val, 238cf7f2e2dSJohn Marino const struct value_print_options *options); 2395796c8dcSSimon Schubert 2405796c8dcSSimon Schubert /* Print a top-level value using syntax appropriate for this language. */ 2415796c8dcSSimon Schubert 2425796c8dcSSimon Schubert int (*la_value_print) (struct value *, struct ui_file *, 2435796c8dcSSimon Schubert const struct value_print_options *); 2445796c8dcSSimon Schubert 2455796c8dcSSimon Schubert /* PC is possibly an unknown languages trampoline. 2465796c8dcSSimon Schubert If that PC falls in a trampoline belonging to this language, 2475796c8dcSSimon Schubert return the address of the first pc in the real function, or 0 2485796c8dcSSimon Schubert if it isn't a language tramp for this language. */ 2495796c8dcSSimon Schubert CORE_ADDR (*skip_trampoline) (struct frame_info *, CORE_ADDR); 2505796c8dcSSimon Schubert 2515796c8dcSSimon Schubert /* Now come some hooks for lookup_symbol. */ 2525796c8dcSSimon Schubert 2535796c8dcSSimon Schubert /* If this is non-NULL, specifies the name that of the implicit 2545796c8dcSSimon Schubert local variable that refers to the current object instance. */ 2555796c8dcSSimon Schubert 2565796c8dcSSimon Schubert char *la_name_of_this; 2575796c8dcSSimon Schubert 2585796c8dcSSimon Schubert /* This is a function that lookup_symbol will call when it gets to 2595796c8dcSSimon Schubert the part of symbol lookup where C looks up static and global 2605796c8dcSSimon Schubert variables. */ 2615796c8dcSSimon Schubert 2625796c8dcSSimon Schubert struct symbol *(*la_lookup_symbol_nonlocal) (const char *, 2635796c8dcSSimon Schubert const struct block *, 2645796c8dcSSimon Schubert const domain_enum); 2655796c8dcSSimon Schubert 2665796c8dcSSimon Schubert /* Find the definition of the type with the given name. */ 2675796c8dcSSimon Schubert struct type *(*la_lookup_transparent_type) (const char *); 2685796c8dcSSimon Schubert 2695796c8dcSSimon Schubert /* Return demangled language symbol, or NULL. */ 2705796c8dcSSimon Schubert char *(*la_demangle) (const char *mangled, int options); 2715796c8dcSSimon Schubert 2725796c8dcSSimon Schubert /* Return class name of a mangled method name or NULL. */ 2735796c8dcSSimon Schubert char *(*la_class_name_from_physname) (const char *physname); 2745796c8dcSSimon Schubert 275c50c785cSJohn Marino /* Table for printing expressions. */ 2765796c8dcSSimon Schubert 2775796c8dcSSimon Schubert const struct op_print *la_op_print_tab; 2785796c8dcSSimon Schubert 2795796c8dcSSimon Schubert /* Zero if the language has first-class arrays. True if there are no 2805796c8dcSSimon Schubert array values, and array objects decay to pointers, as in C. */ 2815796c8dcSSimon Schubert 2825796c8dcSSimon Schubert char c_style_arrays; 2835796c8dcSSimon Schubert 2845796c8dcSSimon Schubert /* Index to use for extracting the first element of a string. */ 2855796c8dcSSimon Schubert char string_lower_bound; 2865796c8dcSSimon Schubert 2875796c8dcSSimon Schubert /* The list of characters forming word boundaries. */ 2885796c8dcSSimon Schubert char *(*la_word_break_characters) (void); 2895796c8dcSSimon Schubert 2905796c8dcSSimon Schubert /* Should return a NULL terminated array of all symbols which 2915796c8dcSSimon Schubert are possible completions for TEXT. WORD is the entire command 2925796c8dcSSimon Schubert on which the completion is being made. */ 2935796c8dcSSimon Schubert char **(*la_make_symbol_completion_list) (char *text, char *word); 2945796c8dcSSimon Schubert 2955796c8dcSSimon Schubert /* The per-architecture (OS/ABI) language information. */ 2965796c8dcSSimon Schubert void (*la_language_arch_info) (struct gdbarch *, 2975796c8dcSSimon Schubert struct language_arch_info *); 2985796c8dcSSimon Schubert 2995796c8dcSSimon Schubert /* Print the index of an element of an array. */ 3005796c8dcSSimon Schubert void (*la_print_array_index) (struct value *index_value, 3015796c8dcSSimon Schubert struct ui_file *stream, 3025796c8dcSSimon Schubert const struct value_print_options *options); 3035796c8dcSSimon Schubert 3045796c8dcSSimon Schubert /* Return non-zero if TYPE should be passed (and returned) by 3055796c8dcSSimon Schubert reference at the language level. */ 3065796c8dcSSimon Schubert int (*la_pass_by_reference) (struct type *type); 3075796c8dcSSimon Schubert 3085796c8dcSSimon Schubert /* Obtain a string from the inferior, storing it in a newly allocated 3095796c8dcSSimon Schubert buffer in BUFFER, which should be freed by the caller. If the 3105796c8dcSSimon Schubert in- and out-parameter *LENGTH is specified at -1, the string is 3115796c8dcSSimon Schubert read until a null character of the appropriate width is found - 3125796c8dcSSimon Schubert otherwise the string is read to the length of characters specified. 3135796c8dcSSimon Schubert On completion, *LENGTH will hold the size of the string in characters. 3145796c8dcSSimon Schubert If a *LENGTH of -1 was specified it will count only actual 3155796c8dcSSimon Schubert characters, excluding any eventual terminating null character. 3165796c8dcSSimon Schubert Otherwise *LENGTH will include all characters - including any nulls. 3175796c8dcSSimon Schubert CHARSET will hold the encoding used in the string. */ 3185796c8dcSSimon Schubert void (*la_get_string) (struct value *value, gdb_byte **buffer, int *length, 319cf7f2e2dSJohn Marino struct type **chartype, const char **charset); 3205796c8dcSSimon Schubert 321*a45ae5f8SJohn Marino /* Compare two symbol names according to language rules. For 322*a45ae5f8SJohn Marino instance, in C++, we might want to ignore whitespaces in 323*a45ae5f8SJohn Marino the symbol name. Or some case-insensitive language might 324*a45ae5f8SJohn Marino want to ignore casing during the match. 325*a45ae5f8SJohn Marino 326*a45ae5f8SJohn Marino Both STR1 and STR2 are expected to be demangled name, except 327*a45ae5f8SJohn Marino for Ada, where STR1 and STR2 are expected to be encoded names. 328*a45ae5f8SJohn Marino The latter is because searches are performed using the encoded 329*a45ae5f8SJohn Marino name in Ada. 330*a45ae5f8SJohn Marino 331*a45ae5f8SJohn Marino The return value follows the same spirit as strcmp. */ 332*a45ae5f8SJohn Marino 333*a45ae5f8SJohn Marino int (*la_symbol_name_compare) (const char *str1, const char *str2); 334*a45ae5f8SJohn Marino 335*a45ae5f8SJohn Marino /* Find all symbols in the current program space matching NAME in 336*a45ae5f8SJohn Marino DOMAIN, according to this language's rules. 337*a45ae5f8SJohn Marino 338*a45ae5f8SJohn Marino The search starts with BLOCK. This function iterates upward 339*a45ae5f8SJohn Marino through blocks. When the outermost block has been finished, 340*a45ae5f8SJohn Marino the function returns. 341*a45ae5f8SJohn Marino 342*a45ae5f8SJohn Marino For each one, call CALLBACK with the symbol and the DATA 343*a45ae5f8SJohn Marino argument. If CALLBACK returns zero, the iteration ends at that 344*a45ae5f8SJohn Marino point. 345*a45ae5f8SJohn Marino 346*a45ae5f8SJohn Marino This field can be NULL, meaning that this language doesn't need 347*a45ae5f8SJohn Marino any special code aside from ordinary searches of the symbol 348*a45ae5f8SJohn Marino table. */ 349*a45ae5f8SJohn Marino void (*la_iterate_over_symbols) (const struct block *block, 350*a45ae5f8SJohn Marino const char *name, 351*a45ae5f8SJohn Marino domain_enum domain, 352*a45ae5f8SJohn Marino int (*callback) (struct symbol *, void *), 353*a45ae5f8SJohn Marino void *data); 354*a45ae5f8SJohn Marino 3555796c8dcSSimon Schubert /* Add fields above this point, so the magic number is always last. */ 356c50c785cSJohn Marino /* Magic number for compat checking. */ 3575796c8dcSSimon Schubert 3585796c8dcSSimon Schubert long la_magic; 3595796c8dcSSimon Schubert 3605796c8dcSSimon Schubert }; 3615796c8dcSSimon Schubert 3625796c8dcSSimon Schubert #define LANG_MAGIC 910823L 3635796c8dcSSimon Schubert 3645796c8dcSSimon Schubert /* Pointer to the language_defn for our current language. This pointer 3655796c8dcSSimon Schubert always points to *some* valid struct; it can be used without checking 3665796c8dcSSimon Schubert it for validity. 3675796c8dcSSimon Schubert 3685796c8dcSSimon Schubert The current language affects expression parsing and evaluation 3695796c8dcSSimon Schubert (FIXME: it might be cleaner to make the evaluation-related stuff 3705796c8dcSSimon Schubert separate exp_opcodes for each different set of semantics. We 3715796c8dcSSimon Schubert should at least think this through more clearly with respect to 3725796c8dcSSimon Schubert what happens if the language is changed between parsing and 3735796c8dcSSimon Schubert evaluation) and printing of things like types and arrays. It does 3745796c8dcSSimon Schubert *not* affect symbol-reading-- each source file in a symbol-file has 3755796c8dcSSimon Schubert its own language and we should keep track of that regardless of the 3765796c8dcSSimon Schubert language when symbols are read. If we want some manual setting for 3775796c8dcSSimon Schubert the language of symbol files (e.g. detecting when ".c" files are 3785796c8dcSSimon Schubert C++), it should be a separate setting from the current_language. */ 3795796c8dcSSimon Schubert 3805796c8dcSSimon Schubert extern const struct language_defn *current_language; 3815796c8dcSSimon Schubert 3825796c8dcSSimon Schubert /* Pointer to the language_defn expected by the user, e.g. the language 3835796c8dcSSimon Schubert of main(), or the language we last mentioned in a message, or C. */ 3845796c8dcSSimon Schubert 3855796c8dcSSimon Schubert extern const struct language_defn *expected_language; 3865796c8dcSSimon Schubert 3875796c8dcSSimon Schubert /* language_mode == 3885796c8dcSSimon Schubert language_mode_auto: current_language automatically set upon selection 3895796c8dcSSimon Schubert of scope (e.g. stack frame) 3905796c8dcSSimon Schubert language_mode_manual: current_language set only by user. */ 3915796c8dcSSimon Schubert 3925796c8dcSSimon Schubert extern enum language_mode 3935796c8dcSSimon Schubert { 3945796c8dcSSimon Schubert language_mode_auto, language_mode_manual 3955796c8dcSSimon Schubert } 3965796c8dcSSimon Schubert language_mode; 3975796c8dcSSimon Schubert 3985796c8dcSSimon Schubert struct type *language_bool_type (const struct language_defn *l, 3995796c8dcSSimon Schubert struct gdbarch *gdbarch); 4005796c8dcSSimon Schubert 4015796c8dcSSimon Schubert struct type *language_string_char_type (const struct language_defn *l, 4025796c8dcSSimon Schubert struct gdbarch *gdbarch); 4035796c8dcSSimon Schubert 4045796c8dcSSimon Schubert struct type *language_lookup_primitive_type_by_name (const struct language_defn *l, 4055796c8dcSSimon Schubert struct gdbarch *gdbarch, 4065796c8dcSSimon Schubert const char *name); 4075796c8dcSSimon Schubert 4085796c8dcSSimon Schubert 4095796c8dcSSimon Schubert /* These macros define the behaviour of the expression 4105796c8dcSSimon Schubert evaluator. */ 4115796c8dcSSimon Schubert 4125796c8dcSSimon Schubert /* Should we strictly type check expressions? */ 4135796c8dcSSimon Schubert #define STRICT_TYPE (type_check != type_check_off) 4145796c8dcSSimon Schubert 4155796c8dcSSimon Schubert /* Should we range check values against the domain of their type? */ 4165796c8dcSSimon Schubert #define RANGE_CHECK (range_check != range_check_off) 4175796c8dcSSimon Schubert 418c50c785cSJohn Marino /* "cast" really means conversion. */ 419c50c785cSJohn Marino /* FIXME -- should be a setting in language_defn. */ 420cf7f2e2dSJohn Marino #define CAST_IS_CONVERSION(LANG) ((LANG)->la_language == language_c || \ 421cf7f2e2dSJohn Marino (LANG)->la_language == language_cplus || \ 422cf7f2e2dSJohn Marino (LANG)->la_language == language_objc) 4235796c8dcSSimon Schubert 4245796c8dcSSimon Schubert extern void language_info (int); 4255796c8dcSSimon Schubert 4265796c8dcSSimon Schubert extern enum language set_language (enum language); 4275796c8dcSSimon Schubert 4285796c8dcSSimon Schubert 4295796c8dcSSimon Schubert /* This page contains functions that return things that are 4305796c8dcSSimon Schubert specific to languages. Each of these functions is based on 4315796c8dcSSimon Schubert the current setting of working_lang, which the user sets 4325796c8dcSSimon Schubert with the "set language" command. */ 4335796c8dcSSimon Schubert 4345796c8dcSSimon Schubert #define LA_PRINT_TYPE(type,varstring,stream,show,level) \ 4355796c8dcSSimon Schubert (current_language->la_print_type(type,varstring,stream,show,level)) 4365796c8dcSSimon Schubert 4375796c8dcSSimon Schubert #define LA_PRINT_TYPEDEF(type,new_symbol,stream) \ 4385796c8dcSSimon Schubert (current_language->la_print_typedef(type,new_symbol,stream)) 4395796c8dcSSimon Schubert 440cf7f2e2dSJohn Marino #define LA_VAL_PRINT(type,valaddr,offset,addr,stream,val,recurse,options) \ 4415796c8dcSSimon Schubert (current_language->la_val_print(type,valaddr,offset,addr,stream, \ 442cf7f2e2dSJohn Marino val,recurse,options)) 4435796c8dcSSimon Schubert #define LA_VALUE_PRINT(val,stream,options) \ 4445796c8dcSSimon Schubert (current_language->la_value_print(val,stream,options)) 4455796c8dcSSimon Schubert 4465796c8dcSSimon Schubert #define LA_PRINT_CHAR(ch, type, stream) \ 4475796c8dcSSimon Schubert (current_language->la_printchar(ch, type, stream)) 448cf7f2e2dSJohn Marino #define LA_PRINT_STRING(stream, elttype, string, length, encoding, force_ellipses, options) \ 4495796c8dcSSimon Schubert (current_language->la_printstr(stream, elttype, string, length, \ 450cf7f2e2dSJohn Marino encoding, force_ellipses,options)) 4515796c8dcSSimon Schubert #define LA_EMIT_CHAR(ch, type, stream, quoter) \ 4525796c8dcSSimon Schubert (current_language->la_emitchar(ch, type, stream, quoter)) 453cf7f2e2dSJohn Marino #define LA_GET_STRING(value, buffer, length, chartype, encoding) \ 454cf7f2e2dSJohn Marino (current_language->la_get_string(value, buffer, length, chartype, encoding)) 4555796c8dcSSimon Schubert 456c50c785cSJohn Marino #define LA_PRINT_ARRAY_INDEX(index_value, stream, options) \ 4575796c8dcSSimon Schubert (current_language->la_print_array_index(index_value, stream, options)) 4585796c8dcSSimon Schubert 459*a45ae5f8SJohn Marino #define LA_ITERATE_OVER_SYMBOLS(BLOCK, NAME, DOMAIN, CALLBACK, DATA) \ 460*a45ae5f8SJohn Marino (current_language->la_iterate_over_symbols (BLOCK, NAME, DOMAIN, CALLBACK, \ 461*a45ae5f8SJohn Marino DATA)) 462*a45ae5f8SJohn Marino 4635796c8dcSSimon Schubert /* Test a character to decide whether it can be printed in literal form 4645796c8dcSSimon Schubert or needs to be printed in another representation. For example, 4655796c8dcSSimon Schubert in C the literal form of the character with octal value 141 is 'a' 4665796c8dcSSimon Schubert and the "other representation" is '\141'. The "other representation" 4675796c8dcSSimon Schubert is program language dependent. */ 4685796c8dcSSimon Schubert 4695796c8dcSSimon Schubert #define PRINT_LITERAL_FORM(c) \ 4705796c8dcSSimon Schubert ((c) >= 0x20 \ 4715796c8dcSSimon Schubert && ((c) < 0x7F || (c) >= 0xA0) \ 4725796c8dcSSimon Schubert && (!sevenbit_strings || (c) < 0x80)) 4735796c8dcSSimon Schubert 4745796c8dcSSimon Schubert /* Type predicates */ 4755796c8dcSSimon Schubert 4765796c8dcSSimon Schubert extern int simple_type (struct type *); 4775796c8dcSSimon Schubert 4785796c8dcSSimon Schubert extern int ordered_type (struct type *); 4795796c8dcSSimon Schubert 4805796c8dcSSimon Schubert extern int same_type (struct type *, struct type *); 4815796c8dcSSimon Schubert 4825796c8dcSSimon Schubert extern int integral_type (struct type *); 4835796c8dcSSimon Schubert 4845796c8dcSSimon Schubert extern int numeric_type (struct type *); 4855796c8dcSSimon Schubert 4865796c8dcSSimon Schubert extern int character_type (struct type *); 4875796c8dcSSimon Schubert 4885796c8dcSSimon Schubert extern int boolean_type (struct type *); 4895796c8dcSSimon Schubert 4905796c8dcSSimon Schubert extern int float_type (struct type *); 4915796c8dcSSimon Schubert 4925796c8dcSSimon Schubert extern int pointer_type (struct type *); 4935796c8dcSSimon Schubert 4945796c8dcSSimon Schubert extern int structured_type (struct type *); 4955796c8dcSSimon Schubert 496c50c785cSJohn Marino /* Checks Binary and Unary operations for semantic type correctness. */ 497c50c785cSJohn Marino /* FIXME: Does not appear to be used. */ 4985796c8dcSSimon Schubert #define unop_type_check(v,o) binop_type_check((v),NULL,(o)) 4995796c8dcSSimon Schubert 5005796c8dcSSimon Schubert extern void binop_type_check (struct value *, struct value *, int); 5015796c8dcSSimon Schubert 5025796c8dcSSimon Schubert /* Error messages */ 5035796c8dcSSimon Schubert 504cf7f2e2dSJohn Marino extern void type_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2); 5055796c8dcSSimon Schubert 506cf7f2e2dSJohn Marino extern void range_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2); 5075796c8dcSSimon Schubert 5085796c8dcSSimon Schubert /* Data: Does this value represent "truth" to the current language? */ 5095796c8dcSSimon Schubert 5105796c8dcSSimon Schubert extern int value_true (struct value *); 5115796c8dcSSimon Schubert 5125796c8dcSSimon Schubert /* Misc: The string representing a particular enum language. */ 5135796c8dcSSimon Schubert 5145796c8dcSSimon Schubert extern enum language language_enum (char *str); 5155796c8dcSSimon Schubert 5165796c8dcSSimon Schubert extern const struct language_defn *language_def (enum language); 5175796c8dcSSimon Schubert 5185796c8dcSSimon Schubert extern char *language_str (enum language); 5195796c8dcSSimon Schubert 5205796c8dcSSimon Schubert /* Add a language to the set known by GDB (at initialization time). */ 5215796c8dcSSimon Schubert 5225796c8dcSSimon Schubert extern void add_language (const struct language_defn *); 5235796c8dcSSimon Schubert 5245796c8dcSSimon Schubert extern enum language get_frame_language (void); /* In stack.c */ 5255796c8dcSSimon Schubert 5265796c8dcSSimon Schubert /* Check for a language-specific trampoline. */ 5275796c8dcSSimon Schubert 5285796c8dcSSimon Schubert extern CORE_ADDR skip_language_trampoline (struct frame_info *, CORE_ADDR pc); 5295796c8dcSSimon Schubert 5305796c8dcSSimon Schubert /* Return demangled language symbol, or NULL. */ 5315796c8dcSSimon Schubert extern char *language_demangle (const struct language_defn *current_language, 5325796c8dcSSimon Schubert const char *mangled, int options); 5335796c8dcSSimon Schubert 5345796c8dcSSimon Schubert /* Return class name from physname, or NULL. */ 5355796c8dcSSimon Schubert extern char *language_class_name_from_physname (const struct language_defn *, 5365796c8dcSSimon Schubert const char *physname); 5375796c8dcSSimon Schubert 5385796c8dcSSimon Schubert /* Splitting strings into words. */ 5395796c8dcSSimon Schubert extern char *default_word_break_characters (void); 5405796c8dcSSimon Schubert 5415796c8dcSSimon Schubert /* Print the index of an array element using the C99 syntax. */ 5425796c8dcSSimon Schubert extern void default_print_array_index (struct value *index_value, 5435796c8dcSSimon Schubert struct ui_file *stream, 5445796c8dcSSimon Schubert const struct value_print_options *options); 5455796c8dcSSimon Schubert 5465796c8dcSSimon Schubert /* Return non-zero if TYPE should be passed (and returned) by 5475796c8dcSSimon Schubert reference at the language level. */ 5485796c8dcSSimon Schubert int language_pass_by_reference (struct type *type); 5495796c8dcSSimon Schubert 5505796c8dcSSimon Schubert /* Return zero; by default, types are passed by value at the language 5515796c8dcSSimon Schubert level. The target ABI may pass or return some structs by reference 5525796c8dcSSimon Schubert independent of this. */ 5535796c8dcSSimon Schubert int default_pass_by_reference (struct type *type); 5545796c8dcSSimon Schubert 5555796c8dcSSimon Schubert /* The default implementation of la_print_typedef. */ 5565796c8dcSSimon Schubert void default_print_typedef (struct type *type, struct symbol *new_symbol, 5575796c8dcSSimon Schubert struct ui_file *stream); 5585796c8dcSSimon Schubert 5595796c8dcSSimon Schubert void default_get_string (struct value *value, gdb_byte **buffer, int *length, 560cf7f2e2dSJohn Marino struct type **char_type, const char **charset); 5615796c8dcSSimon Schubert 5625796c8dcSSimon Schubert void c_get_string (struct value *value, gdb_byte **buffer, int *length, 563cf7f2e2dSJohn Marino struct type **char_type, const char **charset); 5645796c8dcSSimon Schubert 5655796c8dcSSimon Schubert #endif /* defined (LANGUAGE_H) */ 566