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

📄 debug.h

📁 美国加州大学操作系统课程实验平台Nachos
💻 H
字号:
// debug.h //	Data structures for debugging routines.////	The debugging routines allow the user to turn on selected//	debugging messages, controllable from the command line arguments//	passed to Nachos (-d).  You are encouraged to add your own//	debugging flags.  Please.... //// Copyright (c) 1992-1996 The Regents of the University of California.// All rights reserved.  See copyright.h for copyright notice and limitation // of liability and disclaimer of warranty provisions.#ifndef DEBUG_H#define DEBUG_H#include "copyright.h"		#include "utility.h"#include "sysdep.h"// The pre-defined debugging flags are:const char dbgAll = '+';		// turn on all debug messagesconst char dbgThread = 't';		// threadsconst char dbgSynch = 's';		// locks, semaphores, condition varsconst char dbgInt = 'i'; 		// interrupt emulationconst char dbgMach = 'm'; 		// machine emulationconst char dbgDisk = 'd'; 		// disk emulationconst char dbgFile = 'f'; 		// file systemconst char dbgAddr = 'a'; 		// address spacesconst char dbgNet = 'n'; 		// network emulationconst char dbgSys = 'u';                // systemcallclass Debug {  public:    Debug(char *flagList);    bool IsEnabled(char flag);  private:    char *enableFlags;		// controls which DEBUG messages are printed};extern Debug *debug;//----------------------------------------------------------------------// DEBUG//      If flag is enabled, print a message.//----------------------------------------------------------------------#define DEBUG(flag,expr)                                                     \    if (!debug->IsEnabled(flag)) {} else { 				\        cerr << expr << "\n";   				        \    }//----------------------------------------------------------------------// ASSERT//      If condition is false,  print a message and dump core.//	Useful for documenting assumptions in the code.////	NOTE: needs to be a #define, to be able to print the location //	where the error occurred.//----------------------------------------------------------------------#define ASSERT(condition)                                               \    if (condition) {} else { 						\	cerr << "Assertion failed: line " << __LINE__ << " file " << __FILE__ << "\n";      \        Abort();                                                              \    }//----------------------------------------------------------------------// ASSERTNOTREACHED//      Print a message and dump core (equivalent to ASSERT(FALSE) without//	making the compiler whine).  Useful for documenting when//	code should not be reached.////	NOTE: needs to be a #define, to be able to print the location //	where the error occurred.//----------------------------------------------------------------------#define ASSERTNOTREACHED()                                             \    { 						\	cerr << "Assertion failed: line " << __LINE__ << " file " << __FILE__ << "\n";      \        Abort();                                                              \    }//----------------------------------------------------------------------// ASSERTUNIMPLEMENTED//     Print a message that unimplemented code is executed and dump core//----------------------------------------------------------------------#define UNIMPLEMENTED()                                                      \{                                                                            \  cerr << "Reached UNIMPLEMENTED function " << __FUNCTION__ << " in file: "  \       << __FILE__ << " line: " << __LINE__ << ".\n";                        \}#endif // DEBUG_H

⌨️ 快捷键说明

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