2006-07-29 05:46:15 +00:00
|
|
|
#ifndef _DEBUG_H_
|
|
|
|
#define _DEBUG_H_
|
|
|
|
|
|
|
|
#include "conddebug.h"
|
2006-08-19 18:30:52 +00:00
|
|
|
#include "git.h"
|
|
|
|
#include "nsf.h"
|
2006-07-29 05:46:15 +00:00
|
|
|
|
|
|
|
//watchpoint stuffs
|
|
|
|
#define WP_E 0x01 //watchpoint, enable
|
|
|
|
#define WP_W 0x02 //watchpoint, write
|
|
|
|
#define WP_R 0x04 //watchpoint, read
|
|
|
|
#define WP_X 0x08 //watchpoint, execute
|
2008-08-13 07:41:46 +00:00
|
|
|
#define WP_F 0x10 //watchpoint, forbid
|
2006-07-29 05:46:15 +00:00
|
|
|
|
|
|
|
#define BT_C 0x00 //break type, cpu mem
|
2008-08-13 07:41:46 +00:00
|
|
|
#define BT_P 0x20 //break type, ppu mem
|
|
|
|
#define BT_S 0x40 //break type, sprite mem
|
2006-07-29 05:46:15 +00:00
|
|
|
|
2012-08-05 18:54:52 +00:00
|
|
|
#define BREAK_TYPE_STEP -1
|
2012-09-22 15:33:31 +00:00
|
|
|
#define BREAK_TYPE_BADOP -2
|
|
|
|
#define BREAK_TYPE_CYCLES_EXCEED -3
|
|
|
|
#define BREAK_TYPE_INSTRUCTIONS_EXCEED -4
|
2013-05-26 15:18:30 +00:00
|
|
|
#define BREAK_TYPE_LUA -5
|
2012-08-05 18:54:52 +00:00
|
|
|
|
2006-07-29 05:46:15 +00:00
|
|
|
//opbrktype is used to grab the breakpoint type that each instruction will cause.
|
2009-02-21 23:38:20 +00:00
|
|
|
//WP_X is not used because ALL opcodes will have the execute bit set.
|
|
|
|
static const uint8 opbrktype[256] = {
|
|
|
|
/*0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F*/
|
|
|
|
/*0x00*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, 0, WP_R, WP_R|WP_W, 0,
|
|
|
|
/*0x10*/ 0, WP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 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0,
|
|
|
|
/*0xE0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0,
|
|
|
|
/*0xF0*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0
|
|
|
|
};
|
|
|
|
|
2006-07-29 05:46:15 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint16 address;
|
|
|
|
uint16 endaddress;
|
|
|
|
uint8 flags;
|
|
|
|
|
|
|
|
Condition* cond;
|
|
|
|
char* condText;
|
|
|
|
char* desc;
|
2008-08-13 07:41:46 +00:00
|
|
|
|
2006-07-29 05:46:15 +00:00
|
|
|
} watchpointinfo;
|
|
|
|
|
|
|
|
//mbg merge 7/18/06 had to make this extern
|
|
|
|
extern watchpointinfo watchpoint[65]; //64 watchpoints, + 1 reserved for step over
|
|
|
|
|
2010-04-08 21:26:20 +00:00
|
|
|
int getBank(int offs);
|
2006-07-29 05:46:15 +00:00
|
|
|
int GetNesFileAddress(int A);
|
|
|
|
int GetPRGAddress(int A);
|
|
|
|
int GetRomAddress(int A);
|
|
|
|
//int GetEditHex(HWND hwndDlg, int id);
|
|
|
|
uint8 *GetNesPRGPointer(int A);
|
|
|
|
uint8 *GetNesCHRPointer(int A);
|
|
|
|
void KillDebugger();
|
|
|
|
uint8 GetMem(uint16 A);
|
|
|
|
uint8 GetPPUMem(uint8 A);
|
|
|
|
|
|
|
|
//---------CDLogger
|
|
|
|
void LogCDVectors(int which);
|
2012-09-30 16:36:45 +00:00
|
|
|
void LogCDData(uint8 *opcode, uint16 A, int size);
|
2006-07-29 05:46:15 +00:00
|
|
|
extern volatile int codecount, datacount, undefinedcount;
|
|
|
|
extern unsigned char *cdloggerdata;
|
2013-02-24 11:19:36 +00:00
|
|
|
extern unsigned int cdloggerdataSize;
|
2006-07-29 05:46:15 +00:00
|
|
|
|
|
|
|
extern int debug_loggingCD;
|
|
|
|
static INLINE void FCEUI_SetLoggingCD(int val) { debug_loggingCD = val; }
|
|
|
|
static INLINE int FCEUI_GetLoggingCD() { return debug_loggingCD; }
|
|
|
|
//-------
|
|
|
|
|
|
|
|
//-------tracing
|
|
|
|
//we're letting the win32 driver handle this ittself for now
|
|
|
|
//extern int debug_tracing;
|
|
|
|
//static INLINE void FCEUI_SetTracing(int val) { debug_tracing = val; }
|
|
|
|
//static INLINE int FCEUI_GetTracing() { return debug_tracing; }
|
|
|
|
//---------
|
|
|
|
|
|
|
|
//--------debugger
|
|
|
|
extern int iaPC;
|
|
|
|
extern uint32 iapoffset; //mbg merge 7/18/06 changed from int
|
|
|
|
void DebugCycle();
|
2020-01-12 14:07:23 +00:00
|
|
|
bool CondForbidTest(int bp_num);
|
2020-01-12 13:56:37 +00:00
|
|
|
void BreakHit(int bp_num);
|
2013-05-26 15:18:30 +00:00
|
|
|
|
|
|
|
extern bool break_asap;
|
|
|
|
extern uint64 total_cycles_base;
|
|
|
|
extern uint64 delta_cycles_base;
|
|
|
|
extern bool break_on_cycles;
|
|
|
|
extern uint64 break_cycles_limit;
|
|
|
|
extern uint64 total_instructions;
|
|
|
|
extern uint64 delta_instructions;
|
|
|
|
extern bool break_on_instructions;
|
|
|
|
extern uint64 break_instructions_limit;
|
|
|
|
extern void ResetDebugStatisticsCounters();
|
|
|
|
extern void ResetCyclesCounter();
|
|
|
|
extern void ResetInstructionsCounter();
|
|
|
|
extern void ResetDebugStatisticsDeltaCounters();
|
2013-05-26 16:33:43 +00:00
|
|
|
extern void IncrementInstructionsCounters();
|
2006-07-29 05:46:15 +00:00
|
|
|
//-------------
|
|
|
|
|
|
|
|
//internal variables that debuggers will want access to
|
|
|
|
extern uint8 *vnapage[4],*VPage[8];
|
2019-11-08 05:03:31 +00:00
|
|
|
extern uint8 PPU[4],PALRAM[0x20],UPALRAM[3],SPRAM[0x100],VRAMBuffer,PPUGenLatch,XOffset;
|
2015-01-28 18:12:06 +00:00
|
|
|
extern uint32 FCEUPPU_PeekAddress();
|
2018-11-07 08:09:56 +00:00
|
|
|
extern uint8 READPAL_MOTHEROFALL(uint32 A);
|
2009-09-17 06:36:09 +00:00
|
|
|
extern int numWPs;
|
2006-08-01 04:33:12 +00:00
|
|
|
|
|
|
|
///encapsulates the operational state of the debugger core
|
|
|
|
class DebuggerState {
|
|
|
|
public:
|
|
|
|
///indicates whether the debugger is stepping through a single instruction
|
|
|
|
bool step;
|
|
|
|
///indicates whether the debugger is stepping out of a function call
|
|
|
|
bool stepout;
|
2009-02-21 23:38:20 +00:00
|
|
|
///indicates whether the debugger is running one line
|
|
|
|
bool runline;
|
|
|
|
///target timestamp for runline to stop at
|
|
|
|
uint64 runline_end_time;
|
2006-08-01 04:33:12 +00:00
|
|
|
///indicates whether the debugger should break on bad opcodes
|
|
|
|
bool badopbreak;
|
|
|
|
///counts the nest level of the call stack while stepping out
|
|
|
|
int jsrcount;
|
|
|
|
|
|
|
|
///resets the debugger state to an empty, non-debugging state
|
|
|
|
void reset() {
|
|
|
|
numWPs = 0;
|
|
|
|
step = false;
|
|
|
|
stepout = false;
|
|
|
|
jsrcount = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2006-08-19 18:30:52 +00:00
|
|
|
extern NSF_HEADER NSFHeader;
|
|
|
|
|
2014-07-13 12:22:22 +00:00
|
|
|
extern uint8 PSG[0x10];
|
|
|
|
extern uint8 DMCFormat;
|
|
|
|
extern uint8 RawDALatch;
|
|
|
|
extern uint8 DMCAddressLatch;
|
|
|
|
extern uint8 DMCSizeLatch;
|
|
|
|
extern uint8 EnabledChannels;
|
|
|
|
extern uint8 SpriteDMA;
|
|
|
|
extern uint8 RawReg4016;
|
|
|
|
extern uint8 IRQFrameMode;
|
|
|
|
|
2006-08-01 04:33:12 +00:00
|
|
|
///retrieves the core's DebuggerState
|
|
|
|
DebuggerState &FCEUI_Debugger();
|
|
|
|
|
2008-08-13 07:41:46 +00:00
|
|
|
//#define CPU_BREAKPOINT 1
|
|
|
|
//#define PPU_BREAKPOINT 2
|
|
|
|
//#define SPRITE_BREAKPOINT 4
|
|
|
|
//#define READ_BREAKPOINT 8
|
|
|
|
//#define WRITE_BREAKPOINT 16
|
|
|
|
//#define EXECUTE_BREAKPOINT 32
|
2006-08-19 18:30:52 +00:00
|
|
|
|
|
|
|
int offsetStringToInt(unsigned int type, const char* offsetBuffer);
|
|
|
|
unsigned int NewBreak(const char* name, int start, int end, unsigned int type, const char* condition, unsigned int num, bool enable);
|
|
|
|
|
2006-07-29 05:46:15 +00:00
|
|
|
#endif
|