| 1 | /* $Id: exceptstackdump.h,v 1.1 2000-05-02 20:53:12 sandervl Exp $ */ | 
|---|
| 2 | #ifndef __EXCEPTSTACKDUMP_H__ | 
|---|
| 3 | #define __EXCEPTSTACKDUMP_H__ | 
|---|
| 4 |  | 
|---|
| 5 | /* | 
|---|
| 6 | *      This file incorporates code from the following: | 
|---|
| 7 | *      -- Marc Fiammante, John Currier, Kim Rasmussen, | 
|---|
| 8 | *         Anthony Cruise (EXCEPT3.ZIP package for a generic | 
|---|
| 9 | *         exception handling DLL, available at Hobbes). | 
|---|
| 10 | * | 
|---|
| 11 | *      This file Copyright (C) 1992-99 Ulrich Mller, | 
|---|
| 12 | *                                      Kim Rasmussen, | 
|---|
| 13 | *                                      Marc Fiammante, | 
|---|
| 14 | *                                      John Currier, | 
|---|
| 15 | *                                      Anthony Cruise. | 
|---|
| 16 | *      This program is free software; you can redistribute it and/or modify | 
|---|
| 17 | *      it under the terms of the GNU General Public License as published by | 
|---|
| 18 | *      the Free Software Foundation, in version 2 as it comes in the COPYING | 
|---|
| 19 | *      file of the XFolder main distribution. | 
|---|
| 20 | *      This program is distributed in the hope that it will be useful, | 
|---|
| 21 | *      but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 22 | *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 23 | *      GNU General Public License for more details. | 
|---|
| 24 | */ | 
|---|
| 25 |  | 
|---|
| 26 | #ifndef DEBUG_HEADER_INCLUDED | 
|---|
| 27 | #define DEBUG_HEADER_INCLUDED | 
|---|
| 28 |  | 
|---|
| 29 | /******************************************************************** | 
|---|
| 30 | *                                                                  * | 
|---|
| 31 | *   SYM file declarations                                          * | 
|---|
| 32 | *                                                                  * | 
|---|
| 33 | ********************************************************************/ | 
|---|
| 34 |  | 
|---|
| 35 | // Pointer means offset from beginning of file or beginning of struct | 
|---|
| 36 | #pragma pack(1) | 
|---|
| 37 | typedef struct { | 
|---|
| 38 | unsigned short int ppNextMap;     // paragraph pointer to next map | 
|---|
| 39 | unsigned char      bFlags;        // symbol types | 
|---|
| 40 | unsigned char      bReserved1;    // reserved | 
|---|
| 41 | unsigned short int pSegEntry;     // segment entry point value | 
|---|
| 42 | unsigned short int cConsts;       // count of constants in map | 
|---|
| 43 | unsigned short int pConstDef;     // pointer to constant chain | 
|---|
| 44 | unsigned short int cSegs;         // count of segments in map | 
|---|
| 45 | unsigned short int ppSegDef;      // paragraph pointer to first segment | 
|---|
| 46 | unsigned char      cbMaxSym;      // maximum symbol-name length | 
|---|
| 47 | unsigned char      cbModName;     // length of module name | 
|---|
| 48 | char               achModName[1]; // cbModName Bytes of module-name member | 
|---|
| 49 | } MAPDEF; | 
|---|
| 50 |  | 
|---|
| 51 | typedef struct { | 
|---|
| 52 | unsigned short int ppNextMap;     // always zero | 
|---|
| 53 | unsigned char      release;       // release number (minor version number) | 
|---|
| 54 | unsigned char      version;       // major version number | 
|---|
| 55 | } LAST_MAPDEF; | 
|---|
| 56 |  | 
|---|
| 57 | typedef struct { | 
|---|
| 58 | unsigned short int ppNextSeg;     // paragraph pointer to next segment | 
|---|
| 59 | unsigned short int cSymbols;      // count of symbols in list | 
|---|
| 60 | unsigned short int pSymDef;       // offset of symbol chain | 
|---|
| 61 | unsigned short int wReserved1;    // reserved | 
|---|
| 62 | unsigned short int wReserved2;    // reserved | 
|---|
| 63 | unsigned short int wReserved3;    // reserved | 
|---|
| 64 | unsigned short int wReserved4;    // reserved | 
|---|
| 65 | unsigned char      bFlags;        // symbol types; bit 0 signals 32-bit (*UM) | 
|---|
| 66 | unsigned char      bReserved1;    // reserved | 
|---|
| 67 | unsigned short int ppLineDef;     // offset of line number record | 
|---|
| 68 | unsigned char      bReserved2;    // reserved | 
|---|
| 69 | unsigned char      bReserved3;    // reserved | 
|---|
| 70 | unsigned char      cbSegName;     // length of segment name | 
|---|
| 71 | char               achSegName[1]; /* cbSegName Bytes of segment-name member*/ | 
|---|
| 72 | } SEGDEF; | 
|---|
| 73 |  | 
|---|
| 74 | typedef struct { | 
|---|
| 75 | unsigned short int wSymVal;       // symbol address or constant | 
|---|
| 76 | unsigned char      cbSymName;     // length of symbol name | 
|---|
| 77 | char               achSymName[1]; // cbSymName Bytes of symbol-name member | 
|---|
| 78 | } SYMDEF16; | 
|---|
| 79 |  | 
|---|
| 80 | typedef struct { | 
|---|
| 81 | unsigned       int wSymVal;       // symbol address or constant | 
|---|
| 82 | unsigned char      cbSymName;     // length of symbol name | 
|---|
| 83 | char               achSymName[1]; // cbSymName Bytes of symbol-name member | 
|---|
| 84 | } SYMDEF32; | 
|---|
| 85 |  | 
|---|
| 86 | typedef struct { | 
|---|
| 87 | unsigned short int ppNextLine;    // ptr to next linedef (0 if last) | 
|---|
| 88 | unsigned short int wReserved1;    // reserved | 
|---|
| 89 | unsigned short int pLines;        // pointer to line numbers | 
|---|
| 90 | unsigned short int cLines;        // reserved | 
|---|
| 91 | unsigned char      cbFileName;    // length of filename | 
|---|
| 92 | char               achFileName[1];// cbFileName Bytes of filename | 
|---|
| 93 | } LINEDEF; | 
|---|
| 94 |  | 
|---|
| 95 | typedef struct { | 
|---|
| 96 | unsigned short int wCodeOffset;   // executable offset | 
|---|
| 97 | unsigned short int dwFileOffset;  // source offset | 
|---|
| 98 | } LINEINF; | 
|---|
| 99 |  | 
|---|
| 100 | #define SEGDEFOFFSET(MapDef)     (MapDef.ppSegDef*16) | 
|---|
| 101 | #define NEXTSEGDEFOFFSET(SegDef)  (SegDef.ppNextSeg*16) | 
|---|
| 102 |  | 
|---|
| 103 | #define ASYMPTROFFSET(SegDefOffset,Segdef) (SegDefOffset+SegDef.pSymDef) | 
|---|
| 104 | #define SYMDEFOFFSET(SegDefOffset,SegDef,n) (ASYMPTROFFSET(SegDefOffset,SegDef)+(n)*(sizeof(unsigned short int))) | 
|---|
| 105 |  | 
|---|
| 106 | #define ACONSTPTROFFSET(MapDef) (MapDef.ppConstDef) | 
|---|
| 107 | #define CONSTDEFOFFSET(MapDef,n) ((MapDef.ppConstDef)+(n)*(sizeof(unsigned short int))) | 
|---|
| 108 |  | 
|---|
| 109 | #define LINEDEFOFFSET(SegDef) (SegDef.ppLineDef*16) | 
|---|
| 110 | #define NEXTLINEDEFOFFSET(LineDef) (LineDef.ppNextLine*16) | 
|---|
| 111 | #define LINESOFFSET(LinedefOffset,LineDef) ((LinedefOffset)+LineDef.pLines) | 
|---|
| 112 |  | 
|---|
| 113 | /******************************************************************** | 
|---|
| 114 | *                                                                  * | 
|---|
| 115 | *   Object Module Format (OMF) declarations                        * | 
|---|
| 116 | *                                                                  * | 
|---|
| 117 | ********************************************************************/ | 
|---|
| 118 |  | 
|---|
| 119 | struct exehdr_rec { | 
|---|
| 120 | BYTE     signature[2];              // Must be "MZ" | 
|---|
| 121 | USHORT   image_len;                 // Image Length | 
|---|
| 122 | USHORT   pages;                     // Pages | 
|---|
| 123 | USHORT   reloc_items;               // Relocation table items | 
|---|
| 124 | USHORT   min_paragraphs;            // Mininum 16-bytes paragraphs | 
|---|
| 125 | USHORT   max_paragraphs;            // Maximum 16-bytes paragraphs | 
|---|
| 126 | USHORT   stack_pos;                 // Stack position | 
|---|
| 127 | USHORT   offset_in_sp;              // Offset in SP | 
|---|
| 128 | USHORT   checksum;                  // Checksum | 
|---|
| 129 | USHORT   offset_in_ip;              // Offset in IP | 
|---|
| 130 | USHORT   code_pos;                  // Code segment pos. | 
|---|
| 131 | USHORT   reloc_item_pos;            // Position of first relocation item | 
|---|
| 132 | USHORT   overlay_number;            // Overlay number | 
|---|
| 133 | BYTE     unused[8];                 // Unused bytes | 
|---|
| 134 | USHORT   oem_id;                    // OEM Identifier | 
|---|
| 135 | BYTE     oem_info[24];              // OEM Info | 
|---|
| 136 | ULONG    lexe_offset;               // Offset to linear header | 
|---|
| 137 | }; | 
|---|
| 138 |  | 
|---|
| 139 | struct lexehdr_rec { | 
|---|
| 140 | BYTE     signature[2];              // Must be "LX" | 
|---|
| 141 | BYTE     b_ord;                     // Byte ordering | 
|---|
| 142 | BYTE     w_ord;                     // Word ordering | 
|---|
| 143 | ULONG    format_level;              // Format level | 
|---|
| 144 | USHORT   cpu_type;                  // CPU Type | 
|---|
| 145 | USHORT   os_type;                   // Operating system | 
|---|
| 146 | ULONG    module_version;            // Module version | 
|---|
| 147 | ULONG    mod_flags;                 // Module flags | 
|---|
| 148 | ULONG    mod_pages;                 // Module pages | 
|---|
| 149 | ULONG    EIP_object;                // EIP Object no. | 
|---|
| 150 | ULONG    EIP;                       // EIP Value | 
|---|
| 151 | ULONG    ESP_object;                // ESP Object no | 
|---|
| 152 | ULONG    ESP;                       // ESP Value | 
|---|
| 153 | ULONG    page_size;                 // Page size | 
|---|
| 154 | ULONG    page_ofs_shift;            // Page offset shift | 
|---|
| 155 | ULONG    fixup_sect_size;           // Fixup section size | 
|---|
| 156 | ULONG    fixup_sect_checksum;       // Fixup section checksum | 
|---|
| 157 | ULONG    loader_sect_size;          // Loader section size | 
|---|
| 158 | ULONG    loader_sect_checksum;      // Loader section checksum | 
|---|
| 159 | ULONG    obj_table_ofs;             // Object table offset | 
|---|
| 160 | ULONG    obj_count;                 // Object count | 
|---|
| 161 | ULONG    obj_page_tab_ofs;          // Object page table offset | 
|---|
| 162 | ULONG    obj_iter_page_ofs;         // Object iteration pages offset | 
|---|
| 163 | ULONG    res_tab_ofs;               // Resource table offset | 
|---|
| 164 | ULONG    res_table_entries;         // Resource table entries | 
|---|
| 165 | ULONG    res_name_tab_ofs;          // Resident name table offset; | 
|---|
| 166 | ULONG    ent_tab_ofs;               // Entry table offset | 
|---|
| 167 | ULONG    mod_dir_ofs;               // Module directives offset | 
|---|
| 168 | ULONG    mod_dir_count;             // Number of module directives | 
|---|
| 169 | ULONG    fixup_page_tab_ofs;        // Fixup page table offset | 
|---|
| 170 | ULONG    fixup_rec_tab_ofs;         // Fixup record table offset | 
|---|
| 171 | ULONG    imp_tab_ofs;               // Import module table offset | 
|---|
| 172 | ULONG    imp_mod_entries;           // Import module entries | 
|---|
| 173 | ULONG    imp_proc_tab_ofs;          // Import proc table offset | 
|---|
| 174 | ULONG    per_page_check_ofs;        // Per page checksum offset | 
|---|
| 175 | ULONG    data_page_offset;          // Data pages offset | 
|---|
| 176 | ULONG    preload_page_count;        // Preload pages count | 
|---|
| 177 | ULONG    nonres_tab_ofs;            // Nonresident name table offset | 
|---|
| 178 | ULONG    nonres_tab_len;            // Nonresident name table len | 
|---|
| 179 | ULONG    nonres_tab_check;          // Nonresident tables checksum | 
|---|
| 180 | ULONG    auto_ds_objectno;          // Auto DS object number | 
|---|
| 181 | ULONG    debug_info_ofs;            // Debug info offset | 
|---|
| 182 | ULONG    debug_info_len;            // Debug info length | 
|---|
| 183 | ULONG    inst_preload_count;        // Instance preload count | 
|---|
| 184 | ULONG    inst_demand_count;         // Instance demand count | 
|---|
| 185 | ULONG    heapsize;                  // Heap size | 
|---|
| 186 | ULONG    stacksize;                 // Stack size | 
|---|
| 187 | }; | 
|---|
| 188 |  | 
|---|
| 189 | struct debug_head_rec { | 
|---|
| 190 | BYTE signature[3];                  // Debug signature | 
|---|
| 191 | BYTE type;                          // Debug info type | 
|---|
| 192 | }; | 
|---|
| 193 |  | 
|---|
| 194 | struct dir_inf_rec { | 
|---|
| 195 | USHORT   dirstruct_size;            // Size of directory structure | 
|---|
| 196 | USHORT   number_of_entries;         // Number of dnt_rec's in the array | 
|---|
| 197 | USHORT   unknown;                   // Unknown data | 
|---|
| 198 | // Followed by an array of dnt_rec structures | 
|---|
| 199 | }; | 
|---|
| 200 |  | 
|---|
| 201 | struct dnt_rec { | 
|---|
| 202 | USHORT   subsect_type;              // sst Subsection type | 
|---|
| 203 | USHORT   mod_index;                 // Module index (1-based) | 
|---|
| 204 | ULONG    offset;                    // Offset of start of section | 
|---|
| 205 | ULONG    size;                      // Size of section | 
|---|
| 206 | }; | 
|---|
| 207 |  | 
|---|
| 208 | // Modules subsection | 
|---|
| 209 | struct modules_rec { | 
|---|
| 210 | USHORT   code_seg_base;             // Code segment base | 
|---|
| 211 | ULONG    code_seg_offset;           // Code segment offset | 
|---|
| 212 | ULONG    code_seg_len;              // Code segment length | 
|---|
| 213 | USHORT   overlay_no;                // Overlay number | 
|---|
| 214 | USHORT   lib_idx;                   // Index into library section or 0 | 
|---|
| 215 | BYTE     segments;                  // Number of segments | 
|---|
| 216 | BYTE     reserved; | 
|---|
| 217 | BYTE     debug_style[2];            // "HL" for HLL, "CV" or 0 for CodeView | 
|---|
| 218 | BYTE     debug_version[2];          // 00 01 or 00 03 for HLL, 00 00 for CV | 
|---|
| 219 | BYTE     name_len;                  // Length of name (which follows) | 
|---|
| 220 | }; | 
|---|
| 221 |  | 
|---|
| 222 | // Publics subsection | 
|---|
| 223 | struct publics_rec { | 
|---|
| 224 | ULONG    offset;                    // Offset | 
|---|
| 225 | USHORT   segment;                   // Segment | 
|---|
| 226 | USHORT   type;                      // Type index | 
|---|
| 227 | BYTE     name_len;                  // Length of name (wich follows) | 
|---|
| 228 | }; | 
|---|
| 229 |  | 
|---|
| 230 | #if 0 | 
|---|
| 231 | // Linenumbers header | 
|---|
| 232 | struct linhead_rec { | 
|---|
| 233 | BYTE     id;                        // 0x95 for flat mem, 32 bit progs | 
|---|
| 234 | USHORT   length;                    // Record length | 
|---|
| 235 | USHORT   base_group;                // Base group | 
|---|
| 236 | USHORT   base_segment;              // Base segment | 
|---|
| 237 | }; | 
|---|
| 238 | #endif | 
|---|
| 239 |  | 
|---|
| 240 | // First linenumber record | 
|---|
| 241 | struct linfirst_rec { | 
|---|
| 242 | USHORT   lineno;                    // Line number (0) | 
|---|
| 243 | BYTE     entry_type;                // Entry type | 
|---|
| 244 | BYTE     reserved;                  // Reserved | 
|---|
| 245 | USHORT   entries_count;             // Number of table entries | 
|---|
| 246 | USHORT   segment_no;                // Segment number | 
|---|
| 247 | ULONG    filename_tabsize;          // File names table size | 
|---|
| 248 | }; | 
|---|
| 249 |  | 
|---|
| 250 |  | 
|---|
| 251 | // Source line numbers | 
|---|
| 252 | struct linsource_rec { | 
|---|
| 253 | USHORT   source_line;               // Source file line number | 
|---|
| 254 | USHORT   source_idx;                // Source file index | 
|---|
| 255 | ULONG    offset;                    // Offset into segment | 
|---|
| 256 | }; | 
|---|
| 257 |  | 
|---|
| 258 |  | 
|---|
| 259 | // Listing statement numbers | 
|---|
| 260 | struct linlist_rec { | 
|---|
| 261 | ULONG    list_line;                 // Listing file linenumber | 
|---|
| 262 | ULONG    statement;                 // Listing file statement number | 
|---|
| 263 | ULONG    offset;                    // Offset into segment | 
|---|
| 264 | }; | 
|---|
| 265 |  | 
|---|
| 266 |  | 
|---|
| 267 | // Source and Listing statement numbers | 
|---|
| 268 | struct linsourcelist_rec { | 
|---|
| 269 | USHORT   source_line;               // Source file line number | 
|---|
| 270 | USHORT   source_idx;                // Source file index | 
|---|
| 271 | ULONG    list_line;                 // Listing file linenumber | 
|---|
| 272 | ULONG    statement;                 // Listing file statement number | 
|---|
| 273 | ULONG    offset;                    // Offset into segment | 
|---|
| 274 | }; | 
|---|
| 275 |  | 
|---|
| 276 |  | 
|---|
| 277 | // Path table | 
|---|
| 278 | struct pathtab_rec { | 
|---|
| 279 | ULONG    offset;                    // Offset into segment | 
|---|
| 280 | USHORT   path_code;                 // Path code | 
|---|
| 281 | USHORT   source_idx;                // Source file index | 
|---|
| 282 | }; | 
|---|
| 283 |  | 
|---|
| 284 |  | 
|---|
| 285 | // File names table | 
|---|
| 286 | struct filenam_rec { | 
|---|
| 287 | ULONG    first_char;                // First displayable char in list file | 
|---|
| 288 | ULONG    disp_chars;                // Number of displayable chars in list line | 
|---|
| 289 | ULONG    filecount;                 // Number of source/listing files | 
|---|
| 290 | }; | 
|---|
| 291 |  | 
|---|
| 292 |  | 
|---|
| 293 | // Symbol types | 
|---|
| 294 | #define SYM_BEGIN          0x00        // Begin block | 
|---|
| 295 | #define SYM_PROC           0x01        // Function | 
|---|
| 296 | #define SYM_END            0x02        // End block of function | 
|---|
| 297 | #define SYM_AUTO           0x04        // Auto variable | 
|---|
| 298 | #define SYM_STATIC         0x05        // Static variable | 
|---|
| 299 | #define SYM_LABEL          0x0B        // Label | 
|---|
| 300 | #define SYM_WITH           0x0C        // With start symbol (not used) | 
|---|
| 301 | #define SYM_REG            0x0D        // Register variable | 
|---|
| 302 | #define SYM_CONST          0x0E        // Constant | 
|---|
| 303 | #define SYM_ENTRY          0x0F        // Secondary entry (not in C) | 
|---|
| 304 | #define SYM_SKIP           0x10        // For incremental linking (not used) | 
|---|
| 305 | #define SYM_CHANGESEG      0x11        // Change segment (#pragma alloc_text) | 
|---|
| 306 | #define SYM_TYPEDEF        0x12        // Typedef variable | 
|---|
| 307 | #define SYM_PUBLIC         0x13        // Public reference | 
|---|
| 308 | #define SYM_MEMBER         0x14        // Member of minor or major structure | 
|---|
| 309 | #define SYM_BASED          0x15        // Based variable | 
|---|
| 310 | #define SYM_TAG            0x16        // Tag in struct, union, enum ... | 
|---|
| 311 | #define SYM_TABLE          0x17        // Table (used in RPG - not C) | 
|---|
| 312 | #define SYM_MAP            0x18        // Map variable (extern in C) | 
|---|
| 313 | #define SYM_CLASS          0x19        // Class symbol (C++) | 
|---|
| 314 | #define SYM_MEMFUNC        0x1A        // Member function | 
|---|
| 315 | #define SYM_AUTOSCOPE      0x1B        // Scoped auto for C++ (not used) | 
|---|
| 316 | #define SYM_STATICSCOPE    0x1C        // scoped static for C++ (not used) | 
|---|
| 317 | #define SYM_CPPPROC        0x1D        // C++ Proc | 
|---|
| 318 | #define SYM_CPPSTAT        0x1E        // C++ Static var | 
|---|
| 319 | #define SYM_COMP           0x40        // Compiler information | 
|---|
| 320 |  | 
|---|
| 321 |  | 
|---|
| 322 | // Symbolic begin record | 
|---|
| 323 | struct symbegin_rec { | 
|---|
| 324 | ULONG    offset;                    // Segment offset | 
|---|
| 325 | ULONG    length;                    // Length of block | 
|---|
| 326 | BYTE     name_len;                  // Length of block name | 
|---|
| 327 | // Block name follows | 
|---|
| 328 | }; | 
|---|
| 329 |  | 
|---|
| 330 |  | 
|---|
| 331 | // Symbolic auto var record | 
|---|
| 332 | struct symauto_rec { | 
|---|
| 333 | ULONG    stack_offset;              // Stack offset | 
|---|
| 334 | USHORT   type_idx;                  // Type index | 
|---|
| 335 | BYTE     name_len;                  // Length of name | 
|---|
| 336 | // Var name follows | 
|---|
| 337 | }; | 
|---|
| 338 |  | 
|---|
| 339 |  | 
|---|
| 340 | // Symbolic procedure record | 
|---|
| 341 | struct symproc_rec { | 
|---|
| 342 | ULONG    offset;                    // Segment offset | 
|---|
| 343 | USHORT   type_idx;                  // Type index | 
|---|
| 344 | ULONG    length;                    // Length of procedure | 
|---|
| 345 | USHORT   pro_len;                   // Length of prologue | 
|---|
| 346 | ULONG    pro_bodylen;               // Length of prologue + body | 
|---|
| 347 | USHORT   class_type;                // Class type | 
|---|
| 348 | BYTE     near_far;                  // Near or far | 
|---|
| 349 | BYTE     name_len;                  // Length of name | 
|---|
| 350 | // Function name follows | 
|---|
| 351 | }; | 
|---|
| 352 |  | 
|---|
| 353 |  | 
|---|
| 354 | // Symbolic static var record | 
|---|
| 355 | struct symstatic_rec { | 
|---|
| 356 | ULONG    offset;                    // Segment offset | 
|---|
| 357 | USHORT   segaddr;                   // Segment address | 
|---|
| 358 | USHORT   type_idx;                  // Type index | 
|---|
| 359 | BYTE     name_len;                  // Length of name | 
|---|
| 360 | // Var name follows | 
|---|
| 361 | }; | 
|---|
| 362 |  | 
|---|
| 363 |  | 
|---|
| 364 | // Symbolic label var record | 
|---|
| 365 | struct symlabel_rec { | 
|---|
| 366 | ULONG    offset;                    // Segment offset | 
|---|
| 367 | BYTE     near_far;                  // Near or far | 
|---|
| 368 | BYTE     name_len;                  // Length of name | 
|---|
| 369 | // Var name follows | 
|---|
| 370 | }; | 
|---|
| 371 |  | 
|---|
| 372 | // Symbolic register var record | 
|---|
| 373 | struct symreg_rec { | 
|---|
| 374 | USHORT   type_idx;                  // Type index | 
|---|
| 375 | BYTE     reg_no;                    // Register number | 
|---|
| 376 | BYTE     name_len;                  // Length of name | 
|---|
| 377 | // Var name follows | 
|---|
| 378 | }; | 
|---|
| 379 |  | 
|---|
| 380 | // Symbolic change-segment record | 
|---|
| 381 | struct symseg_rec { | 
|---|
| 382 | USHORT   seg_no;                    // Segment number | 
|---|
| 383 | }; | 
|---|
| 384 |  | 
|---|
| 385 | // Symbolic typedef record | 
|---|
| 386 | struct symtypedef_rec { | 
|---|
| 387 | USHORT   type_idx;                  // Type index | 
|---|
| 388 | BYTE     name_len;                  // Length of name | 
|---|
| 389 | // Name follows | 
|---|
| 390 | }; | 
|---|
| 391 |  | 
|---|
| 392 | // Symbolic public record | 
|---|
| 393 | struct sympublic_rec { | 
|---|
| 394 | ULONG    offset;                    // Segment offset | 
|---|
| 395 | USHORT   segaddr;                   // Segment address | 
|---|
| 396 | USHORT   type_idx;                  // Type index | 
|---|
| 397 | BYTE     name_len;                  // Length of name | 
|---|
| 398 | // Name follows | 
|---|
| 399 | }; | 
|---|
| 400 |  | 
|---|
| 401 | // Symbolic member record | 
|---|
| 402 | struct symmember_rec { | 
|---|
| 403 | ULONG    offset;                    // Offset to subrecord | 
|---|
| 404 | BYTE     name_len;                  // Length of name | 
|---|
| 405 | // Name follows | 
|---|
| 406 | }; | 
|---|
| 407 |  | 
|---|
| 408 | // Symbolic based record | 
|---|
| 409 | struct symbased_rec { | 
|---|
| 410 | ULONG    offset;                    // Offset to subrecord | 
|---|
| 411 | USHORT   type_idx;                  // Type index | 
|---|
| 412 | BYTE     name_len;                  // Length of name | 
|---|
| 413 | // Name follows | 
|---|
| 414 | }; | 
|---|
| 415 |  | 
|---|
| 416 | // Symbolic tag record | 
|---|
| 417 | struct symtag_rec { | 
|---|
| 418 | USHORT   type_idx;                  // Type index | 
|---|
| 419 | BYTE     name_len;                  // Length of name | 
|---|
| 420 | // Name follows | 
|---|
| 421 | }; | 
|---|
| 422 |  | 
|---|
| 423 |  | 
|---|
| 424 | // Symbolic table record | 
|---|
| 425 | struct symtable_rec { | 
|---|
| 426 | ULONG    offset;                    // Segment offset | 
|---|
| 427 | USHORT   segaddr;                   // Segment address | 
|---|
| 428 | USHORT   type_idx;                  // Type index | 
|---|
| 429 | ULONG    idx_ofs;                   // Index offset to subrecord | 
|---|
| 430 | BYTE     name_len;                  // Length of name | 
|---|
| 431 | // Name follows | 
|---|
| 432 | }; | 
|---|
| 433 |  | 
|---|
| 434 |  | 
|---|
| 435 | // Type record | 
|---|
| 436 | struct type_rec { | 
|---|
| 437 | USHORT   length;                    // Length of sub-record | 
|---|
| 438 | BYTE     type;                      // Sub-record type | 
|---|
| 439 | BYTE     type_qual;                 // Type qualifier | 
|---|
| 440 | }; | 
|---|
| 441 |  | 
|---|
| 442 |  | 
|---|
| 443 |  | 
|---|
| 444 | // Types | 
|---|
| 445 | #define TYPE_CLASS         0x40        // Class | 
|---|
| 446 | #define TYPE_BASECLASS     0x41        // Base class | 
|---|
| 447 | #define TYPE_FRIEND        0x42        // Friend | 
|---|
| 448 | #define TYPE_CLASSDEF      0x43        // Class definition | 
|---|
| 449 | #define TYPE_MEMBERFUNC    0x45        // Member function | 
|---|
| 450 | #define TYPE_CLASSMEMBER   0x46        // Class member | 
|---|
| 451 | #define TYPE_REF           0x48        // Reference | 
|---|
| 452 | #define TYPE_MEMBERPTR     0x49        // Member pointer | 
|---|
| 453 | #define TYPE_SCALARS       0x51        // Scalars | 
|---|
| 454 | #define TYPE_SET           0x52        // Set | 
|---|
| 455 | #define TYPE_ENTRY         0x53        // Entry | 
|---|
| 456 | #define TYPE_FUNCTION      0x54        // Function | 
|---|
| 457 | #define TYPE_AREA          0x55        // Area | 
|---|
| 458 | #define TYPE_LOGICAL       0x56        // Logical | 
|---|
| 459 | #define TYPE_STACK         0x57        // Stack | 
|---|
| 460 | #define TYPE_MACRO         0x59        // Macro | 
|---|
| 461 | #define TYPE_BITSTRING     0x5C        // Bit string | 
|---|
| 462 | #define TYPE_USERDEF       0x5D        // User defined | 
|---|
| 463 | #define TYPE_CHARSTR       0x60        // Character string | 
|---|
| 464 | #define TYPE_PICTURE       0x61        // Picture | 
|---|
| 465 | #define TYPE_GRAPHIC       0x62        // Graphic | 
|---|
| 466 | #define TYPE_FORMATLAB     0x65        // Format label | 
|---|
| 467 | #define TYPE_FILE          0x67        // File | 
|---|
| 468 | #define TYPE_SUBRANGE      0x6F        // Subrange | 
|---|
| 469 | #define TYPE_CODELABEL     0x72        // Code label | 
|---|
| 470 | #define TYPE_PROCEDURE     0x75        // Procedure | 
|---|
| 471 | #define TYPE_ARRAY         0x78        // Array | 
|---|
| 472 | #define TYPE_STRUCT        0x79        // Structure / Union / Record | 
|---|
| 473 | #define TYPE_POINTER       0x7A        // Pointer | 
|---|
| 474 | #define TYPE_ENUM          0x7B        // Enum | 
|---|
| 475 | #define TYPE_LIST          0x7F        // List | 
|---|
| 476 |  | 
|---|
| 477 |  | 
|---|
| 478 | // Type userdef | 
|---|
| 479 | struct type_userdefrec { | 
|---|
| 480 | BYTE     FID_index;                 // Field ID | 
|---|
| 481 | USHORT   type_index;                // Type index | 
|---|
| 482 | BYTE     FID_string;                // String ID | 
|---|
| 483 | BYTE     name_len;                  // Length of name which follows | 
|---|
| 484 | }; | 
|---|
| 485 |  | 
|---|
| 486 |  | 
|---|
| 487 | // Type function | 
|---|
| 488 | struct type_funcrec { | 
|---|
| 489 | USHORT   params; | 
|---|
| 490 | USHORT   max_params; | 
|---|
| 491 | BYTE     FID_index;                 // Field ID | 
|---|
| 492 | USHORT   type_index;                // Type index of return value | 
|---|
| 493 | BYTE     FID_index1;                // String ID | 
|---|
| 494 | USHORT   typelist_index;            // Index of list of params | 
|---|
| 495 | }; | 
|---|
| 496 |  | 
|---|
| 497 |  | 
|---|
| 498 | // Type struct | 
|---|
| 499 | struct type_structrec { | 
|---|
| 500 | ULONG    size;                      // Size of structure | 
|---|
| 501 | USHORT   field_count;               // Number of fields in structure | 
|---|
| 502 | BYTE     FID_index;                 // Field ID | 
|---|
| 503 | USHORT   type_list_idx;             // Index to type list | 
|---|
| 504 | BYTE     FID_index1;                // Field ID | 
|---|
| 505 | USHORT   type_name_idx;             // Index to names / offsets | 
|---|
| 506 | BYTE     dont_know;                 // Haven't a clue, but it seems to be needed | 
|---|
| 507 | BYTE     name_len;                  // Length of structure name which follows | 
|---|
| 508 | }; | 
|---|
| 509 |  | 
|---|
| 510 | // Type list, type qualifier 1: contains types for structures | 
|---|
| 511 | // This record is repeated for the number of items in the structure definition | 
|---|
| 512 | struct type_list1 { | 
|---|
| 513 | BYTE     FID_index;                 // Field identifier for index | 
|---|
| 514 | USHORT   type_index;                // Type index. | 
|---|
| 515 | }; | 
|---|
| 516 |  | 
|---|
| 517 | // Type list, type qualifier 2: contains names and offsets for structure items | 
|---|
| 518 | // This record is repeated for the number of items in the structure definition | 
|---|
| 519 | struct type_list2 { | 
|---|
| 520 | BYTE     FID_string;                // String identifier | 
|---|
| 521 | BYTE     name_len;                  // Length of name which follows | 
|---|
| 522 | }; | 
|---|
| 523 |  | 
|---|
| 524 | // Type list, subrecord to the above, contains offset of variable in the structure | 
|---|
| 525 | struct type_list2_1 { | 
|---|
| 526 | BYTE     FID_span;                  // Defines what type of variable follows | 
|---|
| 527 | union { | 
|---|
| 528 | BYTE   b_len; | 
|---|
| 529 | USHORT s_len; | 
|---|
| 530 | ULONG  l_len; | 
|---|
| 531 | } u; | 
|---|
| 532 | }; | 
|---|
| 533 |  | 
|---|
| 534 | // Type pointer | 
|---|
| 535 | struct type_pointerrec { | 
|---|
| 536 | BYTE     FID_index;                 // Index identifier | 
|---|
| 537 | USHORT   type_index;                // Type index | 
|---|
| 538 | BYTE     FID_string;                // String identifier | 
|---|
| 539 | BYTE     name_len;                  // Length of name which follows | 
|---|
| 540 | }; | 
|---|
| 541 | #pragma pack() | 
|---|
| 542 |  | 
|---|
| 543 | /* | 
|---|
| 544 | * dbgPrintStack: | 
|---|
| 545 | *      this takes stack data from the TIB and | 
|---|
| 546 | *      context record data structures and tries | 
|---|
| 547 | *      to analyse what the different stack frames | 
|---|
| 548 | *      correspond to in the source files. | 
|---|
| 549 | *      This analysis is either tried upon debug | 
|---|
| 550 | *      code, if present, or otherwise from a | 
|---|
| 551 | *      .SYM file with the same filestem. | 
|---|
| 552 | * | 
|---|
| 553 | *      New with V0.84. | 
|---|
| 554 | * | 
|---|
| 555 | *      This is based on the EXCEPT3.ZIP package | 
|---|
| 556 | *      for the generic EXCEPTQ.DLL exception handler. | 
|---|
| 557 | *      Appently (W) 1995 or later John Currier. | 
|---|
| 558 | *      See the copyright notices on top of this file. | 
|---|
| 559 | */ | 
|---|
| 560 |  | 
|---|
| 561 |  | 
|---|
| 562 | void dbgPrintStack(PEXCEPTIONREPORTRECORD       pERepRec, | 
|---|
| 563 | PEXCEPTIONREGISTRATIONRECORD pERegRec, | 
|---|
| 564 | PCONTEXTRECORD               pCtxRec, | 
|---|
| 565 | PVOID                        p); | 
|---|
| 566 |  | 
|---|
| 567 | /* | 
|---|
| 568 | * DosQueryModFromEIP: | 
|---|
| 569 | *      we need to prototype this undocumented OS/2 API. | 
|---|
| 570 | *      Apparently, it doesn't have to be imported, but | 
|---|
| 571 | *      it's not in the header files. | 
|---|
| 572 | *      This is available on OS/2 2.1 and above. | 
|---|
| 573 | *      This function may be used to get a program module | 
|---|
| 574 | *      name, segment number and offset within the segment | 
|---|
| 575 | *      if you have an absolute address within the calling | 
|---|
| 576 | *      program. Very useful for exception handlers. | 
|---|
| 577 | */ | 
|---|
| 578 |  | 
|---|
| 579 |  | 
|---|
| 580 | extern "C" | 
|---|
| 581 | { | 
|---|
| 582 | APIRET APIENTRY DosQueryModFromEIP(HMODULE *phMod,   // out: trapping module | 
|---|
| 583 | ULONG *pulObjNum, // out: object/segment number | 
|---|
| 584 | ULONG ulBuffLen,  // in:  sizeof(*pszBuff) | 
|---|
| 585 | CHAR *pszBuff,    // out: module name | 
|---|
| 586 | ULONG *pulOffset, // out: offset in module | 
|---|
| 587 | ULONG ulAddress); // in:  address to be analyzed | 
|---|
| 588 |  | 
|---|
| 589 | APIRET APIENTRY DosQueryModFromEIP (PULONG pulModule, | 
|---|
| 590 | PULONG pulObject, | 
|---|
| 591 | ULONG  ulBufferLength, | 
|---|
| 592 | PSZ    pszBuffer, | 
|---|
| 593 | PULONG pulOffset, | 
|---|
| 594 | ULONG  ulEIP); | 
|---|
| 595 |  | 
|---|
| 596 | typedef ULONG  *_Seg16 PULONG16; | 
|---|
| 597 | APIRET16 APIENTRY16 DOS16SIZESEG(USHORT Seg, PULONG16 Size); | 
|---|
| 598 | typedef         APIRET16(APIENTRY16 _PFN16) (); | 
|---|
| 599 | ULONG APIENTRY  DosSelToFlat(ULONG); | 
|---|
| 600 |  | 
|---|
| 601 | APIRET16 APIENTRY16 DOSQPROCSTATUS(ULONG * _Seg16 pBuf, USHORT cbBuf); | 
|---|
| 602 |  | 
|---|
| 603 | #define CONVERT(fp,QSsel) MAKEP((QSsel),OFFSETOF(fp)) | 
|---|
| 604 | } | 
|---|
| 605 | #endif | 
|---|
| 606 |  | 
|---|
| 607 | #endif //__EXCEPTSTACKDUMP_H__ | 
|---|