debug.c
来自「基于4个mips核的noc设计」· C语言 代码 · 共 2,665 行 · 第 1/5 页
C
2,665 行
const char *name; bfd_vma val;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_name *n; if (name == NULL) return false; n = debug_add_to_current_namespace (info, name, DEBUG_OBJECT_INT_CONSTANT, DEBUG_LINKAGE_NONE); if (n == NULL) return false; n->u.int_constant = val; return true;}/* Record a named floating point constant. */booleandebug_record_float_const (handle, name, val) PTR handle; const char *name; double val;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_name *n; if (name == NULL) return false; n = debug_add_to_current_namespace (info, name, DEBUG_OBJECT_FLOAT_CONSTANT, DEBUG_LINKAGE_NONE); if (n == NULL) return false; n->u.float_constant = val; return true;}/* Record a typed constant with an integral value. */booleandebug_record_typed_const (handle, name, type, val) PTR handle; const char *name; debug_type type; bfd_vma val;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_name *n; struct debug_typed_constant *tc; if (name == NULL || type == NULL) return false; n = debug_add_to_current_namespace (info, name, DEBUG_OBJECT_TYPED_CONSTANT, DEBUG_LINKAGE_NONE); if (n == NULL) return false; tc = (struct debug_typed_constant *) xmalloc (sizeof *tc); memset (tc, 0, sizeof *tc); tc->type = type; tc->val = val; n->u.typed_constant = tc; return true;}/* Record a label. */booleandebug_record_label (handle, name, type, addr) PTR handle ATTRIBUTE_UNUSED; const char *name ATTRIBUTE_UNUSED; debug_type type ATTRIBUTE_UNUSED; bfd_vma addr ATTRIBUTE_UNUSED;{ /* FIXME. */ debug_error (_("debug_record_label not implemented")); return false;}/* Record a variable. */booleandebug_record_variable (handle, name, type, kind, val) PTR handle; const char *name; debug_type type; enum debug_var_kind kind; bfd_vma val;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_namespace **nsp; enum debug_object_linkage linkage; struct debug_name *n; struct debug_variable *v; if (name == NULL || type == NULL) return false; if (info->current_unit == NULL || info->current_file == NULL) { debug_error (_("debug_record_variable: no current file")); return false; } if (kind == DEBUG_GLOBAL || kind == DEBUG_STATIC) { nsp = &info->current_file->globals; if (kind == DEBUG_GLOBAL) linkage = DEBUG_LINKAGE_GLOBAL; else linkage = DEBUG_LINKAGE_STATIC; } else { if (info->current_block == NULL) { debug_error (_("debug_record_variable: no current block")); return false; } nsp = &info->current_block->locals; linkage = DEBUG_LINKAGE_AUTOMATIC; } n = debug_add_to_namespace (info, nsp, name, DEBUG_OBJECT_VARIABLE, linkage); if (n == NULL) return false; v = (struct debug_variable *) xmalloc (sizeof *v); memset (v, 0, sizeof *v); v->kind = kind; v->type = type; v->val = val; n->u.variable = v; return true; }/* Make a type with a given kind and size. *//*ARGSUSED*/static struct debug_type *debug_make_type (info, kind, size) struct debug_handle *info ATTRIBUTE_UNUSED; enum debug_type_kind kind; unsigned int size;{ struct debug_type *t; t = (struct debug_type *) xmalloc (sizeof *t); memset (t, 0, sizeof *t); t->kind = kind; t->size = size; return t;}/* Make an indirect type which may be used as a placeholder for a type which is referenced before it is defined. */debug_typedebug_make_indirect_type (handle, slot, tag) PTR handle; debug_type *slot; const char *tag;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_type *t; struct debug_indirect_type *i; t = debug_make_type (info, DEBUG_KIND_INDIRECT, 0); if (t == NULL) return DEBUG_TYPE_NULL; i = (struct debug_indirect_type *) xmalloc (sizeof *i); memset (i, 0, sizeof *i); i->slot = slot; i->tag = tag; t->u.kindirect = i; return t;}/* Make a void type. There is only one of these. */debug_typedebug_make_void_type (handle) PTR handle;{ struct debug_handle *info = (struct debug_handle *) handle; return debug_make_type (info, DEBUG_KIND_VOID, 0);}/* Make an integer type of a given size. The boolean argument is true if the integer is unsigned. */debug_typedebug_make_int_type (handle, size, unsignedp) PTR handle; unsigned int size; boolean unsignedp;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_type *t; t = debug_make_type (info, DEBUG_KIND_INT, size); if (t == NULL) return DEBUG_TYPE_NULL; t->u.kint = unsignedp; return t;}/* Make a floating point type of a given size. FIXME: On some platforms, like an Alpha, you probably need to be able to specify the format. */debug_typedebug_make_float_type (handle, size) PTR handle; unsigned int size;{ struct debug_handle *info = (struct debug_handle *) handle; return debug_make_type (info, DEBUG_KIND_FLOAT, size);}/* Make a boolean type of a given size. */debug_typedebug_make_bool_type (handle, size) PTR handle; unsigned int size;{ struct debug_handle *info = (struct debug_handle *) handle; return debug_make_type (info, DEBUG_KIND_BOOL, size);}/* Make a complex type of a given size. */debug_typedebug_make_complex_type (handle, size) PTR handle; unsigned int size;{ struct debug_handle *info = (struct debug_handle *) handle; return debug_make_type (info, DEBUG_KIND_COMPLEX, size);}/* Make a structure type. The second argument is true for a struct, false for a union. The third argument is the size of the struct. The fourth argument is a NULL terminated array of fields. */debug_typedebug_make_struct_type (handle, structp, size, fields) PTR handle; boolean structp; bfd_vma size; debug_field *fields;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_type *t; struct debug_class_type *c; t = debug_make_type (info, structp ? DEBUG_KIND_STRUCT : DEBUG_KIND_UNION, size); if (t == NULL) return DEBUG_TYPE_NULL; c = (struct debug_class_type *) xmalloc (sizeof *c); memset (c, 0, sizeof *c); c->fields = fields; t->u.kclass = c; return t;}/* Make an object type. The first three arguments after the handle are the same as for debug_make_struct_type. The next arguments are a NULL terminated array of base classes, a NULL terminated array of methods, the type of the object holding the virtual function table if it is not this object, and a boolean which is true if this object has its own virtual function table. */debug_typedebug_make_object_type (handle, structp, size, fields, baseclasses, methods, vptrbase, ownvptr) PTR handle; boolean structp; bfd_vma size; debug_field *fields; debug_baseclass *baseclasses; debug_method *methods; debug_type vptrbase; boolean ownvptr;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_type *t; struct debug_class_type *c; t = debug_make_type (info, structp ? DEBUG_KIND_CLASS : DEBUG_KIND_UNION_CLASS, size); if (t == NULL) return DEBUG_TYPE_NULL; c = (struct debug_class_type *) xmalloc (sizeof *c); memset (c, 0, sizeof *c); c->fields = fields; c->baseclasses = baseclasses; c->methods = methods; if (ownvptr) c->vptrbase = t; else c->vptrbase = vptrbase; t->u.kclass = c; return t;}/* Make an enumeration type. The arguments are a null terminated array of strings, and an array of corresponding values. */debug_typedebug_make_enum_type (handle, names, values) PTR handle; const char **names; bfd_signed_vma *values;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_type *t; struct debug_enum_type *e; t = debug_make_type (info, DEBUG_KIND_ENUM, 0); if (t == NULL) return DEBUG_TYPE_NULL; e = (struct debug_enum_type *) xmalloc (sizeof *e); memset (e, 0, sizeof *e); e->names = names; e->values = values; t->u.kenum = e; return t;}/* Make a pointer to a given type. */debug_typedebug_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_typedebug_make_function_type (handle, type, arg_types, varargs) PTR handle; debug_type type; debug_type *arg_types; 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_typedebug_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_typedebug_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_typedebug_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; 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 boolean argument is true if this set is actually a bitstring, as in CHILL. */debug_typedebug_make_set_type (handle, type, bitstringp)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?