ScummVM API documentation
trace.h
1
/* ScummVM - Graphic Adventure Engine
2
*
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*
20
*/
21
22
23
// This section can only be included once
24
#ifndef PSP_TRACE_H
25
#define PSP_TRACE_H
26
27
#include "common/str.h"
28
29
#define __PSP_PRINT_TO_FILE_AND_SCREEN__
30
31
/* Choose to print to file/screen/both */
32
#ifdef __PSP_PRINT_TO_FILE__
33
#define __PSP_PRINT__(format,...) PspDebugTrace(false, format, ## __VA_ARGS__)
34
#elif defined(__PSP_PRINT_TO_FILE_AND_SCREEN__)
35
#define __PSP_PRINT__(format,...) PspDebugTrace(true, format, ## __VA_ARGS__)
36
#else
/* default - print to screen */
37
#define __PSP_PRINT__(format,...) fprintf(stderr, format, ## __VA_ARGS__)
38
#endif
/* PSP_PRINT_TO_FILE/SCREEN */
39
40
/* Error function - always print to file as well */
41
#define PSP_ERROR(format,...) PspDebugTrace(true, "Error in %s: " format, __PRETTY_FUNCTION__, ## __VA_ARGS__)
42
43
/* Do the indent */
44
#define __PSP_INDENT__ for(int _i=psp_debug_indent; _i>0; _i--) \
45
__PSP_PRINT__( " ")
46
47
/* always print */
48
#define PSP_INFO_PRINT(format,...) __PSP_PRINT__(format, ## __VA_ARGS__)
49
/* always print, with indent */
50
#define PSP_INFO_PRINT_INDENT(format,...) { __PSP_INDENT__; \
51
__PSP_PRINT__(format, ## __VA_ARGS__); }
52
53
void
PspDebugTrace(
bool
alsoToScreen,
const
char
*format, ...);
54
void
mipsBacktrace(uint32 levels,
void
**addresses);
55
56
extern
int
psp_debug_indent;
57
58
// We use this class to print out function calls on the stack in an easy way.
59
//
60
61
class
PSPStackDebugFuncs
{
62
Common::String
_name;
63
64
public
:
65
PSPStackDebugFuncs
(
const
char
*name) : _name(name) {
66
PSP_INFO_PRINT_INDENT(
"++ %s\n"
, _name.c_str());
67
psp_debug_indent++;
68
}
69
70
~
PSPStackDebugFuncs
() {
71
psp_debug_indent--;
72
if
(psp_debug_indent < 0)
73
PSP_ERROR(
"debug indent < 0\n"
);
74
PSP_INFO_PRINT_INDENT(
"-- %s\n"
, _name.c_str());
75
}
76
};
77
78
#endif
/* PSP_TRACE_H */
79
80
81
82
83
// From here on, we allow multiple redefinitions
84
85
// Use these defines for debugging
86
87
//#define __PSP_PRINT_TO_FILE__
88
//#define __PSP_PRINT_TO_FILE_AND_SCREEN__
89
//#define __PSP_DEBUG_FUNCS__ /* can put this locally too */
90
//#define __PSP_DEBUG_PRINT__
91
92
#undef PSP_DEBUG_PRINT
93
#undef PSP_DEBUG_PRINT_FUNC
94
#undef PSP_DEBUG_PRINT_SAMELN
95
#undef PSP_DEBUG_DO
96
#undef DEBUG_ENTER_FUNC
97
#undef DEBUG_EXIT_FUNC
98
99
#ifdef __PSP_DEBUG_PRINT__
100
/* printf with indents */
101
#define PSP_DEBUG_PRINT_SAMELN(format,...) __PSP_PRINT__(format, ## __VA_ARGS__)
102
#define PSP_DEBUG_PRINT(format,...) PSP_INFO_PRINT_INDENT(format, ## __VA_ARGS__)
103
#define PSP_DEBUG_PRINT_FUNC(format,...) { __PSP_INDENT__; \
104
__PSP_PRINT__("In %s: " format, __PRETTY_FUNCTION__, ## __VA_ARGS__); }
105
#define PSP_DEBUG_DO(x) (x)
106
107
#else
/* no debug print */
108
#define PSP_DEBUG_PRINT_SAMELN(format,...)
109
#define PSP_DEBUG_PRINT(format,...)
110
#define PSP_DEBUG_PRINT_FUNC(format,...)
111
#define PSP_DEBUG_DO(x)
112
#endif
/* __PSP_DEBUG_PRINT__ */
113
114
/* We don't need anything but this line at the beginning of each function to debug function calls */
115
/* Debugging function calls */
116
#ifdef __PSP_DEBUG_FUNCS__
117
#define DEBUG_ENTER_FUNC() volatile PSPStackDebugFuncs __foo(__PRETTY_FUNCTION__)
118
#else
/* Don't debug function calls */
119
#define DEBUG_ENTER_FUNC()
120
#endif
/* __PSP_DEBUG_FUNCS__ */
121
122
// Undef the main defines for next time
123
#undef __PSP_PRINT_TO_FILE__
124
#undef __PSP_PRINT_TO_FILE_AND_SCREEN__
125
#undef __PSP_DEBUG_FUNCS__
126
#undef __PSP_DEBUG_PRINT__
Common::String
Definition:
str.h:59
PSPStackDebugFuncs
Definition:
trace.h:61
backends
platform
psp
trace.h
Generated on Fri Nov 22 2024 09:05:37 for ScummVM API documentation by
1.8.13