#include "p-lang.h"
#include "cp-abi.h"
#include "cp-support.h"
+#include "exceptions.h"
\f
-
-
-/* Print data of type TYPE located at VALADDR (within GDB), which came from
- the inferior at address ADDRESS, onto stdio stream STREAM according to
- OPTIONS. The data at VALADDR is in target byte order.
-
- If the data are a string pointer, returns the number of string characters
- printed. */
-
+/* See val_print for a description of the various parameters of this
+ function; they are identical. The semantics of the return value is
+ also identical to val_print. */
int
pascal_val_print (struct type *type, const gdb_byte *valaddr,
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
- if (get_array_bounds (type, &low_bound, &high_bound))
+ if (get_array_bounds (type, &low_bound, &high_bound))
{
len = high_bound - low_bound + 1;
elttype = check_typedef (TYPE_TARGET_TYPE (type));
break;
}
/* Array of unspecified length: treat like pointer to first elt. */
- addr = address;
+ addr = address + embedded_offset;
goto print_unpacked_pointer;
case TYPE_CODE_PTR:
if (options->format && options->format != 's')
{
- print_scalar_formatted (valaddr + embedded_offset, type,
- options, 0, stream);
+ val_print_scalar_formatted (type, valaddr, embedded_offset,
+ original_value, options, 0, stream);
break;
}
if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
print_address_demangle (gdbarch, addr, stream, demangle);
break;
}
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ check_typedef (TYPE_TARGET_TYPE (type));
addr = unpack_pointer (type, valaddr + embedded_offset);
print_unpacked_pointer:
len = extract_unsigned_integer (valaddr + embedded_offset
+ length_pos, length_size,
byte_order);
- LA_PRINT_STRING (stream, char_type,
+ LA_PRINT_STRING (stream, char_type,
valaddr + embedded_offset + string_pos,
len, NULL, 0, options);
}
case TYPE_CODE_ENUM:
if (options->format)
{
- print_scalar_formatted (valaddr + embedded_offset, type,
- options, 0, stream);
+ val_print_scalar_formatted (type, valaddr, embedded_offset,
+ original_value, options, 0, stream);
break;
}
len = TYPE_NFIELDS (type);
case TYPE_CODE_FLAGS:
if (options->format)
- print_scalar_formatted (valaddr + embedded_offset, type,
- options, 0, stream);
+ val_print_scalar_formatted (type, valaddr, embedded_offset,
+ original_value, options, 0, stream);
else
val_print_type_code_flags (type, valaddr + embedded_offset, stream);
break;
case TYPE_CODE_FUNC:
if (options->format)
{
- print_scalar_formatted (valaddr + embedded_offset, type,
- options, 0, stream);
+ val_print_scalar_formatted (type, valaddr, embedded_offset,
+ original_value, options, 0, stream);
break;
}
/* FIXME, we should consider, at least for ANSI C language, eliminating
opts.format = (options->format ? options->format
: options->output_format);
- print_scalar_formatted (valaddr + embedded_offset, type,
- &opts, 0, stream);
+ val_print_scalar_formatted (type, valaddr, embedded_offset,
+ original_value, &opts, 0, stream);
}
else
{
opts.format = (options->format ? options->format
: options->output_format);
- print_scalar_formatted (valaddr + embedded_offset, type,
- &opts, 0, stream);
+ val_print_scalar_formatted (type, valaddr, embedded_offset,
+ original_value, &opts, 0, stream);
}
else
{
opts.format = (options->format ? options->format
: options->output_format);
- print_scalar_formatted (valaddr + embedded_offset, type,
- &opts, 0, stream);
+ val_print_scalar_formatted (type, valaddr, embedded_offset,
+ original_value, &opts, 0, stream);
}
else
{
case TYPE_CODE_FLT:
if (options->format)
{
- print_scalar_formatted (valaddr + embedded_offset, type,
- options, 0, stream);
+ val_print_scalar_formatted (type, valaddr, embedded_offset,
+ original_value, options, 0, stream);
}
else
{
{
/* Hack: remove (char *) for char strings. Their
type is indicated by the quoted string anyway. */
- if (TYPE_CODE (type) == TYPE_CODE_PTR
+ if (TYPE_CODE (type) == TYPE_CODE_PTR
&& TYPE_NAME (type) == NULL
&& TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
&& strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0)
{
struct value_print_options opts = *options;
- v = value_from_longest (TYPE_FIELD_TYPE (type, i),
- unpack_field_as_long (type,
- valaddr + offset, i));
+ v = value_field_bitfield (type, i, valaddr, offset, val);
opts.deref_ref = 0;
common_val_print (v, stream, recurse + 1, &opts,
v4.17 specific. */
struct value *v;
- v = value_from_longest
- (TYPE_FIELD_TYPE (type, i),
- unpack_field_as_long (type, valaddr + offset, i));
+ v = value_field_bitfield (type, i, valaddr, offset, val);
if (v == NULL)
val_print_optimized_out (stream);
for (i = 0; i < n_baseclasses; i++)
{
- int boffset;
+ int boffset = 0;
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
char *basename = type_name_no_tag (baseclass);
- const gdb_byte *base_valaddr;
+ const gdb_byte *base_valaddr = NULL;
int thisoffset;
+ volatile struct gdb_exception ex;
+ int skip = 0;
if (BASETYPE_VIA_VIRTUAL (type, i))
{
thisoffset = offset;
- boffset = baseclass_offset (type, i, valaddr + offset, address + offset);
+ TRY_CATCH (ex, RETURN_MASK_ERROR)
+ {
+ boffset = baseclass_offset (type, i, valaddr, offset, address, val);
+ }
+ if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR)
+ skip = -1;
+ else if (ex.reason < 0)
+ skip = 1;
+ else
+ {
+ skip = 0;
+
+ /* The virtual base class pointer might have been clobbered by the
+ user program. Make sure that it still points to a valid memory
+ location. */
+
+ if (boffset < 0 || boffset >= TYPE_LENGTH (type))
+ {
+ /* FIXME (alloc): not safe is baseclass is really really big. */
+ gdb_byte *buf = alloca (TYPE_LENGTH (baseclass));
+
+ base_valaddr = buf;
+ if (target_read_memory (address + boffset, buf,
+ TYPE_LENGTH (baseclass)) != 0)
+ skip = 1;
+ address = address + boffset;
+ thisoffset = 0;
+ boffset = 0;
+ }
+ else
+ base_valaddr = valaddr;
+ }
if (options->pretty)
{
fputs_filtered (basename ? basename : "", stream);
fputs_filtered ("> = ", stream);
- /* The virtual base class pointer might have been clobbered by the
- user program. Make sure that it still points to a valid memory
- location. */
-
- if (boffset != -1 && (boffset < 0 || boffset >= TYPE_LENGTH (type)))
- {
- /* FIXME (alloc): not safe is baseclass is really really big. */
- gdb_byte *buf = alloca (TYPE_LENGTH (baseclass));
-
- base_valaddr = buf;
- if (target_read_memory (address + boffset, buf,
- TYPE_LENGTH (baseclass)) != 0)
- boffset = -1;
- address = address + boffset;
- thisoffset = 0;
- boffset = 0;
- }
- else
- base_valaddr = valaddr;
-
- if (boffset == -1)
- fprintf_filtered (stream, "<invalid address>");
+ if (skip < 0)
+ val_print_unavailable (stream);
+ else if (skip > 0)
+ val_print_invalid_address (stream);
else
pascal_object_print_value_fields (baseclass, base_valaddr,
thisoffset + boffset, address,