📄 debug.c
字号:
debug_type
debug_make_pointer_type (handle, type)
PTR handle;
debug_type type;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
if (type == NULL)
return DEBUG_TYPE_NULL;
if (type->pointer != DEBUG_TYPE_NULL)
return type->pointer;
t = debug_make_type (info, DEBUG_KIND_POINTER, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
t->u.kpointer = type;
type->pointer = t;
return t;
}
/* Make a function returning a given type. FIXME: We should be able
to record the parameter types. */
debug_type
debug_make_function_type (handle, type, arg_types, varargs)
PTR handle;
debug_type type;
debug_type *arg_types;
bfd_boolean varargs;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
struct debug_function_type *f;
if (type == NULL)
return DEBUG_TYPE_NULL;
t = debug_make_type (info, DEBUG_KIND_FUNCTION, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
f = (struct debug_function_type *) xmalloc (sizeof *f);
memset (f, 0, sizeof *f);
f->return_type = type;
f->arg_types = arg_types;
f->varargs = varargs;
t->u.kfunction = f;
return t;
}
/* Make a reference to a given type. */
debug_type
debug_make_reference_type (handle, type)
PTR handle;
debug_type type;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
if (type == NULL)
return DEBUG_TYPE_NULL;
t = debug_make_type (info, DEBUG_KIND_REFERENCE, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
t->u.kreference = type;
return t;
}
/* Make a range of a given type from a lower to an upper bound. */
debug_type
debug_make_range_type (handle, type, lower, upper)
PTR handle;
debug_type type;
bfd_signed_vma lower;
bfd_signed_vma upper;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
struct debug_range_type *r;
if (type == NULL)
return DEBUG_TYPE_NULL;
t = debug_make_type (info, DEBUG_KIND_RANGE, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
r = (struct debug_range_type *) xmalloc (sizeof *r);
memset (r, 0, sizeof *r);
r->type = type;
r->lower = lower;
r->upper = upper;
t->u.krange = r;
return t;
}
/* Make an array type. The second argument is the type of an element
of the array. The third argument is the type of a range of the
array. The fourth and fifth argument are the lower and upper
bounds, respectively. The sixth argument is true if this array is
actually a string, as in C. */
debug_type
debug_make_array_type (handle, element_type, range_type, lower, upper,
stringp)
PTR handle;
debug_type element_type;
debug_type range_type;
bfd_signed_vma lower;
bfd_signed_vma upper;
bfd_boolean stringp;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
struct debug_array_type *a;
if (element_type == NULL || range_type == NULL)
return DEBUG_TYPE_NULL;
t = debug_make_type (info, DEBUG_KIND_ARRAY, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
a = (struct debug_array_type *) xmalloc (sizeof *a);
memset (a, 0, sizeof *a);
a->element_type = element_type;
a->range_type = range_type;
a->lower = lower;
a->upper = upper;
a->stringp = stringp;
t->u.karray = a;
return t;
}
/* Make a set of a given type. For example, a Pascal set type. The
bfd_boolean argument is true if this set is actually a bitstring, as in
CHILL. */
debug_type
debug_make_set_type (handle, type, bitstringp)
PTR handle;
debug_type type;
bfd_boolean bitstringp;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
struct debug_set_type *s;
if (type == NULL)
return DEBUG_TYPE_NULL;
t = debug_make_type (info, DEBUG_KIND_SET, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
s = (struct debug_set_type *) xmalloc (sizeof *s);
memset (s, 0, sizeof *s);
s->type = type;
s->bitstringp = bitstringp;
t->u.kset = s;
return t;
}
/* Make a type for a pointer which is relative to an object. The
second argument is the type of the object to which the pointer is
relative. The third argument is the type that the pointer points
to. */
debug_type
debug_make_offset_type (handle, base_type, target_type)
PTR handle;
debug_type base_type;
debug_type target_type;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
struct debug_offset_type *o;
if (base_type == NULL || target_type == NULL)
return DEBUG_TYPE_NULL;
t = debug_make_type (info, DEBUG_KIND_OFFSET, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
o = (struct debug_offset_type *) xmalloc (sizeof *o);
memset (o, 0, sizeof *o);
o->base_type = base_type;
o->target_type = target_type;
t->u.koffset = o;
return t;
}
/* Make a type for a method function. The second argument is the
return type, the third argument is the domain, and the fourth
argument is a NULL terminated array of argument types. */
debug_type
debug_make_method_type (handle, return_type, domain_type, arg_types, varargs)
PTR handle;
debug_type return_type;
debug_type domain_type;
debug_type *arg_types;
bfd_boolean varargs;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
struct debug_method_type *m;
if (return_type == NULL)
return DEBUG_TYPE_NULL;
t = debug_make_type (info, DEBUG_KIND_METHOD, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
m = (struct debug_method_type *) xmalloc (sizeof *m);
memset (m, 0, sizeof *m);
m->return_type = return_type;
m->domain_type = domain_type;
m->arg_types = arg_types;
m->varargs = varargs;
t->u.kmethod = m;
return t;
}
/* Make a const qualified version of a given type. */
debug_type
debug_make_const_type (handle, type)
PTR handle;
debug_type type;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
if (type == NULL)
return DEBUG_TYPE_NULL;
t = debug_make_type (info, DEBUG_KIND_CONST, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
t->u.kconst = type;
return t;
}
/* Make a volatile qualified version of a given type. */
debug_type
debug_make_volatile_type (handle, type)
PTR handle;
debug_type type;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
if (type == NULL)
return DEBUG_TYPE_NULL;
t = debug_make_type (info, DEBUG_KIND_VOLATILE, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
t->u.kvolatile = type;
return t;
}
/* Make an undefined tagged type. For example, a struct which has
been mentioned, but not defined. */
debug_type
debug_make_undefined_tagged_type (handle, name, kind)
PTR handle;
const char *name;
enum debug_type_kind kind;
{
struct debug_handle *info = (struct debug_handle *) handle;
struct debug_type *t;
if (name == NULL)
return DEBUG_TYPE_NULL;
switch (kind)
{
case DEBUG_KIND_STRUCT:
case DEBUG_KIND_UNION:
case DEBUG_KIND_CLASS:
case DEBUG_KIND_UNION_CLASS:
case DEBUG_KIND_ENUM:
break;
default:
debug_error ("debug_make_undefined_type: unsupported kind");
return DEBUG_TYPE_NULL;
}
t = debug_make_type (info, kind, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
return debug_tag_type (handle, name, t);
}
/* Make a base class for an object. The second argument is the base
class type. The third argument is the bit position of this base
class in the object (always 0 unless doing multiple inheritance).
The fourth argument is whether this is a virtual class. The fifth
argument is the visibility of the base class. */
/*ARGSUSED*/
debug_baseclass
debug_make_baseclass (handle, type, bitpos, is_virtual, visibility)
PTR handle ATTRIBUTE_UNUSED;
debug_type type;
bfd_vma bitpos;
bfd_boolean is_virtual;
enum debug_visibility visibility;
{
struct debug_baseclass *b;
b = (struct debug_baseclass *) xmalloc (sizeof *b);
memset (b, 0, sizeof *b);
b->type = type;
b->bitpos = bitpos;
b->is_virtual = is_virtual;
b->visibility = visibility;
return b;
}
/* Make a field for a struct. The second argument is the name. The
third argument is the type of the field. The fourth argument is
the bit position of the field. The fifth argument is the size of
the field (it may be zero). The sixth argument is the visibility
of the field. */
/*ARGSUSED*/
debug_field
debug_make_field (handle, name, type, bitpos, bitsize, visibility)
PTR handle ATTRIBUTE_UNUSED;
const char *name;
debug_type type;
bfd_vma bitpos;
bfd_vma bitsize;
enum debug_visibility visibility;
{
struct debug_field *f;
f = (struct debug_field *) xmalloc (sizeof *f);
memset (f, 0, sizeof *f);
f->name = name;
f->type = type;
f->static_member = false;
f->u.f.bitpos = bitpos;
f->u.f.bitsize = bitsize;
f->visibility = visibility;
return f;
}
/* Make a static member of an object. The second argument is the
name. The third argument is the type of the member. The fourth
argument is the physical name of the member (i.e., the name as a
global variable). The fifth argument is the visibility of the
member. */
/*ARGSUSED*/
debug_field
debug_make_static_member (handle, name, type, physname, visibility)
PTR handle ATTRIBUTE_UNUSED;
const char *name;
debug_type type;
const char *physname;
enum debug_visibility visibility;
{
struct debug_field *f;
f = (struct debug_field *) xmalloc (sizeof *f);
memset (f, 0, sizeof *f);
f->name = name;
f->type = type;
f->static_member = true;
f->u.s.physname = physname;
f->visibility = visibility;
return f;
}
/* Make a method. The second argument is the name, and the third
argument is a NULL terminated array of method variants. */
/*ARGSUSED*/
debug_method
debug_make_method (handle, name, variants)
PTR handle ATTRIBUTE_UNUSED;
const char *name;
debug_method_variant *variants;
{
struct debug_method *m;
m = (struct debug_method *) xmalloc (sizeof *m);
memset (m, 0, sizeof *m);
m->name = name;
m->variants = variants;
return m;
}
/* Make a method argument. The second argument is the real name of
the function. The third argument is the type of the function. The
fourth argument is the visibility. The fifth argument is whether
this is a const function. The sixth argument is whether this is a
volatile function. The seventh argument is the offset in the
virtual function table, if any. The eighth argument is the virtual
function context. FIXME: Are the const and volatile arguments
necessary? Could we just use debug_make_const_type? */
/*ARGSUSED*/
debug_method_variant
debug_make_method_variant (handle, physname, type, visibility, constp,
volatilep, voffset, address, context)
PTR handle ATTRIBUTE_UNUSED;
const char *physname;
debug_type type;
enum debug_visibility visibility;
bfd_boolean constp;
bfd_boolean volatilep;
bfd_vma voffset;
bfd_vma address;
debug_type context;
{
struct debug_method_variant *m;
m = (struct debug_method_variant *) xmalloc (sizeof *m);
memset (m, 0, sizeof *m);
m->physname = physname;
m->type = type;
m->visibility = visibility;
m->constp = constp;
m->volatilep = volatilep;
m->voffset = voffset;
m->address = address;
m->context = context;
return m;
}
/* Make a static method argument. The arguments are the same as for
debug_make_method_variant, except that the last two are omitted
since a static method can not also be virtual. */
debug_method_variant
debug_make_static_method_variant (handle, physname, type, visibility,
constp, volatilep, address)
PTR handle ATTRIBUTE_UNUSED;
const char *physname;
debug_type type;
enum debug_visibility visibility;
bfd_boolean constp;
bfd_boolean volatilep;
bfd_vma address;
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -