本文整理汇总了C++中TYPE_LENGTH函数的典型用法代码示例。如果您正苦于以下问题:C++ TYPE_LENGTH函数的具体用法?C++ TYPE_LENGTH怎么用?C++ TYPE_LENGTH使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TYPE_LENGTH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: list_arg_or_local
static void
list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
enum print_values values, int skip_unavailable)
{
struct cleanup *old_chain;
struct ui_out *uiout = current_uiout;
struct ui_file *stb;
gdb_assert (!arg->val || !arg->error);
gdb_assert ((values == PRINT_NO_VALUES && arg->val == NULL
&& arg->error == NULL)
|| values == PRINT_SIMPLE_VALUES
|| (values == PRINT_ALL_VALUES
&& (arg->val != NULL || arg->error != NULL)));
gdb_assert (arg->entry_kind == print_entry_values_no
|| (arg->entry_kind == print_entry_values_only
&& (arg->val || arg->error)));
if (skip_unavailable && arg->val != NULL
&& (value_entirely_unavailable (arg->val)
/* A scalar object that does not have all bits available is
also considered unavailable, because all bits contribute
to its representation. */
|| (val_print_scalar_type_p (value_type (arg->val))
&& !value_bytes_available (arg->val,
value_embedded_offset (arg->val),
TYPE_LENGTH (value_type (arg->val))))))
return;
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
if (values != PRINT_NO_VALUES || what == all)
make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
fputs_filtered (SYMBOL_PRINT_NAME (arg->sym), stb);
if (arg->entry_kind == print_entry_values_only)
fputs_filtered ("@entry", stb);
ui_out_field_stream (uiout, "name", stb);
if (what == all && SYMBOL_IS_ARGUMENT (arg->sym))
ui_out_field_int (uiout, "arg", 1);
if (values == PRINT_SIMPLE_VALUES)
{
check_typedef (arg->sym->type);
type_print (arg->sym->type, "", stb, -1);
ui_out_field_stream (uiout, "type", stb);
}
if (arg->val || arg->error)
{
const char *error_message = NULL;
if (arg->error)
error_message = arg->error;
else
{
TRY
{
struct value_print_options opts;
get_no_prettyformat_print_options (&opts);
opts.deref_ref = 1;
common_val_print (arg->val, stb, 0, &opts,
language_def (SYMBOL_LANGUAGE (arg->sym)));
}
CATCH (except, RETURN_MASK_ERROR)
{
error_message = except.message;
}
END_CATCH
}
if (error_message != NULL)
fprintf_filtered (stb, _("<error reading variable: %s>"),
error_message);
ui_out_field_stream (uiout, "value", stb);
}
do_cleanups (old_chain);
}
示例2: mn10300_push_dummy_call
static CORE_ADDR
mn10300_push_dummy_call (struct gdbarch *gdbarch,
struct value *target_func,
struct regcache *regcache,
CORE_ADDR bp_addr,
int nargs, struct value **args,
CORE_ADDR sp,
int struct_return,
CORE_ADDR struct_addr)
{
const int push_size = register_size (gdbarch, E_PC_REGNUM);
int regs_used;
int len, arg_len;
int stack_offset = 0;
int argnum;
char *val, valbuf[MAX_REGISTER_SIZE];
/* This should be a nop, but align the stack just in case something
went wrong. Stacks are four byte aligned on the mn10300. */
sp &= ~3;
/* Now make space on the stack for the args.
XXX This doesn't appear to handle pass-by-invisible reference
arguments. */
regs_used = struct_return ? 1 : 0;
for (len = 0, argnum = 0; argnum < nargs; argnum++)
{
arg_len = (TYPE_LENGTH (value_type (args[argnum])) + 3) & ~3;
while (regs_used < 2 && arg_len > 0)
{
regs_used++;
arg_len -= push_size;
}
len += arg_len;
}
/* Allocate stack space. */
sp -= len;
if (struct_return)
{
regs_used = 1;
write_register (E_D0_REGNUM, struct_addr);
}
else
regs_used = 0;
/* Push all arguments onto the stack. */
for (argnum = 0; argnum < nargs; argnum++)
{
/* FIXME what about structs? Unions? */
if (TYPE_CODE (value_type (*args)) == TYPE_CODE_STRUCT
&& TYPE_LENGTH (value_type (*args)) > 8)
{
/* Change to pointer-to-type. */
arg_len = push_size;
store_unsigned_integer (valbuf, push_size,
VALUE_ADDRESS (*args));
val = &valbuf[0];
}
else
{
arg_len = TYPE_LENGTH (value_type (*args));
val = (char *) value_contents (*args);
}
while (regs_used < 2 && arg_len > 0)
{
write_register (regs_used,
extract_unsigned_integer (val, push_size));
val += push_size;
arg_len -= push_size;
regs_used++;
}
while (arg_len > 0)
{
write_memory (sp + stack_offset, val, push_size);
arg_len -= push_size;
val += push_size;
stack_offset += push_size;
}
args++;
}
/* Make space for the flushback area. */
sp -= 8;
/* Push the return address that contains the magic breakpoint. */
sp -= 4;
write_memory_unsigned_integer (sp, push_size, bp_addr);
/* Update $sp. */
regcache_cooked_write_unsigned (regcache, E_SP_REGNUM, sp);
return sp;
}
示例3: java_value_print
//.........这里部分代码省略.........
else
{
struct value *v = allocate_value (el_type);
struct value *next_v = allocate_value (el_type);
set_value_address (v, (address
+ get_java_object_header_size (gdbarch) + 4));
set_value_address (next_v, value_raw_address (v));
while (i < length && things_printed < options->print_max)
{
fputs_filtered (", ", stream);
wrap_here (n_spaces (2));
if (i > 0)
{
struct value *tmp;
tmp = next_v;
next_v = v;
v = tmp;
}
else
{
set_value_lazy (v, 1);
set_value_offset (v, 0);
}
set_value_offset (next_v, value_offset (v));
for (reps = 1; i + reps < length; reps++)
{
set_value_lazy (next_v, 1);
set_value_offset (next_v, value_offset (next_v) + TYPE_LENGTH (el_type));
if (memcmp (value_contents (v), value_contents (next_v),
TYPE_LENGTH (el_type)) != 0)
break;
}
if (reps == 1)
fprintf_filtered (stream, "%d: ", i);
else
fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);
opts = *options;
opts.deref_ref = 1;
common_val_print (v, stream, 1, &opts, current_language);
things_printed++;
i += reps;
}
}
if (i < length)
fprintf_filtered (stream, "...");
fprintf_filtered (stream, "}");
return 0;
}
/* If it's type String, print it */
if (TYPE_CODE (type) == TYPE_CODE_PTR
&& TYPE_TARGET_TYPE (type)
&& TYPE_TAG_NAME (TYPE_TARGET_TYPE (type))
示例4: pascal_object_print_value
static void
pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
int offset,
CORE_ADDR address, struct ui_file *stream,
int recurse,
const struct value *val,
const struct value_print_options *options,
struct type **dont_print_vb)
{
struct type **last_dont_print
= (struct type **) obstack_next_free (&dont_print_vb_obstack);
struct obstack tmp_obstack = dont_print_vb_obstack;
int i, n_baseclasses = TYPE_N_BASECLASSES (type);
if (dont_print_vb == 0)
{
/* If we're at top level, carve out a completely fresh
chunk of the obstack and use that until this particular
invocation returns. */
/* Bump up the high-water mark. Now alpha is omega. */
obstack_finish (&dont_print_vb_obstack);
}
for (i = 0; i < n_baseclasses; i++)
{
int boffset = 0;
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
const char *basename = type_name_no_tag (baseclass);
const gdb_byte *base_valaddr = NULL;
int thisoffset;
int skip = 0;
if (BASETYPE_VIA_VIRTUAL (type, i))
{
struct type **first_dont_print
= (struct type **) obstack_base (&dont_print_vb_obstack);
int j = (struct type **) obstack_next_free (&dont_print_vb_obstack)
- first_dont_print;
while (--j >= 0)
if (baseclass == first_dont_print[j])
goto flush_it;
obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
}
thisoffset = offset;
TRY
{
boffset = baseclass_offset (type, i, valaddr, offset, address, val);
}
CATCH (ex, RETURN_MASK_ERROR)
{
if (ex.error == NOT_AVAILABLE_ERROR)
skip = -1;
else
skip = 1;
}
END_CATCH
if (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))
{
gdb_byte *buf;
struct cleanup *back_to;
buf = (gdb_byte *) xmalloc (TYPE_LENGTH (baseclass));
back_to = make_cleanup (xfree, buf);
base_valaddr = buf;
if (target_read_memory (address + boffset, buf,
TYPE_LENGTH (baseclass)) != 0)
skip = 1;
address = address + boffset;
thisoffset = 0;
boffset = 0;
do_cleanups (back_to);
}
else
base_valaddr = valaddr;
}
if (options->prettyformat)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 * recurse, stream);
}
fputs_filtered ("<", stream);
/* Not sure what the best notation is in the case where there is no
baseclass name. */
fputs_filtered (basename ? basename : "", stream);
fputs_filtered ("> = ", stream);
//.........这里部分代码省略.........
示例5: c_textual_element_type
int
c_textual_element_type (struct type *type, char format)
{
struct type *true_type, *iter_type;
if (format != 0 && format != 's')
return 0;
/* We also rely on this for its side effect of setting up all the
typedef pointers. */
true_type = check_typedef (type);
/* TYPE_CODE_CHAR is always textual. */
if (TYPE_CODE (true_type) == TYPE_CODE_CHAR)
return 1;
/* Any other character-like types must be integral. */
if (TYPE_CODE (true_type) != TYPE_CODE_INT)
return 0;
/* We peel typedefs one by one, looking for a match. */
iter_type = type;
while (iter_type)
{
/* Check the name of the type. */
if (TYPE_NAME (iter_type) && textual_name (TYPE_NAME (iter_type)))
return 1;
if (TYPE_CODE (iter_type) != TYPE_CODE_TYPEDEF)
break;
/* Peel a single typedef. If the typedef doesn't have a target
type, we use check_typedef and hope the result is ok -- it
might be for C++, where wchar_t is a built-in type. */
if (TYPE_TARGET_TYPE (iter_type))
iter_type = TYPE_TARGET_TYPE (iter_type);
else
iter_type = check_typedef (iter_type);
}
if (format == 's')
{
/* Print this as a string if we can manage it. For now, no wide
character support. */
if (TYPE_CODE (true_type) == TYPE_CODE_INT
&& TYPE_LENGTH (true_type) == 1)
return 1;
}
else
{
/* If a one-byte TYPE_CODE_INT is missing the not-a-character
flag, then we treat it as text; otherwise, we assume it's
being used as data. */
if (TYPE_CODE (true_type) == TYPE_CODE_INT
&& TYPE_LENGTH (true_type) == 1
&& !TYPE_NOTTEXT (true_type))
return 1;
}
return 0;
}
示例6: build_gdb_vtable_type
/* Return a GDB type representing `struct gdb_gnu_v3_abi_vtable',
described above, laid out appropriately for ARCH.
We use this function as the gdbarch per-architecture data
initialization function. */
static void *
build_gdb_vtable_type (struct gdbarch *arch)
{
struct type *t;
struct field *field_list, *field;
int offset;
struct type *void_ptr_type
= builtin_type (arch)->builtin_data_ptr;
struct type *ptr_to_void_fn_type
= builtin_type (arch)->builtin_func_ptr;
/* ARCH can't give us the true ptrdiff_t type, so we guess. */
struct type *ptrdiff_type
= arch_integer_type (arch, gdbarch_ptr_bit (arch), 0, "ptrdiff_t");
/* We assume no padding is necessary, since GDB doesn't know
anything about alignment at the moment. If this assumption bites
us, we should add a gdbarch method which, given a type, returns
the alignment that type requires, and then use that here. */
/* Build the field list. */
field_list = xmalloc (sizeof (struct field [4]));
memset (field_list, 0, sizeof (struct field [4]));
field = &field_list[0];
offset = 0;
/* ptrdiff_t vcall_and_vbase_offsets[0]; */
FIELD_NAME (*field) = "vcall_and_vbase_offsets";
FIELD_TYPE (*field) = lookup_array_range_type (ptrdiff_type, 0, -1);
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
/* ptrdiff_t offset_to_top; */
FIELD_NAME (*field) = "offset_to_top";
FIELD_TYPE (*field) = ptrdiff_type;
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
/* void *type_info; */
FIELD_NAME (*field) = "type_info";
FIELD_TYPE (*field) = void_ptr_type;
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
/* void (*virtual_functions[0]) (); */
FIELD_NAME (*field) = "virtual_functions";
FIELD_TYPE (*field) = lookup_array_range_type (ptr_to_void_fn_type, 0, -1);
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
/* We assumed in the allocation above that there were four fields. */
gdb_assert (field == (field_list + 4));
t = arch_type (arch, TYPE_CODE_STRUCT, offset, NULL);
TYPE_NFIELDS (t) = field - field_list;
TYPE_FIELDS (t) = field_list;
TYPE_TAG_NAME (t) = "gdb_gnu_v3_abi_vtable";
INIT_CPLUS_SPECIFIC (t);
return t;
}
示例7: gnuv3_print_method_ptr
static void
gnuv3_print_method_ptr (const gdb_byte *contents,
struct type *type,
struct ui_file *stream)
{
struct type *domain = TYPE_DOMAIN_TYPE (type);
struct gdbarch *gdbarch = get_type_arch (domain);
CORE_ADDR ptr_value;
LONGEST adjustment;
int vbit;
/* Extract the pointer to member. */
vbit = gnuv3_decode_method_ptr (gdbarch, contents, &ptr_value, &adjustment);
/* Check for NULL. */
if (ptr_value == 0 && vbit == 0)
{
fprintf_filtered (stream, "NULL");
return;
}
/* Search for a virtual method. */
if (vbit)
{
CORE_ADDR voffset;
const char *physname;
/* It's a virtual table offset, maybe in this class. Search
for a field with the correct vtable offset. First convert it
to an index, as used in TYPE_FN_FIELD_VOFFSET. */
voffset = ptr_value / TYPE_LENGTH (vtable_ptrdiff_type (gdbarch));
physname = gnuv3_find_method_in (domain, voffset, adjustment);
/* If we found a method, print that. We don't bother to disambiguate
possible paths to the method based on the adjustment. */
if (physname)
{
char *demangled_name = gdb_demangle (physname,
DMGL_ANSI | DMGL_PARAMS);
fprintf_filtered (stream, "&virtual ");
if (demangled_name == NULL)
fputs_filtered (physname, stream);
else
{
fputs_filtered (demangled_name, stream);
xfree (demangled_name);
}
return;
}
}
else if (ptr_value != 0)
{
/* Found a non-virtual function: print out the type. */
fputs_filtered ("(", stream);
c_print_type (type, "", stream, -1, 0, &type_print_raw_options);
fputs_filtered (") ", stream);
}
/* We didn't find it; print the raw data. */
if (vbit)
{
fprintf_filtered (stream, "&virtual table offset ");
print_longest (stream, 'd', 1, ptr_value);
}
else
{
struct value_print_options opts;
get_user_print_options (&opts);
print_address_demangle (&opts, gdbarch, ptr_value, stream, demangle);
}
if (adjustment)
{
fprintf_filtered (stream, ", this adjustment ");
print_longest (stream, 'd', 1, adjustment);
}
}
示例8: c_type_print_base
//.........这里部分代码省略.........
demangled_no_static = (char *) xmalloc (length + 1);
strncpy (demangled_no_static, demangled_no_class, length);
*(demangled_no_static + length) = '\0';
fputs_filtered (demangled_no_static, stream);
xfree (demangled_no_static);
}
else
fputs_filtered (demangled_no_class, stream);
xfree (demangled_name);
}
if (TYPE_FN_FIELD_STUB (f, j))
xfree (mangled_name);
fprintf_filtered (stream, ";\n");
}
}
fprintfi_filtered (level, stream, "}");
if (TYPE_LOCALTYPE_PTR (type) && show >= 0)
fprintfi_filtered (level, stream, _(" (Local at %s:%d)\n"),
TYPE_LOCALTYPE_FILE (type),
TYPE_LOCALTYPE_LINE (type));
}
if (TYPE_CODE (type) == TYPE_CODE_TEMPLATE)
goto go_back;
break;
case TYPE_CODE_ENUM:
c_type_print_modifier (type, stream, 0, 1);
/* HP C supports sized enums */
if (deprecated_hp_som_som_object_present)
switch (TYPE_LENGTH (type))
{
case 1:
fputs_filtered ("char ", stream);
break;
case 2:
fputs_filtered ("short ", stream);
break;
default:
break;
}
fprintf_filtered (stream, "enum ");
/* Print the tag name if it exists.
The aCC compiler emits a spurious
"{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
tag for unnamed struct/union/enum's, which we don't
want to print. */
if (TYPE_TAG_NAME (type) != NULL &&
strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
{
fputs_filtered (TYPE_TAG_NAME (type), stream);
if (show > 0)
fputs_filtered (" ", stream);
}
wrap_here (" ");
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)
示例9: xstormy16_use_struct_convention
static int
xstormy16_use_struct_convention (struct type *type)
{
return !xstormy16_type_is_scalar (type)
|| TYPE_LENGTH (type) > E_MAX_RETTYPE_SIZE_IN_REGS;
}
示例10: java_val_print
void
java_val_print (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)
{
struct gdbarch *gdbarch = get_type_arch (type);
struct type *target_type;
CORE_ADDR addr;
CHECK_TYPEDEF (type);
switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
if (options->format && options->format != 's')
{
val_print_scalar_formatted (type, valaddr, embedded_offset,
val, options, 0, stream);
break;
}
addr = unpack_pointer (type, valaddr + embedded_offset);
if (addr == 0)
{
fputs_filtered ("null", stream);
return;
}
target_type = check_typedef (TYPE_TARGET_TYPE (type));
if (TYPE_CODE (target_type) == TYPE_CODE_FUNC)
{
/* Try to print what function it points to. */
print_address_demangle (options, gdbarch, addr, stream, demangle);
return;
}
if (options->addressprint && options->format != 's')
{
fputs_filtered ("@", stream);
print_longest (stream, 'x', 0, (ULONGEST) addr);
}
return;
case TYPE_CODE_CHAR:
case TYPE_CODE_INT:
/* Can't just call c_val_print because that prints bytes as C
chars. */
if (options->format || options->output_format)
{
struct value_print_options opts = *options;
opts.format = (options->format ? options->format
: options->output_format);
val_print_scalar_formatted (type, valaddr, embedded_offset,
val, &opts, 0, stream);
}
else if (TYPE_CODE (type) == TYPE_CODE_CHAR
|| (TYPE_CODE (type) == TYPE_CODE_INT
&& TYPE_LENGTH (type) == 2
&& strcmp (TYPE_NAME (type), "char") == 0))
LA_PRINT_CHAR ((int) unpack_long (type, valaddr + embedded_offset),
type, stream);
else
val_print_type_code_int (type, valaddr + embedded_offset, stream);
break;
case TYPE_CODE_STRUCT:
java_print_value_fields (type, valaddr, embedded_offset,
address, stream, recurse, val, options);
break;
default:
c_val_print (type, valaddr, embedded_offset, address, stream,
recurse, val, options);
break;
}
}
示例11: c_type_print_varspec_suffix
void
c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
int show, int passed_a_ptr, int demangled_args)
{
if (type == 0)
return;
if (TYPE_NAME (type) && show <= 0)
return;
QUIT;
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
if (passed_a_ptr)
fprintf_filtered (stream, ")");
fprintf_filtered (stream, "[");
if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
&& TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
fprintf_filtered (stream, "%d",
(TYPE_LENGTH (type)
/ TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
fprintf_filtered (stream, "]");
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
0, 0);
break;
case TYPE_CODE_MEMBER:
if (passed_a_ptr)
fprintf_filtered (stream, ")");
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
0, 0);
break;
case TYPE_CODE_METHOD:
if (passed_a_ptr)
fprintf_filtered (stream, ")");
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
0, 0);
if (passed_a_ptr)
{
c_type_print_args (type, stream);
}
break;
case TYPE_CODE_PTR:
case TYPE_CODE_REF:
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
1, 0);
break;
case TYPE_CODE_FUNC:
if (passed_a_ptr)
fprintf_filtered (stream, ")");
if (!demangled_args)
{
int i, len = TYPE_NFIELDS (type);
fprintf_filtered (stream, "(");
if (len == 0
&& (TYPE_PROTOTYPED (type)
|| current_language->la_language == language_cplus))
{
fprintf_filtered (stream, "void");
}
else
for (i = 0; i < len; i++)
{
if (i > 0)
{
fputs_filtered (", ", stream);
wrap_here (" ");
}
c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0);
}
fprintf_filtered (stream, ")");
}
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
passed_a_ptr, 0);
break;
case TYPE_CODE_TYPEDEF:
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
passed_a_ptr, 0);
break;
case TYPE_CODE_UNDEF:
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
case TYPE_CODE_ENUM:
case TYPE_CODE_INT:
case TYPE_CODE_FLT:
case TYPE_CODE_VOID:
case TYPE_CODE_ERROR:
case TYPE_CODE_CHAR:
case TYPE_CODE_BOOL:
case TYPE_CODE_SET:
case TYPE_CODE_RANGE:
//.........这里部分代码省略.........
示例12: evaluate_subexp_java
static struct value *
evaluate_subexp_java (struct type *expect_type, struct expression *exp,
int *pos, enum noside noside)
{
int pc = *pos;
int i;
const char *name;
enum exp_opcode op = exp->elts[*pos].opcode;
struct value *arg1;
struct value *arg2;
struct type *type;
switch (op)
{
case UNOP_IND:
if (noside == EVAL_SKIP)
goto standard;
(*pos)++;
arg1 = evaluate_subexp_java (NULL_TYPE, exp, pos, EVAL_NORMAL);
if (is_object_type (value_type (arg1)))
{
struct type *type;
type = type_from_class (exp->gdbarch, java_class_from_object (arg1));
arg1 = value_cast (lookup_pointer_type (type), arg1);
}
return value_ind (arg1);
case BINOP_SUBSCRIPT:
(*pos)++;
arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
/* If the user attempts to subscript something that is not an
array or pointer type (like a plain int variable for example),
then report this as an error. */
arg1 = coerce_ref (arg1);
type = check_typedef (value_type (arg1));
if (TYPE_CODE (type) == TYPE_CODE_PTR)
type = check_typedef (TYPE_TARGET_TYPE (type));
name = TYPE_NAME (type);
if (name == NULL)
name = TYPE_TAG_NAME (type);
i = name == NULL ? 0 : strlen (name);
if (TYPE_CODE (type) == TYPE_CODE_STRUCT
&& i > 2 && name[i - 1] == ']')
{
enum bfd_endian byte_order = gdbarch_byte_order (exp->gdbarch);
CORE_ADDR address;
long length, index;
struct type *el_type;
gdb_byte buf4[4];
struct value *clas = java_class_from_object (arg1);
struct value *temp = clas;
/* Get CLASS_ELEMENT_TYPE of the array type. */
temp = value_struct_elt (&temp, NULL, "methods",
NULL, "structure");
deprecated_set_value_type (temp, value_type (clas));
el_type = type_from_class (exp->gdbarch, temp);
if (TYPE_CODE (el_type) == TYPE_CODE_STRUCT)
el_type = lookup_pointer_type (el_type);
if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (el_type, VALUE_LVAL (arg1));
address = value_as_address (arg1);
address += get_java_object_header_size (exp->gdbarch);
read_memory (address, buf4, 4);
length = (long) extract_signed_integer (buf4, 4, byte_order);
index = (long) value_as_long (arg2);
if (index >= length || index < 0)
error (_("array index (%ld) out of bounds (length: %ld)"),
index, length);
address = (address + 4) + index * TYPE_LENGTH (el_type);
return value_at (el_type, address);
}
else if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));
else
return value_subscript (arg1, value_as_long (arg2));
}
if (name)
error (_("cannot subscript something of type `%s'"), name);
else
error (_("cannot subscript requested type"));
case OP_STRING:
(*pos)++;
i = longest_to_int (exp->elts[pc + 1].longconst);
(*pos) += 3 + BYTES_TO_EXP_ELEM (i + 1);
if (noside == EVAL_SKIP)
goto nosideret;
return java_value_string (&exp->elts[pc + 2].string, i);
case STRUCTOP_PTR:
arg1 = evaluate_subexp_standard (expect_type, exp, pos, noside);
//.........这里部分代码省略.........
示例13: java_link_class_type
static struct type *
java_link_class_type (struct gdbarch *gdbarch,
struct type *type, struct value *clas)
{
struct value *temp;
const char *unqualified_name;
const char *name = TYPE_TAG_NAME (type);
int ninterfaces, nfields, nmethods;
int type_is_object = 0;
struct fn_field *fn_fields;
struct fn_fieldlist *fn_fieldlists;
struct value *fields;
struct value *methods;
struct value *method = NULL;
struct value *field = NULL;
int i, j;
struct objfile *objfile = get_dynamics_objfile (gdbarch);
struct type *tsuper;
gdb_assert (name != NULL);
unqualified_name = strrchr (name, '.');
if (unqualified_name == NULL)
unqualified_name = name;
temp = clas;
temp = value_struct_elt (&temp, NULL, "superclass", NULL, "structure");
if (strcmp (name, "java.lang.Object") == 0)
{
tsuper = get_java_object_type ();
if (tsuper && TYPE_CODE (tsuper) == TYPE_CODE_PTR)
tsuper = TYPE_TARGET_TYPE (tsuper);
type_is_object = 1;
}
else
tsuper = type_from_class (gdbarch, temp);
#if 1
ninterfaces = 0;
#else
temp = clas;
ninterfaces = value_as_long (value_struct_elt (&temp, NULL, "interface_len",
NULL, "structure"));
#endif
TYPE_N_BASECLASSES (type) = (tsuper == NULL ? 0 : 1) + ninterfaces;
temp = clas;
nfields = value_as_long (value_struct_elt (&temp, NULL, "field_count",
NULL, "structure"));
nfields += TYPE_N_BASECLASSES (type);
nfields++; /* Add one for dummy "class" field. */
TYPE_NFIELDS (type) = nfields;
TYPE_FIELDS (type) = (struct field *)
TYPE_ALLOC (type, sizeof (struct field) * nfields);
memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields);
TYPE_FIELD_PRIVATE_BITS (type) =
(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
TYPE_FIELD_PROTECTED_BITS (type) =
(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
TYPE_FIELD_IGNORE_BITS (type) =
(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *)
TYPE_ALLOC (type, B_BYTES (TYPE_N_BASECLASSES (type)));
B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
if (tsuper != NULL)
{
TYPE_BASECLASS (type, 0) = tsuper;
if (type_is_object)
SET_TYPE_FIELD_PRIVATE (type, 0);
}
i = strlen (name);
if (i > 2 && name[i - 1] == ']' && tsuper != NULL)
{
/* FIXME */
TYPE_LENGTH (type) = TYPE_LENGTH (tsuper) + 4; /* size with "length" */
}
else
{
temp = clas;
temp = value_struct_elt (&temp, NULL, "size_in_bytes",
NULL, "structure");
TYPE_LENGTH (type) = value_as_long (temp);
}
fields = NULL;
nfields--; /* First set up dummy "class" field. */
SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields), value_address (clas));
TYPE_FIELD_NAME (type, nfields) = "class";
TYPE_FIELD_TYPE (type, nfields) = value_type (clas);
SET_TYPE_FIELD_PRIVATE (type, nfields);
for (i = TYPE_N_BASECLASSES (type); i < nfields; i++)
//.........这里部分代码省略.........
示例14: parse_find_args
//.........这里部分代码省略.........
/* Watch for overflows. */
if (len > CORE_ADDR_MAX
|| (start_addr + len - 1) < start_addr)
error (_("Search space too large."));
search_space_len = len;
}
else
{
CORE_ADDR end_addr;
v = parse_to_comma_and_eval (&s);
end_addr = value_as_address (v);
if (start_addr > end_addr)
error (_("Invalid search space, end preceeds start."));
search_space_len = end_addr - start_addr + 1;
/* We don't support searching all of memory
(i.e. start=0, end = 0xff..ff).
Bail to avoid overflows later on. */
if (search_space_len == 0)
error (_("Overflow in address range computation, choose smaller range."));
}
if (*s == ',')
++s;
/* Fetch the search string. */
while (*s != '\0')
{
LONGEST x;
int val_bytes;
while (isspace (*s))
++s;
v = parse_to_comma_and_eval (&s);
val_bytes = TYPE_LENGTH (value_type (v));
/* Keep it simple and assume size == 'g' when watching for when we
need to grow the pattern buf. */
if ((pattern_buf_end - pattern_buf + max (val_bytes, sizeof (int64_t)))
> pattern_buf_size)
{
size_t current_offset = pattern_buf_end - pattern_buf;
pattern_buf_size *= 2;
pattern_buf = xrealloc (pattern_buf, pattern_buf_size);
pattern_buf_end = pattern_buf + current_offset;
}
if (size != '\0')
{
x = value_as_long (v);
switch (size)
{
case 'b':
*pattern_buf_end++ = x;
break;
case 'h':
put_bits (x, pattern_buf_end, 16, big_p);
pattern_buf_end += sizeof (int16_t);
break;
case 'w':
put_bits (x, pattern_buf_end, 32, big_p);
pattern_buf_end += sizeof (int32_t);
break;
case 'g':
put_bits (x, pattern_buf_end, 64, big_p);
pattern_buf_end += sizeof (int64_t);
break;
}
}
else
{
memcpy (pattern_buf_end, value_contents_raw (v), val_bytes);
pattern_buf_end += val_bytes;
}
if (*s == ',')
++s;
while (isspace (*s))
++s;
}
if (pattern_buf_end == pattern_buf)
error (_("Missing search pattern."));
pattern_len = pattern_buf_end - pattern_buf;
if (search_space_len < pattern_len)
error (_("Search space too small to contain pattern."));
*max_countp = max_count;
*pattern_bufp = pattern_buf;
*pattern_lenp = pattern_len;
*start_addrp = start_addr;
*search_space_lenp = search_space_len;
/* We successfully parsed the arguments, leave the freeing of PATTERN_BUF
to the caller now. */
discard_cleanups (old_cleanups);
}
示例15: pascal_type_print_varspec_prefix
void
pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
int show, int passed_a_ptr)
{
char *name;
if (type == 0)
return;
if (TYPE_NAME (type) && show <= 0)
return;
QUIT;
switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
fprintf_filtered (stream, "^");
pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
break; /* pointer should be handled normally in pascal */
case TYPE_CODE_MEMBER:
if (passed_a_ptr)
fprintf_filtered (stream, "(");
pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
fprintf_filtered (stream, " ");
name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
if (name)
fputs_filtered (name, stream);
else
pascal_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr);
fprintf_filtered (stream, "::");
break;
case TYPE_CODE_METHOD:
if (passed_a_ptr)
fprintf_filtered (stream, "(");
if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
{
fprintf_filtered (stream, "function ");
}
else
{
fprintf_filtered (stream, "procedure ");
}
if (passed_a_ptr)
{
fprintf_filtered (stream, " ");
pascal_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr);
fprintf_filtered (stream, "::");
}
break;
case TYPE_CODE_REF:
pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
fprintf_filtered (stream, "&");
break;
case TYPE_CODE_FUNC:
if (passed_a_ptr)
fprintf_filtered (stream, "(");
if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
{
fprintf_filtered (stream, "function ");
}
else
{
fprintf_filtered (stream, "procedure ");
}
break;
case TYPE_CODE_ARRAY:
if (passed_a_ptr)
fprintf_filtered (stream, "(");
fprintf_filtered (stream, "array ");
if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
&& TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
fprintf_filtered (stream, "[%d..%d] ",
TYPE_ARRAY_LOWER_BOUND_VALUE (type),
TYPE_ARRAY_UPPER_BOUND_VALUE (type)
);
fprintf_filtered (stream, "of ");
break;
case TYPE_CODE_UNDEF:
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
case TYPE_CODE_ENUM:
case TYPE_CODE_INT:
case TYPE_CODE_FLT:
case TYPE_CODE_VOID:
case TYPE_CODE_ERROR:
case TYPE_CODE_CHAR:
case TYPE_CODE_BOOL:
case TYPE_CODE_SET:
case TYPE_CODE_RANGE:
case TYPE_CODE_STRING:
case TYPE_CODE_BITSTRING:
//.........这里部分代码省略.........