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

📄 xdbg.h

📁 C++封装的视频采集代码
💻 H
字号:
#ifndef INC_OXSEMI_Libs_SysLib_xdbg_h__#define INC_OXSEMI_Libs_SysLib_xdbg_h__#include "Utils/assert.h"// introduce some empty types to allow build based template specialisation.namespace oxsemi{    class debugBuild        {};     //    class profileBuild      {};     // one of these types will be type def'd    class productionBuild   {};     // to oxsemi::buildLevel...}#ifdef _DEBUG#define DEBUG_ONLY(f)       (f)namespace oxsemi{    typedef debugBuild  buildLevel;}#else#define DEBUG_ONLY(f)       ((void)0)#endif // _DEBUG#if !defined(_DEBUG) && !defined(OXSEMI_PRODUCTION)#define PROFILE_ONLY(f)     (f)namespace oxsemi{    typedef profileBuild  buildLevel;}#else#define PROFILE_ONLY(f)     ((void)0)#endif // !defined(_DEBUG) && !defined(OXSEMI_PRODUCTION)#if !defined(OXSEMI_PRODUCTION)#define DEVELOP_ONLY(f)     (f)#else#define DEVELOP_ONLY(f)     ((void)0)namespace oxsemi{    typedef productionBuild  buildLevel;}#endif // !defined(OXSEMI_PRODUCTION)#ifdef OXSEMI_TEST#define TEST_ONLY(f)        f#else#define TEST_ONLY(f)        ((void)0)#endif // OXSEMI_TEST#ifdef FPGA_BUILD#define FPGA_ONLY(f)        f#else#define FPGA_ONLY(f)        ((void)0)#endif // FPGA_BUILD#ifdef ASIC_BUILD#define ASIC_ONLY(f)        f#else#define ASIC_ONLY(f)        ((void)0)#endif // FPGA_BUILD#ifdef OXSEMI_PREEMPTION#define OXSEMI_PREEMPTION_ONLY(f)        f#else#define OXSEMI_PREEMPTION_ONLY(f)        ((void)0)#endif // OXSEMI_PREEMPTIONnamespace oxsemi {namespace debug {void Trace(const char* format, ...);inline void empty_trace__(const char*, ...) {}inline void empty_dbg_trace__(unsigned long mask, const char * format, ...) {}template<bool> struct CompileTimeError;template<> struct CompileTimeError<true> {};/** * This routine displays (with colours) a dump of the given area of memory, * listing 16 bytes per line, on the left as two digit hex numbers, and then * on the right as ASCII characters, with unprintable characters displayed * as dots (and in a different colour). * * @param address An unsigned char * - pointing to the first byte of data *  to display. * @param length An unsigned int - the number of bytes to display. */void TraceMemory(const unsigned char * address, unsigned int length);inline void empty_trace_memory__(const unsigned char * address, unsigned int length) {}} // namespace debug} // namespace oxsemi/** * Compile-time assert. Expresions that can be evaluated at compile * time can be tested using this assert. * * Examples of usage: *      CT_ASSERT(31 == sizeof(bulk_only::CommandBlockWrapper), wrong_size_of_CommandBlockWrapper); *      CT_ASSERT(sizeof(standard::Other_Speed_ConfigurationDescriptor) == sizeof(standard::ConfigurationDescriptor), *          sizeof__ConfigurationDescriptor__and__Other_Speed_ConfigurationDescriptor__not__the__same); *      CT_ASSERT(sizeof(U16) == sizeof(wchar_t), wchar_t__not__compatible__with__U16); */#define CT_ASSERT(expr, msg) \    do { oxsemi::debug::CompileTimeError<(expr)> ERROR_##msg; (void)ERROR_##msg; } while(false)///////////////////////////////////////////////////////////////////////////////// ******// ****** Diagnostic support// ******//// flags to set the level of debug outputenum {    DBGNONE         = 0x00000000,    DBGERROR        = 0x00000001,    DBGWARNING      = 0x00000002,    DBGINFO         = 0x00000004,    DBGRESERVED     = 0x000000F8,    // module-specific defines start at 0x00000100    DBGVERBOSE      = 0xFFFFFFFF,};#if defined OXSEMI_MONEYPENNY#define ASSERT_TRACE(condition_, args...) \   ASSERT(((condition_) || (TRACE(args), false)))#endif/** * There are three builds: debug, profiling, and production (here called release) build. * The following table summarises their differences: * * Build      #define  ASSERT  VERIFY  PTRACE  TRACE  printf * debug      _DEBUG   Yes     Yes     Yes     Yes    Yes * profiling  NDEBUG   Yes     Yes     Yes     No     Yes * release    NDEBUG,  No      No      No      No     Yes *            OXSEMI_PRODUCTION */#if defined(_DEBUG)/**************************************************************** * * Debug build * ****************************************************************/#define TRACE               oxsemi::debug::Trace#define DTRACE              oxsemi::debug::Trace#define TRACE_MEMORY        oxsemi::debug::TraceMemory#define PATH_TESTED#define PATH_NOT_YET_TESTED oxsemi::debug::Trace("PNT %s/%u\n", __FILE__, __LINE__)#ifdef VERBOSE_DEBUG#   define TRACEVERBOSE     oxsemi::debug::Trace#else // VERBOSE_DEBUG#   define TRACEVERBOSE     1 ? (void)0 : oxsemi::debug::empty_trace__#endif // VERBOSE_DEBUG#ifdef __cplusplus#   define PTRACE           1 ? (void)0 : oxsemi::debug::empty_trace__#else   // __cplusplus#   define PTRACE           1 ? (void)0 : (void)0#endif  // __cplusplusnamespace oxsemi{    class FunctionTrace    {      public:        FunctionTrace(const char *function) : function_(function) { oxsemi::debug::Trace("Entering %s\n", function_); }        ~FunctionTrace() { oxsemi::debug::Trace("Leaving %s\n", function_); }      private:        const char * function_;    };}#define TRACE_FUNCTION()    oxsemi::FunctionTrace   ft(__PRETTY_FUNCTION__)#elif !defined(OXSEMI_PRODUCTION)/**************************************************************** * * Profiling build * ****************************************************************/#define TRACE               oxsemi::debug::Trace#define PTRACE              oxsemi::debug::Trace#define TRACE_MEMORY        oxsemi::debug::TraceMemory#define PATH_TESTED#define PATH_NOT_YET_TESTED#ifdef __cplusplus#   define DTRACE           1 ? (void)0 : oxsemi::debug::empty_trace__#   define TRACEVERBOSE     1 ? (void)0 : oxsemi::debug::empty_trace__#else   // __cplusplus#   define DTRACE           1 ? (void)0 : (void)0#   define TRACEVERBOSE     1 ? (void)0 : (void)0#endif  // __cplusplus#define TRACE_FUNCTION()#elif defined(OXSEMI_PRODUCTION)/**************************************************************** * * Production (release) build * ****************************************************************/#define PATH_TESTED#define PATH_NOT_YET_TESTED#ifdef __cplusplus#   define TRACE            1 ? (void)0 : oxsemi::debug::empty_trace__#   define DTRACE           1 ? (void)0 : oxsemi::debug::empty_trace__#   define PTRACE           1 ? (void)0 : oxsemi::debug::empty_trace__#   define TRACEVERBOSE     1 ? (void)0 : oxsemi::debug::empty_trace__#   define TRACE_MEMORY     1 ? (void)0 : oxsemi::debug::empty_trace_memory__#else   // __cplusplus#   define TRACE            1 ? (void)0 : (void)0#   define DTRACE           1 ? (void)0 : (void)0#   define PTRACE           1 ? (void)0 : (void)0#   define TRACEVERBOSE     1 ? (void)0 : (void)0#   define TRACE_MEMORY     1 ? (void)0 : (void)0#endif  // __cplusplus#define TRACE_FUNCTION()#else#error "unsupported build"#endif // defined(_DEBUG)#endif // INC_OXSEMI_Libs_SysLib_xdbg_h__

⌨️ 快捷键说明

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