本文整理汇总了C++中TYPE_TARGET_TYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ TYPE_TARGET_TYPE函数的具体用法?C++ TYPE_TARGET_TYPE怎么用?C++ TYPE_TARGET_TYPE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TYPE_TARGET_TYPE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compile_cplus_convert_memberptr
static gcc_type
compile_cplus_convert_memberptr (compile_cplus_instance *instance,
struct type *type)
{
struct type *containing_class = TYPE_SELF_TYPE (type);
if (containing_class == nullptr)
return GCC_TYPE_NONE;
gcc_type class_type = instance->convert_type (containing_class);
gcc_type member_type
= instance->convert_type (TYPE_TARGET_TYPE (type));
return instance->plugin ().build_pointer_to_member_type
(class_type, member_type);
}
示例2: m2_unbounded_array
static int
m2_unbounded_array (struct type *type, struct ui_file *stream, int show,
int level, const struct type_print_options *flags)
{
if (m2_is_unbounded_array (type))
{
if (show > 0)
{
fputs_filtered ("ARRAY OF ", stream);
m2_print_type (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)),
"", stream, 0, level, flags);
}
return 1;
}
return 0;
}
示例3: print_range_type_named
/* Print the range type named NAME: */
static void
print_range_type_named(char *name, struct ui_file *stream)
{
struct type *raw_type = ada_find_any_type(name);
struct type *base_type;
char *subtype_info;
if (raw_type == NULL)
base_type = builtin_type_int;
else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
base_type = TYPE_TARGET_TYPE (raw_type);
else
base_type = raw_type;
subtype_info = strstr (name, "___XD");
if (subtype_info == NULL && raw_type == NULL)
fprintf_filtered (stream, "? .. ?");
else if (subtype_info == NULL)
print_range (raw_type, stream);
else
{
int prefix_len = subtype_info - name;
char *bounds_str;
int n;
subtype_info += 5;
bounds_str = strchr (subtype_info, '_');
n = 1;
if (*subtype_info == 'L')
{
print_range_bound (base_type, bounds_str, &n, stream);
subtype_info += 1;
}
else
print_dynamic_range_bound (base_type, name, prefix_len, "___L",
stream);
fprintf_filtered (stream, " .. ");
if (*subtype_info == 'U')
print_range_bound (base_type, bounds_str, &n, stream);
else
print_dynamic_range_bound (base_type, name, prefix_len, "___U",
stream);
}
}
示例4: print_go_string
static void
print_go_string (struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
struct value *val,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
struct type *elt_ptr_type = TYPE_FIELD_TYPE (type, 0);
struct type *elt_type = TYPE_TARGET_TYPE (elt_ptr_type);
LONGEST length;
/* TODO(dje): The encapsulation of what a pointer is belongs in value.c.
I.e. If there's going to be unpack_pointer, there should be
unpack_value_field_as_pointer. Do this until we can get
unpack_value_field_as_pointer. */
LONGEST addr;
const gdb_byte *valaddr = value_contents_for_printing (val);
if (! unpack_value_field_as_long (type, valaddr, embedded_offset, 0,
val, &addr))
error (_("Unable to read string address"));
if (! unpack_value_field_as_long (type, valaddr, embedded_offset, 1,
val, &length))
error (_("Unable to read string length"));
/* TODO(dje): Print address of struct or actual string? */
if (options->addressprint)
{
fputs_filtered (paddress (gdbarch, addr), stream);
fputs_filtered (" ", stream);
}
if (length < 0)
{
fputs_filtered (_("<invalid length: "), stream);
fputs_filtered (plongest (addr), stream);
fputs_filtered (">", stream);
return;
}
/* TODO(dje): Perhaps we should pass "UTF8" for ENCODING.
The target encoding is a global switch.
Either choice is problematic. */
val_print_string (elt_type, NULL, addr, length, stream, options);
}
示例5: print_range_type
static void
print_range_type (struct type *raw_type, struct ui_file *stream)
{
const char *name;
struct type *base_type;
const char *subtype_info;
gdb_assert (raw_type != NULL);
name = TYPE_NAME (raw_type);
gdb_assert (name != NULL);
if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
base_type = TYPE_TARGET_TYPE (raw_type);
else
base_type = raw_type;
subtype_info = strstr (name, "___XD");
if (subtype_info == NULL)
print_range (raw_type, stream);
else
{
int prefix_len = subtype_info - name;
char *bounds_str;
int n;
subtype_info += 5;
bounds_str = strchr (subtype_info, '_');
n = 1;
if (*subtype_info == 'L')
{
print_range_bound (base_type, bounds_str, &n, stream);
subtype_info += 1;
}
else
print_dynamic_range_bound (base_type, name, prefix_len, "___L",
stream);
fprintf_filtered (stream, " .. ");
if (*subtype_info == 'U')
print_range_bound (base_type, bounds_str, &n, stream);
else
print_dynamic_range_bound (base_type, name, prefix_len, "___U",
stream);
}
}
示例6: m2_range
void
m2_range (struct type *type, struct ui_file *stream, int show,
int level)
{
if (TYPE_HIGH_BOUND (type) == TYPE_LOW_BOUND (type))
m2_print_type (TYPE_DOMAIN_TYPE (type), "", stream, show, level);
else
{
struct type *target = TYPE_TARGET_TYPE (type);
fprintf_filtered (stream, "[");
print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
fprintf_filtered (stream, "..");
print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
fprintf_filtered (stream, "]");
}
}
示例7: stpy_convert_to_value
static PyObject *
stpy_convert_to_value (PyObject *self, PyObject *args)
{
lazy_string_object *self_string = (lazy_string_object *) self;
struct value *val = NULL;
if (self_string->address == 0)
{
PyErr_SetString (gdbpy_gdb_memory_error,
_("Cannot create a value from NULL."));
return NULL;
}
TRY
{
struct type *type = type_object_to_type (self_string->type);
struct type *realtype;
gdb_assert (type != NULL);
realtype = check_typedef (type);
switch (TYPE_CODE (realtype))
{
case TYPE_CODE_PTR:
/* If a length is specified we need to convert this to an array
of the specified size. */
if (self_string->length != -1)
{
/* PR 20786: There's no way to specify an array of length zero.
Record a length of [0,-1] which is how Ada does it. Anything
we do is broken, but this is one possible solution. */
type = lookup_array_range_type (TYPE_TARGET_TYPE (realtype),
0, self_string->length - 1);
val = value_at_lazy (type, self_string->address);
}
else
val = value_from_pointer (type, self_string->address);
break;
default:
val = value_at_lazy (type, self_string->address);
break;
}
}
CATCH (except, RETURN_MASK_ALL)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
示例8: print_range
static void
print_range(struct type *the_type, struct ui_file *stream)
{
struct type *target_type;
target_type = TYPE_TARGET_TYPE(the_type);
if (target_type == NULL)
target_type = the_type;
switch (TYPE_CODE(target_type))
{
case TYPE_CODE_RANGE:
case TYPE_CODE_INT:
case TYPE_CODE_BOOL:
case TYPE_CODE_CHAR:
case TYPE_CODE_ENUM:
break;
default:
target_type = builtin_type_int;
break;
}
if (TYPE_NFIELDS(the_type) < 2)
{
/* A range needs at least 2 bounds to be printed. If there are less
than 2, just print the type name instead of the range itself.
This check handles cases such as characters, for example.
Note that if the name is not defined, then we don't print anything.
*/
fprintf_filtered(stream, "%.*s",
ada_name_prefix_len(TYPE_NAME(the_type)),
TYPE_NAME(the_type));
}
else
{
/* We extract the range type bounds respectively from the first element
and the last element of the type->fields array */
const LONGEST lower_bound = (LONGEST)TYPE_LOW_BOUND(the_type);
const LONGEST upper_bound =
(LONGEST)TYPE_FIELD_BITPOS(the_type, TYPE_NFIELDS(the_type) - 1);
ada_print_scalar(target_type, lower_bound, stream);
fprintf_filtered(stream, " .. ");
ada_print_scalar(target_type, upper_bound, stream);
}
}
示例9: get_regs_type
static struct type *
get_regs_type (struct objfile *objfile)
{
struct symbol *func_sym;
struct type *func_type, *regsp_type, *regs_type;
func_sym = lookup_global_symbol_from_objfile (objfile,
GCC_FE_WRAPPER_FUNCTION,
VAR_DOMAIN);
if (func_sym == NULL)
error (_("Cannot find function \"%s\" in compiled module \"%s\"."),
GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile));
func_type = SYMBOL_TYPE (func_sym);
if (TYPE_CODE (func_type) != TYPE_CODE_FUNC)
error (_("Invalid type code %d of function \"%s\" in compiled "
"module \"%s\"."),
TYPE_CODE (func_type), GCC_FE_WRAPPER_FUNCTION,
objfile_name (objfile));
/* No register parameter present. */
if (TYPE_NFIELDS (func_type) == 0)
return NULL;
if (TYPE_NFIELDS (func_type) != 1)
error (_("Invalid %d parameters of function \"%s\" in compiled "
"module \"%s\"."),
TYPE_NFIELDS (func_type), GCC_FE_WRAPPER_FUNCTION,
objfile_name (objfile));
regsp_type = check_typedef (TYPE_FIELD_TYPE (func_type, 0));
if (TYPE_CODE (regsp_type) != TYPE_CODE_PTR)
error (_("Invalid type code %d of first parameter of function \"%s\" "
"in compiled module \"%s\"."),
TYPE_CODE (regsp_type), GCC_FE_WRAPPER_FUNCTION,
objfile_name (objfile));
regs_type = check_typedef (TYPE_TARGET_TYPE (regsp_type));
if (TYPE_CODE (regs_type) != TYPE_CODE_STRUCT)
error (_("Invalid type code %d of dereferenced first parameter "
"of function \"%s\" in compiled module \"%s\"."),
TYPE_CODE (regs_type), GCC_FE_WRAPPER_FUNCTION,
objfile_name (objfile));
return regs_type;
}
示例10: m2_print_bounds
static void
m2_print_bounds (struct type *type,
struct ui_file *stream, int show, int level,
int print_high)
{
struct type *target = TYPE_TARGET_TYPE (type);
if (target == NULL)
target = builtin_type_int;
if (TYPE_NFIELDS(type) == 0)
return;
if (print_high)
print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
else
print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
}
示例11: ada_val_print_string
static void
ada_val_print_string (struct type *type, const gdb_byte *valaddr,
int offset, int offset_aligned, CORE_ADDR address,
struct ui_file *stream, int recurse,
struct value *original_value,
const struct value_print_options *options)
{
enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
struct type *elttype = TYPE_TARGET_TYPE (type);
unsigned int eltlen;
unsigned int len;
/* We know that ELTTYPE cannot possibly be null, because we assume
that we're called only when TYPE is a string-like type.
Similarly, the size of ELTTYPE should also be non-null, since
it's a character-like type. */
gdb_assert (elttype != NULL);
gdb_assert (TYPE_LENGTH (elttype) != 0);
eltlen = TYPE_LENGTH (elttype);
len = TYPE_LENGTH (type) / eltlen;
if (options->prettyformat_arrays)
print_spaces_filtered (2 + 2 * recurse, stream);
/* If requested, look for the first null char and only print
elements up to it. */
if (options->stop_print_at_null)
{
int temp_len;
/* Look for a NULL char. */
for (temp_len = 0;
(temp_len < len
&& temp_len < options->print_max
&& char_at (valaddr + offset_aligned,
temp_len, eltlen, byte_order) != 0);
temp_len += 1);
len = temp_len;
}
printstr (stream, elttype, valaddr + offset_aligned, len, 0,
eltlen, options);
}
示例12: f77_create_arrayprint_offset_tbl
static void
f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
{
struct type *tmp_type;
int eltlen;
int ndimen = 1;
int upper, lower, retcode;
tmp_type = type;
while ((TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY))
{
if (TYPE_ARRAY_UPPER_BOUND_TYPE (tmp_type) == BOUND_CANNOT_BE_DETERMINED)
fprintf_filtered (stream, "<assumed size array> ");
retcode = f77_get_dynamic_upperbound (tmp_type, &upper);
if (retcode == BOUND_FETCH_ERROR)
error ("Cannot obtain dynamic upper bound");
retcode = f77_get_dynamic_lowerbound (tmp_type, &lower);
if (retcode == BOUND_FETCH_ERROR)
error ("Cannot obtain dynamic lower bound");
F77_DIM_SIZE (ndimen) = upper - lower + 1;
tmp_type = TYPE_TARGET_TYPE (tmp_type);
ndimen++;
}
/* Now we multiply eltlen by all the offsets, so that later we
can print out array elements correctly. Up till now we
know an offset to apply to get the item but we also
have to know how much to add to get to the next item */
ndimen--;
eltlen = TYPE_LENGTH (tmp_type);
F77_DIM_OFFSET (ndimen) = eltlen;
while (--ndimen > 0)
{
eltlen *= F77_DIM_SIZE (ndimen + 1);
F77_DIM_OFFSET (ndimen) = eltlen;
}
}
示例13: dynamic_array_type
static int
dynamic_array_type (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val,
const struct value_print_options *options)
{
if (TYPE_NFIELDS (type) == 2
&& TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_INT
&& strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0
&& strcmp (TYPE_FIELD_NAME (type, 1), "ptr") == 0
&& !value_bits_any_optimized_out (val,
TARGET_CHAR_BIT * embedded_offset,
TARGET_CHAR_BIT * TYPE_LENGTH (type)))
{
CORE_ADDR addr;
struct type *elttype;
struct type *true_type;
struct type *ptr_type;
struct value *ival;
int length;
length = unpack_field_as_long (type, valaddr + embedded_offset, 0);
ptr_type = TYPE_FIELD_TYPE (type, 1);
elttype = check_typedef (TYPE_TARGET_TYPE (ptr_type));
addr = unpack_pointer (ptr_type,
valaddr + TYPE_FIELD_BITPOS (type, 1) / 8
+ embedded_offset);
true_type = check_typedef (elttype);
true_type = lookup_array_range_type (true_type, 0, length - 1);
ival = value_at (true_type, addr);
true_type = value_type (ival);
d_val_print (true_type,
value_contents_for_printing (ival),
value_embedded_offset (ival), addr,
stream, recurse + 1, ival, options);
return 0;
}
return 1;
}
示例14: print_optional_low_bound
static int
print_optional_low_bound (struct ui_file *stream, struct type *type)
{
struct type *index_type;
long low_bound;
if (print_array_indexes_p ())
return 0;
if (!get_array_low_bound (type, &low_bound))
return 0;
index_type = TYPE_INDEX_TYPE (type);
if (TYPE_CODE (index_type) == TYPE_CODE_RANGE)
{
/* We need to know what the base type is, in order to do the
appropriate check below. Otherwise, if this is a subrange
of an enumerated type, where the underlying value of the
first element is typically 0, we might test the low bound
against the wrong value. */
index_type = TYPE_TARGET_TYPE (index_type);
}
switch (TYPE_CODE (index_type))
{
case TYPE_CODE_ENUM:
if (low_bound == TYPE_FIELD_BITPOS (index_type, 0))
return 0;
break;
case TYPE_CODE_UNDEF:
index_type = builtin_type_long;
/* FALL THROUGH */
default:
if (low_bound == 1)
return 0;
break;
}
ada_print_scalar (index_type, (LONGEST) low_bound, stream);
fprintf_filtered (stream, " => ");
return 1;
}
示例15: go_print_type
void
go_print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags)
{
/* Borrowed from c-typeprint.c. */
if (show > 0)
type = check_typedef (type);
/* Print the type of "abc" as "string", not char[4]. */
if (TYPE_CODE (type) == TYPE_CODE_ARRAY
&& TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CHAR)
{
fputs_filtered ("string", stream);
return;
}
/* Punt the rest to C for now. */
c_print_type (type, varstring, stream, show, level, flags);
}