Rev 1 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | #include "harness/trace.h" |
2 | |||
3 | #include <stdarg.h> |
||
4 | #include <stddef.h> |
||
5 | #include <stdio.h> |
||
6 | #include <sys/types.h> |
||
7 | |||
8 | int harness_debug_level = 4; |
||
9 | |||
10 | void debug_printf(const char* fmt, const char* fn, const char* fmt2, ...) { |
||
11 | va_list ap; |
||
12 | |||
13 | printf(fmt, fn); |
||
14 | |||
15 | va_start(ap, fmt2); |
||
16 | vprintf(fmt2, ap); |
||
17 | va_end(ap); |
||
18 | |||
19 | puts("\033[0m"); |
||
20 | } |
||
21 | |||
18 | pmbaty | 22 | void panic_printf(const char* fmt, const char* fn, const char* fmt2, ...) { |
23 | va_list ap; |
||
24 | |||
25 | FILE* fp = fopen("dethrace.log", "w"); |
||
26 | |||
27 | puts("\033[0;31m"); |
||
28 | printf(fmt, fn); |
||
29 | |||
30 | if (fp != NULL) { |
||
31 | fprintf(fp, fmt, fn); |
||
32 | } |
||
33 | |||
34 | va_start(ap, fmt2); |
||
35 | vprintf(fmt2, ap); |
||
36 | if (fp != NULL) { |
||
37 | vfprintf(fp, fmt2, ap); |
||
38 | } |
||
39 | va_end(ap); |
||
40 | if (fp != NULL) { |
||
41 | fclose(fp); |
||
42 | } |
||
43 | puts("\033[0m"); |
||
44 | } |
||
45 | |||
1 | pmbaty | 46 | void debug_print_vector3(const char* fmt, const char* fn, char* msg, br_vector3* v) { |
47 | printf(fmt, fn); |
||
48 | printf("%s %f, %f, %f\n", msg, v->v[0], v->v[1], v->v[2]); |
||
49 | puts("\033[0m"); |
||
50 | } |
||
51 | |||
52 | void debug_print_matrix34(const char* fmt, const char* fn, char* msg, br_matrix34* m) { |
||
53 | printf(fmt, fn); |
||
54 | printf("matrix34 \"%s\"\n", msg); |
||
55 | for (int i = 0; i < 4; i++) { |
||
56 | printf(" %f, %f, %f\n", m->m[i][0], m->m[i][1], m->m[i][2]); |
||
57 | } |
||
58 | puts("\033[0m"); |
||
59 | } |
||
60 | |||
61 | void debug_print_matrix4(const char* fmt, const char* fn, char* msg, br_matrix4* m) { |
||
62 | printf(fmt, fn); |
||
63 | printf("matrix34 \"%s\"\n", msg); |
||
64 | for (int i = 0; i < 4; i++) { |
||
65 | printf(" %f, %f, %f, %f\n", m->m[i][0], m->m[i][1], m->m[i][2], m->m[i][3]); |
||
66 | } |
||
67 | puts("\033[0m"); |
||
68 | } |
||
69 | |||
70 | // int count_open_fds(void) { |
||
71 | // DIR* dp = opendir("/dev/fd/"); |
||
72 | // struct dirent* de; |
||
73 | // int count = -3; // '.', '..', dp |
||
74 | |||
75 | // if (dp == NULL) |
||
76 | // return -1; |
||
77 | |||
78 | // while ((de = readdir(dp)) != NULL) |
||
79 | // count++; |
||
80 | |||
81 | // (void)closedir(dp); |
||
82 | |||
83 | // return count; |
||
84 | // } |