Changeset 3247 for trunk/tools


Ignore:
Timestamp:
Mar 27, 2000, 12:20:42 PM (25 years ago)
Author:
bird
Message:

Things are beginning to work. ICSDEBUG don't like use the debug info generated
by Sym2Hll yet, don't know why.

Location:
trunk/tools/dbginfo
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/dbginfo/Sym2Hll.cpp

    r3244 r3247  
    1 /* $Id: Sym2Hll.cpp,v 1.2 2000-03-26 21:56:36 bird Exp $
     1/* $Id: Sym2Hll.cpp,v 1.3 2000-03-27 10:20:41 bird Exp $
    22 *
    33 * Sym2Hll - Symbol file to HLL debuginfo converter.
     
    88 *
    99 */
     10/*******************************************************************************
     11*   Defined Constants And Macros                                               *
     12*******************************************************************************/
     13#define INCL_DOSERRORS
     14#define WORD    USHORT
     15#define DWORD   ULONG
    1016
    1117/*******************************************************************************
     
    1319*******************************************************************************/
    1420#include <os2.h>
     21#include <exe386.h>
    1522
    1623#include <stdio.h>
     
    2532#include "kHll.h"
    2633#include "sym.h"
     34#include "kFileFormatBase.h"
     35#include "kFileLX.h"
    2736
    2837/*******************************************************************************
     
    3342
    3443
     44/*******************************************************************************
     45*   External Functions                                                         *
     46*******************************************************************************/
     47APIRET APIENTRY DosReplaceModule (PSZ pszOldModule, PSZ pszNewModule, PSZ pszBackupModule);
     48
    3549
    3650
    3751int main(int argc, char **argv)
    3852{
    39     kHll *pHll;
     53    kHll *      pHll;
     54    kFileLX *   pFileLX;
    4055
    4156    /*
     
    5166    pHll = new kHll();
    5267    assert(pHll != NULL);
     68
     69    try {
     70        pFileLX = new kFileLX(argv[2]);
     71    } catch (int errcd)
     72    {
     73        fprintf(stderr, "failed to open/read LX file (%s). errcd=%d\n", argv[2], errcd);
     74        return -3;
     75    }
     76
    5377
    5478
     
    117141            while (pSegDef != NULL)
    118142            {
     143                struct o32_obj *pLXObject;
    119144                PSYMDEF32       pSymDef32;  /* Symbol definition 32-bit */
    120145                PSYMDEF16       pSymDef16;  /* Symbol definition 16-bit */
     
    160185                 * Add segment to the module - FIXME - need info from the LX Object table...
    161186                 */
    162 
     187                pLXObject = pFileLX->getObject(iSegment-1);
     188                if (pLXObject)
     189                {
     190                    if (!pModule->addSegInfo(iSegment, 0, pLXObject->o32_size))
     191                        fprintf(stderr, "warning: addseginfo failed!\n");
     192                }
     193                else
     194                    fprintf(stderr, "warning: pFileLX->getObject failed for iSegment=%d\n",
     195                            iSegment);
    163196
    164197                /*
     
    233266         */
    234267        pHll->write("debug.hll");
    235         pHll->writeToLX(argv[2]);
     268        rc = pHll->writeToLX(argv[2]);
     269        if (rc == ERROR_ACCESS_DENIED)
     270        {
     271
     272            rc = DosReplaceModule(argv[2], NULL, NULL);
     273            if (rc == NO_ERROR)
     274            {
     275                rc = pHll->writeToLX(argv[2]);
     276            }
     277        }
    236278    }
    237279    else
     
    290332
    291333
    292 /**
    293  * Find the size of a file.
    294  * @returns   Size of file. -1 on error.
    295  * @param     phFile  File handle.
    296  */
    297 signed long fsize(FILE *phFile)
    298 {
    299     int ipos;
    300     signed long cb;
    301 
    302     if ((ipos = ftell(phFile)) < 0
    303         ||
    304         fseek(phFile, 0, SEEK_END) != 0
    305         ||
    306         (cb = ftell(phFile)) < 0
    307         ||
    308         fseek(phFile, ipos, SEEK_SET) != 0
    309         )
    310         cb = -1;
    311     return cb;
    312 }
    313 
    314334
    315335
  • trunk/tools/dbginfo/dbgLXDumper.c

    r3244 r3247  
    1 /* $Id: dbgLXDumper.c,v 1.3 2000-03-26 21:56:37 bird Exp $
     1/* $Id: dbgLXDumper.c,v 1.4 2000-03-27 10:20:42 bird Exp $
    22 *
    33 * dbgLXDumper - reads and interprets the debuginfo found in an LX executable.
     
    1212*   Defined Constants And Macros                                               *
    1313*******************************************************************************/
    14 #define INCL_TYPES
    1514#define INCL_DOSERRORS
    1615#define FOR_EXEHDR          1           /* exe386.h flag */
    1716#define DWORD               ULONG       /* Used by exe386.h / newexe.h */
    1817#define WORD                USHORT      /* Used by exe386.h / newexe.h */
     18
    1919
    2020/*******************************************************************************
     
    302302                        "    ilib          %d\n"
    303303                        "    pad           %d\n"
     304                        "    cSegInfo      %d\n"
    304305                        "    usDebugStyle  %#04x %c%c\n"
    305306                        "    HLL Version   %d.%d\n"
     
    311312                        pModule->iLib,
    312313                        pModule->pad,
     314                        pModule->cSegInfo,
    313315                        pModule->usDebugStyle,
    314316                        pModule->usDebugStyle & 0xFF,
     
    335337                c = pModule->cSegInfo > 0 ? pModule->cSegInfo : 0;
    336338                paSegInfo = (PHLLSEGINFO)((void*)&pModule->achName[pModule->cchName]);
    337                 for (j = 0; j < c; j++)
     339                for (j = 0; j + 1 < c; j++)
    338340                {
    339341                    fprintf(phOut,
  • trunk/tools/dbginfo/kHll.cpp

    r3245 r3247  
    1 /* $Id: kHll.cpp,v 1.5 2000-03-27 07:26:54 bird Exp $
     1/* $Id: kHll.cpp,v 1.6 2000-03-27 10:20:42 bird Exp $
    22 *
    33 * kHll - Implementation of the class kHll.
     
    4040
    4141
     42/*******************************************************************************
     43*   Internal Functions                                                         *
     44*******************************************************************************/
     45signed long     fsize(FILE *phFile);
    4246
    4347
     
    202206    cchName = strlen(pszName);
    203207    pModule = (PHLLMODULE)malloc(sizeof(HLLMODULE) + cchName +
    204                                  sizeof(HLLSEGINFO) * min((cSegInfo - 1), 3));
     208                                 sizeof(HLLSEGINFO) * max((cSegInfo - 1), 3));
    205209    assert(pModule != NULL);
    206210    memset(pModule, 0, sizeof(*pModule));
     
    284288    else
    285289    {
    286         PHLLSEGINFO pSegInfo =  (PHLLSEGINFO)(pModule->cSegInfo * sizeof(HLLSEGINFO)
    287                                               + pModule->achName[pModule->cchName]);
     290        PHLLSEGINFO pSegInfo =  (PHLLSEGINFO)((pModule->cSegInfo - 1) * sizeof(HLLSEGINFO)
     291                                              + &pModule->achName[pModule->cchName]);
    288292        pSegInfo->cb = cb;
    289293        pSegInfo->off = off;
     
    374378{
    375379    int             cch;
     380    int             cchToWrite;
    376381    int             cchWritten = 0;
    377382
     
    383388     */
    384389    offModule = off;
    385     cch = fwrite(pModule, 1, offsetof(HLLMODULE, achName) + pModule->cchName, phFile);
    386     if (cch != offsetof(HLLMODULE, achName) + pModule->cchName)
     390    cchToWrite = offsetof(HLLMODULE, achName) + pModule->cchName + sizeof(HLLSEGINFO) * max(pModule->cSegInfo-1, 0);
     391    cch = fwrite(pModule, 1, cchToWrite, phFile);
     392    if (cch != cchToWrite)
    387393        return -1;
    388394    cchWritten += cch;
     
    789795        int                 cch;
    790796        long                lPosLXHdr;
     797        long                cbLXFile;
    791798
    792799        /*
     
    796803        if (cch == sizeof(ehdr))
    797804        {
     805            cbLXFile = fsize(phFile);
    798806            if (ehdr.e_magic == EMAGIC)
    799807                lPosLXHdr = ehdr.e_lfanew;
     
    811819                         * Check if there is any debug info.
    812820                         */
    813                         if (e32.e32_debuginfo == 0 && e32.e32_debuginfo == 0)
     821                        if ((e32.e32_debuginfo == 0 && e32.e32_debuginfo == 0)
     822                            || (cbLXFile == e32.e32_debuglen + e32.e32_debuginfo)
     823                            )
    814824                        {
    815825                            long lPosDebug;
    816826
     827                            if (e32.e32_debuginfo != 0 && e32.e32_debuglen != 0)
     828                                lPosDebug = e32.e32_debuginfo;
     829                            else
     830                                lPosDebug = cbLXFile;
     831
    817832                            /*
    818                              * Go to end of file and write debug info.
     833                             * Go to debug info position in the file and write debug info.
    819834                             */
    820                             if (fseek(phFile, 0, SEEK_END) == 0
    821                                 &&
    822                                 (lPosDebug = ftell(phFile)) != -1
    823                                 )
     835                            if (fseek(phFile, lPosDebug, SEEK_SET) == 0)
    824836                            {
    825837                                /*
     
    886898
    887899
    888 
     900/**
     901 * Find the size of a file.
     902 * @returns   Size of file. -1 on error.
     903 * @param     phFile  File handle.
     904 */
     905signed long fsize(FILE *phFile)
     906{
     907    int ipos;
     908    signed long cb;
     909
     910    if ((ipos = ftell(phFile)) < 0
     911        ||
     912        fseek(phFile, 0, SEEK_END) != 0
     913        ||
     914        (cb = ftell(phFile)) < 0
     915        ||
     916        fseek(phFile, ipos, SEEK_SET) != 0
     917        )
     918        cb = -1;
     919    return cb;
     920}
     921
Note: See TracChangeset for help on using the changeset viewer.