Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 20 | pmbaty | 1 | #include "diag.h" |
| 2 | #include "CORE/STD/brstdlib.h" |
||
| 3 | #include "brprintf.h" |
||
| 4 | #include "fwsetup.h" |
||
| 5 | #include "harness/trace.h" |
||
| 6 | #include <stdarg.h> |
||
| 7 | |||
| 8 | // Global variables |
||
| 9 | char _diag_scratch[128]; |
||
| 10 | |||
| 11 | // IDA: void __cdecl BrFailure(char *s, ...) |
||
| 12 | void BrFailure(const char* s, ...) { |
||
| 13 | va_list args; |
||
| 14 | const char failure_header[10] = "Failure: "; |
||
| 15 | LOG_TRACE("(\"%s\")", s); |
||
| 16 | |||
| 17 | va_start(args, s); |
||
| 18 | BrStrCpy(_diag_scratch, failure_header); |
||
| 19 | BrVSprintf(&_diag_scratch[sizeof(failure_header) - 1], s, args); |
||
| 20 | |||
| 21 | if (fw.diag->failure == NULL) { |
||
| 22 | BrAbort(); |
||
| 23 | } |
||
| 24 | |||
| 25 | fw.diag->failure(_diag_scratch); |
||
| 26 | va_end(args); |
||
| 27 | } |
||
| 28 | |||
| 29 | // IDA: void __cdecl BrWarning(char *s, ...) |
||
| 30 | void BrWarning(const char* s, ...) { |
||
| 31 | va_list args; |
||
| 32 | const char warning_header[10] = "Warning: "; |
||
| 33 | |||
| 34 | va_start(args, s); |
||
| 35 | BrStrCpy(_diag_scratch, warning_header); |
||
| 36 | BrVSprintf(&_diag_scratch[sizeof(warning_header) - 1], s, args); |
||
| 37 | |||
| 38 | if (fw.diag->warning == NULL) { |
||
| 39 | BrAbort(); |
||
| 40 | } |
||
| 41 | |||
| 42 | fw.diag->warning(_diag_scratch); |
||
| 43 | va_end(args); |
||
| 44 | } |
||
| 45 | |||
| 46 | // IDA: void __cdecl BrFatal(char *name, int line, char *s, ...) |
||
| 47 | void BrFatal(const char* name, int line, const char* s, ...) { |
||
| 48 | va_list args; |
||
| 49 | int n; |
||
| 50 | |||
| 51 | va_start(args, s); |
||
| 52 | n = BrSprintf(_diag_scratch, "FATAL %s:%d\n", name, line); |
||
| 53 | BrVSprintf(&_diag_scratch[n], s, args); |
||
| 54 | if (fw.diag->failure == NULL) { |
||
| 55 | BrAbort(); |
||
| 56 | } |
||
| 57 | |||
| 58 | fw.diag->failure(_diag_scratch); |
||
| 59 | va_end(args); |
||
| 60 | } |
||
| 61 | |||
| 62 | // IDA: void __cdecl _BrAssert(char *condition, char *file, unsigned int line) |
||
| 63 | void _BrAssert(const char* condition, const char* file, unsigned int line) { |
||
| 64 | if (fw.diag->failure == NULL) { |
||
| 65 | BrAbort(); |
||
| 66 | } |
||
| 67 | |||
| 68 | BrSprintf(_diag_scratch, "ASSERTION FAILED %s:%d: \"%s\"\n", file, line, condition); |
||
| 69 | fw.diag->failure(_diag_scratch); |
||
| 70 | } |
||
| 71 | |||
| 72 | // IDA: void __cdecl _BrUAssert(char *condition, char *file, unsigned int line) |
||
| 73 | void _BrUAssert(const char* condition, const char* file, unsigned int line) { |
||
| 74 | if (fw.diag->failure == NULL) { |
||
| 75 | BrAbort(); |
||
| 76 | } |
||
| 77 | |||
| 78 | BrSprintf(_diag_scratch, "ASSERTION FAILED %s:%d: \"%s\"\n", file, line, condition); |
||
| 79 | fw.diag->failure(_diag_scratch); |
||
| 80 | } |