OXYGENHUB
◆ rrdc-perf enhanced-x16-emulator / src / debugger.h
5.6 KiB · Objective-C · last changed chore(): initial commit 25 days ago source blame history raw
9120e874 Andy McCall 1
// *******************************************************************************************
2
// *******************************************************************************************
3
//
4
//		File:		debugger.h
5
//		Date:		5th September 2019
6
//		Purpose:	Debugger header
7
//		Author:		Paul Robson ([email protected])
8
//
9
// *******************************************************************************************
10
// *******************************************************************************************
11
12
#ifndef _DEBUGGER_H
13
#define _DEBUGGER_H
14
15
#include <SDL.h>
16
17
// struct breakpoint and the breakpoint table itself now live in debug_core,
18
// which is the part a UI-less consumer (a debug server, another front end)
19
// needs and which can be tested without standing up an SDL window.
20
#include "debug_core.h"
21
22
#ifdef __cplusplus
23
extern "C" {
24
#endif
25
26
extern int showDebugOnRender;
27
28
void DEBUGRenderDisplay(int width,int height);
29
void DEBUGBreakToDebugger(void);
30
void DEBUGBreakOnWatchpoint(void);
31
int  DEBUGGetCurrentStatus(void);
32
void DEBUGInitUI(SDL_Renderer *pRenderer);
33
void DEBUGFreeUI();
34
35
// Execution control. These mirror the debug window's F5/F10/F11 handlers, and
36
// are what a debug server or an alternative front end drives instead of
37
// synthesising key presses. Safe to call whether or not the window exists.
38
void DEBUGContinue(void);                   // resume free-run
39
void DEBUGStepInto(void);                   // one instruction, then stop
40
41
// The step-over/step-out target lives outside the shared breakpoint table, so
42
// it carries its own owner: a session tearing down must retract a step it
43
// started, and must not retract one the user started at the keyboard.
44
void DEBUGStepOver(debug_owner_t owner);    // step over JSR/JSL; else single-step
45
void DEBUGStepOut(debug_owner_t owner);     // run to the current routine's return
46
47
// Step by SOURCE LINE rather than by instruction: repeat the step above until
48
// the PC reaches a different line. One C statement is many instructions, so in
49
// the Source panel a plain step looks like it does nothing for several presses.
50
//
51
// These are what the UI and DAP should call. They fall back to the instruction
52
// step whenever stepping by line would mean nothing -- the preference is off,
53
// the .dbg carries no high-level (C) line info, or the PC is not on a line at
54
// all -- so an assembly project steps exactly as it always did.
55
void DEBUGStepIntoAuto(void);
56
void DEBUGStepOverAuto(debug_owner_t owner);
57
58
// Whether stepping by line is wanted. On by default; only consulted where the
59
// debug info makes it meaningful. Abandoning a source step in progress is what
60
// DEBUGCancelSourceStep() is for -- pausing, or hitting a breakpoint, ends it.
61
void DEBUGSetSourceStep(bool on);
62
bool DEBUGGetSourceStep(void);
63
void DEBUGCancelSourceStep(void);
64
65
// Abandon a step-over/step-out that is still running. Its breakpoint is the
66
// debugger's own, so nothing else can retract it -- and left armed it stops the
67
// machine later for a session that has gone away.
68
void DEBUGCancelStep(void);
69
70
// Who asked for the pending step, or DEBUG_OWNER_COUNT if none is pending, and
71
// the retract-only-if-mine form that a session teardown wants.
72
debug_owner_t DEBUGStepOwner(void);
73
bool          DEBUGCancelStepFor(debug_owner_t owner);
74
75
void DEBUGPause(void);                      // halt now
76
void DEBUGRunTo(uint16_t pc, uint8_t bank, debug_owner_t owner); // run until (pc,bank)
77
bool DEBUGIsRunning(void);
78
bool DEBUGIsPaused(void);
79
80
// Interrupt following. With follow-interrupts on, an interrupt taken while
81
// stepping stops at the handler's first instruction instead of being run
82
// through invisibly; break-on-interrupt stops on every entry. Both off by
83
// default, so stepping behaves exactly as it did without them.
84
void DEBUGSetFollowInterrupts(bool on);
85
bool DEBUGGetFollowInterrupts(void);
86
void DEBUGSetBreakOnInterrupt(bool on);
87
bool DEBUGGetBreakOnInterrupt(void);
88
89
// Why execution last stopped: "step", "breakpoint", "data breakpoint", "user",
90
// "interrupt", or "" before the first stop. The returned pointer is a string
91
// literal and is never freed. A UI uses this to keep the view still after a
92
// step but re-centre it after an arrival somewhere new.
93
void        DEBUGSetStopReason(const char *reason);
94
// Record the reason and tell a DAP client execution stopped. Edge-triggered:
95
// call this exactly once per RUN->STOP transition, from the site that knows it
96
// is one. Sites that run on every poll while already halted, or that set a
97
// default a later caller overrides, must use DEBUGSetStopReason() instead.
98
void        DEBUGAnnounceStop(const char *reason);
99
const char *DEBUGGetStopReason(void);
100
101
#define DBG_WIDTH 		(60)									// Char cells across
102
#define DBG_HEIGHT 		(60)
103
104
#define DBG_ASMX 		(1)										// Disassembly starts here
105
#define DBG_LBLX 		(26) 									// Debug labels start here
106
#define DBG_DATX		(30)									// Debug data starts here.
107
#define DBG_STCK		(40)									// Debug stack starts here.
108
#define DBG_MEMX 		(1)										// Memory Display starts here
109
#define DBG_ZP_REG     (45)                             // Zero page registers start here
110
#define DBG_VERA_REGX   (45)                             // VERA registers start here
111
112
#define DMODE_STOP 		(0)										// Debugger is waiting for action.
113
#define DMODE_STEP 		(1)										// Debugger is doing a single step
114
#define DMODE_RUN 		(2)										// Debugger is running normally.
115
116
// The run state itself, one of DMODE_*. Defined in debugger.c and driven by
117
// whichever front end is attached -- the SDL debugger, the ImGui debugger, or
118
// the DAP server when a client is stepping.
119
extern int currentMode;
120
#ifdef __cplusplus
121
}
122
#endif
123
124
#endif