Changeset 3247 for trunk/tools
- Timestamp:
- Mar 27, 2000, 12:20:42 PM (25 years ago)
- 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:36bird Exp $1 /* $Id: Sym2Hll.cpp,v 1.3 2000-03-27 10:20:41 bird Exp $ 2 2 * 3 3 * Sym2Hll - Symbol file to HLL debuginfo converter. … … 8 8 * 9 9 */ 10 /******************************************************************************* 11 * Defined Constants And Macros * 12 *******************************************************************************/ 13 #define INCL_DOSERRORS 14 #define WORD USHORT 15 #define DWORD ULONG 10 16 11 17 /******************************************************************************* … … 13 19 *******************************************************************************/ 14 20 #include <os2.h> 21 #include <exe386.h> 15 22 16 23 #include <stdio.h> … … 25 32 #include "kHll.h" 26 33 #include "sym.h" 34 #include "kFileFormatBase.h" 35 #include "kFileLX.h" 27 36 28 37 /******************************************************************************* … … 33 42 34 43 44 /******************************************************************************* 45 * External Functions * 46 *******************************************************************************/ 47 APIRET APIENTRY DosReplaceModule (PSZ pszOldModule, PSZ pszNewModule, PSZ pszBackupModule); 48 35 49 36 50 37 51 int main(int argc, char **argv) 38 52 { 39 kHll *pHll; 53 kHll * pHll; 54 kFileLX * pFileLX; 40 55 41 56 /* … … 51 66 pHll = new kHll(); 52 67 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 53 77 54 78 … … 117 141 while (pSegDef != NULL) 118 142 { 143 struct o32_obj *pLXObject; 119 144 PSYMDEF32 pSymDef32; /* Symbol definition 32-bit */ 120 145 PSYMDEF16 pSymDef16; /* Symbol definition 16-bit */ … … 160 185 * Add segment to the module - FIXME - need info from the LX Object table... 161 186 */ 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); 163 196 164 197 /* … … 233 266 */ 234 267 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 } 236 278 } 237 279 else … … 290 332 291 333 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)) < 0303 ||304 fseek(phFile, 0, SEEK_END) != 0305 ||306 (cb = ftell(phFile)) < 0307 ||308 fseek(phFile, ipos, SEEK_SET) != 0309 )310 cb = -1;311 return cb;312 }313 314 334 315 335 -
trunk/tools/dbginfo/dbgLXDumper.c
r3244 r3247 1 /* $Id: dbgLXDumper.c,v 1. 3 2000-03-26 21:56:37bird Exp $1 /* $Id: dbgLXDumper.c,v 1.4 2000-03-27 10:20:42 bird Exp $ 2 2 * 3 3 * dbgLXDumper - reads and interprets the debuginfo found in an LX executable. … … 12 12 * Defined Constants And Macros * 13 13 *******************************************************************************/ 14 #define INCL_TYPES15 14 #define INCL_DOSERRORS 16 15 #define FOR_EXEHDR 1 /* exe386.h flag */ 17 16 #define DWORD ULONG /* Used by exe386.h / newexe.h */ 18 17 #define WORD USHORT /* Used by exe386.h / newexe.h */ 18 19 19 20 20 /******************************************************************************* … … 302 302 " ilib %d\n" 303 303 " pad %d\n" 304 " cSegInfo %d\n" 304 305 " usDebugStyle %#04x %c%c\n" 305 306 " HLL Version %d.%d\n" … … 311 312 pModule->iLib, 312 313 pModule->pad, 314 pModule->cSegInfo, 313 315 pModule->usDebugStyle, 314 316 pModule->usDebugStyle & 0xFF, … … 335 337 c = pModule->cSegInfo > 0 ? pModule->cSegInfo : 0; 336 338 paSegInfo = (PHLLSEGINFO)((void*)&pModule->achName[pModule->cchName]); 337 for (j = 0; j < c; j++)339 for (j = 0; j + 1 < c; j++) 338 340 { 339 341 fprintf(phOut, -
trunk/tools/dbginfo/kHll.cpp
r3245 r3247 1 /* $Id: kHll.cpp,v 1. 5 2000-03-27 07:26:54bird Exp $1 /* $Id: kHll.cpp,v 1.6 2000-03-27 10:20:42 bird Exp $ 2 2 * 3 3 * kHll - Implementation of the class kHll. … … 40 40 41 41 42 /******************************************************************************* 43 * Internal Functions * 44 *******************************************************************************/ 45 signed long fsize(FILE *phFile); 42 46 43 47 … … 202 206 cchName = strlen(pszName); 203 207 pModule = (PHLLMODULE)malloc(sizeof(HLLMODULE) + cchName + 204 sizeof(HLLSEGINFO) * m in((cSegInfo - 1), 3));208 sizeof(HLLSEGINFO) * max((cSegInfo - 1), 3)); 205 209 assert(pModule != NULL); 206 210 memset(pModule, 0, sizeof(*pModule)); … … 284 288 else 285 289 { 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]); 288 292 pSegInfo->cb = cb; 289 293 pSegInfo->off = off; … … 374 378 { 375 379 int cch; 380 int cchToWrite; 376 381 int cchWritten = 0; 377 382 … … 383 388 */ 384 389 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) 387 393 return -1; 388 394 cchWritten += cch; … … 789 795 int cch; 790 796 long lPosLXHdr; 797 long cbLXFile; 791 798 792 799 /* … … 796 803 if (cch == sizeof(ehdr)) 797 804 { 805 cbLXFile = fsize(phFile); 798 806 if (ehdr.e_magic == EMAGIC) 799 807 lPosLXHdr = ehdr.e_lfanew; … … 811 819 * Check if there is any debug info. 812 820 */ 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 ) 814 824 { 815 825 long lPosDebug; 816 826 827 if (e32.e32_debuginfo != 0 && e32.e32_debuglen != 0) 828 lPosDebug = e32.e32_debuginfo; 829 else 830 lPosDebug = cbLXFile; 831 817 832 /* 818 * Go to end offile and write debug info.833 * Go to debug info position in the file and write debug info. 819 834 */ 820 if (fseek(phFile, 0, SEEK_END) == 0 821 && 822 (lPosDebug = ftell(phFile)) != -1 823 ) 835 if (fseek(phFile, lPosDebug, SEEK_SET) == 0) 824 836 { 825 837 /* … … 886 898 887 899 888 900 /** 901 * Find the size of a file. 902 * @returns Size of file. -1 on error. 903 * @param phFile File handle. 904 */ 905 signed 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.