本文整理汇总了C++中TYPE_FIELD_BITPOS函数的典型用法代码示例。如果您正苦于以下问题:C++ TYPE_FIELD_BITPOS函数的具体用法?C++ TYPE_FIELD_BITPOS怎么用?C++ TYPE_FIELD_BITPOS使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TYPE_FIELD_BITPOS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m2_enum
void
m2_enum (struct type *type, struct ui_file *stream, int show, int level)
{
int lastval, i, len;
if (show < 0)
{
/* If we just printed a tag name, no need to print anything else. */
if (TYPE_TAG_NAME (type) == NULL)
fprintf_filtered (stream, "(...)");
}
else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
{
fprintf_filtered (stream, "(");
len = TYPE_NFIELDS (type);
lastval = 0;
for (i = 0; i < len; i++)
{
QUIT;
if (i > 0)
fprintf_filtered (stream, ", ");
wrap_here (" ");
fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
if (lastval != TYPE_FIELD_BITPOS (type, i))
{
fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i));
lastval = TYPE_FIELD_BITPOS (type, i);
}
lastval++;
}
fprintf_filtered (stream, ")");
}
}
示例2: print_variant_part
static int
print_variant_part (struct type *type, int field_num,
const gdb_byte *valaddr, int offset,
struct ui_file *stream, int recurse,
struct value *val,
const struct value_print_options *options,
int comma_needed,
struct type *outer_type, int outer_offset,
const struct language_defn *language)
{
struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
int which = ada_which_variant_applies (var_type, outer_type,
valaddr + outer_offset);
if (which < 0)
return 0;
else
return print_field_values
(TYPE_FIELD_TYPE (var_type, which),
valaddr,
offset + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT
+ TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT,
stream, recurse, val, options,
comma_needed, outer_type, outer_offset, language);
}
示例3: print_enum_type
static void
print_enum_type (struct type *type, struct ui_file *stream)
{
int len = TYPE_NFIELDS (type);
int i, lastval;
fprintf_filtered (stream, "(");
wrap_here (" ");
lastval = 0;
for (i = 0; i < len; i++)
{
QUIT;
if (i)
fprintf_filtered (stream, ", ");
wrap_here (" ");
fputs_filtered (ada_enum_name (TYPE_FIELD_NAME (type, i)), stream);
if (lastval != TYPE_FIELD_BITPOS (type, i))
{
fprintf_filtered (stream, " => %d", TYPE_FIELD_BITPOS (type, i));
lastval = TYPE_FIELD_BITPOS (type, i);
}
lastval += 1;
}
fprintf_filtered (stream, ")");
}
示例4: is_pascal_string_type
/* Determines if type TYPE is a pascal string type.
Returns a positive value if the type is a known pascal string type.
This function is used by p-valprint.c code to allow better string display.
If it is a pascal string type, then it also sets info needed
to get the length and the data of the string
length_pos, length_size and string_pos are given in bytes.
char_size gives the element size in bytes.
FIXME: if the position or the size of these fields
are not multiple of TARGET_CHAR_BIT then the results are wrong
but this does not happen for Free Pascal nor for GPC. */
int
is_pascal_string_type (struct type *type,int *length_pos,
int *length_size, int *string_pos,
struct type **char_type,
const char **arrayname)
{
if (type != NULL && TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
/* Old Borland type pascal strings from Free Pascal Compiler. */
/* Two fields: length and st. */
if (TYPE_NFIELDS (type) == 2
&& TYPE_FIELD_NAME (type, 0)
&& strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0
&& TYPE_FIELD_NAME (type, 1)
&& strcmp (TYPE_FIELD_NAME (type, 1), "st") == 0)
{
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
if (length_size)
*length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
if (char_type)
*char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 1));
if (arrayname)
*arrayname = TYPE_FIELD_NAME (type, 1);
return 2;
};
/* GNU pascal strings. */
/* Three fields: Capacity, length and schema$ or _p_schema. */
if (TYPE_NFIELDS (type) == 3
&& TYPE_FIELD_NAME (type, 0)
&& strcmp (TYPE_FIELD_NAME (type, 0), "Capacity") == 0
&& TYPE_FIELD_NAME (type, 1)
&& strcmp (TYPE_FIELD_NAME (type, 1), "length") == 0)
{
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
if (length_size)
*length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 1));
if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
/* FIXME: how can I detect wide chars in GPC ?? */
if (char_type)
{
*char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 2));
if (TYPE_CODE (*char_type) == TYPE_CODE_ARRAY)
*char_type = TYPE_TARGET_TYPE (*char_type);
}
if (arrayname)
*arrayname = TYPE_FIELD_NAME (type, 2);
return 3;
};
}
return 0;
}
示例5: alphafbsd_return_in_memory
static int
alphafbsd_return_in_memory (struct type *type)
{
enum type_code code;
int i;
/* All aggregate types that won't fit in a register must be returned
in memory. */
if (TYPE_LENGTH (type) > ALPHA_REGISTER_SIZE)
return 1;
/* The only aggregate types that can be returned in a register are
structs and unions. Arrays must be returned in memory. */
code = TYPE_CODE (type);
if (code != TYPE_CODE_STRUCT && code != TYPE_CODE_UNION)
return 1;
/* We need to check if this struct/union is "integer" like. For
this to be true, the offset of each adressable subfield must be
zero. Note that bit fields are not addressable. */
for (i = 0; i < TYPE_NFIELDS (type); i++)
{
/* If the field bitsize is non-zero, it isn't adressable. */
if (TYPE_FIELD_BITPOS (type, i) != 0
&& TYPE_FIELD_BITSIZE (type, i) == 0)
return 1;
}
return 0;
}
示例6: m2_print_unbounded_array
static void
m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value_print_options *options)
{
CORE_ADDR addr;
LONGEST len;
struct value *val;
type = check_typedef (type);
addr = unpack_pointer (TYPE_FIELD_TYPE (type, 0),
(TYPE_FIELD_BITPOS (type, 0) / 8) +
valaddr + embedded_offset);
val = value_at_lazy (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)),
addr);
len = unpack_field_as_long (type, valaddr + embedded_offset, 1);
fprintf_filtered (stream, "{");
m2_print_array_contents (value_type (val),
value_contents_for_printing (val),
value_embedded_offset (val), addr, stream,
recurse, val, options, len);
fprintf_filtered (stream, ", HIGH = %d}", (int) len);
}
示例7: gnuv2_baseclass_offset
static int
gnuv2_baseclass_offset (struct type *type, int index,
const bfd_byte *valaddr, int embedded_offset,
CORE_ADDR address, const struct value *val)
{
struct type *basetype = TYPE_BASECLASS (type, index);
if (BASETYPE_VIA_VIRTUAL (type, index))
{
/* Must hunt for the pointer to this virtual baseclass. */
int i, len = TYPE_NFIELDS (type);
int n_baseclasses = TYPE_N_BASECLASSES (type);
/* First look for the virtual baseclass pointer
in the fields. */
for (i = n_baseclasses; i < len; i++)
{
if (vb_match (type, i, basetype))
{
struct type *field_type;
int field_offset;
int field_length;
CORE_ADDR addr;
field_type = check_typedef (TYPE_FIELD_TYPE (type, i));
field_offset = TYPE_FIELD_BITPOS (type, i) / 8;
field_length = TYPE_LENGTH (field_type);
if (!value_bytes_available (val, embedded_offset + field_offset,
field_length))
throw_error (NOT_AVAILABLE_ERROR,
_("Virtual baseclass pointer is not available"));
addr = unpack_pointer (field_type,
valaddr + embedded_offset + field_offset);
return addr - (LONGEST) address + embedded_offset;
}
}
/* Not in the fields, so try looking through the baseclasses. */
for (i = index + 1; i < n_baseclasses; i++)
{
/* Don't go through baseclass_offset, as that wraps
exceptions, thus, inner exceptions would be wrapped more
than once. */
int boffset =
gnuv2_baseclass_offset (type, i, valaddr,
embedded_offset, address, val);
if (boffset)
return boffset;
}
error (_("Baseclass offset not found"));
}
/* Baseclass is easily computed. */
return TYPE_BASECLASS_BITPOS (type, index) / 8;
}
示例8: vtable_address_point_offset
/* Return the offset from the start of the imaginary `struct
gdb_gnu_v3_abi_vtable' object to the vtable's "address point"
(i.e., where objects' virtual table pointers point). */
static int
vtable_address_point_offset (struct gdbarch *gdbarch)
{
struct type *vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
return (TYPE_FIELD_BITPOS (vtable_type, vtable_field_virtual_functions)
/ TARGET_CHAR_BIT);
}
示例9: print_variant_part
static int
print_variant_part (struct type *type, int field_num, char *valaddr,
struct ui_file *stream, int format, int recurse,
enum val_prettyprint pretty, int comma_needed,
struct type *outer_type, char *outer_valaddr)
{
struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
int which = ada_which_variant_applies (var_type, outer_type, outer_valaddr);
if (which < 0)
return 0;
else
return print_field_values
(TYPE_FIELD_TYPE (var_type, which),
valaddr + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT
+ TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT,
stream, format, recurse, pretty,
comma_needed, outer_type, outer_valaddr);
}
示例10: store_regs
static void
store_regs (struct type *regs_type, CORE_ADDR regs_base)
{
struct gdbarch *gdbarch = target_gdbarch ();
struct regcache *regcache = get_thread_regcache (inferior_ptid);
int fieldno;
for (fieldno = 0; fieldno < TYPE_NFIELDS (regs_type); fieldno++)
{
const char *reg_name = TYPE_FIELD_NAME (regs_type, fieldno);
ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno);
ULONGEST reg_bitsize = TYPE_FIELD_BITSIZE (regs_type, fieldno);
ULONGEST reg_offset;
struct type *reg_type = check_typedef (TYPE_FIELD_TYPE (regs_type,
fieldno));
ULONGEST reg_size = TYPE_LENGTH (reg_type);
int regnum;
struct value *regval;
CORE_ADDR inferior_addr;
if (strcmp (reg_name, COMPILE_I_SIMPLE_REGISTER_DUMMY) == 0)
continue;
if ((reg_bitpos % 8) != 0 || reg_bitsize != 0)
error (_("Invalid register \"%s\" position %s bits or size %s bits"),
reg_name, pulongest (reg_bitpos), pulongest (reg_bitsize));
reg_offset = reg_bitpos / 8;
if (TYPE_CODE (reg_type) != TYPE_CODE_INT
&& TYPE_CODE (reg_type) != TYPE_CODE_PTR)
error (_("Invalid register \"%s\" type code %d"), reg_name,
TYPE_CODE (reg_type));
regnum = compile_register_name_demangle (gdbarch, reg_name);
regval = value_from_register (reg_type, regnum, get_current_frame ());
if (value_optimized_out (regval))
error (_("Register \"%s\" is optimized out."), reg_name);
if (!value_entirely_available (regval))
error (_("Register \"%s\" is not available."), reg_name);
inferior_addr = regs_base + reg_offset;
if (0 != target_write_memory (inferior_addr, value_contents (regval),
reg_size))
error (_("Cannot write register \"%s\" to inferior memory at %s."),
reg_name, paddress (gdbarch, inferior_addr));
}
}
示例11: 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);
}
}
示例12: 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;
}
示例13: 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;
}
示例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;
index_type = TYPE_INDEX_TYPE (type);
low_bound = 0;
if (index_type == NULL)
return 0;
if (TYPE_CODE (index_type) == TYPE_CODE_RANGE)
{
low_bound = TYPE_LOW_BOUND (index_type);
if (low_bound > TYPE_HIGH_BOUND (index_type))
return 0;
index_type = TYPE_TARGET_TYPE (index_type);
}
else
return 0;
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: gnuv2_baseclass_offset
int
gnuv2_baseclass_offset (struct type *type, int index,
const bfd_byte *valaddr, CORE_ADDR address)
{
struct type *basetype = TYPE_BASECLASS (type, index);
if (BASETYPE_VIA_VIRTUAL (type, index))
{
/* Must hunt for the pointer to this virtual baseclass. */
int i, len = TYPE_NFIELDS (type);
int n_baseclasses = TYPE_N_BASECLASSES (type);
/* First look for the virtual baseclass pointer
in the fields. */
for (i = n_baseclasses; i < len; i++)
{
if (vb_match (type, i, basetype))
{
CORE_ADDR addr
= unpack_pointer (TYPE_FIELD_TYPE (type, i),
valaddr + (TYPE_FIELD_BITPOS (type, i) / 8));
return addr - (LONGEST) address;
}
}
/* Not in the fields, so try looking through the baseclasses. */
for (i = index + 1; i < n_baseclasses; i++)
{
int boffset =
baseclass_offset (type, i, valaddr, address);
if (boffset)
return boffset;
}
/* Not found. */
return -1;
}
/* Baseclass is easily computed. */
return TYPE_BASECLASS_BITPOS (type, index) / 8;
}