File: breakpoint.h

package info (click to toggle)
fuse-emulator 1.0.0.1a%2Bdfsg1-4
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 9,568 kB
  • sloc: ansic: 67,895; sh: 10,265; perl: 3,386; makefile: 787; yacc: 227; lex: 139
file content (149 lines) | stat: -rw-r--r-- 4,301 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* breakpoint.h: a debugger breakpoint
   Copyright (c) 2002-2008 Philip Kendall

   $Id: breakpoint.h 3662 2008-06-09 11:19:29Z pak21 $

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along
   with this program; if not, write to the Free Software Foundation, Inc.,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

   Author contact information:

   E-mail: philip-fuse@shadowmagic.org.uk

*/

#ifndef FUSE_DEBUGGER_BREAKPOINT_H
#define FUSE_DEBUGGER_BREAKPOINT_H

/* Types of breakpoint */
typedef enum debugger_breakpoint_type {
  DEBUGGER_BREAKPOINT_TYPE_EXECUTE,
  DEBUGGER_BREAKPOINT_TYPE_READ,
  DEBUGGER_BREAKPOINT_TYPE_WRITE,
  DEBUGGER_BREAKPOINT_TYPE_PORT_READ,
  DEBUGGER_BREAKPOINT_TYPE_PORT_WRITE,
  DEBUGGER_BREAKPOINT_TYPE_TIME,
  DEBUGGER_BREAKPOINT_TYPE_EVENT,
} debugger_breakpoint_type;

extern const char *debugger_breakpoint_type_text[];
extern const char debugger_breakpoint_type_abbr[][4];

/* Lifetime of a breakpoint */
typedef enum debugger_breakpoint_life {
  DEBUGGER_BREAKPOINT_LIFE_PERMANENT,
  DEBUGGER_BREAKPOINT_LIFE_ONESHOT,
} debugger_breakpoint_life;

extern const char *debugger_breakpoint_life_text[];
extern const char debugger_breakpoint_life_abbr[][5];

typedef struct debugger_breakpoint_address {

  int page;
  libspectrum_word offset;

} debugger_breakpoint_address;

/* Offsets used to encode various bank types in the above 'page' variable */
typedef enum breakpoint_page_offset {
  BREAKPOINT_PAGE_RAM = 0,
  BREAKPOINT_PAGE_ROM = 32,
  BREAKPOINT_PAGE_DOCK = 40,
  BREAKPOINT_PAGE_EXROM = 48,
  BREAKPOINT_PAGE_ROMCS = 56,
} breakpoint_page_offset;

typedef struct debugger_breakpoint_port {

  libspectrum_word port;
  libspectrum_word mask;

} debugger_breakpoint_port;

typedef struct debugger_breakpoint_time {
  libspectrum_dword tstates;
  int triggered;
} debugger_breakpoint_time;

typedef struct debugger_event_t {
  char *type;
  char *detail;
} debugger_event_t;

typedef union debugger_breakpoint_value {

  debugger_breakpoint_address address;
  debugger_breakpoint_port port;
  debugger_breakpoint_time time;
  debugger_event_t event;

} debugger_breakpoint_value;

typedef struct debugger_expression debugger_expression;

/* The breakpoint structure */
typedef struct debugger_breakpoint {
  size_t id;

  debugger_breakpoint_type type;
  debugger_breakpoint_value value;

  size_t ignore;		/* Ignore this breakpoint this many times */
  debugger_breakpoint_life life;
  debugger_expression *condition; /* Conditional expression to activate this
				     breakpoint */

  char *commands;

} debugger_breakpoint;

/* The current breakpoints */
extern GSList *debugger_breakpoints;

int debugger_check( debugger_breakpoint_type type, libspectrum_dword value );

/* Add a new breakpoint */
int
debugger_breakpoint_add_address(
  debugger_breakpoint_type type, int page, libspectrum_word offset,
  size_t ignore, debugger_breakpoint_life life, debugger_expression *condition
);

int
debugger_breakpoint_add_port(
  debugger_breakpoint_type type, libspectrum_word port, libspectrum_word mask,
  size_t ignore, debugger_breakpoint_life life, debugger_expression *condition
);

int
debugger_breakpoint_add_time(
  debugger_breakpoint_type type, libspectrum_dword tstates,
  size_t ignore, debugger_breakpoint_life life, debugger_expression *condition
);

int
debugger_breakpoint_add_event(
  debugger_breakpoint_type type, const char *type_string, const char *detail,
  size_t ignore, debugger_breakpoint_life life, debugger_expression *condition
);

/* Add events corresponding to all the time breakpoints to happen
   during this frame */
int debugger_add_time_events( void );

char*
debugger_breakpoint_decode_page( char *buffer, size_t n, int page );

#endif				/* #ifndef FUSE_DEBUGGER_BREAKPOINT_H */