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