- Timestamp:
- Nov 11, 2015 2:58:00 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/formats/codeview.h
r56291 r58662 35 35 * @{ 36 36 */ 37 38 39 /** 40 * CodeView Header. There are two of this, base header at the start of the debug 41 * information and a trailing header at the end. 42 */ 43 typedef struct RTCVHDR 44 { 45 /** The magic ('NBxx'), see RTCVHDR_MAGIC_XXX. */ 46 uint32_t u32Magic; 47 /** 48 * Base header: Subsection directory offset relative to this header (start). 49 * Trailing header: Offset of the base header relative to the end of the file. 50 * 51 * Called lfoBase, lfaBase, lfoDirectory, lfoDir and probably other things in 52 * the various specs/docs available. */ 53 uint32_t off; 54 } RTCVHDR; 55 /** Pointer to a CodeView header. */ 56 typedef RTCVHDR *PRTCVHDR; 57 58 /** @name CodeView magic values (RTCVHDR::u32Magic). 59 * @{ */ 60 /** CodeView from Visual C++ 5.0. Specified in the 2001 MSDN specs.chm file. */ 61 #define RTCVHDR_MAGIC_NB11 RT_MAKE_U32_FROM_U8('N', 'B', '1', '1') 62 /** External PDB reference (often referred to as PDB 2.0). */ 63 #define RTCVHDR_MAGIC_NB10 RT_MAKE_U32_FROM_U8('N', 'B', '1', '0') 64 /** CodeView v4.10, packed. Specified in the TIS document. */ 65 #define RTCVHDR_MAGIC_NB09 RT_MAKE_U32_FROM_U8('N', 'B', '0', '9') 66 /** CodeView v4.00 thru v4.05. Specified in the TIS document? */ 67 #define RTCVHDR_MAGIC_NB08 RT_MAKE_U32_FROM_U8('N', 'B', '0', '8') 68 /** Quick C for Windows 1.0 debug info. */ 69 #define RTCVHDR_MAGIC_NB07 RT_MAKE_U32_FROM_U8('N', 'B', '0', '7') 70 /** Emitted by ILINK indicating incremental link. Comparable to NB05? */ 71 #define RTCVHDR_MAGIC_NB06 RT_MAKE_U32_FROM_U8('N', 'B', '0', '6') 72 /** Emitted by LINK version 5.20 and later before packing. */ 73 #define RTCVHDR_MAGIC_NB05 RT_MAKE_U32_FROM_U8('N', 'B', '0', '5') 74 /** Emitted by IBM ILINK for HLL (similar to NB02 in many ways). */ 75 #define RTCVHDR_MAGIC_NB04 RT_MAKE_U32_FROM_U8('N', 'B', '0', '4') 76 /** Emitted by LINK version 5.10 (or similar OMF linkers), as shipped with 77 * Microsoft C v6.0 for example. More or less entirely 16-bit. */ 78 #define RTCVHDR_MAGIC_NB02 RT_MAKE_U32_FROM_U8('N', 'B', '0', '2') 79 /* No idea what NB03 might have been. */ 80 /** AIX debugger format according to "IBM OS/2 16/32-bit Object Module Format 81 * (OMF) and Linear eXecutable Module Format (LX)" revision 10 (LXOMF.PDF). */ 82 #define RTCVHDR_MAGIC_NB01 RT_MAKE_U32_FROM_U8('N', 'B', '0', '1') 83 /** Ancient CodeView format according to LXOMF.PDF. */ 84 #define RTCVHDR_MAGIC_NB00 RT_MAKE_U32_FROM_U8('N', 'B', '0', '0') 85 /** @} */ 86 87 88 /** @name CV directory headers. 89 * @{ */ 90 91 /** 92 * Really old CV directory header used with NB00 and NB02. 93 * 94 * Uses 16-bit directory entires (RTCVDIRENT16). 95 */ 96 typedef struct RTCVDIRHDR16 97 { 98 /** The number of directory entries. */ 99 uint16_t cEntries; 100 } RTCVDIRHDR16; 101 /** Pointer to a old CV directory header. */ 102 typedef RTCVDIRHDR16 *PRTCVDIRHDR16; 103 104 /** 105 * Simple 32-bit CV directory base header, used by NB04 (aka IBM HLL). 106 */ 107 typedef struct RTCVDIRHDR32 108 { 109 /** The number of bytes of this header structure. */ 110 uint16_t cbHdr; 111 /** The number of bytes per entry. */ 112 uint16_t cbEntry; 113 /** The number of directory entries. */ 114 uint32_t cEntries; 115 } RTCVDIRHDR32; 116 /** Pointer to a 32-bit CV directory header. */ 117 typedef RTCVDIRHDR32 *PRTCVDIRHDR32; 118 119 /** 120 * Extended 32-bit CV directory header as specified in the TIS doc. 121 * The two extra fields seems to never have been assigned any official purpose. 122 */ 123 typedef struct RTCVDIRHDR32EX 124 { 125 /** This starts the same way as the NB04 header. */ 126 RTCVDIRHDR32 Core; 127 /** Tentatively decleared as the offset to the next directory generated by 128 * the incremental linker. Haven't seen this used yet. */ 129 uint32_t offNextDir; 130 /** Flags, non defined apparently, so MBZ. */ 131 uint32_t fFlags; 132 } RTCVDIRHDR32EX; 133 /** Pointer to an extended 32-bit CV directory header. */ 134 typedef RTCVDIRHDR32EX *PRTCVDIRHDR32EX; 135 136 /** @} */ 137 138 139 /** 140 * 16-bit CV directory entry used with NB00 and NB02. 141 */ 142 typedef struct RTCVDIRENT16 143 { 144 /** Subsection type (RTCVSST). */ 145 uint16_t uSubSectType; 146 /** Which module (1-based, 0xffff is special). */ 147 uint16_t iMod; 148 /** The lowe offset of this subsection relative to the base CV header. */ 149 uint16_t offLow; 150 /** The high part of the subsection offset. */ 151 uint16_t offHigh; 152 /** The size of the subsection. */ 153 uint16_t cb; 154 } RTCVDIRENT16; 155 AssertCompileSize(RTCVDIRENT16, 10); 156 /** Pointer to a 16-bit CV directory entry. */ 157 typedef RTCVDIRENT16 *PRTCVDIRENT16; 158 159 160 /** 161 * 32-bit CV directory entry used starting with NB04. 162 */ 163 typedef struct RTCVDIRENT32 164 { 165 /** Subsection type (RTCVSST). */ 166 uint16_t uSubSectType; 167 /** Which module (1-based, 0xffff is special). */ 168 uint16_t iMod; 169 /** The offset of this subsection relative to the base CV header. */ 170 uint32_t off; 171 /** The size of the subsection. */ 172 uint32_t cb; 173 } RTCVDIRENT32; 174 AssertCompileSize(RTCVDIRENT32, 12); 175 /** Pointer to a 32-bit CV directory entry. */ 176 typedef RTCVDIRENT32 *PRTCVDIRENT32; 177 /** Pointer to a const 32-bit CV directory entry. */ 178 typedef RTCVDIRENT32 const *PCRTCVDIRENT32; 179 180 181 /** 182 * CodeView subsection types. 183 */ 184 typedef enum RTCVSST 185 { 186 /** @name NB00, NB02 and NB04 subsection types. 187 * The actual format of each subsection varies between NB04 and the others, 188 * and it may further vary in NB04 depending on the module type. 189 * @{ */ 190 kCvSst_OldModule = 0x101, 191 kCvSst_OldPublic, 192 kCvSst_OldTypes, 193 kCvSst_OldSymbols, 194 kCvSst_OldSrcLines, 195 kCvSst_OldLibraries, 196 kCvSst_OldImports, 197 kCvSst_OldCompacted, 198 kCvSst_OldSrcLnSeg = 0x109, 199 kCvSst_OldSrcLines3 = 0x10b, 200 /** @} */ 201 202 /** @name NB09, NB11 (and possibly NB05, NB06, NB07, and NB08) subsection types. 203 * @{ */ 204 kCvSst_Module = 0x120, 205 kCvSst_Types, 206 kCvSst_Public, 207 kCvSst_PublicSym, 208 kCvSst_Symbols, 209 kCvSst_AlignSym, 210 kCvSst_SrcLnSeg, 211 kCvSst_SrcModule, 212 kCvSst_Libraries, 213 kCvSst_GlobalSym, 214 kCvSst_GlobalPub, 215 kCvSst_GlobalTypes, 216 kCvSst_MPC, 217 kCvSst_SegMap, 218 kCvSst_SegName, 219 kCvSst_PreComp, 220 kCvSst_PreCompMap, 221 kCvSst_OffsetMap16, 222 kCvSst_OffsetMap32, 223 kCvSst_FileIndex = 0x133, 224 kCvSst_StaticSym 225 /** @} */ 226 } RTCVSST; 227 /** Pointer to a CV subsection type value. */ 228 typedef RTCVSST *PRTCVSST; 229 /** Pointer to a const CV subsection type value. */ 230 typedef RTCVSST const *PCRTCVSST; 231 232 233 /** 234 * CV4 module segment info. 235 */ 236 typedef struct RTCVMODSEGINFO32 237 { 238 /** The segment number. */ 239 uint16_t iSeg; 240 /** Explicit padding. */ 241 uint16_t u16Padding; 242 /** Offset into the segment. */ 243 uint32_t off; 244 /** The size of the contribution. */ 245 uint32_t cb; 246 } RTCVMODSEGINFO32; 247 typedef RTCVMODSEGINFO32 *PRTCVMODSEGINFO32; 248 typedef RTCVMODSEGINFO32 const *PCRTCVMODSEGINFO32; 249 250 251 /** 252 * CV4 segment map header. 253 */ 254 typedef struct RTCVSEGMAPHDR 255 { 256 /** Number of segments descriptors in the table. */ 257 uint16_t cSegs; 258 /** Number of logical segment descriptors. */ 259 uint16_t cLogSegs; 260 } RTCVSEGMAPHDR; 261 /** Pointer to a CV4 segment map header. */ 262 typedef RTCVSEGMAPHDR *PRTCVSEGMAPHDR; 263 /** Pointer to a const CV4 segment map header. */ 264 typedef RTCVSEGMAPHDR const *PCRTCVSEGMAPHDR; 265 266 /** 267 * CV4 Segment map descriptor entry. 268 */ 269 typedef struct RTCVSEGMAPDESC 270 { 271 /** Segment flags. */ 272 uint16_t fFlags; 273 /** The overlay number. */ 274 uint16_t iOverlay; 275 /** Group index into this segment descriptor array. 0 if not relevant. 276 * The group descriptors are found in the second half of the table. */ 277 uint16_t iGroup; 278 /** Complicated. */ 279 uint16_t iFrame; 280 /** Offset (byte) into the kCvSst_SegName table of the segment name, or 281 * 0xffff. */ 282 uint16_t offSegName; 283 /** Offset (byte) into the kCvSst_SegName table of the class name, or 0xffff. */ 284 uint16_t offClassName; 285 /** Offset into the physical segment. */ 286 uint32_t off; 287 /** Size of segment. */ 288 uint32_t cb; 289 } RTCVSEGMAPDESC; 290 /** Pointer to a segment map descriptor entry. */ 291 typedef RTCVSEGMAPDESC *PRTCVSEGMAPDESC; 292 /** Pointer to a const segment map descriptor entry. */ 293 typedef RTCVSEGMAPDESC const *PCRTCVSEGMAPDESC; 294 295 /** @name RTCVSEGMAPDESC_F_XXX - RTCVSEGMAPDESC::fFlags values. 296 * @{ */ 297 #define RTCVSEGMAPDESC_F_READ UINT16_C(0x0001) 298 #define RTCVSEGMAPDESC_F_WRITE UINT16_C(0x0002) 299 #define RTCVSEGMAPDESC_F_EXECUTE UINT16_C(0x0004) 300 #define RTCVSEGMAPDESC_F_32BIT UINT16_C(0x0008) 301 #define RTCVSEGMAPDESC_F_SEL UINT16_C(0x0100) 302 #define RTCVSEGMAPDESC_F_ABS UINT16_C(0x0200) 303 #define RTCVSEGMAPDESC_F_GROUP UINT16_C(0x1000) 304 #define RTCVSEGMAPDESC_F_RESERVED UINT16_C(0xecf0) 305 /** @} */ 306 307 /** 308 * CV4 segment map subsection. 309 */ 310 typedef struct RTCVSEGMAP 311 { 312 /** The header. */ 313 RTCVSEGMAPHDR Hdr; 314 /** Descriptor array. */ 315 RTCVSEGMAPDESC aDescs[1]; 316 } RTCVSEGMAP; 317 /** Pointer to a segment map subsection. */ 318 typedef RTCVSEGMAP *PRTCVSEGMAP; 319 /** Pointer to a const segment map subsection. */ 320 typedef RTCVSEGMAP const *PCRTCVSEGMAP; 321 322 323 /** 324 * Global symbol table header, used by kCvSst_GlobalSym and kCvSst_GlobalPub. 325 */ 326 typedef struct RTCVGLOBALSYMTABHDR 327 { 328 /** The symbol hash function. */ 329 uint16_t uSymHash; 330 /** The address hash function. */ 331 uint16_t uAddrHash; 332 /** The amount of symbol information following immediately after the header. */ 333 uint32_t cbSymbols; 334 /** The amount of symbol hash tables following the symbols. */ 335 uint32_t cbSymHash; 336 /** The amount of address hash tables following the symbol hash tables. */ 337 uint32_t cbAddrHash; 338 } RTCVGLOBALSYMTABHDR; 339 /** Pointer to a global symbol table header. */ 340 typedef RTCVGLOBALSYMTABHDR *PRTCVGLOBALSYMTABHDR; 341 /** Pointer to a const global symbol table header. */ 342 typedef RTCVGLOBALSYMTABHDR const *PCRTCVGLOBALSYMTABHDR; 343 344 345 typedef enum RTCVSYMTYPE 346 { 347 /** @name Symbols that doesn't change with compilation model or target machine. 348 * @{ */ 349 kCvSymType_Compile = 0x0001, 350 kCvSymType_Register, 351 kCvSymType_Constant, 352 kCvSymType_UDT, 353 kCvSymType_SSearch, 354 kCvSymType_End, 355 kCvSymType_Skip, 356 kCvSymType_CVReserve, 357 kCvSymType_ObjName, 358 kCvSymType_EndArg, 359 kCvSymType_CobolUDT, 360 kCvSymType_ManyReg, 361 kCvSymType_Return, 362 kCvSymType_EntryThis, 363 /** @} */ 364 365 /** @name Symbols with 16:16 addresses. 366 * @{ */ 367 kCvSymType_BpRel16 = 0x0100, 368 kCvSymType_LData16, 369 kCvSymType_GData16, 370 kCvSymType_Pub16, 371 kCvSymType_LProc16, 372 kCvSymType_GProc16, 373 kCvSymType_Thunk16, 374 kCvSymType_BLock16, 375 kCvSymType_With16, 376 kCvSymType_Label16, 377 kCvSymType_CExModel16, 378 kCvSymType_VftPath16, 379 kCvSymType_RegRel16, 380 /** @} */ 381 382 /** @name Symbols with 16:32 addresses. 383 * @{ */ 384 kCvSymType_BpRel32 = 0x0200, 385 kCvSymType_LData32, 386 kCvSymType_GData32, 387 kCvSymType_Pub32, 388 kCvSymType_LProc32, 389 kCvSymType_GProc32, 390 kCvSymType_Thunk32, 391 kCvSymType_Block32, 392 kCvSymType_With32, 393 kCvSymType_Label32, 394 kCvSymType_CExModel32, 395 kCvSymType_VftPath32, 396 kCvSymType_RegRel32, 397 kCvSymType_LThread32, 398 kCvSymType_GThread32, 399 /** @} */ 400 401 /** @name Symbols for MIPS. 402 * @{ */ 403 kCvSymType_LProcMips = 0x0300, 404 kCvSymType_GProcMips, 405 /** @} */ 406 407 /** @name Symbols for Microsoft CodeView. 408 * @{ */ 409 kCvSymType_ProcRef = 0x0400, 410 kCvSymType_DataRef, 411 kCvSymType_Align, 412 kCvSymType_LProcRef, 413 /** @} */ 414 415 /** @name Symbols with 32-bit address (I think) and 32-bit type indices. 416 * @{ */ 417 kCvSymType_V2_Register = 0x1001, 418 kCvSymType_V2_Constant, 419 kCvSymType_V2_Udt, 420 kCvSymType_V2_CobolUdt, 421 kCvSymType_V2_ManyReg, 422 kCvSymType_V2_BpRel, 423 kCvSymType_V2_LData, 424 kCvSymType_V2_GData, 425 kCvSymType_V2_Pub, 426 kCvSymType_V2_LProc, 427 kCvSymType_V2_GProc, 428 kCvSymType_V2_VftTable, 429 kCvSymType_V2_RegRel, 430 kCvSymType_V2_LThread, 431 kCvSymType_V2_GThread, 432 kCvSymType_V2_Unknown_1010, 433 kCvSymType_V2_Unknown_1011, 434 kCvSymType_V2_FrameInfo, 435 kCvSymType_V2_Compliand, 436 /** @} */ 437 438 /** @name Version 3 symbol types. 439 * @{ */ 440 /** Name of the object file, preceded by a 4-byte language type (ASM=0) */ 441 kCvSymType_V3_Compliand = 0x1101, 442 kCvSymType_V3_Thunk, 443 kCvSymType_V3_Block, 444 kCvSymType_V3_Unknown_1104, 445 kCvSymType_V3_Label, /**< RTCVSYMV3LABEL */ 446 kCvSymType_V3_Register, 447 kCvSymType_V3_Constant, 448 kCvSymType_V3_Udt, 449 kCvSymType_V3_Unknown_1109, 450 kCvSymType_V3_Unknown_110a, 451 kCvSymType_V3_BpRel, 452 kCvSymType_V3_LData, /**< RTCVSYMV3TYPEDNAME */ 453 kCvSymType_V3_GData, /**< RTCVSYMV3TYPEDNAME */ 454 kCvSymType_V3_Pub, 455 kCvSymType_V3_LProc, 456 kCvSymType_V3_GProc, 457 kCvSymType_V3_RegRel, 458 kCvSymType_V3_LThread, 459 kCvSymType_V3_GThread, 460 kCvSymType_V3_Unknown_1114, 461 kCvSymType_V3_Unknown_1115, 462 kCvSymType_V3_MSTool, /**< RTCVSYMV3MSTOOL */ 463 464 kCvSymType_V3_PubFunc1 = 0x1125, 465 kCvSymType_V3_PubFunc2 = 0x1127, 466 kCvSymType_V3_SectInfo = 0x1136, 467 kCvSymType_V3_SubSectInfo, 468 kCvSymType_V3_Entrypoint, 469 kCvSymType_V3_Unknown_1139, 470 kCvSymType_V3_SecuCookie, 471 kCvSymType_V3_Unknown_113b, 472 kCvSymType_V3_MsToolInfo, 473 kCvSymType_V3_MsToolEnv, 474 475 kCvSymType_VS2013_Local, 476 kCvSymType_VS2013_FpOff = 0x1144, 477 kCvSymType_VS2013_LProc32 = 0x1146, 478 kCvSymType_VS2013_GProc32, 479 /** @} */ 480 481 kCvSymType_EndOfValues 482 } RTCVSYMTYPE; 483 AssertCompile(kCvSymType_V3_Udt == 0x1108); 484 AssertCompile(kCvSymType_V3_GProc == 0x1110); 485 AssertCompile(kCvSymType_V3_MSTool == 0x1116); 486 AssertCompile(kCvSymType_VS2013_Local == 0x113E); 487 typedef RTCVSYMTYPE *PRTCVSYMTYPE; 488 typedef RTCVSYMTYPE const *PCRTCVSYMTYPE; 489 490 491 /** 492 * kCvSymType_V3_MSTool format. 493 */ 494 typedef struct RTCVSYMV3MSTOOL 495 { 496 /** Language or tool ID (3 == masm). */ 497 uint32_t uLanguage; 498 /** Target CPU (0xd0 == AMD64). */ 499 uint32_t uTargetCpu; 500 /** Flags. */ 501 uint32_t fFlags; 502 /** Version. */ 503 uint32_t uVersion; 504 /** The creator name, zero terminated. 505 * 506 * It is followed by key/value pairs of zero terminated strings giving more 507 * details about the current directory ('cwd'), compiler executable ('cl'), 508 * full command line ('cmd'), source path relative to cwd ('src'), the 509 * full program database path ('pdb'), and possibly others. Terminated by a 510 * pair of empty strings, usually. */ 511 char szCreator[1]; 512 } RTCVSYMV3MSTOOL; 513 typedef RTCVSYMV3MSTOOL *PRTCVSYMV3MSTOOL; 514 typedef RTCVSYMV3MSTOOL const *PCRTCVSYMV3MSTOOL; 515 516 /** 517 * kCvSymType_V3_Label format. 518 */ 519 typedef struct RTCVSYMV3LABEL 520 { 521 /** Offset into iSection of this symbol. */ 522 uint32_t offSection; 523 /** The index of the section where the symbol lives. */ 524 uint16_t iSection; 525 /** Flags or something. */ 526 uint8_t fFlags; 527 /** Zero terminated symbol name (variable length). */ 528 char szName[1]; 529 } RTCVSYMV3LABEL; 530 AssertCompileSize(RTCVSYMV3LABEL, 8); 531 typedef RTCVSYMV3LABEL *PRTCVSYMV3LABEL; 532 typedef RTCVSYMV3LABEL const *PCRTCVSYMV3LABEL; 533 534 /** 535 * kCvSymType_V3_LData and kCvSymType_V3_GData format. 536 */ 537 typedef struct RTCVSYMV3TYPEDNAME 538 { 539 /** The type ID. */ 540 uint32_t idType; 541 /** Offset into iSection of this symbol. */ 542 uint32_t offSection; 543 /** The index of the section where the symbol lives. */ 544 uint16_t iSection; 545 /** Zero terminated symbol name (variable length). */ 546 char szName[2]; 547 } RTCVSYMV3TYPEDNAME; 548 AssertCompileSize(RTCVSYMV3TYPEDNAME, 12); 549 typedef RTCVSYMV3TYPEDNAME *PRTCVSYMV3TYPEDNAME; 550 typedef RTCVSYMV3TYPEDNAME const *PCRTCVSYMV3TYPEDNAME; 551 552 /** 553 * kCvSymType_V3_LProc and kCvSymType_V3_GProc format. 554 */ 555 typedef struct RTCVSYMV3PROC 556 { 557 /** Lexical scope linking: Parent. */ 558 uint32_t uParent; 559 /** Lexical scope linking: End. */ 560 uint32_t uEnd; 561 /** Lexical scope linking: Next. */ 562 uint32_t uNext; 563 /** The procedure length. */ 564 uint32_t cbProc; 565 /** Offset into the procedure where the stack frame has been setup and is an 566 * excellent position for a function breakpoint. */ 567 uint32_t offDebugStart; 568 /** Offset into the procedure where the procedure is ready to return and has a 569 * return value (if applicable). */ 570 uint32_t offDebugEnd; 571 /** The type ID for the procedure. */ 572 uint32_t idType; 573 /** Offset into iSection of this procedure. */ 574 uint32_t offSection; 575 /** The index of the section where the procedure lives. */ 576 uint16_t iSection; 577 /** Flags. */ 578 uint8_t fFlags; 579 /** Zero terminated procedure name (variable length). */ 580 char szName[1]; 581 } RTCVSYMV3PROC; 582 AssertCompileSize(RTCVSYMV3PROC, 36); 583 typedef RTCVSYMV3PROC *PRTCVSYMV3PROC; 584 typedef RTCVSYMV3PROC const *PCRTCVSYMV3PROC; 585 586 587 /** @name $$SYMBOLS signatures. 588 * @{ */ 589 /** The $$SYMBOL table signature for CV4. */ 590 #define RTCVSYMBOLS_SIGNATURE_CV4 UINT32_C(0x00000001) 591 /** The $$SYMBOL table signature for CV8 (MSVC 8/2005). 592 * Also seen with MSVC 2010 using -Z7, so maybe more appropriate to call it 593 * CV7? */ 594 #define RTCVSYMBOLS_SIGNATURE_CV8 UINT32_C(0x00000004) 595 /** @} */ 596 597 598 /** 599 * CV8 $$SYMBOLS block header. 600 */ 601 typedef struct RTCV8SYMBOLSBLOCK 602 { 603 /** BLock type (RTCV8SYMBLOCK_TYPE_XXX). */ 604 uint32_t uType; 605 /** The block length, including this header? */ 606 uint32_t cb; 607 } RTCV8SYMBOLSBLOCK; 608 AssertCompileSize(RTCV8SYMBOLSBLOCK, 8); 609 typedef RTCV8SYMBOLSBLOCK *PRTCV8SYMBOLSBLOCK; 610 typedef RTCV8SYMBOLSBLOCK const *PCRTCV8SYMBOLSBLOCK; 611 612 /** @name RTCV8SYMBLOCK_TYPE_XXX - CV8 (MSVC 8/2005) $$SYMBOL table types. 613 * @{ */ 614 /** Symbol information. 615 * Sequence of types. Each type entry starts with a 16-bit length followed 616 * by a 16-bit RTCVSYMTYPE value. Just like CV4/5, but with C-strings 617 * instead of pascal. */ 618 #define RTCV8SYMBLOCK_TYPE_SYMBOLS UINT32_C(0x000000f1) 619 /** Line numbers for a section. */ 620 #define RTCV8SYMBLOCK_TYPE_SECT_LINES UINT32_C(0x000000f2) 621 /** Source file string table. 622 * The strings are null terminated. Indexed by RTCV8SYMBLOCK_TYPE_SRC_INFO. */ 623 #define RTCV8SYMBLOCK_TYPE_SRC_STR UINT32_C(0x000000f3) 624 /** Source file information. */ 625 #define RTCV8SYMBLOCK_TYPE_SRC_INFO UINT32_C(0x000000f4) 626 /** @} */ 627 628 /** 629 * Line number header found in a RTCV8SYMBLOCK_TYPE_SECT_LINES block. 630 * 631 * This is followed by a sequence of RTCV8LINESSRCMAP structures. 632 */ 633 typedef struct RTCV8LINESHDR 634 { 635 /** Offset into the section. */ 636 uint32_t offSection; 637 /** The section number. */ 638 uint16_t iSection; 639 /** Padding/zero/maybe-previous-member-is-a-32-bit-value. */ 640 uint16_t u16Padding; 641 /** Number of bytes covered by this table, starting at offSection. */ 642 uint32_t cbSectionCovered; 643 } RTCV8LINESHDR; 644 AssertCompileSize(RTCV8LINESHDR, 12); 645 typedef RTCV8LINESHDR *PRTCV8LINESHDR; 646 typedef RTCV8LINESHDR const *PCRTCV8LINESHDR; 647 648 /** 649 * CV8 (MSVC 8/2005) line number source map. 650 * 651 * This is followed by an array of RTCV8LINEPAIR. 652 */ 653 typedef struct RTCV8LINESSRCMAP 654 { 655 /** The source file name, given as an offset into the string table 656 * (RTCV8SYMBLOCK_TYPE_SRC_STR). */ 657 uint32_t offSourceName; 658 /** Number of line numbers following this structure. */ 659 uint32_t cLines; 660 /** The size of this source map. */ 661 uint32_t cb; 662 } RTCV8LINESSRCMAP; 663 AssertCompileSize(RTCV8LINESSRCMAP, 12); 664 typedef RTCV8LINESSRCMAP *PRTCV8LINESSRCMAP; 665 typedef RTCV8LINESSRCMAP const *PCRTCV8LINESSRCMAP; 666 667 /** 668 * One line number. 669 */ 670 typedef struct RTCV8LINEPAIR 671 { 672 /** Offset into the section of this line number. */ 673 uint32_t offSection; 674 /** The line number. */ 675 uint32_t uLineNumber : 30; 676 /** Indicates that it's not possible to set breakpoint? */ 677 uint32_t fEndOfStatement : 1; 678 } RTCV8LINEPAIR; 679 AssertCompileSize(RTCV8LINEPAIR, 8); 680 typedef RTCV8LINEPAIR *PRTCV8LINEPAIR; 681 typedef RTCV8LINEPAIR const *PCRTCV8LINEPAIR; 682 683 /** 684 * Source file information found in a RTCV8SYMBLOCK_TYPE_SRC_INFO block. 685 */ 686 typedef struct RTCV8SRCINFO 687 { 688 /** The source file name, given as an offset into the string table 689 * (RTCV8SYMBLOCK_TYPE_SRC_STR). */ 690 uint32_t offSourceName; 691 /** Digest/checksum type. */ 692 uint16_t uDigestType; 693 union 694 { 695 /** RTCV8SRCINFO_DIGEST_TYPE_MD5. */ 696 struct 697 { 698 /** The digest. */ 699 uint8_t ab[16]; 700 /** Structur alignment padding. */ 701 uint8_t abPadding[2]; 702 } md5; 703 /** RTCV8SRCINFO_DIGEST_TYPE_NONE: Padding. */ 704 uint8_t abNone[2]; 705 } Digest; 706 } RTCV8SRCINFO; 707 AssertCompileSize(RTCV8SRCINFO, 24); 708 typedef RTCV8SRCINFO *PRTCV8SRCINFO; 709 typedef RTCV8SRCINFO const *PCRTCV8SRCINFO; 710 711 /** @name RTCV8SRCINFO_DIGEST_TYPE_XXX - CV8 source digest types. 712 * Used by RTCV8SRCINFO::uDigestType. 713 * @{ */ 714 #define RTCV8SRCINFO_DIGEST_TYPE_NONE UINT16_C(0x0000) 715 #define RTCV8SRCINFO_DIGEST_TYPE_MD5 UINT16_C(0x0110) 716 /** @} */ 717 718 719 37 720 /** 38 721 * PDB v2.0 in image debug info. -
trunk/src/VBox/Runtime/common/dbg/dbgmodcodeview.cpp
r58171 r58662 63 63 #include "internal/magics.h" 64 64 65 #include <iprt/formats/codeview.h> 66 65 67 66 68 /********************************************************************************************************************************* 67 69 * Structures and Typedefs * 68 70 *********************************************************************************************************************************/ 69 /**70 * CodeView Header. There are two of this, base header at the start of the debug71 * information and a trailing header at the end.72 */73 typedef struct RTCVHDR74 {75 /** The magic ('NBxx'), see RTCVHDR_MAGIC_XXX. */76 uint32_t u32Magic;77 /**78 * Base header: Subsection directory offset relative to this header (start).79 * Trailing header: Offset of the base header relative to the end of the file.80 *81 * Called lfoBase, lfaBase, lfoDirectory, lfoDir and probably other things in82 * the various specs/docs available. */83 uint32_t off;84 } RTCVHDR;85 /** Pointer to a CodeView header. */86 typedef RTCVHDR *PRTCVHDR;87 88 /** @name CodeView magic values (RTCVHDR::u32Magic).89 * @{ */90 /** CodeView from Visual C++ 5.0. Specified in the 2001 MSDN specs.chm file. */91 #define RTCVHDR_MAGIC_NB11 RT_MAKE_U32_FROM_U8('N', 'B', '1', '1')92 /** External PDB reference (often referred to as PDB 2.0). */93 #define RTCVHDR_MAGIC_NB10 RT_MAKE_U32_FROM_U8('N', 'B', '1', '0')94 /** CodeView v4.10, packed. Specified in the TIS document. */95 #define RTCVHDR_MAGIC_NB09 RT_MAKE_U32_FROM_U8('N', 'B', '0', '9')96 /** CodeView v4.00 thru v4.05. Specified in the TIS document? */97 #define RTCVHDR_MAGIC_NB08 RT_MAKE_U32_FROM_U8('N', 'B', '0', '8')98 /** Quick C for Windows 1.0 debug info. */99 #define RTCVHDR_MAGIC_NB07 RT_MAKE_U32_FROM_U8('N', 'B', '0', '7')100 /** Emitted by ILINK indicating incremental link. Comparable to NB05? */101 #define RTCVHDR_MAGIC_NB06 RT_MAKE_U32_FROM_U8('N', 'B', '0', '6')102 /** Emitted by LINK version 5.20 and later before packing. */103 #define RTCVHDR_MAGIC_NB05 RT_MAKE_U32_FROM_U8('N', 'B', '0', '5')104 /** Emitted by IBM ILINK for HLL (similar to NB02 in many ways). */105 #define RTCVHDR_MAGIC_NB04 RT_MAKE_U32_FROM_U8('N', 'B', '0', '4')106 /** Emitted by LINK version 5.10 (or similar OMF linkers), as shipped with107 * Microsoft C v6.0 for example. More or less entirely 16-bit. */108 #define RTCVHDR_MAGIC_NB02 RT_MAKE_U32_FROM_U8('N', 'B', '0', '2')109 /* No idea what NB03 might have been. */110 /** AIX debugger format according to "IBM OS/2 16/32-bit Object Module Format111 * (OMF) and Linear eXecutable Module Format (LX)" revision 10 (LXOMF.PDF). */112 #define RTCVHDR_MAGIC_NB01 RT_MAKE_U32_FROM_U8('N', 'B', '0', '1')113 /** Ancient CodeView format according to LXOMF.PDF. */114 #define RTCVHDR_MAGIC_NB00 RT_MAKE_U32_FROM_U8('N', 'B', '0', '0')115 /** @} */116 117 118 /** @name CV directory headers.119 * @{ */120 121 /**122 * Really old CV directory header used with NB00 and NB02.123 *124 * Uses 16-bit directory entires (RTCVDIRENT16).125 */126 typedef struct RTCVDIRHDR16127 {128 /** The number of directory entries. */129 uint16_t cEntries;130 } RTCVDIRHDR16;131 /** Pointer to a old CV directory header. */132 typedef RTCVDIRHDR16 *PRTCVDIRHDR16;133 134 /**135 * Simple 32-bit CV directory base header, used by NB04 (aka IBM HLL).136 */137 typedef struct RTCVDIRHDR32138 {139 /** The number of bytes of this header structure. */140 uint16_t cbHdr;141 /** The number of bytes per entry. */142 uint16_t cbEntry;143 /** The number of directory entries. */144 uint32_t cEntries;145 } RTCVDIRHDR32;146 /** Pointer to a 32-bit CV directory header. */147 typedef RTCVDIRHDR32 *PRTCVDIRHDR32;148 149 /**150 * Extended 32-bit CV directory header as specified in the TIS doc.151 * The two extra fields seems to never have been assigned any official purpose.152 */153 typedef struct RTCVDIRHDR32EX154 {155 /** This starts the same way as the NB04 header. */156 RTCVDIRHDR32 Core;157 /** Tentatively decleared as the offset to the next directory generated by158 * the incremental linker. Haven't seen this used yet. */159 uint32_t offNextDir;160 /** Flags, non defined apparently, so MBZ. */161 uint32_t fFlags;162 } RTCVDIRHDR32EX;163 /** Pointer to an extended 32-bit CV directory header. */164 typedef RTCVDIRHDR32EX *PRTCVDIRHDR32EX;165 166 /** @} */167 168 169 /**170 * 16-bit CV directory entry used with NB00 and NB02.171 */172 typedef struct RTCVDIRENT16173 {174 /** Subsection type (RTCVSST). */175 uint16_t uSubSectType;176 /** Which module (1-based, 0xffff is special). */177 uint16_t iMod;178 /** The lowe offset of this subsection relative to the base CV header. */179 uint16_t offLow;180 /** The high part of the subsection offset. */181 uint16_t offHigh;182 /** The size of the subsection. */183 uint16_t cb;184 } RTCVDIRENT16;185 AssertCompileSize(RTCVDIRENT16, 10);186 /** Pointer to a 16-bit CV directory entry. */187 typedef RTCVDIRENT16 *PRTCVDIRENT16;188 189 190 /**191 * 32-bit CV directory entry used starting with NB04.192 */193 typedef struct RTCVDIRENT32194 {195 /** Subsection type (RTCVSST). */196 uint16_t uSubSectType;197 /** Which module (1-based, 0xffff is special). */198 uint16_t iMod;199 /** The offset of this subsection relative to the base CV header. */200 uint32_t off;201 /** The size of the subsection. */202 uint32_t cb;203 } RTCVDIRENT32;204 AssertCompileSize(RTCVDIRENT32, 12);205 /** Pointer to a 32-bit CV directory entry. */206 typedef RTCVDIRENT32 *PRTCVDIRENT32;207 /** Pointer to a const 32-bit CV directory entry. */208 typedef RTCVDIRENT32 const *PCRTCVDIRENT32;209 210 211 /**212 * CodeView subsection types.213 */214 typedef enum RTCVSST215 {216 /** @name NB00, NB02 and NB04 subsection types.217 * The actual format of each subsection varies between NB04 and the others,218 * and it may further vary in NB04 depending on the module type.219 * @{ */220 kCvSst_OldModule = 0x101,221 kCvSst_OldPublic,222 kCvSst_OldTypes,223 kCvSst_OldSymbols,224 kCvSst_OldSrcLines,225 kCvSst_OldLibraries,226 kCvSst_OldImports,227 kCvSst_OldCompacted,228 kCvSst_OldSrcLnSeg = 0x109,229 kCvSst_OldSrcLines3 = 0x10b,230 /** @} */231 232 /** @name NB09, NB11 (and possibly NB05, NB06, NB07, and NB08) subsection types.233 * @{ */234 kCvSst_Module = 0x120,235 kCvSst_Types,236 kCvSst_Public,237 kCvSst_PublicSym,238 kCvSst_Symbols,239 kCvSst_AlignSym,240 kCvSst_SrcLnSeg,241 kCvSst_SrcModule,242 kCvSst_Libraries,243 kCvSst_GlobalSym,244 kCvSst_GlobalPub,245 kCvSst_GlobalTypes,246 kCvSst_MPC,247 kCvSst_SegMap,248 kCvSst_SegName,249 kCvSst_PreComp,250 kCvSst_PreCompMap,251 kCvSst_OffsetMap16,252 kCvSst_OffsetMap32,253 kCvSst_FileIndex = 0x133,254 kCvSst_StaticSym255 /** @} */256 } RTCVSST;257 /** Pointer to a CV subsection type value. */258 typedef RTCVSST *PRTCVSST;259 /** Pointer to a const CV subsection type value. */260 typedef RTCVSST const *PCRTCVSST;261 262 263 /**264 * CV4 module segment info.265 */266 typedef struct RTCVMODSEGINFO32267 {268 /** The segment number. */269 uint16_t iSeg;270 /** Explicit padding. */271 uint16_t u16Padding;272 /** Offset into the segment. */273 uint32_t off;274 /** The size of the contribution. */275 uint32_t cb;276 } RTCVMODSEGINFO32;277 typedef RTCVMODSEGINFO32 *PRTCVMODSEGINFO32;278 typedef RTCVMODSEGINFO32 const *PCRTCVMODSEGINFO32;279 280 281 /**282 * CV4 segment map header.283 */284 typedef struct RTCVSEGMAPHDR285 {286 /** Number of segments descriptors in the table. */287 uint16_t cSegs;288 /** Number of logical segment descriptors. */289 uint16_t cLogSegs;290 } RTCVSEGMAPHDR;291 /** Pointer to a CV4 segment map header. */292 typedef RTCVSEGMAPHDR *PRTCVSEGMAPHDR;293 /** Pointer to a const CV4 segment map header. */294 typedef RTCVSEGMAPHDR const *PCRTCVSEGMAPHDR;295 296 /**297 * CV4 Segment map descriptor entry.298 */299 typedef struct RTCVSEGMAPDESC300 {301 /** Segment flags. */302 uint16_t fFlags;303 /** The overlay number. */304 uint16_t iOverlay;305 /** Group index into this segment descriptor array. 0 if not relevant.306 * The group descriptors are found in the second half of the table. */307 uint16_t iGroup;308 /** Complicated. */309 uint16_t iFrame;310 /** Offset (byte) into the kCvSst_SegName table of the segment name, or311 * 0xffff. */312 uint16_t offSegName;313 /** Offset (byte) into the kCvSst_SegName table of the class name, or 0xffff. */314 uint16_t offClassName;315 /** Offset into the physical segment. */316 uint32_t off;317 /** Size of segment. */318 uint32_t cb;319 } RTCVSEGMAPDESC;320 /** Pointer to a segment map descriptor entry. */321 typedef RTCVSEGMAPDESC *PRTCVSEGMAPDESC;322 /** Pointer to a const segment map descriptor entry. */323 typedef RTCVSEGMAPDESC const *PCRTCVSEGMAPDESC;324 325 /** @name RTCVSEGMAPDESC_F_XXX - RTCVSEGMAPDESC::fFlags values.326 * @{ */327 #define RTCVSEGMAPDESC_F_READ UINT16_C(0x0001)328 #define RTCVSEGMAPDESC_F_WRITE UINT16_C(0x0002)329 #define RTCVSEGMAPDESC_F_EXECUTE UINT16_C(0x0004)330 #define RTCVSEGMAPDESC_F_32BIT UINT16_C(0x0008)331 #define RTCVSEGMAPDESC_F_SEL UINT16_C(0x0100)332 #define RTCVSEGMAPDESC_F_ABS UINT16_C(0x0200)333 #define RTCVSEGMAPDESC_F_GROUP UINT16_C(0x1000)334 #define RTCVSEGMAPDESC_F_RESERVED UINT16_C(0xecf0)335 /** @} */336 337 /**338 * CV4 segment map subsection.339 */340 typedef struct RTCVSEGMAP341 {342 /** The header. */343 RTCVSEGMAPHDR Hdr;344 /** Descriptor array. */345 RTCVSEGMAPDESC aDescs[1];346 } RTCVSEGMAP;347 /** Pointer to a segment map subsection. */348 typedef RTCVSEGMAP *PRTCVSEGMAP;349 /** Pointer to a const segment map subsection. */350 typedef RTCVSEGMAP const *PCRTCVSEGMAP;351 352 353 /**354 * Global symbol table header, used by kCvSst_GlobalSym and kCvSst_GlobalPub.355 */356 typedef struct RTCVGLOBALSYMTABHDR357 {358 /** The symbol hash function. */359 uint16_t uSymHash;360 /** The address hash function. */361 uint16_t uAddrHash;362 /** The amount of symbol information following immediately after the header. */363 uint32_t cbSymbols;364 /** The amount of symbol hash tables following the symbols. */365 uint32_t cbSymHash;366 /** The amount of address hash tables following the symbol hash tables. */367 uint32_t cbAddrHash;368 } RTCVGLOBALSYMTABHDR;369 /** Pointer to a global symbol table header. */370 typedef RTCVGLOBALSYMTABHDR *PRTCVGLOBALSYMTABHDR;371 /** Pointer to a const global symbol table header. */372 typedef RTCVGLOBALSYMTABHDR const *PCRTCVGLOBALSYMTABHDR;373 374 375 typedef enum RTCVSYMTYPE376 {377 /** @name Symbols that doesn't change with compilation model or target machine.378 * @{ */379 kCvSymType_Compile = 0x0001,380 kCvSymType_Register,381 kCvSymType_Constant,382 kCvSymType_UDT,383 kCvSymType_SSearch,384 kCvSymType_End,385 kCvSymType_Skip,386 kCvSymType_CVReserve,387 kCvSymType_ObjName,388 kCvSymType_EndArg,389 kCvSymType_CobolUDT,390 kCvSymType_ManyReg,391 kCvSymType_Return,392 kCvSymType_EntryThis,393 /** @} */394 395 /** @name Symbols with 16:16 addresses.396 * @{ */397 kCvSymType_BpRel16 = 0x0100,398 kCvSymType_LData16,399 kCvSymType_GData16,400 kCvSymType_Pub16,401 kCvSymType_LProc16,402 kCvSymType_GProc16,403 kCvSymType_Thunk16,404 kCvSymType_BLock16,405 kCvSymType_With16,406 kCvSymType_Label16,407 kCvSymType_CExModel16,408 kCvSymType_VftPath16,409 kCvSymType_RegRel16,410 /** @} */411 412 /** @name Symbols with 16:32 addresses.413 * @{ */414 kCvSymType_BpRel32 = 0x0200,415 kCvSymType_LData32,416 kCvSymType_GData32,417 kCvSymType_Pub32,418 kCvSymType_LProc32,419 kCvSymType_GProc32,420 kCvSymType_Thunk32,421 kCvSymType_Block32,422 kCvSymType_With32,423 kCvSymType_Label32,424 kCvSymType_CExModel32,425 kCvSymType_VftPath32,426 kCvSymType_RegRel32,427 kCvSymType_LThread32,428 kCvSymType_GThread32,429 /** @} */430 431 /** @name Symbols for MIPS.432 * @{ */433 kCvSymType_LProcMips = 0x0300,434 kCvSymType_GProcMips,435 /** @} */436 437 /** @name Symbols for Microsoft CodeView.438 * @{ */439 kCvSymType_ProcRef,440 kCvSymType_DataRef,441 kCvSymType_Align442 /** @} */443 } RTCVSYMTYPE;444 typedef RTCVSYMTYPE *PRTCVSYMTYPE;445 typedef RTCVSYMTYPE const *PCRTCVSYMTYPE;446 447 448 /** The $$SYMBOL table signature for CV4. */449 #define RTCVSYMBOLS_SIGNATURE_CV4 UINT32_C(0x00000001)450 451 452 71 /** 453 72 * Directory sorting order. … … 587 206 Log(("RTDbgCv: Check failed on line %d: " #a_Expr "\n", __LINE__)); \ 588 207 Log(a_LogArgs); \ 589 /*return VERR_CV_BAD_FORMAT;*/ \ 208 /*AssertFailed();*/ \ 209 return VERR_CV_BAD_FORMAT; \ 590 210 } \ 591 211 } while (0) … … 598 218 { \ 599 219 Log(("RTDbgCv: Check failed on line %d: " #a_Expr "\n", __LINE__)); \ 600 /*return VERR_CV_BAD_FORMAT;*/ \ 220 /*AssertFailed();*/ \ 221 return VERR_CV_BAD_FORMAT; \ 601 222 } \ 602 223 } while (0) … … 709 330 710 331 /** 332 * Gets a name string for a symbol type. 333 * 334 * @returns symbol type name (read only). 335 * @param enmSymType The symbol type to name. 336 */ 337 static const char *rtDbgModCvSsSymTypeName(RTCVSYMTYPE enmSymType) 338 { 339 switch (enmSymType) 340 { 341 #define CASE_RET_STR(Name) case kCvSymType_##Name: return #Name; 342 CASE_RET_STR(Compile); 343 CASE_RET_STR(Register); 344 CASE_RET_STR(Constant); 345 CASE_RET_STR(UDT); 346 CASE_RET_STR(SSearch); 347 CASE_RET_STR(End); 348 CASE_RET_STR(Skip); 349 CASE_RET_STR(CVReserve); 350 CASE_RET_STR(ObjName); 351 CASE_RET_STR(EndArg); 352 CASE_RET_STR(CobolUDT); 353 CASE_RET_STR(ManyReg); 354 CASE_RET_STR(Return); 355 CASE_RET_STR(EntryThis); 356 CASE_RET_STR(BpRel16); 357 CASE_RET_STR(LData16); 358 CASE_RET_STR(GData16); 359 CASE_RET_STR(Pub16); 360 CASE_RET_STR(LProc16); 361 CASE_RET_STR(GProc16); 362 CASE_RET_STR(Thunk16); 363 CASE_RET_STR(BLock16); 364 CASE_RET_STR(With16); 365 CASE_RET_STR(Label16); 366 CASE_RET_STR(CExModel16); 367 CASE_RET_STR(VftPath16); 368 CASE_RET_STR(RegRel16); 369 CASE_RET_STR(BpRel32); 370 CASE_RET_STR(LData32); 371 CASE_RET_STR(GData32); 372 CASE_RET_STR(Pub32); 373 CASE_RET_STR(LProc32); 374 CASE_RET_STR(GProc32); 375 CASE_RET_STR(Thunk32); 376 CASE_RET_STR(Block32); 377 CASE_RET_STR(With32); 378 CASE_RET_STR(Label32); 379 CASE_RET_STR(CExModel32); 380 CASE_RET_STR(VftPath32); 381 CASE_RET_STR(RegRel32); 382 CASE_RET_STR(LThread32); 383 CASE_RET_STR(GThread32); 384 CASE_RET_STR(LProcMips); 385 CASE_RET_STR(GProcMips); 386 CASE_RET_STR(ProcRef); 387 CASE_RET_STR(DataRef); 388 CASE_RET_STR(Align); 389 CASE_RET_STR(LProcRef); 390 CASE_RET_STR(V2_Register); 391 CASE_RET_STR(V2_Constant); 392 CASE_RET_STR(V2_Udt); 393 CASE_RET_STR(V2_CobolUdt); 394 CASE_RET_STR(V2_ManyReg); 395 CASE_RET_STR(V2_BpRel); 396 CASE_RET_STR(V2_LData); 397 CASE_RET_STR(V2_GData); 398 CASE_RET_STR(V2_Pub); 399 CASE_RET_STR(V2_LProc); 400 CASE_RET_STR(V2_GProc); 401 CASE_RET_STR(V2_VftTable); 402 CASE_RET_STR(V2_RegRel); 403 CASE_RET_STR(V2_LThread); 404 CASE_RET_STR(V2_GThread); 405 CASE_RET_STR(V2_Unknown_1010); 406 CASE_RET_STR(V2_Unknown_1011); 407 CASE_RET_STR(V2_FrameInfo); 408 CASE_RET_STR(V2_Compliand); 409 CASE_RET_STR(V3_Compliand); 410 CASE_RET_STR(V3_Thunk); 411 CASE_RET_STR(V3_Block); 412 CASE_RET_STR(V3_Unknown_1104); 413 CASE_RET_STR(V3_Label); 414 CASE_RET_STR(V3_Register); 415 CASE_RET_STR(V3_Constant); 416 CASE_RET_STR(V3_Udt); 417 CASE_RET_STR(V3_Unknown_1109); 418 CASE_RET_STR(V3_Unknown_110a); 419 CASE_RET_STR(V3_BpRel); 420 CASE_RET_STR(V3_LData); 421 CASE_RET_STR(V3_GData); 422 CASE_RET_STR(V3_Pub); 423 CASE_RET_STR(V3_LProc); 424 CASE_RET_STR(V3_GProc); 425 CASE_RET_STR(V3_RegRel); 426 CASE_RET_STR(V3_LThread); 427 CASE_RET_STR(V3_GThread); 428 CASE_RET_STR(V3_Unknown_1114); 429 CASE_RET_STR(V3_Unknown_1115); 430 CASE_RET_STR(V3_MSTool); 431 CASE_RET_STR(V3_PubFunc1); 432 CASE_RET_STR(V3_PubFunc2); 433 CASE_RET_STR(V3_SectInfo); 434 CASE_RET_STR(V3_SubSectInfo); 435 CASE_RET_STR(V3_Entrypoint); 436 CASE_RET_STR(V3_Unknown_1139); 437 CASE_RET_STR(V3_SecuCookie); 438 CASE_RET_STR(V3_Unknown_113b); 439 CASE_RET_STR(V3_MsToolInfo); 440 CASE_RET_STR(V3_MsToolEnv); 441 CASE_RET_STR(VS2013_Local); 442 CASE_RET_STR(VS2013_FpOff); 443 CASE_RET_STR(VS2013_LProc32); 444 CASE_RET_STR(VS2013_GProc32); 445 #undef CASE_RET_STR 446 case kCvSymType_EndOfValues: break; 447 } 448 return "<unknown type>"; 449 } 450 451 452 453 /** 711 454 * Adds a symbol to the container. 712 455 * … … 718 461 * @param cchName The symbol name length. 719 462 * @param fFlags Flags reserved for future exploits, MBZ. 463 * @param cbSym Symbol size, 0 if not avaiable. 720 464 */ 721 465 static int rtDbgModCvAddSymbol(PRTDBGMODCV pThis, uint32_t iSeg, uint64_t off, const char *pchName, 722 uint 8_t cchName, uint32_t fFlags)466 uint32_t cchName, uint32_t fFlags, uint32_t cbSym) 723 467 { 724 468 const char *pszName = RTStrCacheEnterN(g_hDbgModStrCache, pchName, cchName); … … 783 527 } 784 528 785 int rc = RTDbgModSymbolAdd(pThis->hCnt, pszName, iSeg, off, 0, 0 /*fFlags*/, NULL);529 int rc = RTDbgModSymbolAdd(pThis->hCnt, pszName, iSeg, off, cbSym, 0 /*fFlags*/, NULL); 786 530 Log(("Symbol: %04x:%08x %.*s [%Rrc]\n", iSeg, off, cchName, pchName, rc)); 787 531 if (rc == VERR_DBG_ADDRESS_CONFLICT || rc == VERR_DBG_DUPLICATE_SYMBOL) … … 797 541 798 542 /** 543 * Validates the a zero terminated string. 544 * 545 * @returns String length if valid, UINT16_MAX if invalid. 546 * @param pszString The string to validate. 547 * @param pvRec The pointer to the record containing the string. 548 * @param cbRec The record length. 549 */ 550 static uint16_t rtDbgModCvValidateZeroString(const char *pszString, void const *pvRec, uint16_t cbRec) 551 { 552 size_t offStrMember = (uintptr_t)pszString - (uintptr_t)pvRec; 553 AssertReturn(offStrMember < _1K, UINT16_MAX); 554 AssertReturn(offStrMember <= cbRec, UINT16_MAX); 555 cbRec -= (uint16_t)offStrMember; 556 557 const char *pchEnd = RTStrEnd(pszString, cbRec); 558 AssertReturn(pchEnd, UINT16_MAX); 559 560 int rc = RTStrValidateEncoding(pszString); 561 AssertRCReturn(rc, UINT16_MAX); 562 563 return (uint16_t)(pchEnd - pszString); 564 } 565 566 567 /** 799 568 * Parses a CV4 symbol table, adding symbols to the container. 800 569 * … … 805 574 * @param fFlags Flags reserved for future exploits, MBZ. 806 575 */ 807 static int rtDbgModCvSsProcessV4 SymTab(PRTDBGMODCV pThis, void const *pvSymTab, size_t cbSymTab, uint32_t fFlags)576 static int rtDbgModCvSsProcessV4PlusSymTab(PRTDBGMODCV pThis, void const *pvSymTab, size_t cbSymTab, uint32_t fFlags) 808 577 { 809 578 int rc = VINF_SUCCESS; … … 819 588 uint16_t uSymType = *uCursor.pu16++; 820 589 821 Log3((" %p: uSymType=%#06x LB %#x\n", pbRecStart - (uint8_t *)pvSymTab, uSymType, cbRec)); 590 Log3((" %p: uSymType=%#06x LB %#x %s\n", 591 pbRecStart - (uint8_t *)pvSymTab, uSymType, cbRec, rtDbgModCvSsSymTypeName((RTCVSYMTYPE)uSymType))); 822 592 RTDBGMODCV_CHECK_RET_BF(cbRec >= 2 && cbRec <= cbSymTab, ("cbRec=%#x cbSymTab=%#x\n", cbRec, cbSymTab)); 823 593 … … 836 606 RTDBGMODCV_CHECK_NOMSG_RET_BF(cbRec >= 2 + 2+2+2+1 + cchName); 837 607 838 rc = rtDbgModCvAddSymbol(pThis, iSeg, off, uCursor.pch, cchName, 0 );608 rc = rtDbgModCvAddSymbol(pThis, iSeg, off, uCursor.pch, cchName, 0, 0); 839 609 break; 840 610 } … … 852 622 RTDBGMODCV_CHECK_NOMSG_RET_BF(cbRec >= 2 + 4+2+2+1 + cchName); 853 623 854 rc = rtDbgModCvAddSymbol(pThis, iSeg, off, uCursor.pch, cchName, 0 );624 rc = rtDbgModCvAddSymbol(pThis, iSeg, off, uCursor.pch, cchName, 0, 0); 855 625 break; 856 626 } 857 627 858 628 /** @todo add GProc and LProc so we can gather sizes as well as just symbols. */ 629 630 case kCvSymType_V3_LData: 631 case kCvSymType_V3_GData: 632 case kCvSymType_V3_Pub: 633 { 634 PCRTCVSYMV3LABEL pLabel = (PCRTCVSYMV3LABEL)uCursor.pv; 635 RTDBGMODCV_CHECK_NOMSG_RET_BF(cbRec >= sizeof(*pLabel)); 636 uint16_t cchName = rtDbgModCvValidateZeroString(pLabel->szName, pLabel, cbRec); 637 if (cchName != UINT16_MAX && cchName > 0) 638 rc = rtDbgModCvAddSymbol(pThis, pLabel->iSection, pLabel->offSection, pLabel->szName, cchName, 0, 0); 639 break; 640 } 641 642 case kCvSymType_V3_LProc: 643 case kCvSymType_V3_GProc: 644 { 645 PCRTCVSYMV3PROC pProc = (PCRTCVSYMV3PROC)uCursor.pv; 646 RTDBGMODCV_CHECK_NOMSG_RET_BF(cbRec >= sizeof(*pProc)); 647 uint16_t cchName = rtDbgModCvValidateZeroString(pProc->szName, pProc, cbRec); 648 if (cchName != UINT16_MAX && cchName > 0) 649 rc = rtDbgModCvAddSymbol(pThis, pProc->iSection, pProc->offSection, pProc->szName, cchName, 650 0, pProc->cbProc); 651 break; 652 } 653 859 654 } 860 655 } … … 864 659 uCursor.pu8 = pbRecStart + cbRec + 2; 865 660 cbSymTab -= cbRec + 2; 661 } 662 return rc; 663 } 664 665 666 /** 667 * Parses a CV8 symbol table, adding symbols to the container. 668 * 669 * @returns IPRT status code 670 * @param pThis The CodeView debug info reader instance. 671 * @param pvSymTab The symbol table. 672 * @param cbSymTab The size of the symbol table. 673 * @param fFlags Flags reserved for future exploits, MBZ. 674 */ 675 static int rtDbgModCvSsProcessV8SymTab(PRTDBGMODCV pThis, void const *pvSymTab, size_t cbSymTab, uint32_t fFlags) 676 { 677 int rc = VINF_SUCCESS; 678 RTCPTRUNION uCursor; 679 uCursor.pv = pvSymTab; 680 681 for (;;) 682 { 683 RTDBGMODCV_CHECK_RET_BF(cbSymTab > sizeof(RTCV8SYMBOLSBLOCK), ("cbSymTab=%zu\n", cbSymTab)); 684 PCRTCV8SYMBOLSBLOCK pBlockHdr = (PCRTCV8SYMBOLSBLOCK)uCursor.pv; 685 Log3((" %p: uType=%#04x LB %#x\n", (uint8_t *)pBlockHdr - (uint8_t *)pvSymTab, pBlockHdr->uType, pBlockHdr->cb)); 686 RTDBGMODCV_CHECK_RET_BF(pBlockHdr->cb <= cbSymTab - sizeof(RTCV8SYMBOLSBLOCK), 687 ("cb=%#u cbSymTab=%zu\n", pBlockHdr->cb, cbSymTab)); 688 689 switch (pBlockHdr->uType) 690 { 691 case RTCV8SYMBLOCK_TYPE_SYMBOLS: 692 rc = rtDbgModCvSsProcessV4PlusSymTab(pThis, pBlockHdr + 1, pBlockHdr->cb, fFlags); 693 break; 694 695 case RTCV8SYMBLOCK_TYPE_SRC_STR: 696 /** @todo would have to cache the string table as the line numbers using it 697 * may be in a different .debug$S section and wlinking will therefore 698 * issue two sstSymbols entries for the module. */ 699 break; 700 701 case RTCV8SYMBLOCK_TYPE_SECT_LINES: 702 break; 703 704 case RTCV8SYMBLOCK_TYPE_SRC_INFO: 705 /* Not something we currently care about. Could be useful later 706 for checking if a source file has changed. */ 707 break; 708 default: 709 Log(("rtDbgModCvSsProcessV8SymTab: Unknown block type %#x (LB %#x)\n", pBlockHdr->uType, pBlockHdr->cb)); 710 break; 711 } 712 uint32_t cbAligned = RT_ALIGN_32(sizeof(*pBlockHdr) + pBlockHdr->cb, 4); 713 if (RT_SUCCESS(rc) && cbSymTab > cbAligned) 714 { 715 uCursor.pu8 += cbAligned; 716 cbSymTab -= cbAligned; 717 } 718 else 719 break; 866 720 } 867 721 return rc; … … 893 747 * Parse the symbols. 894 748 */ 895 return rtDbgModCvSsProcessV4 SymTab(pThis, pHdr + 1, pHdr->cbSymbols, 0);749 return rtDbgModCvSsProcessV4PlusSymTab(pThis, pHdr + 1, pHdr->cbSymbols, 0); 896 750 } 897 751 … … 938 792 939 793 uint32_t u32Signature = *(uint32_t const *)pvSubSect; 940 RTDBGMODCV_CHECK_RET_BF(u32Signature == RTCVSYMBOLS_SIGNATURE_CV4 ,794 RTDBGMODCV_CHECK_RET_BF(u32Signature == RTCVSYMBOLS_SIGNATURE_CV4 || u32Signature == RTCVSYMBOLS_SIGNATURE_CV8, 941 795 ("%#x, expected %#x\n", u32Signature, RTCVSYMBOLS_SIGNATURE_CV4)); 942 943 return rtDbgModCvSsProcessV4SymTab(pThis, (uint8_t const *)pvSubSect + 4, cbSubSect - 4, 0); 796 if (u32Signature == RTCVSYMBOLS_SIGNATURE_CV8) 797 return rtDbgModCvSsProcessV8SymTab(pThis, (uint8_t const *)pvSubSect + 4, cbSubSect - 4, 0); 798 return rtDbgModCvSsProcessV4PlusSymTab(pThis, (uint8_t const *)pvSubSect + 4, cbSubSect - 4, 0); 944 799 } 945 800 … … 1552 1407 { 1553 1408 PCRTCVDIRENT32 pDirEnt = &pThis->paDirEnts[i]; 1554 if (pDirEnt->iMod > iMod) 1409 if ( pDirEnt->iMod > iMod 1410 || pDirEnt->iMod == iMod) /* wlink subjected to MSVC 2010 /Z7 files with multiple .debug$S. */ 1555 1411 { 1556 1412 if (pDirEnt->uSubSectType != uSst) -
trunk/src/VBox/Runtime/tools/RTLdrFlt.cpp
r56978 r58662 292 292 { 293 293 if (aMappings[iMapping].iSeg == NIL_RTDBGSEGIDX) 294 { 294 295 RTPrintf(" mapping #%u: %RTptr-%RTptr\n", 295 296 iMapping, 296 297 aMappings[iMapping].Address, 297 298 aMappings[iMapping].Address + RTDbgModImageSize(hDbgMod) - 1); 299 if (cVerbosityLevel > 2) 300 { 301 uint32_t cSegments = RTDbgModSegmentCount(hDbgMod); 302 for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++) 303 { 304 RTDBGSEGMENT SegInfo; 305 rc = RTDbgModSegmentByIndex(hDbgMod, iSeg, &SegInfo); 306 if (RT_SUCCESS(rc)) 307 RTPrintf(" seg #%u: %RTptr LB %RTptr '%s'\n", 308 iSeg, SegInfo.uRva, SegInfo.cb, SegInfo.szName); 309 else 310 RTPrintf(" seg #%u: %Rrc\n", iSeg, rc); 311 } 312 } 313 } 298 314 else 299 315 { … … 301 317 rc = RTDbgModSegmentByIndex(hDbgMod, aMappings[iMapping].iSeg, &SegInfo); 302 318 if (RT_SUCCESS(rc)) 303 RTPrintf(" mapping #%u: %RTptr-%RTptr (segment #%u - '%s') ",319 RTPrintf(" mapping #%u: %RTptr-%RTptr (segment #%u - '%s')\n", 304 320 iMapping, 305 321 aMappings[iMapping].Address, … … 307 323 SegInfo.iSeg, SegInfo.szName); 308 324 else 309 RTPrintf(" mapping #%u: %RTptr-???????? (segment #%u) ",310 iMapping, aMappings[iMapping].Address, aMappings[iMapping].iSeg );325 RTPrintf(" mapping #%u: %RTptr-???????? (segment #%u) rc=%Rrc\n", 326 iMapping, aMappings[iMapping].Address, aMappings[iMapping].iSeg, rc); 311 327 } 312 328 … … 320 336 rc = RTDbgModSymbolByOrdinal(hDbgMod, iSymbol, &SymInfo); 321 337 if (RT_SUCCESS(rc)) 322 RTPrintf(" #%04u at %08x:%RTptr %05llx %s\n",323 SymInfo.iOrdinal, SymInfo.iSeg, SymInfo.offSeg, 338 RTPrintf(" #%04u at %08x:%RTptr (%RTptr) %05llx %s\n", 339 SymInfo.iOrdinal, SymInfo.iSeg, SymInfo.offSeg, SymInfo.Value, 324 340 (uint64_t)SymInfo.cb, SymInfo.szName); 325 341 }
Note:
See TracChangeset
for help on using the changeset viewer.