| 1 | /* This file has been modified by Data General Corporation, November 1989. */ |
| 2 | |
| 3 | #ifndef _tdesc_h |
| 4 | #define _tdesc_h |
| 5 | #ifdef __STDC__ |
| 6 | #define _ARGS(x) x |
| 7 | #else |
| 8 | #define _ARGS(x) () |
| 9 | #endif |
| 10 | |
| 11 | /* |
| 12 | This file provides an abstract interface to "tdesc" information. |
| 13 | It is designed to be used in a uniform manner by several kinds |
| 14 | of debuggers: |
| 15 | (1) code in live debugged process (e.g., a traceback routine) |
| 16 | (2) a separate-process debugger debugging a live process |
| 17 | (3) a separate-process debugger debugging a memory dump |
| 18 | |
| 19 | Dcontext model notes |
| 20 | * captures machine context |
| 21 | * partial: excludes memory |
| 22 | * frames |
| 23 | * kinds |
| 24 | * make one for starters, chain in reverse order to previous ones |
| 25 | * representation: pointer to opaque |
| 26 | * alloc/free protocol |
| 27 | |
| 28 | Overall model |
| 29 | * access functions |
| 30 | * handle |
| 31 | * error handling |
| 32 | */ |
| 33 | |
| 34 | |
| 35 | |
| 36 | typedef int dc_boolean_t; /* range 0 .. 1 */ |
| 37 | #define DC_FALSE 0 |
| 38 | #define DC_TRUE 1 |
| 39 | |
| 40 | |
| 41 | typedef int dc_tristate_t; /* range 0 .. 2 */ |
| 42 | #define DC_NO 0 |
| 43 | #define DC_YES 1 |
| 44 | #define DC_MAYBE 2 |
| 45 | |
| 46 | |
| 47 | #define DC_MII_PRECEDING_TDESC_END (1<<0) |
| 48 | #define DC_MII_FOLLOWING_TDESC_START (1<<1) |
| 49 | |
| 50 | #define DC_MIO_ENTRY_POINT (1<< 0) |
| 51 | #define DC_MIO_PROLOGUE_END (1<< 1) |
| 52 | #define DC_MIO_EPILOGUE_START (1<< 2) |
| 53 | #define DC_MIO_IMPLICIT_PROLOGUE_END (1<<16) |
| 54 | #define DC_MIO_LITERAL_ENTRY_POINT (1<<17) |
| 55 | #define DC_MIO_LITERAL_EPILOGUE_START (1<<18) |
| 56 | |
| 57 | |
| 58 | /* |
| 59 | A word is 32 bits of information. In memory, a word is word-aligned. |
| 60 | |
| 61 | A common and important use of word_t is to represent values in the |
| 62 | target process, including (byte) addresses in the target process. |
| 63 | In this case, C arithmetic can be used to simulate machine address |
| 64 | arithmetic on the target. (Unsigned arithmetic is actually modulus |
| 65 | arithmetic.) |
| 66 | */ |
| 67 | typedef unsigned int dc_word_t; |
| 68 | |
| 69 | |
| 70 | /*----------------*/ |
| 71 | |
| 72 | |
| 73 | /* The exactness of locations may not be certainly known. */ |
| 74 | typedef dc_tristate_t dc_exactness_t; |
| 75 | |
| 76 | |
| 77 | /* |
| 78 | The model includes five kinds of contexts. Because each context |
| 79 | has an associated region and frame, these describe region kinds |
| 80 | and frame kinds as well. |
| 81 | [more description needed] |
| 82 | Currently, only call contexts exist. |
| 83 | */ |
| 84 | |
| 85 | typedef int dc_kind_t; /* range 0 .. 4 */ |
| 86 | #define DC_CALL_KIND 0 |
| 87 | #define DC_SAVE_KIND 1 |
| 88 | #define DC_EXCEPTION_KIND 2 |
| 89 | #define DC_PROTECTION_KIND 3 |
| 90 | #define DC_SPECIAL_KIND 4 |
| 91 | #define DC_NUM_KINDS 5 |
| 92 | |
| 93 | |
| 94 | typedef struct dc_debug_info { |
| 95 | unsigned int protocol; /* 1 for this structure */ |
| 96 | dc_word_t tdesc_ptr; |
| 97 | unsigned int text_words_count; |
| 98 | dc_word_t text_words_ptr; |
| 99 | unsigned int data_words_count; |
| 100 | dc_word_t data_words_ptr; |
| 101 | } dc_debug_info_t; |
| 102 | |
| 103 | |
| 104 | typedef struct dc_mstate { |
| 105 | dc_word_t reg[32]; /* general registers */ |
| 106 | dc_word_t xip; |
| 107 | dc_word_t nip; |
| 108 | dc_word_t fip; |
| 109 | dc_word_t fpsr; |
| 110 | dc_word_t fpcr; |
| 111 | dc_word_t psr; |
| 112 | } dc_mstate_t; |
| 113 | |
| 114 | |
| 115 | |
| 116 | #if 0 |
| 117 | |
| 118 | void error_fcn (env, continuable, message) |
| 119 | dc_word_t env; /* environment (arbitrary datum) */ |
| 120 | boolean_t continuable; /* whether error function may return */ |
| 121 | char *message; /* string (no trailing newline) */ |
| 122 | |
| 123 | /* In the future, we probably want the error_fcn to be: */ |
| 124 | void error_fcn (env, continuable, code, ...) |
| 125 | dc_word_t env; /* environment (arbitrary datum) */ |
| 126 | boolean_t continuable; /* whether error function may return */ |
| 127 | int code; /* error code */ |
| 128 | ... /* parameters to message associated |
| 129 | with the code */ |
| 130 | |
| 131 | void read_fcn (env, memory, length, buffer) |
| 132 | dc_word_t env; /* environment (arbitrary datum) */ |
| 133 | dc_word_t memory; /* start address in image */ |
| 134 | int length; /* in bytes */ |
| 135 | char *buffer; /* start address of buffer */ |
| 136 | /* There are no alignment assumptions for the read function. */ |
| 137 | |
| 138 | void write_fcn (env, memory, length, buffer) |
| 139 | dc_word_t env; /* environment (arbitrary datum) */ |
| 140 | dc_word_t memory; /* start address in image */ |
| 141 | int length; /* in bytes */ |
| 142 | char *buffer; /* start address of buffer */ |
| 143 | /* There are no alignment assumptions for the write function. */ |
| 144 | /* The write function is optional. It must be provided if changes |
| 145 | to writable registers are to be made. */ |
| 146 | |
| 147 | void exec_fcn (env, mstate) |
| 148 | dc_word_t env; /* environment (arbitrary datum) */ |
| 149 | dc_mstate_t *mstate; /* machine state (read-write) */ |
| 150 | /* The execute function is optional. It would be used (in the future) |
| 151 | by the implementation of a procedurally specified tdesc mechanism. */ |
| 152 | |
| 153 | #endif |
| 154 | |
| 155 | /*----------------*/ |
| 156 | |
| 157 | |
| 158 | typedef struct dc_map_info_in { |
| 159 | dc_word_t flags; |
| 160 | dc_word_t preceding_tdesc_end; |
| 161 | dc_word_t following_tdesc_start; |
| 162 | } dc_map_info_in_t; |
| 163 | |
| 164 | |
| 165 | typedef struct dc_map_info_out { |
| 166 | dc_word_t flags; |
| 167 | dc_word_t entry_point; |
| 168 | dc_word_t prologue_end; |
| 169 | dc_word_t epilogue_start; |
| 170 | } dc_map_info_out_t; |
| 171 | |
| 172 | |
| 173 | typedef void *dc_handle_t; |
| 174 | |
| 175 | typedef void (*tdesc_error_fcn_type) _ARGS(( |
| 176 | dc_word_t env, /* environment (arbitrary datum) */ |
| 177 | dc_boolean_t continuable, /* whether error function may return */ |
| 178 | const char *message /* string (no trailing newline) */ |
| 179 | )); |
| 180 | typedef void (*tdesc_io_fcn_type) _ARGS(( |
| 181 | dc_word_t env, /* environment (arbitrary datum) */ |
| 182 | dc_word_t memory, /* start address in image */ |
| 183 | int length, /* in bytes */ |
| 184 | void *buffer /* start address of buffer */ |
| 185 | )); |
| 186 | typedef void (*tdesc_exec_fcn_type) _ARGS(( |
| 187 | dc_word_t env, /* environment (arbitrary datum) */ |
| 188 | dc_mstate_t *mstate /* machine state (read-write) */ |
| 189 | )); |
| 190 | typedef void (*tdesc_map_fcn_type) _ARGS(( |
| 191 | dc_word_t map_env, |
| 192 | dc_word_t loc, |
| 193 | dc_map_info_in_t map_info_in, |
| 194 | dc_map_info_out_t *map_info_out |
| 195 | )); |
| 196 | |
| 197 | |
| 198 | extern dc_handle_t dc_initiate _ARGS(( |
| 199 | dc_word_t debug_info_ptr, |
| 200 | tdesc_error_fcn_type error_fcn, |
| 201 | dc_word_t error_env, |
| 202 | tdesc_io_fcn_type read_fcn, |
| 203 | dc_word_t read_env, |
| 204 | tdesc_io_fcn_type write_fcn, /* NULL => absent */ |
| 205 | dc_word_t write_env, |
| 206 | tdesc_exec_fcn_type exec_fcn, /* NULL => absent */ |
| 207 | dc_word_t exec_env, |
| 208 | tdesc_map_fcn_type map_fcn, /* NULL => absent */ |
| 209 | dc_word_t map_env |
| 210 | )); |
| 211 | extern void dc_terminate _ARGS(( |
| 212 | dc_handle_t handle |
| 213 | )); |
| 214 | |
| 215 | typedef int dc_register_state_t; /* range 0 to 2 */ |
| 216 | |
| 217 | #define DC_INVALID 0 |
| 218 | #define DC_READABLE 1 |
| 219 | #define DC_WRITABLE 2 |
| 220 | |
| 221 | #define DC_NUM_REG 32 |
| 222 | |
| 223 | #define DC_AUX_LOC 0 |
| 224 | #define DC_AUX_SXIP 1 |
| 225 | #define DC_AUX_SNIP 2 |
| 226 | #define DC_AUX_SFIP 3 |
| 227 | #define DC_AUX_FPSR 4 |
| 228 | #define DC_AUX_FPCR 5 |
| 229 | #define DC_NUM_AUX 6 |
| 230 | |
| 231 | |
| 232 | typedef void *dc_dcontext_t; |
| 233 | |
| 234 | extern dc_dcontext_t dc_make_dcontext _ARGS(( |
| 235 | dc_handle_t handle, |
| 236 | dc_word_t reg_info[DC_NUM_REG], |
| 237 | dc_word_t reg_flags[2], |
| 238 | dc_word_t aux_info[DC_NUM_AUX], |
| 239 | dc_word_t aux_flags[2], |
| 240 | dc_exactness_t loc_exact, |
| 241 | dc_word_t psr_info, |
| 242 | dc_boolean_t psr_ind, |
| 243 | dc_word_t psr_flags[2] |
| 244 | )); |
| 245 | extern void dc_free_dcontext _ARGS(( |
| 246 | dc_dcontext_t dcontext |
| 247 | )); |
| 248 | extern dc_register_state_t dc_location_state _ARGS(( |
| 249 | dc_dcontext_t dcontext |
| 250 | )); |
| 251 | extern dc_exactness_t dc_location_exactness _ARGS(( |
| 252 | dc_dcontext_t dcontext |
| 253 | )); |
| 254 | extern dc_word_t dc_location _ARGS(( |
| 255 | dc_dcontext_t dcontext |
| 256 | )); |
| 257 | extern void dc_set_location _ARGS(( |
| 258 | dc_dcontext_t dcontext, |
| 259 | dc_word_t value |
| 260 | )); |
| 261 | extern dc_register_state_t dc_general_register_state _ARGS(( |
| 262 | dc_dcontext_t dcontext, |
| 263 | int reg |
| 264 | )); |
| 265 | extern dc_word_t dc_general_register _ARGS(( |
| 266 | dc_dcontext_t dcontext, |
| 267 | int reg |
| 268 | )); |
| 269 | extern void dc_set_general_register _ARGS(( |
| 270 | dc_dcontext_t dcontext, |
| 271 | int reg, |
| 272 | dc_word_t value |
| 273 | )); |
| 274 | extern dc_register_state_t dc_auxiliary_register_state _ARGS(( |
| 275 | dc_dcontext_t dcontext, |
| 276 | int reg |
| 277 | )); |
| 278 | extern dc_word_t dc_auxiliary_register _ARGS(( |
| 279 | dc_dcontext_t dcontext, |
| 280 | int reg |
| 281 | )); |
| 282 | extern void dc_set_auxiliary_register _ARGS(( |
| 283 | dc_dcontext_t dcontext, |
| 284 | int reg, |
| 285 | dc_word_t value |
| 286 | )); |
| 287 | extern dc_register_state_t dc_psr_register_bit_state _ARGS(( |
| 288 | dc_dcontext_t dcontext, |
| 289 | int bit |
| 290 | )); |
| 291 | extern dc_word_t dc_psr_register _ARGS(( |
| 292 | dc_dcontext_t dcontext |
| 293 | )); |
| 294 | extern void dc_set_psr_register _ARGS(( |
| 295 | dc_dcontext_t dcontext, |
| 296 | dc_word_t mask, |
| 297 | dc_word_t value |
| 298 | )); |
| 299 | extern dc_word_t dc_frame_address _ARGS(( |
| 300 | dc_dcontext_t dcontext |
| 301 | )); |
| 302 | extern dc_kind_t dc_context_kind _ARGS(( |
| 303 | dc_dcontext_t dcontext |
| 304 | )); |
| 305 | extern dc_register_state_t dc_return_address_state _ARGS(( |
| 306 | dc_dcontext_t dcontext |
| 307 | )); |
| 308 | extern dc_exactness_t dc_return_address_exactness _ARGS(( |
| 309 | dc_dcontext_t dcontext |
| 310 | )); |
| 311 | extern dc_word_t dc_return_address _ARGS(( |
| 312 | dc_dcontext_t dcontext |
| 313 | )); |
| 314 | extern void dc_set_return_address _ARGS(( |
| 315 | dc_dcontext_t dcontext, |
| 316 | dc_word_t value |
| 317 | )); |
| 318 | extern void dc_get_exception_info(); |
| 319 | extern void dc_get_protection_info(); |
| 320 | extern void dc_get_special_info(); |
| 321 | extern dc_dcontext_t dc_previous_dcontext _ARGS(( |
| 322 | dc_dcontext_t dcontext |
| 323 | )); |
| 324 | extern dc_boolean_t dc_location_in_text_chunk _ARGS(( |
| 325 | dc_dcontext_t dcontext, |
| 326 | dc_word_t value |
| 327 | )); |
| 328 | |
| 329 | #endif |