⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
		struct list_head *this;		int numblocks = 0;		uint32_t dirty = 0;		list_for_each(this, &c->clean_list) {			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);			numblocks ++;			dirty += jeb->wasted_size;			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {				printk(JFFS2_DBG "clean_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,					jeb->unchecked_size, jeb->free_size);			}		}		printk (JFFS2_DBG "Contains %d blocks with total wasted size %u, average wasted size: %u\n",			numblocks, dirty, dirty / numblocks);	}	if (list_empty(&c->very_dirty_list)) {		printk(JFFS2_DBG "very_dirty_list: empty\n");	} else {		struct list_head *this;		int numblocks = 0;		uint32_t dirty = 0;		list_for_each(this, &c->very_dirty_list) {			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);			numblocks ++;			dirty += jeb->dirty_size;			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {				printk(JFFS2_DBG "very_dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,					jeb->unchecked_size, jeb->free_size);			}		}		printk (JFFS2_DBG "Contains %d blocks with total dirty size %u, average dirty size: %u\n",			numblocks, dirty, dirty / numblocks);	}	if (list_empty(&c->dirty_list)) {		printk(JFFS2_DBG "dirty_list: empty\n");	} else {		struct list_head *this;		int numblocks = 0;		uint32_t dirty = 0;		list_for_each(this, &c->dirty_list) {			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);			numblocks ++;			dirty += jeb->dirty_size;			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {				printk(JFFS2_DBG "dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,					jeb->unchecked_size, jeb->free_size);			}		}		printk (JFFS2_DBG "contains %d blocks with total dirty size %u, average dirty size: %u\n",			numblocks, dirty, dirty / numblocks);	}	if (list_empty(&c->erasable_list)) {		printk(JFFS2_DBG "erasable_list: empty\n");	} else {		struct list_head *this;		list_for_each(this, &c->erasable_list) {			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {				printk(JFFS2_DBG "erasable_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,					jeb->unchecked_size, jeb->free_size);			}		}	}	if (list_empty(&c->erasing_list)) {		printk(JFFS2_DBG "erasing_list: empty\n");	} else {		struct list_head *this;		list_for_each(this, &c->erasing_list) {			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {				printk(JFFS2_DBG "erasing_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,					jeb->unchecked_size, jeb->free_size);			}		}	}	if (list_empty(&c->erase_pending_list)) {		printk(JFFS2_DBG "erase_pending_list: empty\n");	} else {		struct list_head *this;		list_for_each(this, &c->erase_pending_list) {			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {				printk(JFFS2_DBG "erase_pending_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,					jeb->unchecked_size, jeb->free_size);			}		}	}	if (list_empty(&c->erasable_pending_wbuf_list)) {		printk(JFFS2_DBG "erasable_pending_wbuf_list: empty\n");	} else {		struct list_head *this;		list_for_each(this, &c->erasable_pending_wbuf_list) {			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {				printk(JFFS2_DBG "erasable_pending_wbuf_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,					jeb->unchecked_size, jeb->free_size);			}		}	}	if (list_empty(&c->free_list)) {		printk(JFFS2_DBG "free_list: empty\n");	} else {		struct list_head *this;		list_for_each(this, &c->free_list) {			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {				printk(JFFS2_DBG "free_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,					jeb->unchecked_size, jeb->free_size);			}		}	}	if (list_empty(&c->bad_list)) {		printk(JFFS2_DBG "bad_list: empty\n");	} else {		struct list_head *this;		list_for_each(this, &c->bad_list) {			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {				printk(JFFS2_DBG "bad_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,					jeb->unchecked_size, jeb->free_size);			}		}	}	if (list_empty(&c->bad_used_list)) {		printk(JFFS2_DBG "bad_used_list: empty\n");	} else {		struct list_head *this;		list_for_each(this, &c->bad_used_list) {			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {				printk(JFFS2_DBG "bad_used_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,					jeb->unchecked_size, jeb->free_size);			}		}	}}void__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f){	down(&f->sem);	jffs2_dbg_dump_fragtree_nolock(f);	up(&f->sem);}void__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f){	struct jffs2_node_frag *this = frag_first(&f->fragtree);	uint32_t lastofs = 0;	int buggy = 0;	printk(JFFS2_DBG_MSG_PREFIX " dump fragtree of ino #%u\n", f->inocache->ino);	while(this) {		if (this->node)			printk(JFFS2_DBG "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), right (%p), parent (%p)\n",				this->ofs, this->ofs+this->size, ref_offset(this->node->raw),				ref_flags(this->node->raw), this, frag_left(this), frag_right(this),				frag_parent(this));		else			printk(JFFS2_DBG "frag %#04x-%#04x: hole (*%p). left (%p), right (%p), parent (%p)\n",				this->ofs, this->ofs+this->size, this, frag_left(this),				frag_right(this), frag_parent(this));		if (this->ofs != lastofs)			buggy = 1;		lastofs = this->ofs + this->size;		this = frag_next(this);	}	if (f->metadata)		printk(JFFS2_DBG "metadata at 0x%08x\n", ref_offset(f->metadata->raw));	if (buggy) {		JFFS2_ERROR("frag tree got a hole in it.\n");		BUG();	}}#define JFFS2_BUFDUMP_BYTES_PER_LINE	32void__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs){	int skip;	int i;	printk(JFFS2_DBG_MSG_PREFIX " dump from offset %#08x to offset %#08x (%x bytes).\n",		offs, offs + len, len);	i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE;	offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1);	if (skip != 0)		printk(JFFS2_DBG "%#08x: ", offs);	while (skip--)		printk("   ");	while (i < len) {		if ((i % JFFS2_BUFDUMP_BYTES_PER_LINE) == 0 && i != len -1) {			if (i != 0)				printk("\n");			offs += JFFS2_BUFDUMP_BYTES_PER_LINE;			printk(JFFS2_DBG "%0#8x: ", offs);		}		printk("%02x ", buf[i]);		i += 1;	}	printk("\n");}/* * Dump a JFFS2 node. */void__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs){	union jffs2_node_union node;	int len = sizeof(union jffs2_node_union);	size_t retlen;	uint32_t crc;	int ret;	printk(JFFS2_DBG_MSG_PREFIX " dump node at offset %#08x.\n", ofs);	ret = jffs2_flash_read(c, ofs, len, &retlen, (unsigned char *)&node);	if (ret || (retlen != len)) {		JFFS2_ERROR("read %d bytes failed or short. ret %d, retlen %zd.\n",			len, ret, retlen);		return;	}	printk(JFFS2_DBG "magic:\t%#04x\n", je16_to_cpu(node.u.magic));	printk(JFFS2_DBG "nodetype:\t%#04x\n", je16_to_cpu(node.u.nodetype));	printk(JFFS2_DBG "totlen:\t%#08x\n", je32_to_cpu(node.u.totlen));	printk(JFFS2_DBG "hdr_crc:\t%#08x\n", je32_to_cpu(node.u.hdr_crc));	crc = crc32(0, &node.u, sizeof(node.u) - 4);	if (crc != je32_to_cpu(node.u.hdr_crc)) {		JFFS2_ERROR("wrong common header CRC.\n");		return;	}	if (je16_to_cpu(node.u.magic) != JFFS2_MAGIC_BITMASK &&		je16_to_cpu(node.u.magic) != JFFS2_OLD_MAGIC_BITMASK)	{		JFFS2_ERROR("wrong node magic: %#04x instead of %#04x.\n",			je16_to_cpu(node.u.magic), JFFS2_MAGIC_BITMASK);		return;	}	switch(je16_to_cpu(node.u.nodetype)) {	case JFFS2_NODETYPE_INODE:		printk(JFFS2_DBG "the node is inode node\n");		printk(JFFS2_DBG "ino:\t%#08x\n", je32_to_cpu(node.i.ino));		printk(JFFS2_DBG "version:\t%#08x\n", je32_to_cpu(node.i.version));		printk(JFFS2_DBG "mode:\t%#08x\n", node.i.mode.m);		printk(JFFS2_DBG "uid:\t%#04x\n", je16_to_cpu(node.i.uid));		printk(JFFS2_DBG "gid:\t%#04x\n", je16_to_cpu(node.i.gid));		printk(JFFS2_DBG "isize:\t%#08x\n", je32_to_cpu(node.i.isize));		printk(JFFS2_DBG "atime:\t%#08x\n", je32_to_cpu(node.i.atime));		printk(JFFS2_DBG "mtime:\t%#08x\n", je32_to_cpu(node.i.mtime));		printk(JFFS2_DBG "ctime:\t%#08x\n", je32_to_cpu(node.i.ctime));		printk(JFFS2_DBG "offset:\t%#08x\n", je32_to_cpu(node.i.offset));		printk(JFFS2_DBG "csize:\t%#08x\n", je32_to_cpu(node.i.csize));		printk(JFFS2_DBG "dsize:\t%#08x\n", je32_to_cpu(node.i.dsize));		printk(JFFS2_DBG "compr:\t%#02x\n", node.i.compr);		printk(JFFS2_DBG "usercompr:\t%#02x\n", node.i.usercompr);		printk(JFFS2_DBG "flags:\t%#04x\n", je16_to_cpu(node.i.flags));		printk(JFFS2_DBG "data_crc:\t%#08x\n", je32_to_cpu(node.i.data_crc));		printk(JFFS2_DBG "node_crc:\t%#08x\n", je32_to_cpu(node.i.node_crc));		crc = crc32(0, &node.i, sizeof(node.i) - 8);		if (crc != je32_to_cpu(node.i.node_crc)) {			JFFS2_ERROR("wrong node header CRC.\n");			return;		}		break;	case JFFS2_NODETYPE_DIRENT:		printk(JFFS2_DBG "the node is dirent node\n");		printk(JFFS2_DBG "pino:\t%#08x\n", je32_to_cpu(node.d.pino));		printk(JFFS2_DBG "version:\t%#08x\n", je32_to_cpu(node.d.version));		printk(JFFS2_DBG "ino:\t%#08x\n", je32_to_cpu(node.d.ino));		printk(JFFS2_DBG "mctime:\t%#08x\n", je32_to_cpu(node.d.mctime));		printk(JFFS2_DBG "nsize:\t%#02x\n", node.d.nsize);		printk(JFFS2_DBG "type:\t%#02x\n", node.d.type);		printk(JFFS2_DBG "node_crc:\t%#08x\n", je32_to_cpu(node.d.node_crc));		printk(JFFS2_DBG "name_crc:\t%#08x\n", je32_to_cpu(node.d.name_crc));		node.d.name[node.d.nsize] = '\0';		printk(JFFS2_DBG "name:\t\"%s\"\n", node.d.name);		crc = crc32(0, &node.d, sizeof(node.d) - 8);		if (crc != je32_to_cpu(node.d.node_crc)) {			JFFS2_ERROR("wrong node header CRC.\n");			return;		}		break;	default:		printk(JFFS2_DBG "node type is unknown\n");		break;	}}#endif /* JFFS2_DBG_DUMPS || JFFS2_DBG_PARANOIA_CHECKS */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -