1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: dbg_DebugString.h 4 5 Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 18508 $ 14 *---------------------------------------------------------------------------*/ 15 16 /*! 17 @file 18 19 :include nn/dbg.h 20 */ 21 22 #ifndef NN_DBG_DBG_DEBUGSTRING_H_ 23 #define NN_DBG_DBG_DEBUGSTRING_H_ 24 25 #include <nn/config.h> 26 #include <nn/types.h> 27 #include <nn/Result.h> 28 #include <nn/dbg/dbg_Result.h> 29 30 /*! 31 @addtogroup nn_dbg dbg のマクロ定義 32 @brief デバッグ用のマクロです。 33 @{ 34 */ 35 36 /*! 37 @brief @ref NN_LOG のバッファサイズです。 38 */ 39 #define NN_DBG_PRINTF_BUFFER_LENGTH 256 40 41 // TPrintf用バッファサイズ 42 #define NN_DBG_TPRINTF_BUFFER_LENGTH 128 43 44 //------------------------------------------------------------------- 45 // NN_LOG 46 47 /*! 48 @param[in] ... 標準ライブラリの printf の引数と同様です。 49 50 @brief 文字列をデバッグウィンドウに出力します。 51 52 バッファサイズは @ref NN_DBG_PRINTF_BUFFER_LENGTH です。 53 @ref NN_DBG_PRINTF_BUFFER_LENGTH よりも大きなサイズの文字列を扱うことはできません。 54 */ 55 #ifndef NN_SWITCH_DISABLE_DEBUG_PRINT 56 #ifdef __cplusplus 57 #define NN_LOG( ... ) (void)nn::dbg::detail::Printf(__VA_ARGS__) 58 #else // ifdef __cplusplus 59 #define NN_LOG( ... ) (void)nndbgDetailPrintf(__VA_ARGS__) 60 #endif // ifdef __cplusplus else 61 #else // ifndef NN_SWITCH_DISABLE_DEBUG_PRINT 62 #define NN_LOG( ... ) ((void)0) 63 #endif // ifndef NN_SWITCH_DISABLE_DEBUG_PRINT else 64 65 //------------------------------------------------------------------- 66 // NN_TLOG_ 67 68 /* 69 @def NN_TLOG_ 70 71 @brief 文字列をデバッグ出力します。NN_LOG の省メモリ版です。 72 73 SDK 内部でのみ使用します。 74 */ 75 #ifndef NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK 76 #ifdef __cplusplus 77 #define NN_TLOG_( ... ) (void)nn::dbg::detail::TPrintf(__VA_ARGS__) 78 #else // ifdef __cplusplus 79 #define NN_TLOG_( ... ) (void)nndbgDetailTPrintf(__VA_ARGS__) 80 #endif // ifdef __cplusplus else 81 #else // ifndef NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK 82 #define NN_TLOG_( ... ) ((void)0) 83 #endif // ifndef NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK else 84 85 //------------------------------------------------------------------- 86 // NN_SLOG_ 87 88 /* 89 @def NN_TLOG_ 90 91 @brief 文字列をデバッグ出力します。NN_LOG の省メモリ版です。 92 93 SDK 内部でのみ使用します。 94 */ 95 #ifndef NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK 96 #ifdef __cplusplus 97 #define NN_SLOG_( ... ) (void)nn::dbg::detail::Printf(__VA_ARGS__) 98 #else // ifdef __cplusplus 99 #define NN_SLOG_( ... ) (void)nndbgDetailPrintf(__VA_ARGS__) 100 #endif // ifdef __cplusplus else 101 #else // ifndef NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK 102 #define NN_SLOG_( ... ) ((void)0) 103 #endif // ifndef NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK else 104 105 /*! 106 @} 107 */ 108 109 //------------------------------------------------------------------- 110 // for C++ 111 112 #ifdef __cplusplus 113 namespace nn { namespace dbg { 114 namespace detail 115 { 116 /* 117 @brief 文字列をデバッグ出力します。 118 119 @param[in] fmt 一般的な printf のフォーマット文字列 120 */ 121 void Printf(const char* fmt, ...); 122 123 /* 124 @brief 文字列をデバッグ出力します。Printf の省メモリ版です。 125 126 @param[in] fmt 一般的な printf のフォーマット文字列。ただし、浮動小数点系のもの(%%f など) は指定できません。 127 */ 128 void TPrintf(const char* fmt, ...); 129 130 /* 131 @brief 文字列をデバッグ出力します。 132 133 VPrint は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 134 135 @param[in] fmt 一般的な printf のフォーマット文字列 136 @param[in] vlist 可変引数パラメータ 137 */ 138 void VPrintf(const char* fmt, ::std::va_list arg); 139 140 /* 141 @brief 文字列をデバッグ出力します。VPrintf の省メモリ版です。 142 143 TVPrint は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 144 145 @param[in] fmt 一般的な printf のフォーマット文字列。ただし、浮動小数点系のもの(%%f など) は指定できません。 146 @param[in] vlist 可変引数パラメータ 147 */ 148 void TVPrintf(const char* fmt, ::std::va_list arg); 149 150 /* 151 @brief 文字列をデバッグ出力します。 152 153 PutString は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 154 155 @param[in] text 出力文字列 156 @param[in] length 出力文字列の長さ 157 */ 158 void PutString(const char* text, s32 length); 159 } 160 }} 161 #endif // ifdef __cplusplus 162 163 //------------------------------------------------------------------- 164 // for C / C++ 165 166 #include <nn/util/detail/util_CLibImpl.h> 167 168 #include <nn/dbg/dbg_Break.h> 169 170 #ifdef __cplusplus 171 extern "C" { 172 #endif // ifdef __cplusplus 173 174 /* 175 @brief 対応する C++ 関数 @ref nn::dbg::detail::Printf を参照してください。 176 */ 177 void nndbgDetailPrintf(const char* fmt, ...); 178 179 /* 180 @brief 対応する C++ 関数 @ref nn::dbg::detail::TPrintf を参照してください。 181 */ 182 void nndbgDetailTPrintf(const char* fmt, ...); 183 184 /* 185 @brief 対応する C++ 関数 @ref nn::dbg::detail::VPrintf を参照してください。 186 187 nndbgDetailVPrintf は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 188 */ 189 void nndbgDetailVPrintf(const char* fmt, va_list arg); 190 191 /* 192 @brief 対応する C++ 関数 @ref nn::dbg::detail::TVPrintf を参照してください。 193 194 nndbgDetailTVPrintf は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 195 */ 196 void nndbgDetailTVPrintf(const char* fmt, va_list arg); 197 198 /* 199 @brief 文字列を表示し、プログラムを停止します。 200 201 nndbgAssertionFailureHandler は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 202 203 @param[in] print 文字列を表示するかどうかを決定する条件 204 @param[in] filename ファイル名 205 @param[in] lineno 行番号 206 @param[in] fmt 一般的な printf のフォーマット文字列 207 208 @return 常に0 209 */ 210 int nndbgAssertionFailureHandler(bool print, const char* filename, int lineno, const char* fmt, ...); 211 212 /* 213 @brief 文字列を表示し、プログラムを停止します。nndbgAssertionFailureHandler の省メモリ版です。 214 215 nndbgTAssertionFailureHandler は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 216 217 @param[in] print 文字列を表示するかどうかを決定する条件 218 @param[in] filename ファイル名 219 @param[in] lineno 行番号 220 @param[in] fmt 一般的な printf のフォーマット文字列。ただし、浮動小数点系のもの(%%f など) は指定できません。 221 222 @return 常に0 223 */ 224 int nndbgTAssertionFailureHandler(bool print, const char* filename, int lineno, const char* fmt, ...); 225 226 #ifdef __cplusplus 227 } 228 #endif // ifdef __cplusplus 229 230 #endif // NN_DBG_DBG_DEBUGSTRING_H_ 231