Changeset 3239 for trunk/tools
- Timestamp:
- Mar 26, 2000, 4:16:19 PM (26 years ago)
- Location:
- trunk/tools/dbginfo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/dbginfo/kHll.cpp
r3238 r3239 1 /* $Id: kHll.cpp,v 1. 2 2000-03-25 23:50:11bird Exp $1 /* $Id: kHll.cpp,v 1.3 2000-03-26 14:16:18 bird Exp $ 2 2 * 3 3 * kHll - Implementation of the class kHll. … … 32 32 #include <string.h> 33 33 #include <stddef.h> 34 #include <stdlib.h> 34 35 #include <assert.h> 35 36 … … 40 41 41 42 42 kHLLPubSym::kHLLPubSym( 43 44 45 46 /******************************************************************************* 47 * * 48 * kHllBaseEntry * 49 * * 50 * kHllBaseEntry * 51 * * 52 *******************************************************************************/ 53 54 55 /** 56 * Writes a list to disk. 57 * @returns Number of bytes written. 58 * @returns Count of bytes written on success. (includes 0) 59 * -3 Invalid offsets. 60 * -2 Seek error. 61 * -1 Write error. 62 * @param phFile Output filehandle. 63 * @param pEntry Pointer to the start of the list which is to be written. 64 */ 65 int kHllBaseEntry::writeList(FILE *phFile, kHllBaseEntry *pEntry) 66 { 67 int cch; 68 int cchWritten = 0; 69 70 /* 71 * Loop thru the list and write all the entries to disk. 72 */ 73 while (pEntry != NULL) 74 { 75 cchWritten += cch = pEntry->write(phFile); 76 if (cch < 0) 77 return cch; 78 if (cch == 0) 79 return -1; 80 pEntry = (kHllBaseEntry*)pEntry->getNext(); 81 } 82 83 return cchWritten; 84 } 85 86 87 88 89 90 91 /******************************************************************************* 92 * * 93 * kHllPubSymEntry * 94 * * 95 * kHllPubSymEntry * 96 * * 97 *******************************************************************************/ 98 99 100 101 /** 102 * Creates an HLL public symbol entry. 103 * @param pszName Symbol name. 104 * @param off Offset into the object. 105 * @param iObj LX Object index. 106 * @param iType Type index. (index into type table) 107 */ 108 kHllPubSymEntry::kHllPubSymEntry( 43 109 const char * pszName, 44 110 unsigned long off, 45 111 unsigned short iObj, 46 112 unsigned short iType 47 ); 48 49 50 kHLLPubSym::~kHLLPubSym(); 51 52 53 int kHLLPubSym::write(FILE *phFile) 54 { 55 56 } 57 58 59 60 61 62 63 64 65 66 67 68 69 /** 70 * Constructor - Creates an empty HLL object. 71 */ 72 kHll::kHll() 73 { 74 } 113 ) 114 { 115 pPubSym = (PHLLPUBLICSYM)malloc(strlen(pszName) + sizeof(HLLPUBLICSYM)); 116 assert(pPubSym != NULL); 117 118 pPubSym->cchName = strlen(pszName); 119 strcpy((char*)&pPubSym->achName[0], pszName); 120 pPubSym->off = off; 121 pPubSym->iObj = iObj; 122 pPubSym->iType = iType; 123 } 124 75 125 76 126 … … 78 128 * Destructor. 79 129 */ 80 kHll::~kHll() 81 { 82 } 83 84 85 /** 86 * Adds an LX object to the HLL info. 87 * @returns Object handle. NULL on error. 88 * @param pszName Object name. 89 * @param cb Size of object. 90 */ 91 const void * kHll::addObject( 92 const char * pszName, 93 unsigned long int cb 130 kHllPubSymEntry::~kHllPubSymEntry() 131 { 132 if (pPubSym != NULL) 133 free(pPubSym); 134 pPubSym = NULL; 135 } 136 137 138 139 /** 140 * Write this entry to file. 141 * @returns Number of bytes written. 142 * @param phFile File handle. 143 */ 144 int kHllPubSymEntry::write(FILE *phFile) 145 { 146 assert(pPubSym != NULL); 147 return fwrite(pPubSym, 148 1, 149 offsetof(HLLPUBLICSYM, achName) + pPubSym->cchName, 150 phFile); 151 } 152 153 154 155 156 157 /******************************************************************************* 158 * * 159 * kHllModuleEntry * 160 * * 161 * kHllModuleEntry * 162 * * 163 *******************************************************************************/ 164 165 166 167 168 169 170 171 /** 172 * Creates an HLL module entry. 173 * @param pszName Module name. (NULL is not allowed!) 174 * @param iLib Library index. 175 * @param cObjects Number of objects in the array. 176 * @param paObjects Pointer to an array of objects. 177 */ 178 kHllModuleEntry::kHllModuleEntry( 179 const char * pszName, 180 unsigned short iLib, 181 unsigned char cObjects/*= 0 */, 182 PMODOBJECT paObjects/*= NULL */ 183 ) 184 : fValidOffsetsAndSizes(FALSE) 185 { 186 int i; 187 int cchName; 188 PHLLOBJECT pObj; 189 190 /* 191 * Debug parameter validations. 192 */ 193 assert(pszName != NULL); 194 assert(cObjects == 0 || paObjects != NULL); 195 196 /* 197 * Allocate data storage and fill HLL structure. 198 */ 199 cchName = strlen(pszName); 200 pModule = (PHLLMODULE)malloc(sizeof(HLLMODULE) + cchName + 201 sizeof(HLLOBJECT) * min((cObjects - 1), 3)); 202 assert(pModule != NULL); 203 memset(pModule, 0, sizeof(*pModule)); 204 pModule->cchName = cchName; 205 strcpy((char*)&pModule->achName[0], pszName); 206 pModule->chVerMajor = 4; 207 pModule->chVerMinor = 0; 208 pModule->cObjects = cObjects; 209 pModule->iLib = iLib; 210 pModule->usDebugStyle = HLL_MOD_STYLE; 211 pModule->overlay = 0; 212 pModule->pad = 0; 213 214 /* objects */ 215 if (cObjects > 0) 216 { 217 pModule->Object.cb = paObjects->cb; 218 pModule->Object.iObj = paObjects->iObject; 219 pModule->Object.off = paObjects->offset; 220 221 for (i = 1, pObj = (PHLLOBJECT)&pModule->achName[cchName]; i < cObjects; i++, pObj++) 222 { 223 pObj->cb = paObjects[i].cb; 224 pObj->iObj = paObjects[i].iObject; 225 pObj->off = paObjects[i].offset; 226 } 227 } 228 } 229 230 231 /** 232 * Destructor - free storage. 233 */ 234 kHllModuleEntry::~kHllModuleEntry() 235 { 236 if (pModule != NULL) 237 free(pModule); 238 pModule = NULL; 239 } 240 241 242 243 /** 244 * Adds an object to the module. 245 * @returns Success indicator. 246 * @param iObject LX Object index. 247 * @param off Offset into the object to the module data. 248 * @param cb Size of module data (in the object). 249 */ 250 BOOL kHllModuleEntry::addObject( 251 unsigned short int iObject, 252 unsigned long off, 253 unsigned long cb 94 254 ) 95 255 { 96 pszName = pszName; 97 cb = cb; 98 return NULL; 99 } 100 101 102 /** 103 * Adds a module. 104 * @returns Object handle. NULL on error. 105 * @param pszName Module name 106 * @param pvLib Library module handle. 107 * @param cObjects Number of objects in the array. 108 * @param paObjects Pointer to an array of objects. 109 */ 110 const void * kHll::addModule( 111 const char * pszName, 112 const void * pvLib, 113 unsigned cObject, 114 PMODOBJECT paObjects) 115 { 116 return NULL; 256 assert(pModule != NULL); 257 258 /* 259 * Reallocate? (Note that we'll initially allocated space for 3 objects.) 260 */ 261 if (pModule->cObjects >= 3) 262 { 263 void *pv = realloc(pModule, sizeof(HLLMODULE) + pModule->cchName 264 + (pModule->cObjects + 1) * sizeof(HLLOBJECT)); 265 assert(pv != NULL); 266 if (pv == NULL) 267 return FALSE; 268 pModule = (PHLLMODULE)pv; 269 } 270 271 272 /* 273 * Add module. 274 */ 275 if (pModule->cObjects == 0) 276 { 277 pModule->Object.cb = cb; 278 pModule->Object.off = off; 279 pModule->Object.iObj = iObject; 280 } 281 else 282 { 283 PHLLOBJECT pObject = (PHLLOBJECT)(pModule->cObjects * sizeof(HLLOBJECT) 284 + pModule->achName[pModule->cchName]); 285 pObject->cb = cb; 286 pObject->off = off; 287 pObject->iObj = iObject; 288 } 289 pModule->cObjects++; 290 291 return TRUE; 117 292 } 118 293 … … 127 302 * @param pvType Type handle. NULL if not type. 128 303 */ 129 const void * kHll ::addPublicSymbol(304 const void * kHllModuleEntry::addPublicSymbol( 130 305 const char * pszName, 131 306 unsigned long int off, … … 134 309 ) 135 310 { 136 PHLLPUBLICSYM pPubSym; 137 311 kHllPubSymEntry * pEntry; 312 313 /* parameter assertion */ 138 314 assert(pszName != NULL); 139 pPubSym = (PHLLPUBLICSYM)malloc(sizeof(HLLPUBLICSYM) + strlen(pszName)); 140 if (pPubSym != NULL) 141 { 142 strcpy(pPubSym->hll.achName, pszName); 143 pPubSym->hll.cchName = strlen(pszName); 144 pPubSym->hll.iObj = iObject; 145 pPubSym->hll.off = off; 146 pPubSym->hll.iType = pvType == NULL ? 0 : -1; //FIXME/TODO: Types->getIndex(pvType); check if 0 or -1. 147 PublicSymbols.insert(pPubSym); 148 free(pPubSym); 149 } 150 151 return NULL; 152 } 153 154 155 315 316 /* 317 * Create a public symbol entry 318 * Insert into it's list. 319 * Invalidate offsets. 320 */ 321 pEntry = new kHllPubSymEntry( 322 pszName, 323 off, 324 iObject, 325 pvType == NULL ? 0 : -1 //FIXME/TODO: Types->getIndex(pvType); check if 0 or -1. 326 ); 327 328 PublicSymbols.insert(pEntry); 329 330 fValidOffsetsAndSizes = FALSE; 331 332 return pEntry; 333 } 334 335 336 337 /** 338 * Write this HLL entry to file. 339 * @returns Count of bytes written. -1 on error. 340 * @param phFile Filehandle. 341 * @param off Current offset into the HLL data. 342 * This is stored and used when making the directory 343 * entries for this module. 344 */ 345 int kHllModuleEntry::write(FILE *phFile, unsigned long off) 346 { 347 int cch; 348 int cchWritten = 0; 349 350 /* validate object state */ 351 assert(pModule != NULL); 352 353 /* 354 * Write module HLL data. 355 */ 356 offModule = off; 357 cch = fwrite(pModule, 1, offsetof(HLLMODULE, achName) + pModule->cchName, phFile); 358 if (cch != offsetof(HLLMODULE, achName) + pModule->cchName) 359 return -1; 360 cchWritten += cch; 361 cbModule = cch; 362 off += cch; 363 364 /* 365 * Write the lists. 366 * Public Symbols 367 * Types 368 * Symbols 369 * Source 370 */ 371 offPublicSymbols = off; 372 cbPublicSymbols = cch = kHllBaseEntry::writeList(phFile, PublicSymbols.getFirst()); 373 if (cch < 0) 374 return cch; 375 cchWritten += cch; 376 off += cch; 377 378 /* 379 offTypes = off; 380 cbTypes = cch = kHllBaseEntry::writeList(phFile, Types.getFirst()); 381 if (cch < 0) 382 return cch; 383 cchWritten += cch; 384 off += cch; 385 386 387 offSymbols = off; 388 cbSymbols = cch = kHllBaseEntry::writeList(phFile, Symbols.getFirst()); 389 if (cch < 0) 390 return cch; 391 cchWritten += cch; 392 off += cch; 393 394 offSource = off; 395 cbSource = cch = kHllBaseEntry::writeList(phFile, Source.getFirst()); 396 if (cch < 0) 397 return cch; 398 cchWritten += cch; 399 off += cch; 400 */ 401 402 /* 403 * Marks offsets and sizes valid and returns succesfully. 404 */ 405 fValidOffsetsAndSizes = TRUE; 406 return cchWritten; 407 } 408 409 410 411 /** 412 * Writes the directory entries for this module to file. 413 * @returns Count of bytes written on success. 414 * -3 Invalid offsets. 415 * -2 Seek error. 416 * -1 Write error. 417 * 0 no data written (this is an error condition!) 418 * @param phFile Filehandle. 419 * @param iMod Index of this module. 420 */ 421 int kHllModuleEntry::writeDirEntries(FILE *phFile, unsigned short iMod) 422 { 423 HLLDIRENTRY hllDirEntry; 424 int cch; 425 int cchWritten = 0; 426 427 /* 428 * Check that offsets are valid! 429 */ 430 assert(fValidOffsetsAndSizes); 431 if (!fValidOffsetsAndSizes) 432 return -3; 433 434 /* 435 * Write Directory Entries. 436 * Module. 437 * Public Symbols. (if any) 438 * Types. (if any) 439 * Symbols. (if any) 440 * Source. (if any) 441 */ 442 hllDirEntry.usType = HLL_DE_MODULES; 443 hllDirEntry.cb = cbModule; 444 hllDirEntry.off = offModule; 445 hllDirEntry.iMod = iMod; 446 cch = fwrite(&hllDirEntry, 1, sizeof(hllDirEntry), phFile); 447 if (cch != sizeof(hllDirEntry)) 448 return -1; 449 cchWritten += cch; 450 451 if (cbPublicSymbols > 0) 452 { 453 hllDirEntry.usType = HLL_DE_PUBLICS; 454 hllDirEntry.cb = cbPublicSymbols; 455 hllDirEntry.off = offPublicSymbols; 456 hllDirEntry.iMod = iMod; 457 cch = fwrite(&hllDirEntry, 1, sizeof(hllDirEntry), phFile); 458 if (cch != sizeof(hllDirEntry)) 459 return -1; 460 cchWritten += cch; 461 } 462 463 /* 464 if (cbTypes > 0) 465 { 466 hllDirEntry.usType = HLL_DE_TYPES; 467 hllDirEntry.cb = cbTypes; 468 hllDirEntry.off = offTypes; 469 hllDirEntry.iMod = iMod; 470 cch = fwrite(&hllDirEntry, 1, sizeof(hllDirEntry), phFile); 471 if (cch != sizeof(hllDirEntry)) 472 return -1; 473 cchWritten += cch; 474 } 475 476 if (cbSymbols > 0) 477 { 478 hllDirEntry.usType = HLL_DE_SYMBOLS; 479 hllDirEntry.cb = cbSymbols; 480 hllDirEntry.off = offSymbols; 481 hllDirEntry.iMod = iMod; 482 cch = fwrite(&hllDirEntry, 1, sizeof(hllDirEntry), phFile); 483 if (cch != sizeof(hllDirEntry)) 484 return -1; 485 cchWritten += cch; 486 } 487 488 if (cbSource > 0) 489 { 490 hllDirEntry.usType = HLL_DE_IBMSRC; 491 hllDirEntry.cb = cbSource; 492 hllDirEntry.off = offSource; 493 hllDirEntry.iMod = iMod; 494 cch = fwrite(&hllDirEntry, 1, sizeof(hllDirEntry), phFile); 495 if (cch != sizeof(hllDirEntry)) 496 return -1; 497 cchWritten += cch; 498 } 499 500 */ 501 502 return cchWritten; 503 } 504 505 506 507 508 509 510 511 512 513 514 515 516 /******************************************************************************* 517 * * 518 * kHll * 519 * * 520 * kHll * 521 * * 522 *******************************************************************************/ 523 524 525 526 /** 527 * Writes HLL debuginfo to the given file at the current position. 528 * The file should be opened in write mode. 529 * @returns Number of bytes written. 530 * @param phFile Filehandle to output file. Starts writing at current pos. 531 */ 532 int kHll::write(FILE *phFile) 533 { 534 HLLHDR hllHdr; 535 HLLDIR hllDir; 536 kHllModuleEntry * pModule; 537 int cch; /* Number of bytes written to the file in an operation. */ 538 int cchWritten = 0; /* Number of bytes written to the file. */ 539 long int lPosStart; /* Starting position. */ 540 long int lPosDir; /* Directory position. */ 541 long int lPos; /* A file position. */ 542 int iMod; /* Module index (passed in to writeDirEntries) */ 543 544 /* Get starting position. */ 545 lPosStart = ftell(phFile); 546 547 /* Make temporary header and write it */ 548 memcpy(hllHdr.achSignature, "NB04", 4); 549 hllHdr.offDirectory = 0; 550 hllHdr.ulReserved = 1; 551 cch = fwrite(&hllHdr, 1, sizeof(hllHdr), phFile); 552 if (cch != sizeof(hllHdr)) 553 return -1; 554 cchWritten += cch; 555 556 557 /* 558 * Start writing modules 559 */ 560 pModule = (kHllModuleEntry*)Modules.getFirst(); 561 while (pModule != NULL) 562 { 563 cch = pModule->write(phFile, cchWritten); 564 if (cch <= 0) 565 return cch; 566 cchWritten += cch; 567 pModule = (kHllModuleEntry *)pModule->getNext(); 568 } 569 570 571 /* 572 * Write libraries. 573 */ 574 //Not implemented yet - TODO/FIXME! 575 576 577 /* 578 * Write directory. 579 * Make and write temporary directory header. 580 * Write directory entries per module. 581 * Write directory entry for libraries. 582 * Remake and rewrite directory header. (correct cEntries) 583 */ 584 lPosDir = ftell(phFile); 585 hllDir.cEntries = 0; 586 hllDir.ulReserved = 0; //FIXME/TODO - not quite sure what this is or should be! 587 cch = fwrite(&hllDir, 1, offsetof(HLLDIR, aEntries), phFile); 588 if (cch != offsetof(HLLDIR, aEntries)) 589 return -1; 590 cchWritten += cch; 591 592 iMod = 1; 593 pModule = (kHllModuleEntry*)Modules.getFirst(); 594 while (pModule != NULL) 595 { 596 cch = pModule->writeDirEntries(phFile, iMod); 597 if (cch == -1) 598 return -1; 599 cchWritten += cch; 600 pModule = (kHllModuleEntry *)pModule->getNext(); 601 iMod++; 602 } 603 604 //Library - TODO/FIXME 605 606 lPos = ftell(phFile); 607 hllDir.cEntries = (lPos - lPosDir - offsetof(HLLDIR, aEntries)) / sizeof(HLLDIRENTRY); 608 if (fseek(phFile, lPosDir, SEEK_SET) != 0) 609 return -2; 610 cch = fwrite(&hllDir, 1, offsetof(HLLDIR, aEntries), phFile); 611 if (cch != offsetof(HLLDIR, aEntries)) 612 return -1; 613 614 /* 615 * Rewrite HLL header (with correct directory offset). 616 */ 617 hllHdr.offDirectory = lPosDir - lPosStart; 618 cch = fwrite(&hllHdr, 1, sizeof(hllHdr), phFile); 619 if (cch != sizeof(hllHdr)) 620 return -1; 621 622 623 return cch; 624 } 625 626 627 628 /** 629 * Constructor - Creates an empty HLL object. 630 */ 631 kHll::kHll() 632 { 633 } 634 635 636 637 /** 638 * Destructor. 639 */ 640 kHll::~kHll() 641 { 642 } 643 644 645 646 /** 647 * Adds a module. 648 * @returns Pointer to the module object added. NULL on error. 649 * @param pszName Module name 650 * @param pvLib Library module handle. 651 * @param cObjects Number of objects in the array. 652 * @param paObjects Pointer to an array of objects. 653 */ 654 kHllModuleEntry * kHll::addModule( 655 const char * pszName, 656 const void * pvLib, 657 unsigned cObjects, 658 PMODOBJECT paObjects) 659 { 660 kHllModuleEntry * pEntry; 661 assert(pszName != NULL); 662 663 pEntry = new kHllModuleEntry( 664 pszName, 665 pvLib == NULL ? 0 : -1, //FIXME/TODO: Libs->getIndex(pvLib); check if 0 or -1; 666 cObjects, 667 paObjects); 668 669 Modules.insert(pEntry); 670 return pEntry; 671 } 672 673 674 675 /** 676 * Writes the HLL info to a file. (Not LX?) 677 * @returns Success indicator. 678 * @param pszFilename Name of the output file. 679 * @remark IMPORTANT! This is mostly for debugging! 680 * It completely overwrites the file if it exists! 681 */ 156 682 BOOL kHll::write( 157 683 const char *pszFilename 158 684 ) 159 685 { 686 FILE * phFile; 687 688 phFile = fopen(pszFilename, "wb"); 689 if (phFile != NULL) 690 { 691 int cch = write(phFile); 692 if (cch > 0) 693 { 694 fclose(phFile); 695 return TRUE; 696 } 697 else 698 fprintf(stderr, "write failed with cch=%d\n", cch); 699 fclose(phFile); 700 } 701 160 702 return FALSE; 161 703 } 162 704 163 705 706 707 /** 708 * Writes the HLL info to a file. (Not LX?) 709 * Failes if there is debuginfo in the file. 710 * No backup is made. (sorry) 711 * @returns OS2 return code. 712 * @param pszFilename Name of the output file. 713 */ 714 APIRET kHll::writeToLX( 715 const char *pszFilename 716 ) 717 { 718 APIRET rc; 719 FILE * phFile; 720 721 phFile = fopen(pszFilename, "rb+"); 722 if (phFile != NULL) 723 { 724 struct exe_hdr ehdr; 725 struct e32_exe e32; 726 int cch; 727 long lPosLXHdr; 728 729 /* 730 * Read exe header 731 */ 732 cch = fread(&ehdr, 1, sizeof(ehdr), phFile); 733 if (cch == sizeof(ehdr)) 734 { 735 if (ehdr.e_magic == NEMAGIC) 736 lPosLXHdr = ehdr.e_lfanew; 737 else 738 lPosLXHdr = 0; 739 if (fseek(phFile, lPosLXHdr, SEEK_SET) == 0) 740 { 741 cch = fread(&e32, 1, sizeof(e32), phFile); 742 if (cch == sizeof(e32)) 743 { 744 if (*(unsigned short*)&e32.e32_magic[0] == E32MAGIC) 745 { 746 /* 747 * Found exeheader. 748 * Check if there is any debug info. 749 */ 750 if (e32.e32_debuginfo > 0 && e32.e32_debuginfo > 0) 751 { 752 long lPosDebug; 753 754 /* 755 * Go to end of file and write debug info. 756 */ 757 if (fseek(phFile, 0, SEEK_END) == 0 758 && 759 (lPosDebug = ftell(phFile)) != -1 760 ) 761 { 762 /* 763 * Write the HLL data to disk. 764 */ 765 cch = write(phFile); 766 if (cch > 0) 767 { 768 /* 769 * Update exeheader. 770 */ 771 e32.e32_debuglen = cch; 772 e32.e32_debuginfo = lPosDebug; 773 if (fseek(phFile, lPosLXHdr, SEEK_SET) == 0) 774 { 775 /* 776 * Write the updated header to disk. 777 */ 778 cch = fwrite(&e32, 1, sizeof(e32), phFile); 779 if (cch == sizeof(e32)) 780 rc = NO_ERROR; 781 else 782 rc = ERROR_WRITE_FAULT; 783 } 784 else 785 rc = ERROR_SEEK; 786 } 787 else 788 { 789 fprintf(stderr, "error - write failed with cch=%d\n", cch); 790 rc = ERROR_WRITE_FAULT; 791 } 792 } 793 else 794 rc = ERROR_SEEK; 795 } 796 else 797 { 798 fprintf(stderr, "error - debuginfo exists\n"); 799 rc = ERROR_BAD_EXE_FORMAT; 800 } 801 802 } 803 else 804 rc = ERROR_INVALID_EXE_SIGNATURE; 805 } 806 else 807 rc = ERROR_BAD_EXE_FORMAT; 808 } 809 else 810 rc = ERROR_BAD_EXE_FORMAT; 811 } 812 else 813 rc = ERROR_READ_FAULT; 814 815 fclose(phFile); 816 } 817 else 818 rc = ERROR_ACCESS_DENIED; //? 819 820 821 return rc; 822 } 823 824 825 -
trunk/tools/dbginfo/kHll.h
r3238 r3239 1 /* $Id: kHll.h,v 1. 2 2000-03-25 23:50:11bird Exp $1 /* $Id: kHll.h,v 1.3 2000-03-26 14:16:19 bird Exp $ 2 2 * 3 3 * kHll - Declarations of the class kHll. … … 29 29 30 30 31 class kHll 31 32 /** 33 * HLL General entry. 34 * Provided as a base class for kList entries. 35 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 36 */ 37 class kHllBaseEntry : public kListEntry 38 { 39 public: 40 /** 41 * Write this HLL entry to file. 42 * @returns Count of bytes written (on success). 43 * -3 Invalid offsets. 44 * -2 Seek error. 45 * -1 Write error. 46 * 0 No data written. Concidered as an error! 47 * @param phFile Filehandle. 48 */ 49 virtual int write(FILE *phFile) = 0; 50 static int writeList(FILE *phFile, kHllBaseEntry *pEntry); 51 }; 52 53 32 54 33 55 /** … … 35 57 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 36 58 */ 37 class kHllPubSymEntry : public k ListEntry59 class kHllPubSymEntry : public kHllBaseEntry 38 60 { 39 61 private: … … 41 63 42 64 public: 43 kH LLPubSym(65 kHllPubSymEntry( 44 66 const char * pszName, 45 67 unsigned long off, … … 47 69 unsigned short iType 48 70 ); 49 ~kHLLPubSym(); 50 51 int write(FILE *phFile); 52 }; 53 54 55 56 /** 57 * HLL Debug Info generator. 58 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 59 */ 60 class kHll 61 { 62 71 ~kHllPubSymEntry(); 72 73 int write(FILE *phFile); 74 }; 75 76 77 78 /** 79 * HLL Module entry. 80 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 81 */ 82 class kHllModuleEntry : public kListEntry 83 { 63 84 private: 64 85 /** @cat 65 86 * Internal data. 66 */ 67 kList<kHllModuleEntry> Modules; 68 kList<kHllPubSymEntry> PublicSymbols; 69 70 71 public: 72 /** @cat 73 * Constructors and Destructors. 74 */ 75 kHll(); 76 ~kHll(); 87 * HLL Module data. 88 * Lists of HLL elements 89 * Offsets and sizes - set by write(..). 90 */ 91 PHLLMODULE pModule; 92 93 kList<kHllPubSymEntry> PublicSymbols; 94 /* 95 kList<kHllTypeEntry> Types; 96 kList<kHllSymEntry> Symbols; 97 kList<kHllSrcEntry> Source; 98 */ 99 100 BOOL fValidOffsetsAndSizes; 101 unsigned long offModule; 102 unsigned long cbModule; 103 unsigned long offPublicSymbols; 104 unsigned long cbPublicSymbols; 105 unsigned long offTypes; 106 unsigned long cbTypes; 107 unsigned long offSymbols; 108 unsigned long cbSymbols; 109 unsigned long offSource; 110 unsigned long cbSource; 111 112 113 /** @cat 114 * Internal methods. 115 */ 116 int writeList(FILE *phFile, kList<kHllBaseEntry> &List); 117 118 119 public: 120 /** @cat 121 * Constructor and destructor. 122 */ 123 kHllModuleEntry( 124 const char * pszName, 125 unsigned short iLib, 126 unsigned char cObjects = 0, 127 PMODOBJECT paObjects = NULL 128 ); 129 ~kHllModuleEntry(); 130 77 131 78 132 /** @cat 79 133 * Add menthods 80 134 */ 81 const void * addObject( 82 const char * pszName, 83 unsigned long int cb 135 BOOL addObject( 136 unsigned short int iObject, 137 unsigned long off, 138 unsigned long cb 84 139 ); 85 const void * addModule( 86 const char * pszName, 87 const void * pvLib, 88 unsigned cObject, 89 PMODOBJECT paObjects 90 ); 140 91 141 const void * addPublicSymbol( 92 142 const char * pszName, … … 95 145 const void * pvType 96 146 ); 147 148 149 /** @cat 150 * Output. 151 */ 152 int write(FILE *phFile, unsigned long off); 153 int writeDirEntries(FILE *phFile, unsigned short iMod); 154 }; 155 156 157 158 /** 159 * HLL Debug Info generator. 160 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 161 */ 162 class kHll 163 { 164 165 private: 166 /** @cat 167 * Internal data. 168 */ 169 kList<kHllModuleEntry> Modules; 97 170 /* 98 const void * addPublicSymbol( 99 const char * pszName, 100 unsigned long int off, 101 unsigned short int iObject, 102 const char * pszType 171 kList<kHllLibraryEntry> Libraries; 172 */ 173 174 /** @cat 175 * Internal methods. 176 */ 177 int write(FILE *phFile); 178 179 180 public: 181 /** @cat 182 * Constructors and Destructors. 183 */ 184 kHll(); 185 ~kHll(); 186 187 /** @cat 188 * Add menthods 189 */ 190 kHllModuleEntry * addModule( 191 const char * pszName, 192 const void * pvLib, 193 unsigned cObjects, 194 PMODOBJECT paObjects 103 195 ); 104 */105 196 106 197 … … 108 199 * Output. 109 200 */ 110 BOOL write( 111 const char *pszFilename 112 ); 201 BOOL write( 202 const char *pszFilename 203 ); 204 APIRET writeToLX( 205 const char *pszFilename 206 ); 207 113 208 114 209 };
Note:
See TracChangeset
for help on using the changeset viewer.