Changeset 68 for trunk/src/helpers/debug.c
- Timestamp:
- May 15, 2001, 6:15:18 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/debug.c
r31 r68 366 366 367 367 /* 368 *@@ WriteAddressInfo: 369 * formats and writes a line into the trap log 370 * file. 371 * 372 * This gets called for each line from the 373 * stack dump. At this point, the line in the 374 * trap log already has: 375 * 376 + CS:EIP : 000109FF XMLVIEW :0 377 + ^^^ and we write here 378 * After this call, we have. 379 * 380 + CS:EIP : 000109FF XMLVIEW :0 xxx.c 123 ConfirmCreate__Fv 381 + ^^^ and we write here 382 * 383 *@@added V0.9.12 (2001-05-12) [umoeller] 384 */ 385 386 VOID WriteDebugInfo(FILE *LogFile, // in: open log file 387 PXDEBUGINFO pxdi) // in: debug info 388 { 389 fprintf(LogFile, 390 "%s%s%s", 391 pxdi->szNrFile, 392 pxdi->szNrLine, 393 pxdi->szNrPub); 394 } 395 396 /* 368 397 *@@ dbgPrintDebugInfo: 369 398 * this is the main entry point into analyzing debug 370 399 * code. 400 * 371 401 * This analyzes a given address and tries to find 372 402 * debug code descriptions for this address. If found, … … 383 413 APIRET dbgPrintDebugInfo(FILE *LogFile, // out: log file to write to 384 414 CHAR *FileName, // in: EXE/DLL module file name 385 ULONG Object, // in: trapping object 386 ULONG TrapOffset) // in: trapping address 415 ULONG Object, // in: trapping object (from DosQueryModFromEIP) 416 ULONG TrapOffset) // in: trapping address (from DosQueryModFromEIP) 387 417 { 388 418 APIRET rc = 0; … … 391 421 static struct new_exe NewExeHeader; 392 422 423 ULONG ulSegment = Object + 1; // segment no. is object no. + 1 424 393 425 XDEBUGINFO xdi; 394 426 memset(&xdi, 0, sizeof(xdi)); … … 430 462 431 463 // do analysis for 32-bit code 432 rc = Read32PmDebug(LogFile, 433 &xdi, 434 ModuleFile, 435 Object + 1, 436 TrapOffset, 437 FileName); 438 if (rc == 0) 439 { 440 fprintf(LogFile, "%s", xdi.szNrFile); 441 fprintf(LogFile, "%s", xdi.szNrLine); 442 fprintf(LogFile, "%s", xdi.szNrPub); 443 } // endif 464 if (!(rc = Read32PmDebug(LogFile, 465 &xdi, // output 466 ModuleFile, 467 ulSegment, 468 TrapOffset, 469 FileName))) 470 WriteDebugInfo(LogFile, &xdi); 471 444 472 close(ModuleFile); 445 473 … … 451 479 if (ModuleFile != -1) 452 480 { 453 rc = Read32PmDebug(LogFile, &xdi, ModuleFile, Object + 1, TrapOffset, FileName); 454 if (rc == 0) 455 { 456 fprintf(LogFile, "%s", xdi.szNrFile); 457 fprintf(LogFile, "%s", xdi.szNrLine); 458 fprintf(LogFile, "%s", xdi.szNrPub); 459 } // endif 481 if (!(rc = Read32PmDebug(LogFile, 482 &xdi, 483 ModuleFile, 484 ulSegment, 485 TrapOffset, 486 FileName))) 487 WriteDebugInfo(LogFile, &xdi); 488 460 489 close(ModuleFile); 461 490 } 462 } // endif491 } 463 492 464 493 return rc; … … 473 502 */ 474 503 475 if ((xdi.pseg = (struct new_seg *)calloc(NE_CSEG(NewExeHeader), sizeof(struct new_seg))) == NULL) 504 if ((xdi.pseg = (struct new_seg *)calloc(NE_CSEG(NewExeHeader), 505 sizeof(struct new_seg))) 506 == NULL) 476 507 { 477 508 fprintf(LogFile, "Out of memory!"); … … 479 510 return -1; 480 511 } 481 if (lseek(ModuleFile, E_LFANEW(OldExeHeader) + NE_SEGTAB(NewExeHeader), SEEK_SET) == -1L) 512 if ( lseek(ModuleFile, 513 E_LFANEW(OldExeHeader) + NE_SEGTAB(NewExeHeader), 514 SEEK_SET) == -1L) 482 515 { 483 516 fprintf(LogFile, "Error %u seeking segment table in %s\n", errno, FileName); … … 487 520 } 488 521 489 if (read(ModuleFile, (void *)xdi.pseg, NE_CSEG(NewExeHeader) * sizeof(struct new_seg)) == -1) 522 if (read(ModuleFile, 523 (void *)xdi.pseg, 524 NE_CSEG(NewExeHeader) * sizeof(struct new_seg)) 525 == -1) 490 526 { 491 527 fprintf(LogFile, "Error %u reading segment table from %s\n", errno, FileName); … … 494 530 return 10; 495 531 } 496 rc = Read16CodeView(LogFile, &xdi, ModuleFile, Object + 1, TrapOffset, FileName); 497 if (rc == 0) 498 { 499 fprintf(LogFile, "%s", xdi.szNrFile); 500 fprintf(LogFile, "%s", xdi.szNrLine); 501 fprintf(LogFile, "%s", xdi.szNrPub); 502 } // endif 532 533 if (!(rc = Read16CodeView(LogFile, 534 &xdi, 535 ModuleFile, 536 ulSegment, 537 TrapOffset, 538 FileName))) 539 WriteDebugInfo(LogFile, &xdi); 540 503 541 free(xdi.pseg); 504 542 close(ModuleFile); … … 508 546 { 509 547 strcpy(FileName + strlen(FileName) - 3, "DBG"); // Build DBG File name 510 ModuleFile = sopen(FileName, O_RDONLY | O_BINARY, SH_DENYNO); 548 ModuleFile = sopen(FileName, 549 O_RDONLY | O_BINARY, SH_DENYNO); 511 550 if (ModuleFile != -1) 512 551 { 513 rc = Read16CodeView(LogFile, &xdi, ModuleFile, Object + 1, TrapOffset, FileName); 514 if (rc == 0) 515 { 516 fprintf(LogFile, "%s", xdi.szNrFile); 517 fprintf(LogFile, "%s", xdi.szNrLine); 518 fprintf(LogFile, "%s", xdi.szNrPub); 519 } // endif 552 if (!(rc = Read16CodeView(LogFile, 553 &xdi, 554 ModuleFile, 555 ulSegment, 556 TrapOffset, 557 FileName))) 558 WriteDebugInfo(LogFile, &xdi); 559 520 560 close(ModuleFile); 521 561 } 522 } // endif562 } 523 563 return rc; 524 525 564 } 526 565 else … … 608 647 } 609 648 610 if (read(ModuleFile, (void *)&G_eodbug, 8) == -1) 649 if (read(ModuleFile, 650 (void *)&G_eodbug, 8) 651 == -1) 611 652 { 612 653 fprintf(LogFile, "Error %u reading debug info from %s\n", errno, FileName); … … 619 660 } 620 661 621 if ((pxdi->lfaBase = lseek(ModuleFile, -(LONG)G_eodbug.dfaBase, SEEK_END)) == -1L) 662 if ( (pxdi->lfaBase = lseek(ModuleFile, 663 -(LONG)G_eodbug.dfaBase, 664 SEEK_END)) 665 == -1L) 622 666 { 623 667 fprintf(LogFile, "Error %u seeking base codeview data in %s\n", errno, FileName); … … 625 669 } 626 670 627 if (read(ModuleFile, (void *)&pxdi->base, 8) == -1) 671 if (read(ModuleFile, 672 (void *)&pxdi->base, 8) 673 == -1) 628 674 { 629 675 fprintf(LogFile, "Error %u reading base codeview data in %s\n", errno, FileName); … … 631 677 } 632 678 633 if (lseek(ModuleFile, pxdi->base.lfoDir - 8 + 4, SEEK_CUR) == -1) 679 if (lseek(ModuleFile, 680 pxdi->base.lfoDir - 8 + 4, 681 SEEK_CUR) 682 == -1) 634 683 { 635 684 fprintf(LogFile, "Error %u seeking dir codeview data in %s\n", errno, FileName); … … 637 686 } 638 687 639 if (read(ModuleFile, (void *)&numdir, 4) == -1) 688 if (read(ModuleFile, 689 (void *)&numdir, 4) 690 == -1) 640 691 { 641 692 fprintf(LogFile, "Error %u reading dir codeview data in %s\n", errno, FileName); … … 644 695 645 696 // Read dir table into buffer 646 if ( (pxdi->pDirTab32 = (SSDIR32*)calloc(numdir,647 sizeof(SSDIR32)) 648 )== NULL)697 if ( (pxdi->pDirTab32 = (SSDIR32*)calloc(numdir, 698 sizeof(SSDIR32))) 699 == NULL) 649 700 { 650 701 fprintf(LogFile, "Out of memory!"); … … 652 703 } 653 704 654 if (read(ModuleFile, (void *)pxdi->pDirTab32, numdir * sizeof(SSDIR32)) == -1) 705 if (read(ModuleFile, 706 (void*)pxdi->pDirTab32, 707 numdir * sizeof(SSDIR32)) 708 == -1) 655 709 { 656 710 fprintf(LogFile, "Error %u reading codeview dir table from %s\n", errno, FileName); … … 667 721 continue; 668 722 } 723 669 724 NrPublic = 0x0; 670 725 NrSymbol = 0; … … 673 728 CurrSymSeg = 0; 674 729 // point to subsection 675 lseek(ModuleFile, pxdi->pDirTab32[i].lfoStart + pxdi->lfaBase, SEEK_SET); 676 read(ModuleFile, (void*)&(pxdi->ssmod32.csBase), sizeof(SSMOD32)); 677 read(ModuleFile, (void*)ModName, (unsigned)pxdi->ssmod32.csize); 730 lseek(ModuleFile, 731 pxdi->pDirTab32[i].lfoStart + pxdi->lfaBase, 732 SEEK_SET); 733 read(ModuleFile, 734 (void*)&pxdi->ssmod32.csBase, 735 sizeof(SSMOD32)); 736 read(ModuleFile, 737 (void*)ModName, 738 (unsigned)pxdi->ssmod32.csize); 678 739 ModIndex = pxdi->pDirTab32[i].modindex; 679 740 ModName[pxdi->ssmod32.csize] = '\0'; … … 687 748 { 688 749 // point to subsection 689 lseek(ModuleFile, pxdi->pDirTab32[i].lfoStart + pxdi->lfaBase, SEEK_SET); 750 lseek(ModuleFile, 751 pxdi->pDirTab32[i].lfoStart + pxdi->lfaBase, 752 SEEK_SET); 753 690 754 switch (pxdi->pDirTab32[i].sst) 691 755 { … … 694 758 while (bytesread < pxdi->pDirTab32[i].cb) 695 759 { 696 bytesread += read(ModuleFile, (void *)&pxdi->sspub32.offset, sizeof(pxdi->sspub32)); 697 bytesread += read(ModuleFile, (void *)ename, (unsigned)pxdi->sspub32.csize); 760 bytesread += read(ModuleFile, 761 (void *)&pxdi->sspub32.offset, 762 sizeof(pxdi->sspub32)); 763 bytesread += read(ModuleFile, 764 (void*)ename, 765 (unsigned)pxdi->sspub32.csize); 698 766 ename[pxdi->sspub32.csize] = '\0'; 699 767 if ( (pxdi->sspub32.segment == TrapSeg) … … 705 773 read_types = TRUE; 706 774 sprintf(pxdi->szNrPub, 707 "%s %s (%s, seg %04lX : ofs %08lX\n", 708 (pxdi->sspub32.type == 1) ? " Abs" : " ", 775 "%s %s (%s)\n", 776 (pxdi->sspub32.type == 1) 777 ? " Abs" 778 : " ", 709 779 ename, 710 ModName, // () 711 (ULONG)pxdi->sspub32.segment, 712 pxdi->sspub32.offset 780 ModName 713 781 ); 714 782 // but continue, because there might be a
Note:
See TracChangeset
for help on using the changeset viewer.