Changeset 13909
- Timestamp:
- Apr 7, 2000, 4:47:01 AM (25 years ago)
- Location:
- tags/trunk/tools/dbginfo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tags/trunk/tools/dbginfo/kHll.cpp ¶
r13863 r13909 1 /* $Id: kHll.cpp,v 1. 9 2000-03-31 15:35:09bird Exp $1 /* $Id: kHll.cpp,v 1.10 2000-04-07 02:47:00 bird Exp $ 2 2 * 3 3 * kHll - Implementation of the class kHll. … … 146 146 /** 147 147 * Write this entry to file. 148 * @returns Number of bytes written. 149 * @param phFile File handle. 148 * @returns Count of bytes written (on success). 149 * -3 Invalid offsets. 150 * -2 Seek error. 151 * -1 Write error. 152 * 0 No data written. Concidered as an error! 153 * @param phFile Filehandle. 150 154 */ 151 155 int kHllPubSymEntry::write(FILE *phFile) … … 156 160 offsetof(HLLPUBLICSYM, achName) + pPubSym->cchName, 157 161 phFile); 162 } 163 164 165 166 167 168 169 170 /******************************************************************************* 171 * * 172 * kHllLineNumberChunk * 173 * * 174 * kHllLineNumberChunk * 175 * * 176 *******************************************************************************/ 177 178 179 180 181 int cLines; 182 PHLLLINENUMBERENTRY paLines; 183 HLLFIRSTENTRY FirstEntry; 184 185 /** 186 * Constructor. 187 * @param iSeg Segment number for these linenumbers. 188 * @param offBase Base offset for all line number offsets. (defaults to 0) 189 */ 190 kHllLineNumberChunk::kHllLineNumberChunk( 191 unsigned short int iSeg, 192 unsigned long int offBase /*= 0*/ 193 ) 194 { 195 memset(&FirstEntry, 0, sizeof(FirstEntry)); 196 FirstEntry.hll04.iSeg = iSeg; 197 FirstEntry.hll04.u1.offBase = offBase; 198 FirstEntry.hll04.uchType = 0; 199 } 200 201 202 203 /** 204 * Destructor. 205 */ 206 kHllLineNumberChunk::~kHllLineNumberChunk() 207 { 208 if (paLines != NULL) 209 free(paLines); 210 paLines = 0; 211 FirstEntry.hll04.cEntries = 0; 212 } 213 214 215 216 /** 217 * Adds a line information. 218 * @returns Success indicator. 219 * @param iusFile File index. 220 * @param usLine Line number 221 * @param off Offset into object. 222 */ 223 BOOL kHllLineNumberChunk::addLineInfo( 224 unsigned short int iusFile, 225 unsigned short int usLine, 226 unsigned long int off 227 ) 228 { 229 /* 230 * Allocate more memory? 231 */ 232 if (FirstEntry.hll04.cEntries % 20 == 0) 233 { 234 void *pv = realloc(paLines, (FirstEntry.hll04.cEntries + 20) * sizeof(paLines[0].hll04)); 235 assert(pv != NULL); 236 if (pv == NULL) 237 return FALSE; 238 paLines = (PHLLLINENUMBERENTRY)pv; 239 } 240 241 /* 242 * Add line info entry. 243 */ 244 paLines[FirstEntry.hll04.cEntries].hll04.iusSourceFile = iusFile; 245 paLines[FirstEntry.hll04.cEntries].hll04.off = off; 246 paLines[FirstEntry.hll04.cEntries].hll04.usLine = usLine; 247 FirstEntry.hll04.cEntries++; 248 249 return FALSE; 250 } 251 252 253 /** 254 * Write this entry to file. 255 * @returns Count of bytes written (on success). 256 * -3 Invalid offsets. 257 * -2 Seek error. 258 * -1 Write error. 259 * 0 No data written. Concidered as an error! 260 * @param phFile Filehandle. 261 */ 262 int kHllLineNumberChunk::write(FILE *phFile) 263 { 264 int cb; 265 int cbWritten; 266 267 /* 268 * First entry 269 */ 270 cb = sizeof(paLines[0])*FirstEntry.hll04.cEntries; 271 cbWritten = fwrite(&FirstEntry, 1, cb, phFile); 272 if (cbWritten != cb) 273 return -1; 274 275 /* 276 * Line array. 277 */ 278 cb = sizeof(paLines[0])*FirstEntry.hll04.cEntries; 279 cbWritten = fwrite(paLines, 1, cb, phFile); 280 if (cbWritten != cb) 281 return -1; 282 283 return cbWritten + sizeof(FirstEntry.hll04); 284 } 285 286 287 288 289 290 /******************************************************************************* 291 * * 292 * kHllSrcEntry * 293 * * 294 * kHllSrcEntry * 295 * * 296 *******************************************************************************/ 297 298 299 300 301 302 /** 303 * Constructor. 304 */ 305 kHllSrcEntry::kHllSrcEntry() 306 : 307 cFilenames(0), 308 pachFilenames(NULL), 309 cbFilenames(0), 310 cbFilenamesAllocated(0) 311 { 312 } 313 314 315 /** 316 * Destructor. 317 */ 318 kHllSrcEntry::~kHllSrcEntry() 319 { 320 if (pachFilenames != NULL) 321 free(pachFilenames); 322 pachFilenames = NULL; 323 cFilenames = cbFilenames = cbFilenamesAllocated = 0; 324 } 325 326 327 328 /** 329 * Add/queries a Linenumber chunk. 330 * A linenumber chunk is a collection of linenumber information for a 331 * module segement. 332 * @returns Pointer to linenumber chunk which you may add linenumber info to. 333 * NULL on failiure. 334 * @param iSeg Segment number for these linenumbers. 335 * @param offBase Base offset for all line number offsets. (defaults to 0) 336 */ 337 kHllLineNumberChunk * 338 kHllSrcEntry::addLineNumberChunk( 339 unsigned short int iSeg, 340 unsigned long int offBase/* = 0*/ 341 ) 342 { 343 kHllLineNumberChunk *pChunk; 344 345 /* 346 * Try find existing chunk. 347 */ 348 pChunk = Lines.getFirst(); 349 while (pChunk != NULL && pChunk->getSeg() != iSeg) 350 pChunk = (kHllLineNumberChunk*)pChunk->getNext(); 351 352 /* 353 * If not found, then create a new one and add it to the list. 354 */ 355 if (pChunk != NULL) 356 { 357 pChunk = new kHllLineNumberChunk(iSeg, offBase); 358 assert(pChunk != NULL); 359 if (pChunk != NULL) 360 Lines.insert(pChunk); 361 } 362 363 return pChunk; 364 } 365 366 367 368 /** 369 * Adds a file for this module. 370 * @returns Filename index used when adding linenumbers. 371 * @param pszFilename Pointer to filaname string. 372 */ 373 unsigned short kHllSrcEntry::addFile( 374 const char * pszFilename 375 ) 376 { 377 return addFile(pszFilename, strlen(pszFilename)); 378 } 379 380 381 382 /** 383 * Adds a file for this module. 384 * @returns Filename index used when adding linenumbers. 385 * 0 on error. 386 * @param pachFilename Pointer to filaname string (not zero terminated). 387 * @param cchFilename Length of filename. 388 */ 389 unsigned short kHllSrcEntry::addFile( 390 const char * pachFilename, 391 int cchFilename 392 ) 393 { 394 assert(pachFilename != NULL); 395 assert(cchFilename < 256); 396 if (cchFilename >= 256) 397 cchFilename = 255; 398 399 /* 400 * Allocate more memory? 401 */ 402 if ((cbFilenames + cchFilename + 1) >= cbFilenamesAllocated) 403 { 404 void *pv = realloc(pachFilenames, cbFilenamesAllocated + 256); 405 assert(pv != NULL); 406 if (pv == NULL) 407 return 0; 408 pachFilenames = (char*)pv; 409 cbFilenamesAllocated += 256; 410 } 411 412 413 /* 414 * Add filename 415 */ 416 pachFilenames[cbFilenames++] = cchFilename; 417 memcpy(&pachFilenames[cbFilenames], pachFilename, cchFilename); 418 cbFilenames += cchFilename; 419 420 return ++cFilenames; 421 } 422 423 424 425 /** 426 * Write this entry to file. 427 * @returns Count of bytes written (on success). 428 * -3 Invalid offsets. 429 * -2 Seek error. 430 * -1 Write error. 431 * 0 No data written. Concidered as an error! 432 * @param phFile Filehandle. 433 */ 434 int kHllSrcEntry::write(FILE *phFile) 435 { 436 HLLFIRSTENTRY FirstEntry; 437 HLLFILENAMEENTRY FilenameEntry; 438 int cb; 439 int cbWrote; 440 int cbWritten; 441 442 /* 443 * Filenames - if no filename present we'll add a dummy filename! 444 * First entry for the filenames. 445 * Filename entry header. 446 * Write filename entries. 447 */ 448 FirstEntry.hll04.usLine = 0; 449 FirstEntry.hll04.uchType = 3; /* filename */ 450 FirstEntry.hll04.uchReserved = 0; 451 FirstEntry.hll04.cEntries = max(cFilenames, 1); 452 FirstEntry.hll04.iSeg = 0; 453 FirstEntry.hll04.u1.cbFileNameTable = cbFilenames > 0 ? cbFilenames : 8; 454 cb = sizeof(FirstEntry.hll04); 455 cbWritten = cbWrote = fwrite(&FirstEntry, 1, cb, phFile); 456 if (cb != cbWrote) 457 return -1; 458 459 FilenameEntry.cSourceFiles = max(cFilenames, 1); 460 FilenameEntry.offSource = 0; 461 FilenameEntry.cSourceRecords = 0; 462 cb = offsetof(HLLFILENAMEENTRY, cchName); 463 cbWritten += cbWrote = fwrite(&FilenameEntry, 1, cb, phFile); 464 if (cbWrote != cb) 465 return -1; 466 467 if (cbFilenames > 0) 468 { 469 cbWritten += cbWrote = fwrite(pachFilenames, 1, cbFilenames, phFile); 470 if (cbWrote != cbFilenames) 471 return -1; 472 } 473 else 474 { /* no filename - write dummy empty */ 475 cbWritten += cbWrote = fwrite("\07dummy.c", 1, 8, phFile); 476 if (cbWrote != 8) 477 return -1; 478 } 479 480 481 /* 482 * Write linenumbers. 483 */ 484 if (Lines.getFirst() != NULL) 485 { 486 cbWritten += cbWrote = kHllBaseEntry::writeList(phFile, Lines.getFirst()); 487 if (cbWrote < 0) 488 return cbWrote; 489 } 490 491 return cbWritten; 158 492 } 159 493 … … 369 703 /** 370 704 * Write this HLL entry to file. 371 * @returns Count of bytes written. -1 on error. 705 * @returns Count of bytes written. 706 * -3 Invalid offsets. 707 * -2 Seek error. 708 * -1 Write error. 372 709 * @param phFile Filehandle. 373 710 * @param off Current offset into the HLL data. … … 425 762 cchWritten += cch; 426 763 off += cch; 764 */ 427 765 428 766 offSource = off; 429 cbSource = cch = kHllBaseEntry::writeList(phFile, Source.getFirst());767 cbSource = cch = Source.write(phFile); 430 768 if (cch < 0) 431 769 return cch; 432 770 cchWritten += cch; 433 771 off += cch; 434 */435 772 436 773 /* … … 519 856 cchWritten += cch; 520 857 } 858 */ 521 859 522 860 if (cbSource > 0) … … 532 870 } 533 871 534 */535 872 536 873 return cchWritten; -
TabularUnified tags/trunk/tools/dbginfo/kHll.h ¶
r13900 r13909 1 /* $Id: kHll.h,v 1. 6 2000-04-05 18:45:21 bird Exp $1 /* $Id: kHll.h,v 1.7 2000-04-07 02:47:01 bird Exp $ 2 2 * 3 3 * kHll - Declarations of the class kHll. … … 67 67 68 68 /** 69 * Linenumber chunk. 70 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 71 */ 72 class kHllLineNumberChunk : public kHllBaseEntry 73 { 74 private: 75 PHLLLINENUMBERENTRY paLines; 76 HLLFIRSTENTRY FirstEntry; 77 78 public: 79 kHllLineNumberChunk( 80 unsigned short int iSeg, 81 unsigned long int offBase = 0 82 ); 83 ~kHllLineNumberChunk(); 84 85 BOOL addLineInfo( 86 unsigned short int iusFile, 87 unsigned short int usLine, 88 unsigned long int off 89 ); 90 91 int write(FILE *phFile); 92 int getSeg() { return FirstEntry.hll04.iSeg; } 93 }; 94 95 96 /** 69 97 * HLL Source entry. 70 * @shortdesc 71 * @dstruct 72 * @version 73 * @verdesc 74 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 75 * @approval 98 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 76 99 */ 77 100 class kHllSrcEntry 78 101 { 79 102 private: 80 int cFilenames; 81 char * pchFilenames; 82 83 int cLines; 84 HLLLINENUMBERENTRY paLines; 85 86 public: 87 103 unsigned long int cFilenames; 104 char * pachFilenames; 105 unsigned long int cbFilenames; 106 unsigned long int cbFilenamesAllocated; 107 108 kList<kHllLineNumberChunk> 109 Lines; 110 111 public: 112 kHllSrcEntry(); 88 113 ~kHllSrcEntry(); 89 114 90 BOOL addLineInfo( 91 int iFile, 92 int iLine, 93 unsigned short int iObject, 94 unsigned long int off 95 ); 96 int addFile( 97 const char * pszFilename, 98 99 ); 100 115 kHllLineNumberChunk * 116 addLineNumberChunk( 117 unsigned short int iSeg, 118 unsigned long int offBase = 0 119 ); 120 unsigned short addFile( 121 const char * pszFilename 122 ); 123 unsigned short addFile( 124 const char * pachFilename, 125 int cchFilename 126 ); 101 127 int write(FILE *phFile); 102 128 }; … … 123 149 kList<kHllTypeEntry> Types; 124 150 kList<kHllSymEntry> Symbols; 125 kList<kHllSrcEntry> Source;126 151 */ 152 kHllSrcEntry Source; 127 153 128 154 BOOL fValidOffsetsAndSizes; … … 180 206 const void * pvType 181 207 ); 208 kHllSrcEntry * getSourceEntry() { return &Source; } 182 209 183 210
Note:
See TracChangeset
for help on using the changeset viewer.