summaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c425
1 files changed, 194 insertions, 231 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 51c5fb7ed1e..0babccadaef 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -192,8 +192,6 @@ static struct value *evaluate_subexp (struct type *, struct expression *,
static struct value *evaluate_subexp_type (struct expression *, int *);
-static struct type *ada_create_fundamental_type (struct objfile *, int);
-
static int is_dynamic_field (struct type *, int);
static struct type *to_fixed_variant_branch_type (struct type *, char *,
@@ -281,6 +279,11 @@ static int ada_is_direct_array_type (struct type *);
static void error_breakpoint_runtime_sym_not_found (const char *err_desc);
static int is_runtime_sym_defined (const char *name, int allow_tramp);
+
+static void ada_language_arch_info (struct gdbarch *,
+ struct language_arch_info *);
+
+static void check_size (const struct type *);
@@ -753,6 +756,7 @@ ada_main_name (void)
struct minimal_symbol *msym;
CORE_ADDR main_program_name_addr;
static char main_program_name[1024];
+
/* For Ada, the name of the main procedure is stored in a specific
string constant, generated by the binder. Look for that symbol,
extract its address, and then read that string. If we didn't find
@@ -2196,16 +2200,16 @@ ada_value_ptr_subscript (struct value *arr, struct type *type, int arity,
the Ada slice of HIGH-LOW+1 elements starting at index LOW. The lower
bound of this array is LOW, as per Ada rules. */
static struct value *
-ada_value_slice_ptr (struct value *array_ptr, struct type *type,
+ada_value_slice_ptr (struct value *array_ptr, struct type *type,
int low, int high)
{
- CORE_ADDR base = value_as_address (array_ptr)
+ CORE_ADDR base = value_as_address (array_ptr)
+ ((low - TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)))
* TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
- struct type *index_type =
- create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type)),
+ struct type *index_type =
+ create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type)),
low, high);
- struct type *slice_type =
+ struct type *slice_type =
create_array_type (NULL, TYPE_TARGET_TYPE (type), index_type);
return value_from_pointer (lookup_reference_type (slice_type), base);
}
@@ -2215,11 +2219,11 @@ static struct value *
ada_value_slice (struct value *array, int low, int high)
{
struct type *type = VALUE_TYPE (array);
- struct type *index_type =
+ struct type *index_type =
create_range_type (NULL, TYPE_INDEX_TYPE (type), low, high);
- struct type *slice_type =
+ struct type *slice_type =
create_array_type (NULL, TYPE_TARGET_TYPE (type), index_type);
- return value_cast (slice_type, value_slice (array, low, high-low+1));
+ return value_cast (slice_type, value_slice (array, low, high - low + 1));
}
/* If type is a record type in the form of a standard GNAT array
@@ -2439,7 +2443,7 @@ ada_array_length (struct value *arr, int n)
}
else
return
- value_from_longest (builtin_type_ada_int,
+ value_from_longest (builtin_type_int,
value_as_long (desc_one_bound (desc_bounds (arr),
n, 1))
- value_as_long (desc_one_bound (desc_bounds (arr),
@@ -2452,7 +2456,7 @@ ada_array_length (struct value *arr, int n)
static struct value *
empty_array (struct type *arr_type, int low)
{
- struct type *index_type =
+ struct type *index_type =
create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (arr_type)),
low, low - 1);
struct type *elt_type = ada_array_element_type (arr_type, 1);
@@ -6179,6 +6183,20 @@ extended_canonical_line_spec (struct symtab_and_line sal, const char *name)
return r;
}
+
+ /* Exception-related */
+
+int
+ada_is_exception_sym (struct symbol *sym)
+{
+ char *type_name = type_name_no_tag (SYMBOL_TYPE (sym));
+
+ return (SYMBOL_CLASS (sym) != LOC_TYPEDEF
+ && SYMBOL_CLASS (sym) != LOC_BLOCK
+ && SYMBOL_CLASS (sym) != LOC_CONST
+ && type_name != NULL && strcmp (type_name, "exception") == 0);
+}
+
/* Return type of Ada breakpoint associated with bp_stat:
0 if not an Ada-specific breakpoint, 1 for break on specific exception,
2 for break on unhandled exception, 3 for assert. */
@@ -6430,25 +6448,6 @@ ada_print_exception_breakpoint_task (struct breakpoint *b)
}
}
-int
-ada_is_exception_sym (struct symbol *sym)
-{
- char *type_name = type_name_no_tag (SYMBOL_TYPE (sym));
-
- return (SYMBOL_CLASS (sym) != LOC_TYPEDEF
- && SYMBOL_CLASS (sym) != LOC_BLOCK
- && SYMBOL_CLASS (sym) != LOC_CONST
- && type_name != NULL && strcmp (type_name, "exception") == 0);
-}
-
-int
-ada_maybe_exception_partial_symbol (struct partial_symbol *sym)
-{
- return (SYMBOL_CLASS (sym) != LOC_TYPEDEF
- && SYMBOL_CLASS (sym) != LOC_BLOCK
- && SYMBOL_CLASS (sym) != LOC_CONST);
-}
-
/* Cause the appropriate error if no appropriate runtime symbol is
found to set a breakpoint, using ERR_DESC to describe the
breakpoint. */
@@ -6573,7 +6572,7 @@ ada_breakpoint_rewrite (char *arg, int *break_on_exceptionp)
}
return arg;
}
-#endif
+#endif /* GNAT_GDB */
/* Field Access */
@@ -7720,9 +7719,8 @@ ada_template_to_fixed_record_type_1 (struct type *type, char *valaddr,
for (f = 0; f < nfields; f += 1)
{
- off =
- align_value (off,
- field_alignment (type, f)) + TYPE_FIELD_BITPOS (type, f);
+ off = align_value (off, field_alignment (type, f))
+ + TYPE_FIELD_BITPOS (type, f);
TYPE_FIELD_BITPOS (rtype, f) = off;
TYPE_FIELD_BITSIZE (rtype, f) = 0;
@@ -8348,7 +8346,7 @@ pos_atr (struct value *arg)
static struct value *
value_pos_atr (struct value *arg)
{
- return value_from_longest (builtin_type_ada_int, pos_atr (arg));
+ return value_from_longest (builtin_type_int, pos_atr (arg));
}
/* Evaluate the TYPE'VAL attribute applied to ARG. */
@@ -9066,7 +9064,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
array = value_addr (array);
if (noside == EVAL_AVOID_SIDE_EFFECTS
- && ada_is_array_descriptor_type (check_typedef
+ && ada_is_array_descriptor_type (check_typedef
(VALUE_TYPE (array))))
return empty_array (ada_type_of_array (array, 0), low_bound);
@@ -9083,7 +9081,8 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
to_fixed_array_type (TYPE_TARGET_TYPE (VALUE_TYPE (array)),
NULL, 1);
return ada_value_slice_ptr (array, arr_type0,
- (int) low_bound, (int) high_bound);
+ (int) low_bound,
+ (int) high_bound);
}
}
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
@@ -9324,7 +9323,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
if (noside == EVAL_SKIP)
goto nosideret;
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (builtin_type_ada_int, not_lval);
+ return value_zero (builtin_type_int, not_lval);
else
return value_pos_atr (arg1);
@@ -9333,9 +9332,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
if (noside == EVAL_SKIP)
goto nosideret;
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (builtin_type_ada_int, not_lval);
+ return value_zero (builtin_type_int, not_lval);
else
- return value_from_longest (builtin_type_ada_int,
+ return value_from_longest (builtin_type_int,
TARGET_CHAR_BIT
* TYPE_LENGTH (VALUE_TYPE (arg1)));
@@ -10088,179 +10087,7 @@ static const struct op_print ada_op_print_tab[] = {
{NULL, 0, 0, 0}
};
- /* Assorted Types and Interfaces */
-
-struct type *builtin_type_ada_int;
-struct type *builtin_type_ada_short;
-struct type *builtin_type_ada_long;
-struct type *builtin_type_ada_long_long;
-struct type *builtin_type_ada_char;
-struct type *builtin_type_ada_float;
-struct type *builtin_type_ada_double;
-struct type *builtin_type_ada_long_double;
-struct type *builtin_type_ada_natural;
-struct type *builtin_type_ada_positive;
-struct type *builtin_type_ada_system_address;
-
-struct type **const (ada_builtin_types[]) =
-{
- &builtin_type_ada_int,
- &builtin_type_ada_long,
- &builtin_type_ada_short,
- &builtin_type_ada_char,
- &builtin_type_ada_float,
- &builtin_type_ada_double,
- &builtin_type_ada_long_long,
- &builtin_type_ada_long_double,
- &builtin_type_ada_natural, &builtin_type_ada_positive,
- /* The following types are carried over from C for convenience. */
-&builtin_type_int,
- &builtin_type_long,
- &builtin_type_short,
- &builtin_type_char,
- &builtin_type_float,
- &builtin_type_double,
- &builtin_type_long_long,
- &builtin_type_void,
- &builtin_type_signed_char,
- &builtin_type_unsigned_char,
- &builtin_type_unsigned_short,
- &builtin_type_unsigned_int,
- &builtin_type_unsigned_long,
- &builtin_type_unsigned_long_long,
- &builtin_type_long_double,
- &builtin_type_complex, &builtin_type_double_complex, 0};
-
-/* Not really used, but needed in the ada_language_defn. */
-
-static void
-emit_char (int c, struct ui_file *stream, int quoter)
-{
- ada_emit_char (c, stream, quoter, 1);
-}
-
-static int
-parse (void)
-{
- warnings_issued = 0;
- return ada_parse ();
-}
-
-static const struct exp_descriptor ada_exp_descriptor = {
- ada_print_subexp,
- ada_operator_length,
- ada_op_name,
- ada_dump_subexp_body,
- ada_evaluate_subexp
-};
-
-const struct language_defn ada_language_defn = {
- "ada", /* Language name */
- language_ada,
- ada_builtin_types,
- range_check_off,
- type_check_off,
- case_sensitive_on, /* Yes, Ada is case-insensitive, but
- that's not quite what this means. */
-#ifdef GNAT_GDB
- ada_lookup_symbol,
- ada_lookup_minimal_symbol,
-#endif /* GNAT_GDB */
- array_row_major,
- &ada_exp_descriptor,
- parse,
- ada_error,
- resolve,
- ada_printchar, /* Print a character constant */
- ada_printstr, /* Function to print string constant */
- emit_char, /* Function to print single char (not used) */
- ada_create_fundamental_type, /* Create fundamental type in this language */
- ada_print_type, /* Print a type using appropriate syntax */
- ada_val_print, /* Print a value using appropriate syntax */
- ada_value_print, /* Print a top-level value */
- NULL, /* Language specific skip_trampoline */
- NULL, /* value_of_this */
- ada_lookup_symbol_nonlocal, /* Looking up non-local symbols. */
- basic_lookup_transparent_type, /* lookup_transparent_type */
- ada_la_decode, /* Language specific symbol demangler */
- NULL, /* Language specific class_name_from_physname */
- ada_op_print_tab, /* expression operators for printing */
- 0, /* c-style arrays */
- 1, /* String lower bound */
- &builtin_type_ada_char,
- ada_get_gdb_completer_word_break_characters,
-#ifdef GNAT_GDB
- ada_translate_error_message, /* Substitute Ada-specific terminology
- in errors and warnings. */
-#endif /* GNAT_GDB */
- LANG_MAGIC
-};
-
-static void
-build_ada_types (struct gdbarch *current_gdbarch)
-{
- builtin_type_ada_int =
- init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
- 0, "integer", (struct objfile *) NULL);
- builtin_type_ada_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
- 0, "long_integer", (struct objfile *) NULL);
- builtin_type_ada_short =
- init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
- 0, "short_integer", (struct objfile *) NULL);
- builtin_type_ada_char =
- init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0, "character", (struct objfile *) NULL);
- builtin_type_ada_float =
- init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
- 0, "float", (struct objfile *) NULL);
- builtin_type_ada_double =
- init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
- 0, "long_float", (struct objfile *) NULL);
- builtin_type_ada_long_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- 0, "long_long_integer", (struct objfile *) NULL);
- builtin_type_ada_long_double =
- init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
- 0, "long_long_float", (struct objfile *) NULL);
- builtin_type_ada_natural =
- init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
- 0, "natural", (struct objfile *) NULL);
- builtin_type_ada_positive =
- init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
- 0, "positive", (struct objfile *) NULL);
-
-
- builtin_type_ada_system_address =
- lookup_pointer_type (init_type (TYPE_CODE_VOID, 1, 0, "void",
- (struct objfile *) NULL));
- TYPE_NAME (builtin_type_ada_system_address) = "system__address";
-}
-
-void
-_initialize_ada_language (void)
-{
-
- build_ada_types (current_gdbarch);
- gdbarch_data_register_post_init (build_ada_types);
- add_language (&ada_language_defn);
-
- varsize_limit = 65536;
-#ifdef GNAT_GDB
- add_setshow_uinteger_cmd ("varsize-limit", class_support,
- &varsize_limit, "\
-Set the maximum number of bytes allowed in a dynamic-sized object.", "\
-Show the maximum number of bytes allowed in a dynamic-sized object.",
- NULL, NULL, &setlist, &showlist);
- obstack_init (&cache_space);
-#endif /* GNAT_GDB */
-
- obstack_init (&symbol_list_obstack);
-
- decoded_names_store = htab_create_alloc
- (256, htab_hash_string, (int (*)(const void *, const void *)) streq,
- NULL, xcalloc, xfree);
-}
+ /* Fundamental Ada Types */
/* Create a fundamental Ada type using default reasonable for the current
target machine.
@@ -10343,7 +10170,9 @@ ada_create_fundamental_type (struct objfile *objfile, int typeid)
0, "integer", objfile);
break;
case FT_SIGNED_INTEGER:
- type = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 0, "integer", objfile); /* FIXME -fnf */
+ type = init_type (TYPE_CODE_INT, TARGET_INT_BIT /
+ TARGET_CHAR_BIT,
+ 0, "integer", objfile); /* FIXME -fnf */
break;
case FT_UNSIGNED_INTEGER:
type = init_type (TYPE_CODE_INT,
@@ -10399,22 +10228,156 @@ ada_create_fundamental_type (struct objfile *objfile, int typeid)
return (type);
}
+enum ada_primitive_types {
+ ada_primitive_type_int,
+ ada_primitive_type_long,
+ ada_primitive_type_short,
+ ada_primitive_type_char,
+ ada_primitive_type_float,
+ ada_primitive_type_double,
+ ada_primitive_type_void,
+ ada_primitive_type_long_long,
+ ada_primitive_type_long_double,
+ ada_primitive_type_natural,
+ ada_primitive_type_positive,
+ ada_primitive_type_system_address,
+ nr_ada_primitive_types
+};
+
+static void
+ada_language_arch_info (struct gdbarch *current_gdbarch,
+ struct language_arch_info *lai)
+{
+ const struct builtin_type *builtin = builtin_type (current_gdbarch);
+ lai->primitive_type_vector
+ = GDBARCH_OBSTACK_CALLOC (current_gdbarch, nr_ada_primitive_types + 1,
+ struct type *);
+ lai->primitive_type_vector [ada_primitive_type_int] =
+ init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
+ 0, "integer", (struct objfile *) NULL);
+ lai->primitive_type_vector [ada_primitive_type_long] =
+ init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
+ 0, "long_integer", (struct objfile *) NULL);
+ lai->primitive_type_vector [ada_primitive_type_short] =
+ init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
+ 0, "short_integer", (struct objfile *) NULL);
+ lai->primitive_type_vector [ada_primitive_type_char] =
+ init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ 0, "character", (struct objfile *) NULL);
+ lai->string_char_type = builtin->builtin_char;
+ lai->primitive_type_vector [ada_primitive_type_float] =
+ init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
+ 0, "float", (struct objfile *) NULL);
+ lai->primitive_type_vector [ada_primitive_type_double] =
+ init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
+ 0, "long_float", (struct objfile *) NULL);
+ lai->primitive_type_vector [ada_primitive_type_long_long] =
+ init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
+ 0, "long_long_integer", (struct objfile *) NULL);
+ lai->primitive_type_vector [ada_primitive_type_long_double] =
+ init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
+ 0, "long_long_float", (struct objfile *) NULL);
+ lai->primitive_type_vector [ada_primitive_type_natural] =
+ init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
+ 0, "natural", (struct objfile *) NULL);
+ lai->primitive_type_vector [ada_primitive_type_positive] =
+ init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
+ 0, "positive", (struct objfile *) NULL);
+ lai->primitive_type_vector [ada_primitive_type_void] = builtin->builtin_void;
+
+ lai->primitive_type_vector [ada_primitive_type_system_address] =
+ lookup_pointer_type (init_type (TYPE_CODE_VOID, 1, 0, "void",
+ (struct objfile *) NULL));
+ TYPE_NAME (lai->primitive_type_vector [ada_primitive_type_system_address])
+ = "system__address";
+}
+
+ /* Language vector */
+
+/* Not really used, but needed in the ada_language_defn. */
+
+static void
+emit_char (int c, struct ui_file *stream, int quoter)
+{
+ ada_emit_char (c, stream, quoter, 1);
+}
+
+static int
+parse (void)
+{
+ warnings_issued = 0;
+ return ada_parse ();
+}
+
+static const struct exp_descriptor ada_exp_descriptor = {
+ ada_print_subexp,
+ ada_operator_length,
+ ada_op_name,
+ ada_dump_subexp_body,
+ ada_evaluate_subexp
+};
+
+const struct language_defn ada_language_defn = {
+ "ada", /* Language name */
+ language_ada,
+ NULL,
+ range_check_off,
+ type_check_off,
+ case_sensitive_on, /* Yes, Ada is case-insensitive, but
+ that's not quite what this means. */
+#ifdef GNAT_GDB
+ ada_lookup_symbol,
+ ada_lookup_minimal_symbol,
+#endif /* GNAT_GDB */
+ array_row_major,
+ &ada_exp_descriptor,
+ parse,
+ ada_error,
+ resolve,
+ ada_printchar, /* Print a character constant */
+ ada_printstr, /* Function to print string constant */
+ emit_char, /* Function to print single char (not used) */
+ ada_create_fundamental_type, /* Create fundamental type in this language */
+ ada_print_type, /* Print a type using appropriate syntax */
+ ada_val_print, /* Print a value using appropriate syntax */
+ ada_value_print, /* Print a top-level value */
+ NULL, /* Language specific skip_trampoline */
+ NULL, /* value_of_this */
+ ada_lookup_symbol_nonlocal, /* Looking up non-local symbols. */
+ basic_lookup_transparent_type, /* lookup_transparent_type */
+ ada_la_decode, /* Language specific symbol demangler */
+ NULL, /* Language specific class_name_from_physname */
+ ada_op_print_tab, /* expression operators for printing */
+ 0, /* c-style arrays */
+ 1, /* String lower bound */
+ NULL,
+ ada_get_gdb_completer_word_break_characters,
+ ada_language_arch_info,
+#ifdef GNAT_GDB
+ ada_translate_error_message, /* Substitute Ada-specific terminology
+ in errors and warnings. */
+#endif /* GNAT_GDB */
+ LANG_MAGIC
+};
+
void
-ada_dump_symtab (struct symtab *s)
+_initialize_ada_language (void)
{
- int i;
- fprintf (stderr, "New symtab: [\n");
- fprintf (stderr, " Name: %s/%s;\n",
- s->dirname ? s->dirname : "?", s->filename ? s->filename : "?");
- fprintf (stderr, " Format: %s;\n", s->debugformat);
- if (s->linetable != NULL)
- {
- fprintf (stderr, " Line table (section %d):\n", s->block_line_section);
- for (i = 0; i < s->linetable->nitems; i += 1)
- {
- struct linetable_entry *e = s->linetable->item + i;
- fprintf (stderr, " %4ld: %8lx\n", (long) e->line, (long) e->pc);
- }
- }
- fprintf (stderr, "]\n");
+ add_language (&ada_language_defn);
+
+ varsize_limit = 65536;
+#ifdef GNAT_GDB
+ add_setshow_uinteger_cmd ("varsize-limit", class_support,
+ &varsize_limit, "\
+Set the maximum number of bytes allowed in a dynamic-sized object.", "\
+Show the maximum number of bytes allowed in a dynamic-sized object.",
+ NULL, NULL, &setlist, &showlist);
+ obstack_init (&cache_space);
+#endif /* GNAT_GDB */
+
+ obstack_init (&symbol_list_obstack);
+
+ decoded_names_store = htab_create_alloc
+ (256, htab_hash_string, (int (*)(const void *, const void *)) streq,
+ NULL, xcalloc, xfree);
}