Changeset 2955 for trunk/kLdr/tstkLdrMod.c
- Timestamp:
- Feb 7, 2007, 8:07:16 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kLdr/tstkLdrMod.c
r2899 r2955 116 116 rc = kLdrModGetBits(pMod, pvBits2, (uintptr_t)pvBits, BasicTestsGetImport, NULL); 117 117 if (rc) 118 return Failure("failed to get image bits, rc=%d ( a)", rc);118 return Failure("failed to get image bits, rc=%d (%s) (a)", rc, kLdrErrStr(rc)); 119 119 if (TestMemComp(pvBits2, pvBits, cbImage)) 120 120 return Failure("relocation test failed, mismatching bits (a)"); … … 125 125 rc = kLdrModRelocateBits(pMod, pvBits2, 0x1000, (uintptr_t)pvBits, BasicTestsGetImport, NULL); 126 126 if (rc) 127 return Failure("failed to relocate, rc=%d ( b1)");127 return Failure("failed to relocate, rc=%d (%s) (b1)", rc, kLdrErrStr(rc)); 128 128 rc = kLdrModRelocateBits(pMod, pvBits2, (uintptr_t)pvBits, 0x1000, BasicTestsGetImport, NULL); 129 129 if (rc) 130 return Failure("failed to relocate, rc=%d ( b2)");130 return Failure("failed to relocate, rc=%d (%s) (b2)", rc, kLdrErrStr(rc)); 131 131 if (TestMemComp(pvBits2, pvBits, cbImage)) 132 132 return Failure("relocation test failed, mismatching bits (b)"); … … 138 138 rc = kLdrModRelocateBits(pMod, pvBits, 0x1000000, (uintptr_t)pvBits, BasicTestsGetImport, NULL); 139 139 if (rc) 140 return Failure("failed to relocate, rc=%d ( c1)");140 return Failure("failed to relocate, rc=%d (%s) (c1)", rc, kLdrErrStr(rc)); 141 141 memset(pvBits2, 0xfe, cbImage); 142 142 rc = kLdrModGetBits(pMod, pvBits2, 0x1000000, BasicTestsGetImport, NULL); 143 143 if (rc) 144 return Failure("failed to get image bits, rc=%d ( c1)", rc);144 return Failure("failed to get image bits, rc=%d (%s) (c1)", rc, kLdrErrStr(rc)); 145 145 if (TestMemComp(pvBits2, pvBits, cbImage)) 146 146 return Failure("relocation test failed, mismatching bits (c1)"); … … 149 149 rc = kLdrModRelocateBits(pMod, pvBits, ~(uintptr_t)0x1010000, 0x1000000, BasicTestsGetImport, NULL); 150 150 if (rc) 151 return Failure("failed to relocate, rc=%d ( c2)");151 return Failure("failed to relocate, rc=%d (%s) (c2)", rc, kLdrErrStr(rc)); 152 152 memset(pvBits2, 0xef, cbImage); 153 153 rc = kLdrModGetBits(pMod, pvBits2, ~(uintptr_t)0x1010000, BasicTestsGetImport, NULL); 154 154 if (rc) 155 return Failure("failed to get image bits, rc=%d ( c2)", rc);155 return Failure("failed to get image bits, rc=%d (%s) (c2)", rc, kLdrErrStr(rc)); 156 156 if (TestMemComp(pvBits2, pvBits, cbImage)) 157 157 return Failure("relocation test failed, mismatching bits (c2)"); … … 160 160 rc = kLdrModRelocateBits(pMod, pvBits, MY_BASEADDRESS, ~(uintptr_t)0x1010000, BasicTestsGetImport, NULL); 161 161 if (rc) 162 return Failure("failed to relocate, rc=%d ( c3)");162 return Failure("failed to relocate, rc=%d (%s) (c3)", rc, kLdrErrStr(rc)); 163 163 memset(pvBits2, 0xef, cbImage); 164 164 rc = kLdrModGetBits(pMod, pvBits2, MY_BASEADDRESS, BasicTestsGetImport, NULL); 165 165 if (rc) 166 return Failure("failed to get image bits, rc=%d ( c3)", rc);166 return Failure("failed to get image bits, rc=%d (%s) (c3)", rc, kLdrErrStr(rc)); 167 167 if (TestMemComp(pvBits2, pvBits, cbImage)) 168 168 return Failure("relocation test failed, mismatching bits (c3)"); … … 171 171 rc = kLdrModRelocateBits(pMod, pvBits, ~(uintptr_t)0 / 2 - 0x10000, MY_BASEADDRESS, BasicTestsGetImport, NULL); 172 172 if (rc) 173 return Failure("failed to relocate, rc=%d (c4)");173 return Failure("failed to relocate, rc=%d %(s) (c4)", rc, kLdrErrStr(rc)); 174 174 memset(pvBits2, 0xdc, cbImage); 175 175 rc = kLdrModGetBits(pMod, pvBits2, ~(uintptr_t)0 / 2 - 0x10000, BasicTestsGetImport, NULL); 176 176 if (rc) 177 return Failure("failed to get image bits, rc=%d ( c4)", rc);177 return Failure("failed to get image bits, rc=%d (%s) (c4)", rc, kLdrErrStr(rc)); 178 178 if (TestMemComp(pvBits2, pvBits, cbImage)) 179 179 return Failure("relocation test failed, mismatching bits (c4)"); … … 182 182 rc = kLdrModRelocateBits(pMod, pvBits, (uintptr_t)pvBits, ~(uintptr_t)0 / 2 - 0x10000, BasicTestsGetImport, NULL); 183 183 if (rc) 184 return Failure("failed to relocate, rc=%d ( c5)");184 return Failure("failed to relocate, rc=%d (%s) (c5)", rc, kLdrErrStr(rc)); 185 185 memset(pvBits2, 0xcd, cbImage); 186 186 rc = kLdrModGetBits(pMod, pvBits2, (uintptr_t)pvBits, BasicTestsGetImport, NULL); 187 187 if (rc) 188 return Failure("failed to get image bits, rc=%d ( c5)", rc);188 return Failure("failed to get image bits, rc=%d (%s) (c5)", rc, kLdrErrStr(rc)); 189 189 if (TestMemComp(pvBits2, pvBits, cbImage)) 190 190 return Failure("relocation test failed, mismatching bits (c5)"); … … 216 216 &uValue2, &fKind2); 217 217 if (rc) 218 return Failure("Couldn't find symbol %#x (%.*s) by ordinal. rc=%d ", iSymbol, cchSymbol, pchSymbol, rc);218 return Failure("Couldn't find symbol %#x (%.*s) by ordinal. rc=%d (%s)", iSymbol, cchSymbol, pchSymbol, rc, kLdrErrStr(rc)); 219 219 if (uValue != uValue2) 220 220 return Failure("Symbol %#x (%.*s): Value mismatch %016" PRI_KLDRADDR " != %016" PRI_KLDRADDR " (enum!=query/ord) pvBits=%p", … … 231 231 NULL, NULL, &uValue2, &fKind2); 232 232 if (rc) 233 return Failure("Couldn't find symbol %#x (%.*s) by name. rc=%d ", iSymbol, cchSymbol, pchSymbol, rc);233 return Failure("Couldn't find symbol %#x (%.*s) by name. rc=%d (%s)", iSymbol, cchSymbol, pchSymbol, rc, kLdrErrStr(rc)); 234 234 if (uValue != uValue2) 235 235 return Failure("Symbol %#x (%.*s): Value mismatch %016" PRI_KLDRADDR " != %016" PRI_KLDRADDR " (enum!=query/name) pvBits=%p", … … 292 292 rc = kLdrModGetImport(pMod, pvBits, i, szImportModule, sizeof(szImportModule)); 293 293 if (rc) 294 return Failure("failed to get import module name, rc=%d . (%.260s)", rc, szImportModule);294 return Failure("failed to get import module name, rc=%d (%s). (%.260s)", rc, kLdrErrStr(rc), szImportModule); 295 295 printf("import #%d: '%s'\n", i, szImportModule); 296 296 } … … 305 305 rc = kLdrModGetStackInfo(pMod, pvBits, MY_BASEADDRESS, &StackInfo); 306 306 if (rc) 307 return Failure("kLdrModGetStackInfo failed with rc=%d ", rc);307 return Failure("kLdrModGetStackInfo failed with rc=%d (%s)", rc, kLdrErrStr(rc)); 308 308 printf("Stack: Address=%016" PRI_KLDRADDR " LinkAddress=%016" PRI_KLDRADDR "\n" 309 309 " cbStack=%016" PRI_KLDRSIZE " cbStackThread=%016" PRI_KLDRSIZE "\n", … … 324 324 rc = kLdrModQueryMainEntrypoint(pMod, pvBits, MY_BASEADDRESS, &MainEPAddress); 325 325 if (rc) 326 return Failure("kLdrModQueryMainEntrypoint failed with rc=%d ", rc);326 return Failure("kLdrModQueryMainEntrypoint failed with rc=%d (%s)", rc, kLdrErrStr(rc)); 327 327 printf("Entrypoint: %016" PRI_KLDRADDR "\n", MainEPAddress); 328 328 if (MainEPAddress == ~(KLDRADDR)42) … … 342 342 printf("NO Debugger Information\n"); 343 343 else 344 return Failure("kLdrModHasDbgInfo failed with rc=%d ", rc);344 return Failure("kLdrModHasDbgInfo failed with rc=%d (%s)", rc, kLdrErrStr(rc)); 345 345 rc = kLdrModEnumDbgInfo(pMod, pvBits, BasicTestEnumDbgInfoCallback, NULL); 346 346 if (rc) 347 return Failure("kLdrModEnumDbgInfo failed with rc=%d ", rc);347 return Failure("kLdrModEnumDbgInfo failed with rc=%d (%s)", rc, kLdrErrStr(rc)); 348 348 349 349 … … 381 381 rc = kLdrModEnumSymbols(pMod, pvBits, MY_BASEADDRESS, 0, BasicTestsEnumSymCallback, pvBits); 382 382 if (rc) 383 return Failure("kLdrModEnumSymbols failed with rc=%d ", rc);383 return Failure("kLdrModEnumSymbols failed with rc=%d (%s)", rc, kLdrErrStr(rc)); 384 384 385 385 … … 490 490 rc = kLdrModGetBits(pMod, pvBits, (uintptr_t)pvBits, BasicTestsGetImport, NULL); 491 491 if (rc) 492 return Failure("failed to get image bits, rc=%d ", rc);492 return Failure("failed to get image bits, rc=%d (%s)", rc, kLdrErrStr(rc)); 493 493 494 494 /* … … 525 525 rc = kLdrModFixupMapping(pMod, BasicTestsGetImport, NULL); 526 526 if (rc) 527 return Failure("kLdrModFixupMapping (a) failed, rc=%d ", rc);527 return Failure("kLdrModFixupMapping (a) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 528 528 529 529 rc = kLdrModReload(pMod); 530 530 if (rc) 531 return Failure("kLdrModReload (a) failed, rc=%d ", rc);531 return Failure("kLdrModReload (a) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 532 532 533 533 rc = kLdrModReload(pMod); 534 534 if (rc) 535 return Failure("kLdrModReload (b) failed, rc=%d ", rc);535 return Failure("kLdrModReload (b) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 536 536 537 537 rc = kLdrModFixupMapping(pMod, BasicTestsGetImport, NULL); 538 538 if (rc) 539 return Failure("kLdrModFixupMapping (b) failed, rc=%d ", rc);539 return Failure("kLdrModFixupMapping (b) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 540 540 541 541 rc = kLdrModAllocTLS(pMod); 542 542 if (rc) 543 return Failure("kLdrModAllocTLS (a) failed, rc=%d ", rc);543 return Failure("kLdrModAllocTLS (a) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 544 544 kLdrModFreeTLS(pMod); 545 545 546 546 rc = kLdrModAllocTLS(pMod); 547 547 if (rc) 548 return Failure("kLdrModAllocTLS (b) failed, rc=%d ", rc);548 return Failure("kLdrModAllocTLS (b) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 549 549 kLdrModFreeTLS(pMod); 550 550 … … 555 555 rc = BasicTestsSub2(pMod, NULL); 556 556 if (rc) 557 return Failure("BasicTestsSub2 in Map2 failed, rc=%d ", rc);557 return Failure("BasicTestsSub2 in Map2 failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 558 558 return 0; 559 559 } … … 570 570 rc = kLdrModMap(pMod); 571 571 if (rc) 572 return Failure("kLdrModMap failed, rc=%d ", rc);572 return Failure("kLdrModMap failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 573 573 rc = BasicTestsSubMap2(pMod); 574 574 rc2 = kLdrModUnmap(pMod); 575 575 if (rc2) 576 576 { 577 Failure("kLdrModUnmap failed, rc=%d ", rc2);577 Failure("kLdrModUnmap failed, rc=%d (%s)", rc2, kLdrErrStr(rc2)); 578 578 rc = rc ? rc : rc2; 579 579 } … … 603 603 rc2 = kLdrModClose(pMod); 604 604 if (rc2) 605 Failure("failed to close '%s', rc=%d ", pszFilename, rc);605 Failure("failed to close '%s', rc=%d (%s)", pszFilename, rc, kLdrErrStr(rc)); 606 606 if (rc2 && !rc) 607 607 rc = rc2; 608 608 } 609 609 else 610 Failure("Failed to open '%s', rc=%d ", pszFilename, rc);610 Failure("Failed to open '%s', rc=%d (%s)", pszFilename, rc, kLdrErrStr(rc)); 611 611 return rc ? 1 : 0; 612 612 }
Note:
See TracChangeset
for help on using the changeset viewer.