ada-lang.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. /* Ada language support definitions for GDB, the GNU debugger.
  2. Copyright (C) 1992-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #if !defined (ADA_LANG_H)
  15. #define ADA_LANG_H 1
  16. struct frame_info;
  17. struct inferior;
  18. struct type_print_options;
  19. struct parser_state;
  20. #include "value.h"
  21. #include "gdbtypes.h"
  22. #include "breakpoint.h"
  23. /* Names of specific files known to be part of the runtime
  24. system and that might consider (confusing) debugging information.
  25. Each name (a basic regular expression string) is followed by a
  26. comma. FIXME: Should be part of a configuration file. */
  27. #if defined (__linux__)
  28. #define ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS \
  29. "^[agis]-.*\\.ad[bs]$", \
  30. "/lib.*/libpthread\\.so[.0-9]*$", "/lib.*/libpthread\\.a$", \
  31. "/lib.*/libc\\.so[.0-9]*$", "/lib.*/libc\\.a$",
  32. #endif
  33. #if !defined (ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS)
  34. #define ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS \
  35. "^unwind-seh.c$", \
  36. "^[agis]-.*\\.ad[bs]$",
  37. #endif
  38. /* Names of compiler-generated auxiliary functions probably of no
  39. interest to users. Each name (a basic regular expression string)
  40. is followed by a comma. */
  41. #define ADA_KNOWN_AUXILIARY_FUNCTION_NAME_PATTERNS \
  42. "___clean[.$a-zA-Z0-9_]*$", \
  43. "___finalizer[.$a-zA-Z0-9_]*$",
  44. /* The maximum number of frame levels searched for non-local,
  45. non-global symbols. This limit exists as a precaution to prevent
  46. infinite search loops when the stack is screwed up. */
  47. #define MAX_ENCLOSING_FRAME_LEVELS 7
  48. /* Maximum number of steps followed in looking for the ultimate
  49. referent of a renaming. This prevents certain infinite loops that
  50. can otherwise result. */
  51. #define MAX_RENAMING_CHAIN_LENGTH 10
  52. struct block;
  53. /* Corresponding encoded/decoded names and opcodes for Ada user-definable
  54. operators. */
  55. struct ada_opname_map
  56. {
  57. const char *encoded;
  58. const char *decoded;
  59. enum exp_opcode op;
  60. };
  61. /* Table of Ada operators in encoded and decoded forms. */
  62. /* Defined in ada-lang.c */
  63. extern const struct ada_opname_map ada_opname_table[];
  64. /* Denotes a type of renaming symbol (see ada_parse_renaming). */
  65. enum ada_renaming_category
  66. {
  67. /* Indicates a symbol that does not encode a renaming. */
  68. ADA_NOT_RENAMING,
  69. /* For symbols declared
  70. Foo : TYPE renamed OBJECT; */
  71. ADA_OBJECT_RENAMING,
  72. /* For symbols declared
  73. Foo : exception renames EXCEPTION; */
  74. ADA_EXCEPTION_RENAMING,
  75. /* For packages declared
  76. package Foo renames PACKAGE; */
  77. ADA_PACKAGE_RENAMING,
  78. /* For subprograms declared
  79. SUBPROGRAM_SPEC renames SUBPROGRAM;
  80. (Currently not used). */
  81. ADA_SUBPROGRAM_RENAMING
  82. };
  83. /* The different types of catchpoints that we introduced for catching
  84. Ada exceptions. */
  85. enum ada_exception_catchpoint_kind
  86. {
  87. ada_catch_exception,
  88. ada_catch_exception_unhandled,
  89. ada_catch_assert,
  90. ada_catch_handlers
  91. };
  92. /* Ada task structures. */
  93. struct ada_task_info
  94. {
  95. /* The PTID of the thread that this task runs on. This ptid is computed
  96. in a target-dependent way from the associated Task Control Block. */
  97. ptid_t ptid;
  98. /* The ID of the task. */
  99. CORE_ADDR task_id;
  100. /* The name of the task. */
  101. char name[257];
  102. /* The current state of the task. */
  103. int state;
  104. /* The priority associated to the task. */
  105. int priority;
  106. /* If non-zero, the task ID of the parent task. */
  107. CORE_ADDR parent;
  108. /* If the task is waiting on a task entry, this field contains
  109. the ID of the other task. Zero otherwise. */
  110. CORE_ADDR called_task;
  111. /* If the task is accepting a rendezvous with another task, this field
  112. contains the ID of the calling task. Zero otherwise. */
  113. CORE_ADDR caller_task;
  114. /* The CPU on which the task is running. This is dependent on
  115. the runtime actually providing that info, which is not always
  116. the case. Normally, we should be able to count on it on
  117. bare-metal targets. */
  118. int base_cpu;
  119. };
  120. extern int ada_get_field_index (const struct type *type,
  121. const char *field_name,
  122. int maybe_missing);
  123. extern int ada_parse (struct parser_state *); /* Defined in ada-exp.y */
  124. /* Defined in ada-typeprint.c */
  125. extern void ada_print_type (struct type *, const char *, struct ui_file *, int,
  126. int, const struct type_print_options *);
  127. extern void ada_print_typedef (struct type *type, struct symbol *new_symbol,
  128. struct ui_file *stream);
  129. /* Implement la_value_print_inner for Ada. */
  130. extern void ada_value_print_inner (struct value *, struct ui_file *, int,
  131. const struct value_print_options *);
  132. extern void ada_value_print (struct value *, struct ui_file *,
  133. const struct value_print_options *);
  134. /* Defined in ada-lang.c */
  135. extern void ada_emit_char (int, struct type *, struct ui_file *, int, int);
  136. extern void ada_printchar (int, struct type *, struct ui_file *);
  137. extern void ada_printstr (struct ui_file *, struct type *, const gdb_byte *,
  138. unsigned int, const char *, int,
  139. const struct value_print_options *);
  140. struct value *ada_convert_actual (struct value *actual,
  141. struct type *formal_type0);
  142. extern bool ada_is_access_to_unconstrained_array (struct type *type);
  143. extern struct value *ada_value_subscript (struct value *, int,
  144. struct value **);
  145. extern void ada_fixup_array_indexes_type (struct type *index_desc_type);
  146. extern struct type *ada_array_element_type (struct type *, int);
  147. extern int ada_array_arity (struct type *);
  148. extern struct value *ada_coerce_to_simple_array_ptr (struct value *);
  149. struct value *ada_coerce_to_simple_array (struct value *);
  150. extern int ada_is_simple_array_type (struct type *);
  151. extern int ada_is_array_descriptor_type (struct type *);
  152. extern int ada_is_bogus_array_descriptor (struct type *);
  153. extern LONGEST ada_discrete_type_low_bound (struct type *);
  154. extern LONGEST ada_discrete_type_high_bound (struct type *);
  155. extern struct value *ada_get_decoded_value (struct value *value);
  156. extern struct type *ada_get_decoded_type (struct type *type);
  157. extern const char *ada_decode_symbol (const struct general_symbol_info *);
  158. /* Decode the GNAT-encoded name NAME, returning the decoded name. If
  159. the name does not appear to be GNAT-encoded, then the result
  160. depends on WRAP. If WRAP is true (the default), then the result is
  161. simply wrapped in <...>. If WRAP is false, then the empty string
  162. will be returned. */
  163. extern std::string ada_decode (const char *name, bool wrap = true);
  164. extern std::vector<struct block_symbol> ada_lookup_symbol_list
  165. (const char *, const struct block *, domain_enum);
  166. extern struct block_symbol ada_lookup_symbol (const char *,
  167. const struct block *,
  168. domain_enum);
  169. extern void ada_lookup_encoded_symbol
  170. (const char *name, const struct block *block, domain_enum domain,
  171. struct block_symbol *symbol_info);
  172. extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *);
  173. extern int ada_scan_number (const char *, int, LONGEST *, int *);
  174. extern struct value *ada_value_primitive_field (struct value *arg1,
  175. int offset,
  176. int fieldno,
  177. struct type *arg_type);
  178. extern struct type *ada_parent_type (struct type *);
  179. extern int ada_is_ignored_field (struct type *, int);
  180. extern int ada_is_constrained_packed_array_type (struct type *);
  181. extern struct value *ada_value_primitive_packed_val (struct value *,
  182. const gdb_byte *,
  183. long, int, int,
  184. struct type *);
  185. extern struct type *ada_coerce_to_simple_array_type (struct type *);
  186. extern bool ada_is_character_type (struct type *);
  187. extern bool ada_is_string_type (struct type *);
  188. extern int ada_is_tagged_type (struct type *, int);
  189. extern int ada_is_tag_type (struct type *);
  190. extern gdb::unique_xmalloc_ptr<char> ada_tag_name (struct value *);
  191. extern struct value *ada_tag_value_at_base_address (struct value *obj);
  192. extern int ada_is_parent_field (struct type *, int);
  193. extern int ada_is_wrapper_field (struct type *, int);
  194. extern int ada_is_variant_part (struct type *, int);
  195. extern struct type *ada_variant_discrim_type (struct type *, struct type *);
  196. extern const char *ada_variant_discrim_name (struct type *);
  197. extern int ada_is_aligner_type (struct type *);
  198. extern struct type *ada_aligned_type (struct type *);
  199. extern const gdb_byte *ada_aligned_value_addr (struct type *,
  200. const gdb_byte *);
  201. extern int ada_is_system_address_type (struct type *);
  202. extern int ada_which_variant_applies (struct type *, struct value *);
  203. extern struct type *ada_to_fixed_type (struct type *, const gdb_byte *,
  204. CORE_ADDR, struct value *,
  205. int check_tag);
  206. extern struct value *ada_to_fixed_value (struct value *val);
  207. extern struct type *ada_template_to_fixed_record_type_1 (struct type *type,
  208. const gdb_byte *valaddr,
  209. CORE_ADDR address,
  210. struct value *dval0,
  211. int keep_dynamic_fields);
  212. extern int ada_name_prefix_len (const char *);
  213. extern const char *ada_type_name (struct type *);
  214. extern struct type *ada_find_parallel_type (struct type *,
  215. const char *suffix);
  216. extern bool get_int_var_value (const char *, LONGEST &value);
  217. extern int ada_prefer_type (struct type *, struct type *);
  218. extern struct type *ada_get_base_type (struct type *);
  219. extern struct type *ada_check_typedef (struct type *);
  220. extern std::string ada_encode (const char *);
  221. extern const char *ada_enum_name (const char *);
  222. extern int ada_is_modular_type (struct type *);
  223. extern ULONGEST ada_modulus (struct type *);
  224. extern struct value *ada_value_ind (struct value *);
  225. extern void ada_print_scalar (struct type *, LONGEST, struct ui_file *);
  226. extern int ada_is_range_type_name (const char *);
  227. extern enum ada_renaming_category ada_parse_renaming (struct symbol *,
  228. const char **,
  229. int *, const char **);
  230. extern void ada_find_printable_frame (struct frame_info *fi);
  231. extern char *ada_breakpoint_rewrite (char *, int *);
  232. extern char *ada_main_name (void);
  233. extern void create_ada_exception_catchpoint
  234. (struct gdbarch *gdbarch, enum ada_exception_catchpoint_kind ex_kind,
  235. const std::string &excep_string, const std::string &cond_string, int tempflag,
  236. int disabled, int from_tty);
  237. /* Return true if BP is an Ada catchpoint. */
  238. extern bool is_ada_exception_catchpoint (breakpoint *bp);
  239. /* Some information about a given Ada exception. */
  240. struct ada_exc_info
  241. {
  242. /* The name of the exception. */
  243. const char *name;
  244. /* The address of the symbol corresponding to that exception. */
  245. CORE_ADDR addr;
  246. bool operator< (const ada_exc_info &) const;
  247. bool operator== (const ada_exc_info &) const;
  248. };
  249. extern std::vector<ada_exc_info> ada_exceptions_list (const char *regexp);
  250. /* Tasking-related: ada-tasks.c */
  251. extern int valid_task_id (int);
  252. extern struct ada_task_info *ada_get_task_info_from_ptid (ptid_t ptid);
  253. extern int ada_get_task_number (thread_info *thread);
  254. typedef gdb::function_view<void (struct ada_task_info *task)>
  255. ada_task_list_iterator_ftype;
  256. extern void iterate_over_live_ada_tasks
  257. (ada_task_list_iterator_ftype iterator);
  258. extern const char *ada_get_tcb_types_info (void);
  259. extern void print_ada_task_info (struct ui_out *uiout,
  260. const char *taskno_str,
  261. struct inferior *inf);
  262. /* Look for a symbol for an overloaded operator for the operation OP.
  263. PARSE_COMPLETION is true if currently parsing for completion.
  264. NARGS and ARGVEC describe the arguments to the call. Returns a
  265. "null" block_symbol if no such operator is found. */
  266. extern block_symbol ada_find_operator_symbol (enum exp_opcode op,
  267. bool parse_completion,
  268. int nargs, value *argvec[]);
  269. /* Resolve a function call, selecting among possible function symbols.
  270. SYM and BLOCK are passed to ada_lookup_symbol_list. CONTEXT_TYPE
  271. describes the calling context. PARSE_COMPLETION is true if
  272. currently parsing for completion. NARGS and ARGVEC describe the
  273. arguments to the call. This returns the chosen symbol and will
  274. update TRACKER accordingly. */
  275. extern block_symbol ada_resolve_funcall (struct symbol *sym,
  276. const struct block *block,
  277. struct type *context_type,
  278. bool parse_completion,
  279. int nargs, value *argvec[],
  280. innermost_block_tracker *tracker);
  281. /* Resolve a symbol reference, selecting among possible values. SYM
  282. and BLOCK are passed to ada_lookup_symbol_list. CONTEXT_TYPE
  283. describes the calling context. PARSE_COMPLETION is true if
  284. currently parsing for completion. If DEPROCEDURE_P is nonzero,
  285. then a symbol that names a zero-argument function will be passed
  286. through ada_resolve_function. This returns the chosen symbol and
  287. will update TRACKER accordingly. */
  288. extern block_symbol ada_resolve_variable (struct symbol *sym,
  289. const struct block *block,
  290. struct type *context_type,
  291. bool parse_completion,
  292. int deprocedure_p,
  293. innermost_block_tracker *tracker);
  294. /* The type of nth index in arrays of given type (n numbering from 1).
  295. Does not examine memory. Throws an error if N is invalid or TYPE
  296. is not an array type. NAME is the name of the Ada attribute being
  297. evaluated ('range, 'first, 'last, or 'length); it is used in building
  298. the error message. */
  299. extern struct type *ada_index_type (struct type *type, int n,
  300. const char *name);
  301. #endif