138032Speter/* Ada language support definitions for GDB, the GNU debugger. 2261370Sgshapiro Copyright 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 364565Sgshapiro Free Software Foundation, Inc. 438032Speter 538032SpeterThis file is part of GDB. 638032Speter 738032SpeterThis program is free software; you can redistribute it and/or modify 838032Speterit under the terms of the GNU General Public License as published by 938032Speterthe Free Software Foundation; either version 2 of the License, or 1038032Speter(at your option) any later version. 1138032Speter 1238032SpeterThis program is distributed in the hope that it will be useful, 1338032Speterbut WITHOUT ANY WARRANTY; without even the implied warranty of 1438032SpeterMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1590795SgshapiroGNU General Public License for more details. 1690795Sgshapiro 1790795SgshapiroYou should have received a copy of the GNU General Public License 18261370Sgshapiroalong with this program; if not, write to the Free Software 1964565SgshapiroFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 2064565Sgshapiro 2190795Sgshapiro#if !defined (ADA_LANG_H) 2238032Speter#define ADA_LANG_H 1 23266711Sgshapiro 2438032Speterstruct partial_symbol; 2564565Sgshapirostruct frame_info; 2664565Sgshapiro 2764565Sgshapiro#include "value.h" 2864565Sgshapiro#include "gdbtypes.h" 2964565Sgshapiro#include "breakpoint.h" 3064565Sgshapiro 3164565Sgshapiro/* Names of specific files known to be part of the runtime 3264565Sgshapiro system and that might consider (confusing) debugging information. 3364565Sgshapiro Each name (a basic regular expression string) is followed by a 3464565Sgshapiro comma. FIXME: Should be part of a configuration file. */ 3564565Sgshapiro#if defined(__alpha__) && defined(__osf__) && !defined(VXWORKS_TARGET) 3690795Sgshapiro#define ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS \ 3790795Sgshapiro "^[agis]-.*\\.ad[bs]$", \ 3864565Sgshapiro "/usr/shlib/libpthread\\.so", 3964565Sgshapiro#elif defined (__linux__) 4064565Sgshapiro#define ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS \ 4164565Sgshapiro "^[agis]-.*\\.ad[bs]$", \ 4264565Sgshapiro "/lib.*/libpthread\\.so[.0-9]*$", "/lib.*/libpthread\\.a$", \ 4338032Speter "/lib.*/libc\\.so[.0-9]*$", "/lib.*/libc\\.a$", 4438032Speter#endif 4538032Speter 4638032Speter#if !defined (ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS) 4738032Speter#define ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS \ 4838032Speter "^[agis]-.*\\.ad[bs]$", 4938032Speter#endif 5038032Speter 5138032Speter/* Names of compiler-generated auxiliary functions probably of no 5264565Sgshapiro interest to users. Each name (a basic regular expression string) 5338032Speter is followed by a comma. */ 5438032Speter#define ADA_KNOWN_AUXILIARY_FUNCTION_NAME_PATTERNS \ 5538032Speter "___clean[.a-zA-Z0-9_]*$", 5690795Sgshapiro 5738032Speter/* The maximum number of frame levels searched for non-local, 5842580Speter * non-global symbols. This limit exists as a precaution to prevent 5990795Sgshapiro * infinite search loops when the stack is screwed up. */ 6038032Speter#define MAX_ENCLOSING_FRAME_LEVELS 7 6138032Speter 6290795Sgshapiro/* Maximum number of steps followed in looking for the ultimate 6364565Sgshapiro referent of a renaming. This prevents certain infinite loops that 6464565Sgshapiro can otherwise result. */ 6598125Sgshapiro#define MAX_RENAMING_CHAIN_LENGTH 10 6638032Speter 6764565Sgshapirostruct block; 6838032Speter 6964565Sgshapiro/* Corresponding encoded/decoded names and opcodes for Ada user-definable 7064565Sgshapiro operators. */ 71249865Sgshapirostruct ada_opname_map 7238032Speter{ 7390795Sgshapiro const char *encoded; 7438032Speter const char *decoded; 7590795Sgshapiro enum exp_opcode op; 7690795Sgshapiro}; 7790795Sgshapiro 78249865Sgshapiro/* Table of Ada operators in encoded and decoded forms. */ 7938032Speter/* Defined in ada-lang.c */ 8038032Speterextern const struct ada_opname_map ada_opname_table[]; 8138032Speter 8290795Sgshapiroenum ada_operator 8390795Sgshapiro { 8490795Sgshapiro /* X IN A'RANGE(N). N is an immediate operand, surrounded by 8590795Sgshapiro BINOP_IN_BOUNDS before and after. A is an array, X an index 8638032Speter value. Evaluates to true iff X is within range of the Nth 8738032Speter dimension (1-based) of A. (A multi-dimensional array 8838032Speter type is represented as array of array of ...) */ 8938032Speter BINOP_IN_BOUNDS = OP_EXTENDED0, 9038032Speter 9138032Speter /* X IN L .. U. True iff L <= X <= U. */ 9238032Speter TERNOP_IN_RANGE, 9338032Speter 94249865Sgshapiro /* Ada attributes ('Foo). */ 9538032Speter OP_ATR_FIRST, 9690795Sgshapiro OP_ATR_LAST, 9738032Speter OP_ATR_LENGTH, 9838032Speter OP_ATR_IMAGE, 9942580Speter OP_ATR_MAX, 10090795Sgshapiro OP_ATR_MIN, 10190795Sgshapiro OP_ATR_MODULUS, 10290795Sgshapiro OP_ATR_POS, 10390795Sgshapiro OP_ATR_SIZE, 10490795Sgshapiro OP_ATR_TAG, 10542580Speter OP_ATR_VAL, 10642580Speter 107249865Sgshapiro /* Ada type qualification. It is encoded as for UNOP_CAST, above, 10838032Speter and denotes the TYPE'(EXPR) construct. */ 10938032Speter UNOP_QUAL, 11038032Speter 11190795Sgshapiro /* X IN TYPE. The `TYPE' argument is immediate, with 11298125Sgshapiro UNOP_IN_RANGE before and after it. True iff X is a member of 11338032Speter type TYPE (typically a subrange). */ 11438032Speter UNOP_IN_RANGE, 11538032Speter 11638032Speter /* End marker */ 11738032Speter OP_ADA_LAST 11838032Speter }; 11938032Speter 12038032Speter/* A triple, (symbol, block, symtab), representing one instance of a 12138032Speter * symbol-lookup operation. */ 12290795Sgshapirostruct ada_symbol_info { 12390795Sgshapiro struct symbol* sym; 12438032Speter struct block* block; 12564565Sgshapiro struct symtab* symtab; 12690795Sgshapiro}; 12764565Sgshapiro 12890795Sgshapiro/* Ada task structures. */ 12938032Speter 13038032Speter/* Ada task control block, as defined in the GNAT runt-time library. */ 13138032Speter 13238032Speterstruct task_control_block 13390795Sgshapiro{ 13490795Sgshapiro char state; 13590795Sgshapiro CORE_ADDR parent; 13638032Speter int priority; 137249865Sgshapiro char image [32]; 13838032Speter int image_len; /* This field is not always present in the ATCB. */ 13938032Speter CORE_ADDR call; 14038032Speter CORE_ADDR thread; 14138032Speter CORE_ADDR lwp; /* This field is not always present in the ATCB. */ 14238032Speter}; 14398125Sgshapiro 14498125Sgshapirostruct task_ptid 14598125Sgshapiro{ 14698125Sgshapiro int pid; /* The Process id */ 14798125Sgshapiro long lwp; /* The Light Weight Process id */ 14898125Sgshapiro long tid; /* The Thread id */ 14998125Sgshapiro}; 15098125Sgshapirotypedef struct task_ptid task_ptid_t; 15198125Sgshapiro 15238032Speterstruct task_entry 15338032Speter{ 15438032Speter CORE_ADDR task_id; 15538032Speter struct task_control_block atcb; 15638032Speter int task_num; 15738032Speter int known_tasks_index; 15838032Speter struct task_entry *next_task; 15990795Sgshapiro task_ptid_t task_ptid; 16038032Speter int stack_per; 16138032Speter}; 16238032Speter 16338032Speter/* The maximum number of tasks known to the Ada runtime. */ 16438032Speterextern const int MAX_NUMBER_OF_KNOWN_TASKS; 16538032Speter 16638032Speter/* task entry list. */ 16738032Speterextern struct task_entry *task_list; 16838032Speter 16938032Speter 17038032Speter/* Assuming V points to an array of S objects, make sure that it contains at 17138032Speter least M objects, updating V and S as necessary. */ 17238032Speter 17338032Speter#define GROW_VECT(v, s, m) \ 17438032Speter if ((s) < (m)) grow_vect ((void**) &(v), &(s), (m), sizeof(*(v))); 17538032Speter 17690795Sgshapiroextern void grow_vect (void **, size_t *, size_t, int); 17764565Sgshapiro 17838032Speterextern int ada_get_field_index (const struct type *type, 17990795Sgshapiro const char *field_name, 18090795Sgshapiro int maybe_missing); 18190795Sgshapiro 18238032Speterextern int ada_parse (void); /* Defined in ada-exp.y */ 18338032Speter 18438032Speterextern void ada_error (char *); /* Defined in ada-exp.y */ 18538032Speter 18638032Speter /* Defined in ada-typeprint.c */ 18738032Speterextern void ada_print_type (struct type *, char *, struct ui_file *, int, 18838032Speter int); 18938032Speter 19038032Speterextern int ada_val_print (struct type *, char *, int, CORE_ADDR, 19138032Speter struct ui_file *, int, int, int, 19238032Speter enum val_prettyprint); 19390795Sgshapiro 19490795Sgshapiroextern int ada_value_print (struct value *, struct ui_file *, int, 19590795Sgshapiro enum val_prettyprint); 19638032Speter 19738032Speter /* Defined in ada-lang.c */ 19838032Speter 19964565Sgshapiroextern struct value *value_from_contents_and_address (struct type *, char *, 20038032Speter CORE_ADDR); 20138032Speter 20238032Speterextern void ada_emit_char (int, struct ui_file *, int, int); 20338032Speter 20438032Speterextern void ada_printchar (int, struct ui_file *); 20538032Speter 20638032Speterextern void ada_printstr (struct ui_file *, char *, unsigned int, int, int); 20738032Speter 20838032Speterextern void ada_convert_actuals (struct value *, int, struct value **, 20938032Speter CORE_ADDR *); 21038032Speter 21138032Speterextern struct value *ada_value_subscript (struct value *, int, 21290795Sgshapiro struct value **); 21338032Speter 21490795Sgshapiroextern struct type *ada_array_element_type (struct type *, int); 21538032Speter 21638032Speterextern int ada_array_arity (struct type *); 21738032Speter 21890795Sgshapirostruct type *ada_type_of_array (struct value *, int); 21990795Sgshapiro 22098125Sgshapiroextern struct value *ada_coerce_to_simple_array_ptr (struct value *); 22138032Speter 22238032Speterextern int ada_is_simple_array_type (struct type *); 22398125Sgshapiro 22464565Sgshapiroextern int ada_is_array_descriptor_type (struct type *); 22538032Speter 22664565Sgshapiroextern int ada_is_bogus_array_descriptor (struct type *); 22790795Sgshapiro 22864565Sgshapiroextern struct type *ada_index_type (struct type *, int); 22990795Sgshapiro 23038032Speterextern struct value *ada_array_bound (struct value *, int, int); 23138032Speter 23238032Speterextern char *ada_decode_symbol (const struct general_symbol_info*); 23338032Speter 23464565Sgshapiroextern const char *ada_decode (const char*); 23564565Sgshapiro 23638032Speterextern enum language ada_update_initial_language (enum language, 23764565Sgshapiro struct partial_symtab*); 23890795Sgshapiro 23990795Sgshapiroextern void clear_ada_sym_cache (void); 24064565Sgshapiro 24190795Sgshapiroextern char **ada_make_symbol_completion_list (const char *text0, 24238032Speter const char *word); 24338032Speter 24438032Speterextern int ada_lookup_symbol_list (const char *, const struct block *, 24538032Speter domain_enum, struct ada_symbol_info**); 24664565Sgshapiro 24764565Sgshapiroextern char *ada_fold_name (const char *); 24838032Speter 24938032Speterextern struct symbol *ada_lookup_symbol (const char *, const struct block *, 25038032Speter domain_enum, int *, 25138032Speter struct symtab **); 25264565Sgshapiro 25338032Speterextern struct minimal_symbol *ada_lookup_simple_minsym (const char *); 25490795Sgshapiro 25590795Sgshapiroextern void ada_fill_in_ada_prototype (struct symbol *); 25690795Sgshapiro 25738032Speterextern int user_select_syms (struct ada_symbol_info *, int, int); 25838032Speter 25964565Sgshapiroextern int get_selections (int *, int, int, int, char *); 26038032Speter 26190795Sgshapiroextern char *ada_start_decode_line_1 (char *); 26290795Sgshapiro 26390795Sgshapiroextern struct symtabs_and_lines ada_finish_decode_line_1 (char **, 26490795Sgshapiro struct symtab *, 26590795Sgshapiro int, char ***); 26638032Speter 26738032Speterextern struct symtabs_and_lines ada_sals_for_line (const char*, int, 26864565Sgshapiro int, char***, int); 26938032Speter 27090795Sgshapiroextern int ada_scan_number (const char *, int, LONGEST *, int *); 27190795Sgshapiro 27238032Speterextern struct type *ada_parent_type (struct type *); 27338032Speter 27438032Speterextern int ada_is_ignored_field (struct type *, int); 27538032Speter 276249865Sgshapiroextern int ada_is_packed_array_type (struct type *); 27742580Speter 27842580Speterextern struct value *ada_value_primitive_packed_val (struct value *, char *, 27964565Sgshapiro long, int, int, 28090795Sgshapiro struct type *); 28190795Sgshapiro 28242580Speterextern struct type *ada_coerce_to_simple_array_type (struct type *); 28342580Speter 28442580Speterextern int ada_is_character_type (struct type *); 28590795Sgshapiro 28690795Sgshapiroextern int ada_is_string_type (struct type *); 28790795Sgshapiro 28890795Sgshapiroextern int ada_is_tagged_type (struct type *, int); 28990795Sgshapiro 29090795Sgshapiroextern int ada_is_tag_type (struct type *); 29190795Sgshapiro 29290795Sgshapiroextern struct type *ada_tag_type (struct value *); 29342580Speter 29438032Speterextern struct value *ada_value_tag (struct value *); 29538032Speter 29664565Sgshapiroextern const char *ada_tag_name (struct value *); 29790795Sgshapiro 29864565Sgshapiroextern int ada_is_parent_field (struct type *, int); 29938032Speter 30042580Speterextern int ada_is_wrapper_field (struct type *, int); 30142580Speter 30242580Speterextern int ada_is_variant_part (struct type *, int); 30342580Speter 30442580Speterextern struct type *ada_variant_discrim_type (struct type *, struct type *); 30542580Speter 30690795Sgshapiroextern int ada_is_others_clause (struct type *, int); 30790795Sgshapiro 30890795Sgshapiroextern int ada_in_variant (LONGEST, struct type *, int); 30990795Sgshapiro 31090795Sgshapiroextern char *ada_variant_discrim_name (struct type *); 31190795Sgshapiro 31290795Sgshapiroextern struct value *ada_value_struct_elt (struct value *, char *, char *); 31390795Sgshapiro 31490795Sgshapiroextern int ada_is_aligner_type (struct type *); 31590795Sgshapiro 31638032Speterextern struct type *ada_aligned_type (struct type *); 31790795Sgshapiro 31890795Sgshapiroextern char *ada_aligned_value_addr (struct type *, char *); 31990795Sgshapiro 32090795Sgshapiroextern const char *ada_attribute_name (enum exp_opcode); 32164565Sgshapiro 32264565Sgshapiroextern int ada_is_fixed_point_type (struct type *); 32364565Sgshapiro 32464565Sgshapiroextern int ada_is_system_address_type (struct type *); 32564565Sgshapiro 32664565Sgshapiroextern DOUBLEST ada_delta (struct type *); 32790795Sgshapiro 32838032Speterextern DOUBLEST ada_fixed_to_float (struct type *, LONGEST); 32938032Speter 33042580Speterextern LONGEST ada_float_to_fixed (struct type *, DOUBLEST); 33142580Speter 33290795Sgshapiroextern int ada_is_vax_floating_type (struct type *); 33390795Sgshapiro 33490795Sgshapiroextern int ada_vax_float_type_suffix (struct type *); 33590795Sgshapiro 33690795Sgshapiroextern struct value *ada_vax_float_print_function (struct type *); 33790795Sgshapiro 33890795Sgshapiroextern struct type *ada_system_address_type (void); 33990795Sgshapiro 34090795Sgshapiroextern int ada_which_variant_applies (struct type *, struct type *, char *); 34190795Sgshapiro 34290795Sgshapiroextern struct type *ada_to_fixed_type (struct type *, char *, CORE_ADDR, 34364565Sgshapiro struct value *); 34490795Sgshapiro 34590795Sgshapiroextern struct type * 34698125Sgshapiro ada_template_to_fixed_record_type_1 (struct type *type, char *valaddr, 34790795Sgshapiro CORE_ADDR address, struct value *dval0, 34890795Sgshapiro int keep_dynamic_fields); 34990795Sgshapiro 35042580Speterextern int ada_name_prefix_len (const char *); 35142580Speter 35242580Speterextern char *ada_type_name (struct type *); 35390795Sgshapiro 35490795Sgshapiroextern struct type *ada_find_parallel_type (struct type *, 35590795Sgshapiro const char *suffix); 35690795Sgshapiro 35790795Sgshapiroextern LONGEST get_int_var_value (char *, int *); 35890795Sgshapiro 35990795Sgshapiroextern struct symbol *ada_find_any_symbol (const char *name); 36090795Sgshapiro 36190795Sgshapiroextern struct type *ada_find_any_type (const char *name); 36290795Sgshapiro 36390795Sgshapiroextern struct symbol *ada_find_renaming_symbol (const char *name, 36490795Sgshapiro struct block *block); 36590795Sgshapiro 36690795Sgshapiroextern int ada_prefer_type (struct type *, struct type *); 36790795Sgshapiro 36842580Speterextern struct type *ada_get_base_type (struct type *); 36938032Speter 37064565Sgshapiroextern struct type *ada_check_typedef (struct type *); 37164565Sgshapiro 37238032Speterextern char *ada_encode (const char *); 373 374extern const char *ada_enum_name (const char *); 375 376extern int ada_is_modular_type (struct type *); 377 378extern ULONGEST ada_modulus (struct type *); 379 380extern struct value *ada_value_ind (struct value *); 381 382extern void ada_print_scalar (struct type *, LONGEST, struct ui_file *); 383 384extern int ada_is_range_type_name (const char *); 385 386extern const char *ada_renaming_type (struct type *); 387 388extern int ada_is_object_renaming (struct symbol *); 389 390extern char *ada_simple_renamed_entity (struct symbol *); 391 392extern char *ada_breakpoint_rewrite (char *, int *); 393 394extern char *ada_main_name (void); 395 396/* Tasking-related: ada-tasks.c */ 397 398extern int valid_task_id (int); 399 400extern void init_task_list (void); 401 402extern int ada_is_exception_breakpoint (bpstat bs); 403 404extern void ada_adjust_exception_stop (bpstat bs); 405 406extern void ada_print_exception_stop (bpstat bs); 407 408extern int ada_get_current_task (ptid_t); 409 410extern int breakpoint_ada_task_match (CORE_ADDR, ptid_t); 411 412extern int ada_print_exception_breakpoint_nontask (struct breakpoint *); 413 414extern void ada_print_exception_breakpoint_task (struct breakpoint *); 415 416extern void ada_find_printable_frame (struct frame_info *fi); 417 418extern void ada_reset_thread_registers (void); 419 420extern int ada_build_task_list (void); 421 422/* Look up a symbol by name using the search conventions of 423 a specific language (optional block, optional symtab). 424 FIXME: Should be symtab.h. */ 425 426extern struct symbol *lookup_symbol_in_language (const char *, 427 const struct block *, 428 domain_enum, 429 enum language, 430 int *, 431 struct symtab **); 432#endif 433