Ignore:
Timestamp:
May 15, 2001, 6:15:18 PM (24 years ago)
Author:
umoeller
Message:

Lotsa fixes from the last two weeks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/debug.c

    r31 r68  
    366366
    367367/*
     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
     386VOID 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/*
    368397 *@@ dbgPrintDebugInfo:
    369398 *      this is the main entry point into analyzing debug
    370399 *      code.
     400 *
    371401 *      This analyzes a given address and tries to find
    372402 *      debug code descriptions for this address. If found,
     
    383413APIRET dbgPrintDebugInfo(FILE *LogFile,         // out: log file to write to
    384414                         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)
    387417{
    388418    APIRET                  rc = 0;
     
    391421    static struct new_exe   NewExeHeader;
    392422
     423    ULONG                   ulSegment = Object + 1;     // segment no. is object no. + 1
     424
    393425    XDEBUGINFO              xdi;
    394426    memset(&xdi, 0, sizeof(xdi));
     
    430462
    431463            // 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
    444472            close(ModuleFile);
    445473
     
    451479                if (ModuleFile != -1)
    452480                {
    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
    460489                    close(ModuleFile);
    461490                }
    462             }                   // endif
     491            }
    463492
    464493            return rc;
     
    473502                 */
    474503
    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)
    476507                {
    477508                    fprintf(LogFile, "Out of memory!");
     
    479510                    return -1;
    480511                }
    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)
    482515                {
    483516                    fprintf(LogFile, "Error %u seeking segment table in %s\n", errno, FileName);
     
    487520                }
    488521
    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)
    490526                {
    491527                    fprintf(LogFile, "Error %u reading segment table from %s\n", errno, FileName);
     
    494530                    return 10;
    495531                }
    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
    503541                free(xdi.pseg);
    504542                close(ModuleFile);
     
    508546                {
    509547                    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);
    511550                    if (ModuleFile != -1)
    512551                    {
    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
    520560                        close(ModuleFile);
    521561                    }
    522                 }               // endif
     562                }
    523563                return rc;
    524 
    525564            }
    526565            else
     
    608647    }
    609648
    610     if (read(ModuleFile, (void *)&G_eodbug, 8) == -1)
     649    if (read(ModuleFile,
     650             (void *)&G_eodbug, 8)
     651            == -1)
    611652    {
    612653        fprintf(LogFile, "Error %u reading debug info from %s\n", errno, FileName);
     
    619660    }
    620661
    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)
    622666    {
    623667        fprintf(LogFile, "Error %u seeking base codeview data in %s\n", errno, FileName);
     
    625669    }
    626670
    627     if (read(ModuleFile, (void *)&pxdi->base, 8) == -1)
     671    if (read(ModuleFile,
     672             (void *)&pxdi->base, 8)
     673        == -1)
    628674    {
    629675        fprintf(LogFile, "Error %u reading base codeview data in %s\n", errno, FileName);
     
    631677    }
    632678
    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)
    634683    {
    635684        fprintf(LogFile, "Error %u seeking dir codeview data in %s\n", errno, FileName);
     
    637686    }
    638687
    639     if (read(ModuleFile, (void *)&numdir, 4) == -1)
     688    if (read(ModuleFile,
     689             (void *)&numdir, 4)
     690        == -1)
    640691    {
    641692        fprintf(LogFile, "Error %u reading dir codeview data in %s\n", errno, FileName);
     
    644695
    645696    // 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)
    649700    {
    650701        fprintf(LogFile, "Out of memory!");
     
    652703    }
    653704
    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)
    655709    {
    656710        fprintf(LogFile, "Error %u reading codeview dir table from %s\n", errno, FileName);
     
    667721            continue;
    668722        }
     723
    669724        NrPublic = 0x0;
    670725        NrSymbol = 0;
     
    673728        CurrSymSeg = 0;
    674729        // 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);
    678739        ModIndex = pxdi->pDirTab32[i].modindex;
    679740        ModName[pxdi->ssmod32.csize] = '\0';
     
    687748        {
    688749            // 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
    690754            switch (pxdi->pDirTab32[i].sst)
    691755            {
     
    694758                    while (bytesread < pxdi->pDirTab32[i].cb)
    695759                    {
    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);
    698766                        ename[pxdi->sspub32.csize] = '\0';
    699767                        if (    (pxdi->sspub32.segment == TrapSeg)
     
    705773                            read_types = TRUE;
    706774                            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                                            : " ",
    709779                                    ename,
    710                                     ModName, // ()
    711                                     (ULONG)pxdi->sspub32.segment,
    712                                     pxdi->sspub32.offset
     780                                    ModName
    713781                                );
    714782                            // but continue, because there might be a
Note: See TracChangeset for help on using the changeset viewer.