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: 27626 $ 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 @brief 文字列をデバッグ出力します。 162 163 内部で length を指定するオーバーロードの PutString を呼び出します。 164 165 @param[in] text 出力文字列 (NULL 終端されている必要があります) 166 */ 167 void PutString(const char* text); 168 } 169 }} 170 #endif // ifdef __cplusplus 171 172 //------------------------------------------------------------------- 173 // for C / C++ 174 175 #include <nn/util/detail/util_CLibImpl.h> 176 177 #include <nn/dbg/dbg_Break.h> 178 179 #ifdef __cplusplus 180 extern "C" { 181 #endif // ifdef __cplusplus 182 183 /* 184 @brief 対応する C++ 関数 @ref nn::dbg::detail::Printf を参照してください。 185 */ 186 void nndbgDetailPrintf(const char* fmt, ...); 187 188 /* 189 @brief 対応する C++ 関数 @ref nn::dbg::detail::TPrintf を参照してください。 190 */ 191 void nndbgDetailTPrintf(const char* fmt, ...); 192 193 /* 194 @brief 対応する C++ 関数 @ref nn::dbg::detail::VPrintf を参照してください。 195 196 nndbgDetailVPrintf は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 197 */ 198 void nndbgDetailVPrintf(const char* fmt, va_list arg); 199 200 /* 201 @brief 対応する C++ 関数 @ref nn::dbg::detail::TVPrintf を参照してください。 202 203 nndbgDetailTVPrintf は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 204 */ 205 void nndbgDetailTVPrintf(const char* fmt, va_list arg); 206 207 /* 208 @brief 文字列を表示し、プログラムを停止します。 209 210 nndbgAssertionFailureHandler は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 211 212 @param[in] print 文字列を表示するかどうかを決定する条件 213 @param[in] filename ファイル名 214 @param[in] lineno 行番号 215 @param[in] fmt 一般的な printf のフォーマット文字列 216 217 @return 常に0 218 */ 219 int nndbgAssertionFailureHandler(bool print, const char* filename, int lineno, const char* fmt, ...); 220 221 /* 222 @brief 文字列を表示し、プログラムを停止します。nndbgAssertionFailureHandler の省メモリ版です。 223 224 nndbgTAssertionFailureHandler は weak シンボルでコンパイルされているため、ユーザ独自の定義に書き換えが可能です。 225 226 @param[in] print 文字列を表示するかどうかを決定する条件 227 @param[in] filename ファイル名 228 @param[in] lineno 行番号 229 @param[in] fmt 一般的な printf のフォーマット文字列。ただし、浮動小数点系のもの(%%f など) は指定できません。 230 231 @return 常に0 232 */ 233 int nndbgTAssertionFailureHandler(bool print, const char* filename, int lineno, const char* fmt, ...); 234 235 #ifdef __cplusplus 236 } 237 #endif // ifdef __cplusplus 238 239 #endif // NN_DBG_DBG_DEBUGSTRING_H_ 240