#include "psymtab.h"
#include "value.h"
+#include "mi/mi-common.h"
/* Define whether or not the C operator '/' truncates towards zero for
differently signed operands (truncation direction is undefined in C).
trying to allocate some memory for it. */
check_size (type);
- result = allocate_value (type);
+ if (value_lazy (val)
+ || TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val)))
+ result = allocate_value_lazy (type);
+ else
+ {
+ result = allocate_value (type);
+ memcpy (value_contents_raw (result), value_contents (val),
+ TYPE_LENGTH (type));
+ }
set_value_component_location (result, val);
set_value_bitsize (result, value_bitsize (val));
set_value_bitpos (result, value_bitpos (val));
set_value_address (result, value_address (val));
- if (value_lazy (val)
- || TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val)))
- set_value_lazy (result, 1);
- else
- memcpy (value_contents_raw (result), value_contents (val),
- TYPE_LENGTH (type));
return result;
}
}
type = ada_check_typedef (type);
return (TYPE_CODE (type) == TYPE_CODE_ARRAY
|| (TYPE_CODE (type) == TYPE_CODE_PTR
- && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY));
+ && TYPE_CODE (ada_check_typedef (TYPE_TARGET_TYPE (type)))
+ == TYPE_CODE_ARRAY));
}
/* Non-zero iff TYPE belongs to a GNAT array descriptor. */
elt_type = create_array_type (array_type, elt_type, range_type);
if (ada_is_unconstrained_packed_array_type (value_type (arr)))
- TYPE_FIELD_BITSIZE (elt_type, 0) =
- decode_packed_array_bitsize (value_type (arr));
+ {
+ /* We need to store the element packed bitsize, as well as
+ recompute the array size, because it was previously
+ computed based on the unpacked element size. */
+ LONGEST lo = value_as_long (low);
+ LONGEST hi = value_as_long (high);
+
+ TYPE_FIELD_BITSIZE (elt_type, 0) =
+ decode_packed_array_bitsize (value_type (arr));
+ /* If the array has no element, then the size is already
+ zero, and does not need to be recomputed. */
+ if (lo < hi)
+ {
+ int array_bitsize =
+ (hi - lo + 1) * TYPE_FIELD_BITSIZE (elt_type, 0);
+
+ TYPE_LENGTH (array_type) = (array_bitsize + 7) / 8;
+ }
+ }
}
return lookup_pointer_type (elt_type);
ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
int low, int high)
{
+ struct type *type0 = ada_check_typedef (type);
CORE_ADDR base = value_as_address (array_ptr)
- + ((low - ada_discrete_type_low_bound (TYPE_INDEX_TYPE (type)))
- * TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
+ + ((low - ada_discrete_type_low_bound (TYPE_INDEX_TYPE (type0)))
+ * TYPE_LENGTH (TYPE_TARGET_TYPE (type0)));
struct type *index_type =
- create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type)),
+ create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type0)),
low, high);
struct type *slice_type =
- create_array_type (NULL, TYPE_TARGET_TYPE (type), index_type);
+ create_array_type (NULL, TYPE_TARGET_TYPE (type0), index_type);
return value_at_lazy (slice_type, base);
}
static struct value *
ada_value_slice (struct value *array, int low, int high)
{
- struct type *type = value_type (array);
+ struct type *type = ada_check_typedef (value_type (array));
struct type *index_type =
create_range_type (NULL, TYPE_INDEX_TYPE (type), low, high);
struct type *slice_type =
static struct value *
empty_array (struct type *arr_type, int low)
{
+ struct type *arr_type0 = ada_check_typedef (arr_type);
struct type *index_type =
- create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (arr_type)),
+ create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (arr_type0)),
low, low - 1);
- struct type *elt_type = ada_array_element_type (arr_type, 1);
+ struct type *elt_type = ada_array_element_type (arr_type0, 1);
return allocate_value (create_array_type (NULL, elt_type, index_type));
}
/* A new expression, with 6 more elements (3 for funcall, 4 for function
symbol, -oplen for operator being replaced). */
struct expression *newexp = (struct expression *)
- xmalloc (sizeof (struct expression)
+ xzalloc (sizeof (struct expression)
+ EXP_ELEM_TO_BYTES ((*expp)->nelts + 7 - oplen));
struct expression *exp = *expp;
newexp->nelts = exp->nelts + 7 - oplen;
newexp->language_defn = exp->language_defn;
+ newexp->gdbarch = exp->gdbarch;
memcpy (newexp->elts, exp->elts, EXP_ELEM_TO_BYTES (pc));
memcpy (newexp->elts + pc + 7, exp->elts + pc + oplen,
EXP_ELEM_TO_BYTES (exp->nelts - pc - oplen));
case '_':
if (*string2 == '\0')
{
- if (is_name_suffix (string2))
+ if (is_name_suffix (string1))
return 0;
else
return -1;
}
+ /* FALLTHROUGH */
default:
if (*string2 == '(')
return strcmp_iw_ordered (string1, string2);
{
const size_t completions_size =
VEC_length (char_ptr, completions) * sizeof (char *);
- char **result = malloc (completions_size);
+ char **result = xmalloc (completions_size);
memcpy (result, VEC_address (char_ptr, completions), completions_size);
struct type *result;
int constrained_packed_array_p;
+ type0 = ada_check_typedef (type0);
if (TYPE_FIXED_INSTANCE (type0))
return type0;
LONGEST low, LONGEST high)
{
int i;
- int expr_pc = *pos+1;
+ int expr_pc = *pos + 1;
for (i = 0; i < num_indices - 2; i += 2)
{
for (ind = indices[i + 1] + 1; ind < indices[i + 2]; ind += 1)
{
- int pos;
+ int localpos;
- pos = expr_pc;
- assign_component (container, lhs, ind, exp, &pos);
+ localpos = expr_pc;
+ assign_component (container, lhs, ind, exp, &localpos);
}
}
ada_evaluate_subexp (NULL, exp, pos, EVAL_SKIP);
static enum print_stop_action
print_it_exception (enum exception_catchpoint_kind ex, struct breakpoint *b)
{
- const CORE_ADDR addr = ada_exception_name_addr (ex, b);
- char exception_name[256];
+ annotate_catchpoint (b->number);
- if (addr != 0)
+ if (ui_out_is_mi_like_p (uiout))
{
- read_memory (addr, exception_name, sizeof (exception_name) - 1);
- exception_name [sizeof (exception_name) - 1] = '\0';
+ ui_out_field_string (uiout, "reason",
+ async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
+ ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition));
}
- ada_find_printable_frame (get_current_frame ());
+ ui_out_text (uiout, "\nCatchpoint ");
+ ui_out_field_int (uiout, "bkptno", b->number);
+ ui_out_text (uiout, ", ");
- annotate_catchpoint (b->number);
switch (ex)
{
case ex_catch_exception:
- if (addr != 0)
- printf_filtered (_("\nCatchpoint %d, %s at "),
- b->number, exception_name);
- else
- printf_filtered (_("\nCatchpoint %d, exception at "), b->number);
- break;
case ex_catch_exception_unhandled:
- if (addr != 0)
- printf_filtered (_("\nCatchpoint %d, unhandled %s at "),
- b->number, exception_name);
- else
- printf_filtered (_("\nCatchpoint %d, unhandled exception at "),
- b->number);
- break;
+ {
+ const CORE_ADDR addr = ada_exception_name_addr (ex, b);
+ char exception_name[256];
+
+ if (addr != 0)
+ {
+ read_memory (addr, exception_name, sizeof (exception_name) - 1);
+ exception_name [sizeof (exception_name) - 1] = '\0';
+ }
+ else
+ {
+ /* For some reason, we were unable to read the exception
+ name. This could happen if the Runtime was compiled
+ without debugging info, for instance. In that case,
+ just replace the exception name by the generic string
+ "exception" - it will read as "an exception" in the
+ notification we are about to print. */
+ sprintf (exception_name, "exception");
+ }
+ /* In the case of unhandled exception breakpoints, we print
+ the exception name as "unhandled EXCEPTION_NAME", to make
+ it clearer to the user which kind of catchpoint just got
+ hit. We used ui_out_text to make sure that this extra
+ info does not pollute the exception name in the MI case. */
+ if (ex == ex_catch_exception_unhandled)
+ ui_out_text (uiout, "unhandled ");
+ ui_out_field_string (uiout, "exception-name", exception_name);
+ }
+ break;
case ex_catch_assert:
- printf_filtered (_("\nCatchpoint %d, failed assertion at "),
- b->number);
- break;
+ /* In this case, the name of the exception is not really
+ important. Just print "failed assertion" to make it clearer
+ that his program just hit an assertion-failure catchpoint.
+ We used ui_out_text because this info does not belong in
+ the MI output. */
+ ui_out_text (uiout, "failed assertion");
+ break;
}
+ ui_out_text (uiout, " at ");
+ ada_find_printable_frame (get_current_frame ());
return PRINT_SRC_AND_LOC;
}
NULL, /* insert */
NULL, /* remove */
NULL, /* breakpoint_hit */
+ NULL, /* resources_needed */
print_it_catch_exception,
print_one_catch_exception,
+ NULL, /* print_one_detail */
print_mention_catch_exception,
print_recreate_catch_exception
};
NULL, /* insert */
NULL, /* remove */
NULL, /* breakpoint_hit */
+ NULL, /* resources_needed */
print_it_catch_exception_unhandled,
print_one_catch_exception_unhandled,
+ NULL, /* print_one_detail */
print_mention_catch_exception_unhandled,
print_recreate_catch_exception_unhandled
};
NULL, /* insert */
NULL, /* remove */
NULL, /* breakpoint_hit */
+ NULL, /* resources_needed */
print_it_catch_assert,
print_one_catch_assert,
+ NULL, /* print_one_detail */
print_mention_catch_assert,
print_recreate_catch_assert
};