1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     dbg_OldSymbols.cpp
4 
5   Copyright (C)2009-2012 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: 46347 $
14  *---------------------------------------------------------------------------*/
15 
16 #include <nn/dbg.h>
17 #include <nn/os.h>
18 #include <cstdarg>
19 
20 using namespace nn::dbg;
21 
22 extern "C"
23 {
nndbgAssertionFailureHandler(bool print,const char * filename,int lineno,const char * fmt,...)24     int nndbgAssertionFailureHandler(bool print, const char* filename, int lineno, const char* fmt, ...)
25     {
26         if (print)
27         {
28             va_list arg;
29             va_start(arg, fmt);
30             detail::TPrintf("Assertion failure at %s:%d\n  ", filename, lineno);
31             detail::TVPrintf(fmt, arg);
32             detail::TPrintf("\n");
33             va_end(arg);
34         }
35 
36         Break(BREAK_REASON_ASSERT);
37         return 0;
38     }
nndbgTAssertionFailureHandler(bool print,const char * filename,int lineno,const char * fmt,...)39     int nndbgTAssertionFailureHandler(bool print, const char* filename, int lineno, const char* fmt, ...)
40     {
41         if (print)
42         {
43             va_list arg;
44             va_start(arg, fmt);
45             detail::TPrintf("Assertion failure at %s:%d\n  ", filename, lineno);
46             detail::VPrintf(fmt, arg);
47             detail::TPrintf("\n");
48             va_end(arg);
49         }
50 
51         Break(BREAK_REASON_ASSERT);
52         return 0;
53     }
nnResultFailureHandler(nnResult result,const char * filename,int lineno,const char * fmt,...)54     int nnResultFailureHandler  (nnResult result, const char* filename, int lineno, const char* fmt, ...)
55     {
56 #ifndef NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK
57         va_list arg;
58         va_start(arg, fmt);
59         detail::TPrintf("Assertion failure at %s:%d\n  ", filename, lineno);
60         detail::TPrintf("RESULT FAILURE [%x]: ", nn::Result(result).GetPrintableBits());
61         detail::VPrintf(fmt, arg);
62         detail::PrintResult(result);
63         va_end(arg);
64 #else
65         NN_UNUSED_VAR(result);
66         NN_UNUSED_VAR(filename);
67         NN_UNUSED_VAR(lineno);
68         NN_UNUSED_VAR(fmt);
69 #endif
70 
71         Break(BREAK_REASON_ASSERT);
72         return 0;
73     }
nnResultTFailureHandler(nnResult result,const char * filename,int lineno,const char * fmt,...)74     int nnResultTFailureHandler (nnResult result, const char* filename, int lineno, const char* fmt, ...)
75     {
76 #ifndef NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK
77         va_list arg;
78         va_start(arg, fmt);
79         detail::TPrintf("Assertion failure at %s:%d\n  ", filename, lineno);
80         detail::TPrintf("RESULT FAILURE [%x]: ", nn::Result(result).GetPrintableBits());
81         detail::TVPrintf(fmt, arg);
82         detail::PrintResult(result);
83         va_end(arg);
84 #else
85         NN_UNUSED_VAR(result);
86         NN_UNUSED_VAR(filename);
87         NN_UNUSED_VAR(lineno);
88         NN_UNUSED_VAR(fmt);
89 #endif
90 
91         Break(BREAK_REASON_ASSERT);
92         return 0;
93     }
nnResultPanicHandler(nnResult result,const char * filename,int lineno,const char * fmt,...)94     int nnResultPanicHandler   (nnResult result, const char* filename, int lineno, const char* fmt, ...)
95     {
96 #ifndef NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK
97         va_list arg;
98         va_start(arg, fmt);
99         detail::TPrintf("Panic at %s:%d\n  ", filename, lineno);
100         detail::TPrintf("RESULT FAILURE [%x]: ", nn::Result(result).GetPrintableBits());
101         detail::VPrintf(fmt, arg);
102         detail::PrintResult(result);
103         va_end(arg);
104 #else
105         NN_UNUSED_VAR(result);
106         NN_UNUSED_VAR(filename);
107         NN_UNUSED_VAR(lineno);
108         NN_UNUSED_VAR(fmt);
109 #endif
110         return 0;
111     }
nnResultTPanicHandler(nnResult result,const char * filename,int lineno,const char * fmt,...)112     int nnResultTPanicHandler  (nnResult result, const char* filename, int lineno, const char* fmt, ...)
113     {
114 #ifndef NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK
115         va_list arg;
116         va_start(arg, fmt);
117         detail::TPrintf("Panic at %s:%d\n  ", filename, lineno);
118         detail::TPrintf("RESULT FAILURE [%x]: ", nn::Result(result).GetPrintableBits());
119         detail::TVPrintf(fmt, arg);
120         detail::PrintResult(result);
121         va_end(arg);
122 #else
123         NN_UNUSED_VAR(result);
124         NN_UNUSED_VAR(filename);
125         NN_UNUSED_VAR(lineno);
126         NN_UNUSED_VAR(fmt);
127 #endif
128         return 0;
129     }
130 }
131 
132 namespace nn
133 {
134     namespace dbg
135     {
PrintResult(nn::Result result)136         void PrintResult(nn::Result result)
137         {
138 #ifndef NN_SWITCH_DISABLE_ASSERT_WARNING
139             detail::PrintResult(result);
140 #else
141             NN_UNUSED_VAR(result);
142 #endif
143         }
144 
TPrintResult(nn::Result result)145         void TPrintResult(nn::Result result)
146         {
147 #ifndef NN_SWITCH_DISABLE_ASSERT_WARNING
148             detail::PrintResult(result);
149 #else
150             NN_UNUSED_VAR(result);
151 #endif
152         }
153     }
154 
155     namespace os
156     {
157         namespace CTR
158         {
159             namespace detail
160             {
InternalErrorHandler(Result result,const char * filename,int lineno)161                 void InternalErrorHandler( Result result, const char* filename, int lineno )
162                 {
163                     HandleInternalError(result, filename, lineno);
164                 }
InternalErrorHandler(Result result)165                 void InternalErrorHandler( Result result )
166                 {
167                     HandleInternalError(result);
168                 }
169             }
170         }
171     }
172 }
173