Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmeteor/source/debug.hpp
2 views
1
// Meteor - A Nintendo Gameboy Advance emulator
2
// Copyright (C) 2009-2011 Philippe Daouadi
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
#ifndef __DEBUG_H__
18
#define __DEBUG_H__
19
20
#include <fstream>
21
#include <iostream>
22
#include <iomanip>
23
#include <cstdlib>
24
25
// for abort macro
26
#include "ameteor.hpp"
27
28
// from cinterface.cpp
29
void print_bizhawk(const char *msg);
30
void print_bizhawk(std::string &msg);
31
void abort_bizhawk(const char *msg);
32
void keyupdate_bizhawk();
33
extern bool traceenabled;
34
void trace_bizhawk(std::string msg);
35
extern int slcallbackline;
36
void scanlinecallback_bizhawk();
37
38
#if 0
39
#define met_abort(str) \
40
{ \
41
std::cerr << IOS_NOR << "Fatal error :\n" << str << "\nFile : " \
42
<< __FILE__ << "\nLine : " << __LINE__ << "\nr15 = " \
43
<< IOS_ADD << ::AMeteor::_cpu.Reg(15) << "\n[r15] = " << IOS_ADD \
44
<< ::AMeteor::_memory.Read32(::AMeteor::_cpu.Reg(15)) \
45
<< "\nFlag T : " << ::AMeteor::_cpu.ICpsr().thumb << std::endl; \
46
abort(); \
47
}
48
#endif
49
#ifdef METDEBUG
50
#include <sstream>
51
//extern "C" int __stdcall MessageBoxA(int, const char *, const char *, int);
52
#define met_abort(_str) if(true)\
53
{ \
54
std::stringstream _zisrny; \
55
_zisrny << IOS_NOR << "Fatal error :\n" << _str << "\nFile : " \
56
<< __FILE__ << "\nLine : " << __LINE__ << "\nr15 = " \
57
<< IOS_ADD << ::AMeteor::_cpu.Reg(15) << "\n[r15] = " << IOS_ADD \
58
<< ::AMeteor::_memory.Read32(::AMeteor::_cpu.Reg(15)) \
59
<< "\nFlag T : " << ::AMeteor::_cpu.ICpsr().thumb << std::endl; \
60
abort_bizhawk(_zisrny.str().c_str()); \
61
}
62
63
#else
64
#define met_abort(str) {}
65
#endif
66
67
#define STDBG std::cout
68
//#define STDBG debug_stream
69
70
#if defined METDEBUG && defined METDEBUGLOG
71
//XXX
72
# define MYDEBUG
73
# define debug(_str) \
74
{ \
75
std::stringstream _zisrny; \
76
_zisrny << _str << std::endl; \
77
print_bizhawk(_zisrny.str()); \
78
}
79
//STDBG << str << std::endl
80
//# define debug_(str) \
81
// STDBG << str
82
#else
83
# define debug(s) {}
84
//# define debug_(s) {}
85
#endif
86
87
#define IOS_ADD \
88
"0x" << std::setbase(16) << std::setw(8) << std::setfill('0') \
89
<< std::uppercase
90
#define IOS_TRACE \
91
std::setbase(16) << std::setw(8) << std::setfill('0') << std::uppercase
92
#define IOS_NOR \
93
std::setbase(10) << std::setw(0) << std::setfill(' ')
94
95
namespace AMeteor
96
{
97
void debug_bits(uint32_t u);
98
void debug_bits_16(uint16_t u);
99
100
#if defined MET_REGS_DEBUG
101
void PrintRegs ();
102
void PrintStack (uint32_t stackadd);
103
#else
104
#define PrintRegs()
105
#define PrintStack(b)
106
#endif
107
}
108
109
#endif
110
111