- Timestamp:
- Nov 1, 2006, 1:12:16 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tools/qsysxcpt_pm.cpp
r147 r148 212 212 BOOL bQueryMem = TRUE ) 213 213 { 214 fprintf( file, " <Register name=\"%s\" value=\"%08lX\"",214 fprintf( file, " <Register name=\"%s\" value=\"%08lX\"", 215 215 pszName, ulValue ); 216 216 … … 238 238 { 239 239 fprintf( file, ">\n" ); 240 qt_excWriteErrorMsg( file, 6, "DosQueryMem returned %lu"240 qt_excWriteErrorMsg( file, 7, "DosQueryMem returned %lu" 241 241 "and flags %08lX", arc, ulFlags ); 242 fprintf( file, " </Register>\n" );242 fprintf( file, " </Register>\n" ); 243 243 } 244 244 } … … 258 258 ulOffset = 0; 259 259 260 fprintf (file, " <Frame pointer=\"%08lX\">\n", ulRegEbp);261 fprintf (file, " <Location address=\"%08lX\">\n", ulRegEip);260 fprintf (file, " <Frame pointer=\"%08lX\">\n", ulRegEbp); 261 fprintf (file, " <Location address=\"%08lX\">\n", ulRegEip); 262 262 263 263 arc = DosQueryModFromEIP (&hMod, &ulObject, … … 266 266 267 267 if (arc != NO_ERROR) 268 qt_excWriteErrorMsg (file, 7, "%s: DosQueryModFromEIP returned %lu",268 qt_excWriteErrorMsg (file, 8, "%s: DosQueryModFromEIP returned %lu", 269 269 szMod, arc); 270 270 else 271 fprintf (file, " <Module ID=\"%04lX\" segment=\"%04lX\" "272 "offset=\"%08lX\"/>\n",271 fprintf (file, " <Module ID=\"%04lX\" segment=\"%04lX\" " 272 "offset=\"%08lX\"/>\n", 273 273 hMod, ulObject + 1, ulOffset); 274 274 … … 308 308 } 309 309 } 310 fprintf (file, " <Dump address=\"%08lX\">\n", pch);310 fprintf (file, " <Dump address=\"%08lX\">\n ", pch); 311 311 if (arc == NO_ERROR && 312 312 ulFlags & (PAG_COMMIT|PAG_READ) == (PAG_COMMIT | PAG_READ)) … … 320 320 qt_excWriteErrorMsg (file, 0, "%08lX: DosQueryMem returned %lu" 321 321 "and flags %08lX", pch, arc, ulFlags); 322 fprintf (file, " </Dump>\n");323 } 324 325 fprintf (file, " </Location>\n");326 fprintf (file, " </Frame>\n");322 fprintf (file, " </Dump>\n"); 323 } 324 325 fprintf (file, " </Location>\n"); 326 fprintf (file, " </Frame>\n"); 327 327 } 328 328 … … 336 336 ULONG ulRegEip = pContextRec->ctx_RegEip; 337 337 338 fprintf (file, " <Frames>\n");338 fprintf (file, " <Frames>\n"); 339 339 340 340 /* first the trapping address itself */ … … 362 362 != (PAG_COMMIT|PAG_READ))) 363 363 { 364 fprintf (file, " <Frame pointer=\"%08lX\">\n", ulRegEbp);365 qt_excWriteErrorMsg (file, 6, "DosQueryMem returned %lu "364 fprintf (file, " <Frame pointer=\"%08lX\">\n", ulRegEbp); 365 qt_excWriteErrorMsg (file, 7, "DosQueryMem returned %lu " 366 366 "and flags %08lX", arc, ulFlags); 367 fprintf (file, " </Frame>\n");367 fprintf (file, " </Frame>\n"); 368 368 /* try go to the next page */ 369 369 /// @todo (r=dmik) I don't know how much it is accurate, … … 380 380 } 381 381 382 fprintf (file, " </Frames>\n");382 fprintf (file, " </Frames>\n"); 383 383 } 384 384 … … 393 393 if (ptib) 394 394 { 395 fprintf (file, " <Thread ID=\"%04lX\" slot=\"%04lX\" "396 "priority=\"%04lX\" ",395 fprintf (file, " <Thread ID=\"%04lX\" slot=\"%04lX\" " 396 "priority=\"%04lX\" ", 397 397 ptib->tib_ptib2->tib2_ultid, ptib->tib_ordinal, 398 398 ptib->tib_ptib2->tib2_ulpri); … … 405 405 else 406 406 { 407 fprintf (file, " <Thread ID=\"%04lX\" slot=\"%04lX\" "408 "priority=\"%04lX\" state=\"%02lX\">\n",407 fprintf (file, " <Thread ID=\"%04lX\" slot=\"%04lX\" " 408 "priority=\"%04lX\" state=\"%02lX\">\n", 409 409 pThrdRec->tid, pThrdRec->slot, pThrdRec->priority, 410 410 pThrdRec->state); … … 413 413 /* *** registers */ 414 414 415 fprintf (file, " <CPU>\n"416 " <Registers>\n");415 fprintf (file, " <CPU>\n" 416 " <Registers>\n"); 417 417 418 418 if (pContextRec->ContextFlags & CONTEXT_SEGMENTS) … … 444 444 } 445 445 446 fprintf (file, " </Registers>\n"447 " </CPU>\n");446 fprintf (file, " </Registers>\n" 447 " </CPU>\n"); 448 448 449 449 /* *** stack */ 450 450 451 fprintf (file, " <Stack base=\"%08lX\" limit=\"%08lX\">\n",451 fprintf (file, " <Stack base=\"%08lX\" limit=\"%08lX\">\n", 452 452 (ULONG) ptib->tib_pstack, 453 453 (ULONG) ptib->tib_pstacklimit); … … 458 458 } 459 459 460 fprintf (file, " </Stack>\n" 461 " </Thread>\n"); 462 } 463 464 typedef struct _PROCESSINFO 465 { 466 /* common values */ 467 char *pszFullName; 468 char *pszBaseName; 469 /* direct info pointers */ 470 PPIB ppib; 471 PTIB ptib; 472 BOOL bHaveSysState; /**< TRUE when both pProcRec and pLibRec are not NULL */ 473 QSPREC *pProcRec; /**< NULL when bHaveSysState is FALSE */ 474 QSLREC *pLibRec; /**< NULL when bHaveSysState is FALSE */ 475 } PROCESSINFO; 460 fprintf (file, " </Stack>\n" 461 " </Thread>\n"); 462 } 463 464 #ifndef max 465 #define max(a,b) (((a) > (b)) ? (a) : (b)) 466 #endif 467 468 /** @internal 469 * Writes the module description string (if found) as the 'desciption' 470 * attribute. Returns TRUE if the description was found and written. 471 */ 472 static BOOL qt_excWriteModuleDesc (FILE *file, char *pszFileName) 473 { 474 /* see OS2TK\h\exe.h, OS2TK\h\exe386.h and LXSPEC.INF for details */ 475 enum { EXEID = 0x5a4d, LXOffset = 0x3C, sizeof_exe = LXOffset + 4, 476 E32MAGIC = 0x584c, e32_nrestab = 34 * 4, 477 sizeof_e32 = e32_nrestab + 4, 478 max_nresname = 255 + 1 /* trailing 0 */ }; 479 480 UCHAR achBuf [max (max_nresname, max (sizeof_e32, sizeof_exe))]; 481 482 BOOL bFound = FALSE; 483 ULONG ul1 = 0, ul2 = 0; 484 485 HFILE hf = NULL; 486 APIRET arc = NO_ERROR; 487 488 arc = DosOpen (pszFileName, &hf, &ul1, 489 0, 0, OPEN_ACTION_OPEN_IF_EXISTS, 490 OPEN_SHARE_DENYWRITE | OPEN_ACCESS_READONLY, 491 NULL); 492 if (arc != NO_ERROR) 493 return FALSE; 494 495 do 496 { 497 /* read the old EXE header plus the offset to the LX header */ 498 arc = DosRead (hf, achBuf, sizeof_exe, &ul1); 499 if (arc != NO_ERROR || sizeof_exe != ul1) 500 break; 501 502 if (*(USHORT *) &achBuf == EXEID) 503 { 504 /* go to the LX header */ 505 ul1 = *(ULONG *) &achBuf [LXOffset]; 506 arc = DosSetFilePtr (hf, (LONG) ul1, FILE_BEGIN, &ul2); 507 if (arc != NO_ERROR || ul1 != ul2) 508 break; 509 510 /* read it upto the e32_nrestab field */ 511 arc = DosRead (hf, achBuf, sizeof_e32, &ul1); 512 if (arc != NO_ERROR || sizeof_e32 != ul1 || 513 *(USHORT *) &achBuf != E32MAGIC) 514 break; 515 } 516 else 517 if (*(USHORT *) &achBuf == E32MAGIC) 518 { 519 /* there may be no old EXE header, but LX only, 520 * read it upto the e32_nrestab field */ 521 if (sizeof_e32 > sizeof_exe) 522 { 523 arc = DosRead (hf, achBuf + sizeof_exe, 524 sizeof_e32 - sizeof_exe, &ul1); 525 if (arc != NO_ERROR || sizeof_e32 - sizeof_exe != ul1) 526 break; 527 } 528 } 529 else 530 break; 531 532 /* go to the beginning of the non-resident name table */ 533 ul1 = *(ULONG *) &achBuf [e32_nrestab]; 534 if (ul1) 535 { 536 arc = DosSetFilePtr (hf, (LONG) ul1, FILE_BEGIN, &ul2); 537 if (arc != NO_ERROR || ul1 != ul2) 538 break; 539 540 /* read the first entry */ 541 arc = DosRead (hf, achBuf, max_nresname, &ul1); 542 if (arc != NO_ERROR || max_nresname != ul1) 543 break; 544 545 /* if the ordinal is 0, then it's a description field (we don't do 546 * the full table search, since it shoud be ordered by ordinals) */ 547 if (*(USHORT *) &achBuf [1 + *achBuf] == 0) 548 { 549 /* place the trailing zero */ 550 achBuf [1 + *achBuf] = 0; 551 /* write the description attribute */ 552 fprintf (file, "\n desc=\"%s\"", achBuf + 1); 553 bFound = TRUE; 554 } 555 } 556 } 557 while (0); 558 559 DosClose (hf); 560 return bFound; 561 } 476 562 477 563 /*! \internal … … 484 570 { 485 571 static const char *apszOrigins[] = { "self", "imported", "loaded" }; 572 573 FILESTATUS3 Status; 574 APIRET arc = NO_ERROR; 486 575 487 576 fprintf (file, " <Module ID=%\"%04lX\" name=\"", hmte); 488 577 qt_excEscapeString (file, pszName); 489 if (ulOrigin >= 1 && ulOrigin <= 3) 490 fprintf (file, "\"\n" 491 " origin=\"%s\"/>\n", 492 apszOrigins [ulOrigin - 1]); 493 else 494 fprintf (file, "\"/>\n"); 578 fprintf (file, "\""); 579 580 arc = DosQueryPathInfo (pszName, FIL_STANDARD, &Status, sizeof (Status)); 581 582 if ((ulOrigin >= 1 && ulOrigin <= 3) || arc == NO_ERROR ) 583 { 584 fprintf (file, "\n "); 585 if (ulOrigin >= 1 && ulOrigin <= 3) 586 fprintf (file, " origin=\"%s\"", 587 apszOrigins [ulOrigin - 1]); 588 if (arc == NO_ERROR) 589 fprintf (file, " timestamp=\"%04d-%02d-%02dT%02d:%02d:%02d\"", 590 Status.fdateLastWrite.year + 1980, 591 Status.fdateLastWrite.month, Status.fdateLastWrite.day, 592 Status.ftimeLastWrite.hours, Status.ftimeLastWrite.minutes, 593 Status.ftimeLastWrite.twosecs * 2); 594 } 595 596 qt_excWriteModuleDesc (file, pszName); 597 598 fprintf (file, "/>\n"); 495 599 } 496 600 … … 525 629 } 526 630 527 /** Struct for recursive qt_excWriteModulesOnStack() to reduce stack usage */ 631 /** @internal 632 * Struct for recursive qt_excWriteModulesOnStack() to reduce stack usage 633 */ 528 634 typedef struct _WMOS_STATE 529 635 { … … 621 727 } 622 728 } 729 730 /** @internal Simple process info struct */ 731 typedef struct _PROCESSINFO 732 { 733 /* common values */ 734 char *pszFullName; 735 char *pszBaseName; 736 /* direct info pointers */ 737 PPIB ppib; 738 PTIB ptib; 739 BOOL bHaveSysState; /**< TRUE when both pProcRec and pLibRec are not NULL */ 740 QSPREC *pProcRec; /**< NULL when bHaveSysState is FALSE */ 741 QSLREC *pLibRec; /**< NULL when bHaveSysState is FALSE */ 742 } PROCESSINFO; 623 743 624 744 /*! \internal … … 1014 1134 1015 1135 fprintf (file, 1016 "<Trap timestamp=\"%04d-%02d-%02dT%02d:%02d:%02d %c%02d:%02d\""1017 "version=\"1.0\"\n"1136 "<Trap timestamp=\"%04d-%02d-%02dT%02d:%02d:%02d\"" //%c%02d:%02d\"" 1137 " version=\"1.0\"\n" 1018 1138 " generator=\"Qt Library Version %s\"\n" 1019 1139 " xmlns=\"http://db.hugaida.com/xml/os2/sys/Trap\">\n", 1020 1140 dt.year, dt.month, dt.day, 1021 1141 dt.hours, dt.minutes, dt.seconds, 1022 (dt.timezone > 0 ? '-' : '+'),1023 abs (dt.timezone / 60),1024 abs (dt.timezone % 60),1025 QT_VERSION_STR 1142 //(dt.timezone > 0 ? '-' : '+'), 1143 //abs (dt.timezone / 60), 1144 //abs (dt.timezone % 60), 1145 QT_VERSION_STR); 1026 1146 1027 1147 XcptPvt::file = file;
Note:
See TracChangeset
for help on using the changeset viewer.