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

📄 debug.h

📁 浙江大学的悟空嵌入式系统模拟器
💻 H
字号:
/**
 *  Copyright (c) 2005 Zhejiang University, P.R.China
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */ 

//=============================================================================
/**
 *  \file    Processor/PPC/Debug.h
 *
 *  \brief   Debug utils for PPC CPU
 *
 *  \author  Chenfeng Zhou <ini_autumn@163.com>
 *
 *  Last update: <2005-04-04 19:48:57 by Cheney Chow>
 *
 *  $Id: Debug.h,v 1.1 2005/06/16 06:06:36 qilj Exp $
 */
//=============================================================================

#ifndef _PPC_DEBUG_H_
#define _PPC_DEBUG_H_

#include <cstdio>
#include <cassert>
#include <iostream>

//#include "Utils/Logger.h"

//! error code
enum Error_Code {
    PPC_SUCCESS = 0,
    PPC_FAILED = -1
};

/**
 * @def PPC_ASSERT
 */
#define PPC_ASSERT(exp) assert(exp)

/**
 * @def PPC_ERROR_RETURN (format, args...)
 * Pretty printing and exit
 */
#define PPC_ERROR_RETURN(X) do {                          \
        fprintf (stderr, "In file %s:%u, %s()\n", __FILE__, __LINE__, __FUNCTION__); \
        printf X;                              \
		return;									\
        }                                                    \
    while (0)

#define PPC_ERROR_FAIL(X) do {                          \
	fprintf (stderr, "In file %s:%u, %s()\n", __FILE__, __LINE__, __FUNCTION__); \
	printf X;                              \
	return -1;									\
	}                                                    \
	while (0)

/**
 * @def PPC_ERROR(format, args...)
 * Just Pretty printing
 */
//#define PPC_ERROR(X)  do {                                \
//        fprintf (stderr, "In file %s:%u, %s()\n", __FILE__, __LINE__, __FUNCTION__); \
//        printf X; }                            \
//    while (0)

#if defined(PPC_DEBUG)
#define  PPC_SHOW(X) do {\
	if (PPC::Logger::instance()->is_tracing()) { \
	std::cout<<X;}	\
	}while(0)

#define  PPC_ERROR(X) do {	\
		if (PPC::Logger::instance()->is_tracing()) {	\
		 WUKONG_ERROR<<(Core::u32*)GET_CPU().get_pc()<<": "; \
		 WUKONG_ERROR<<X;	\
		 WUKONG_ERROR.flush();}	\
		}while(0)

#define PPC_TRACE_RETURN(X) do {	\
	if (PPC::Logger::instance()->is_tracing()) {	\
	WUKONG_TRACE<<(Core::u32*)GET_CPU().get_pc()<<": ";	\
	WUKONG_TRACE<<X;	\
	WUKONG_TRACE.flush();}	\
	return;}			\
	while(0)

#define PPC_TRACE(X) do {	\
		if (PPC::Logger::instance()->is_tracing()) {	\
		WUKONG_TRACE<<(Core::u32*)GET_CPU().get_pc()<<": ";	\
		WUKONG_TRACE<<X;	\
		WUKONG_TRACE.flush();}}	\
		while(0)

#define PPC_TRACE_1(X, p1) do {	\
	if (PPC::Logger::instance()->is_tracing()) {	\
	WUKONG_TRACE<<(Core::u32*)GET_CPU().get_pc()<<": ";	\
	WUKONG_TRACE<<X<<" "<<p1<<"\n";	\
	WUKONG_TRACE.flush();}}	\
	while(0)

#define PPC_TRACE_2(X, p1, p2) do {	\
	if (PPC::Logger::instance()->is_tracing()) {	\
	WUKONG_TRACE<<(Core::u32*)GET_CPU().get_pc()<<": ";	\
	WUKONG_TRACE<<X<<" "<<p1<<", "<<p2<<"\n";	\
	WUKONG_TRACE.flush();}}	\
	while(0)

#define PPC_TRACE_3(X, p1, p2, p3) do {	\
	if (PPC::Logger::instance()->is_tracing()) {	\
	WUKONG_TRACE<<(Core::u32*)GET_CPU().get_pc()<<": ";	\
	WUKONG_TRACE<<X<<" "<<p1<<", "<<p2<<", "<<p3<<"\n";	\
	WUKONG_TRACE.flush();}}	\
	while(0)

#define PPC_TRACE_5(X, p1, p2, p3, p4, p5) do {	\
	if (PPC::Logger::instance()->is_tracing()) {	\
	WUKONG_TRACE<<(Core::u32*)GET_CPU().get_pc()<<": ";	\
	WUKONG_TRACE<<X<<" "<<p1<<", "<<p2<<", "<<p3<<", "<<p4<<", "<<p5<<"\n";	\
	WUKONG_TRACE.flush();}}	\
	while(0)


#define DUMP_CPU_STATE PPC::Logger::instance()->dump_cpu_state()
#define DUMP_MEM(start, size) PPC::Logger::instance()->dump_mem(start, size)

#else

#define PPC_SHOW(X)
#define PPC_ERROR(X)
#define PPC_TRACE_RETURN(X) return
#define PPC_TRACE(X)
#define PPC_TRACE_1(X, p1)
#define PPC_TRACE_2(X, p1, p2)
#define PPC_TRACE_3(X, p1, p2, p3)
#define PPC_TRACE_5(X, p1, p2, p3, p4, p5)

#define DUMP_CPU_STATE 
#define DUMP_MEM(start, size)

#endif //PPC_DEBUG


#endif  // _PPC_DEBUG_H_

⌨️ 快捷键说明

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