debug.c
来自「基于4个mips核的noc设计」· C语言 代码 · 共 2,665 行 · 第 1/5 页
C
2,665 行
PTR handle; debug_type type; 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_typedebug_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_typedebug_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; 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_typedebug_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_typedebug_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_typedebug_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_baseclassdebug_make_baseclass (handle, type, bitpos, virtual, visibility) PTR handle ATTRIBUTE_UNUSED; debug_type type; bfd_vma bitpos; boolean 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->virtual = 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_fielddebug_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_fielddebug_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_methoddebug_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_variantdebug_make_method_variant (handle, physname, type, visibility, constp, volatilep, voffset, context) PTR handle ATTRIBUTE_UNUSED; const char *physname; debug_type type; enum debug_visibility visibility; boolean constp; boolean volatilep; bfd_vma voffset; 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->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_variantdebug_make_static_method_variant (handle, physname, type, visibility, constp, volatilep) PTR handle ATTRIBUTE_UNUSED; const char *physname; debug_type type; enum debug_visibility visibility; boolean constp; boolean volatilep;{ 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_STATIC_METHOD; return m;}/* Name a type. */debug_typedebug_name_type (handle, name, type) PTR handle; const char *name; debug_type type;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_type *t; struct debug_named_type *n; struct debug_name *nm; if (name == NULL || type == NULL) return DEBUG_TYPE_NULL; if (info->current_unit == NULL || info->current_file == NULL) { debug_error (_("debug_name_type: no current file")); return DEBUG_TYPE_NULL; } t = debug_make_type (info, DEBUG_KIND_NAMED, 0); if (t == NULL) return DEBUG_TYPE_NULL; n = (struct debug_named_type *) xmalloc (sizeof *n); memset (n, 0, sizeof *n); n->type = type; t->u.knamed = n; /* We always add the name to the global namespace. This is probably wrong in some cases, but it seems to be right for stabs. FIXME. */ nm = debug_add_to_namespace (info, &info->current_file->globals, name, DEBUG_OBJECT_TYPE, DEBUG_LINKAGE_NONE); if (nm == NULL) return DEBUG_TYPE_NULL; nm->u.type = t; n->name = nm; return t;}/* Tag a type. */debug_typedebug_tag_type (handle, name, type) PTR handle; const char *name; debug_type type;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_type *t; struct debug_named_type *n; struct debug_name *nm; if (name == NULL || type == NULL) return DEBUG_TYPE_NULL; if (info->current_file == NULL) { debug_error (_("debug_tag_type: no current file")); return DEBUG_TYPE_NULL; } if (type->kind == DEBUG_KIND_TAGGED) { if (strcmp (type->u.knamed->name->name, name) == 0) return type; debug_error (_("debug_tag_type: extra tag attempted")); return DEBUG_TYPE_NULL; } t = debug_make_type (info, DEBUG_KIND_TAGGED, 0); if (t == NULL) return DEBUG_TYPE_NULL; n = (struct debug_named_type *) xmalloc (sizeof *n); memset (n, 0, sizeof *n); n->type = type; t->u.knamed = n; /* We keep a global namespace of tags for each compilation unit. I don't know if that is the right thing to do. */ nm = debug_add_to_namespace (info, &info->current_file->globals, name, DEBUG_OBJECT_TAG, DEBUG_LINKAGE_NONE); if (nm == NULL) return DEBUG_TYPE_NULL; nm->u.tag = t; n->name = nm; return t;}/* Record the size of a given type. *//*ARGSUSED*/booleandebug_record_type_size (handle, type, size) PTR handle ATTRIBUTE_UNUSED; debug_type type; unsigned int size;{ if (type->size != 0 && type->size != size) fprintf (stderr, _("Warning: changing type size from %d to %d\n"), type->size, size); type->size = size; return true;}/* Find a named type. */debug_typedebug_find_named_type (handle, name) PTR handle; const char *name;{ struct debug_handle *info = (struct debug_handle *) handle; struct debug_block *b; struct debug_file *f; /* We only search the current compilation unit. I don't know if this is right or not. */ if (info->current_unit == NULL) { debug_error (_("debug_find_named_type: no current compilation unit")); return DEBUG_TYPE_NULL; } for (b = info->current_block; b != NULL; b = b->parent) { if (b->locals != NULL) { struct debug_name *n; for (n = b->locals->list; n != NULL; n = n->next) { if (n->kind == DEBUG_OBJECT_TYPE && n->name[0] == name[0] && strcmp (n->name, name) == 0) return n->u.type; } } } for (f = info->current_unit->files; f != NULL; f = f->next) { if (f->globals != NULL) { struct debug_name *n; for (n = f->globals->list; n != NULL; n = n->next) { if (n->kind == DEBUG_OBJECT_TYPE && n->name[0] == name[0] && strcmp (n->name, name) == 0) return n->u.type; } } } return DEBUG_TYPE_NULL; }/* Find a tagged type. */debug_typedebug_find_tagged_type (handle, name, kind)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?